Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-api-cloud
This commit is contained in:
commit
0bf9e847c7
15 files changed
+260
-9
No files matched your search
@@ -13,6 +13,10 @@
|
||||
<artifactId>pjcloud-app-server-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-upms-api</artifactId>
|
||||
</dependency>
|
||||
<!--必备: undertow容器-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.bsd.pjcloud.canteen.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品 SKU 更新库存 Request DTO
|
||||
*
|
||||
* @author LeeYan9
|
||||
* @since 2022-08-26
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CanteenSpuUpdateStockReqDTO {
|
||||
|
||||
/**
|
||||
* 商品 SKU
|
||||
*/
|
||||
@NotNull(message = "商品 SPU 不能为空")
|
||||
private List<Item> items;
|
||||
|
||||
@Data
|
||||
public static class Item {
|
||||
|
||||
/**
|
||||
* 商品 SKU 编号
|
||||
*/
|
||||
@NotNull(message = "商品 SPU 编号不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 库存变化数量
|
||||
*
|
||||
* 正数:增加库存
|
||||
* 负数:扣减库存
|
||||
*/
|
||||
@NotNull(message = "库存变化数量不能为空")
|
||||
private Integer incrCount;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.bsd.pjcloud.canteen.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ADCanteenDailyMenuListVO {
|
||||
/**
|
||||
* 每日菜品id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* spuid
|
||||
*/
|
||||
private Long spuId;
|
||||
|
||||
/**
|
||||
* 菜品名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 商品价格,单位使用:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 菜品分类编号
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 菜品封面图
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private Integer stock;
|
||||
|
||||
/**
|
||||
* 时间类型
|
||||
*/
|
||||
private Integer hourType;
|
||||
}
|
||||
+10
@@ -171,4 +171,14 @@ public class CanteenDailyMenuController {
|
||||
}
|
||||
|
||||
|
||||
// ---------APP------------
|
||||
@GetMapping("/ad/getCanteenList")
|
||||
@SysLog("查询每日菜品列表")
|
||||
public R getCanteenList(@RequestParam("day") String day,
|
||||
@RequestParam(value = "hourType", required = false) Integer hourType,
|
||||
@RequestParam(value = "categoryId", required = false) Long categoryId) {
|
||||
|
||||
return R.ok(canteenDailyMenuService.getCanteenMenuList(day,hourType,categoryId));
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -7,6 +7,7 @@ import com.alibaba.excel.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
@@ -126,4 +127,13 @@ public class CanteenSpuController {
|
||||
|
||||
|
||||
|
||||
|
||||
// --------------APP-----------------
|
||||
|
||||
|
||||
@PostMapping("/ad/updateSkuStock")
|
||||
@SysLog("更新菜品库存")
|
||||
public R updateSkuStock(@RequestBody CanteenSpuUpdateStockReqDTO updateStockReqDTO){
|
||||
return canteenSpuService.updateSkuStock(updateStockReqDTO);
|
||||
}
|
||||
}
|
||||
+11
@@ -15,4 +15,15 @@ public interface CanteenDailyMenuMapper extends PjcloudBaseMapper<CanteenDailyMe
|
||||
|
||||
List<DailyMenuVO> selectTimeFood(@Param("time") String time,@Param("merchantId") Long merchantId,
|
||||
@Param("categoryId") Long categoryId, DataScope dataScope);
|
||||
|
||||
|
||||
/**
|
||||
* ad查询菜品列表
|
||||
* @param day
|
||||
* @param hourType
|
||||
* @param categoryId
|
||||
* @return
|
||||
*/
|
||||
Object getCanteenMenuList(@Param("day") String day,@Param("hourType") Integer hourType,
|
||||
@Param("categoryId") Long categoryId,DataScope dataScope);
|
||||
}
|
||||
+24
-3
@@ -1,5 +1,6 @@
|
||||
package com.bsd.pjcloud.canteen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.bsd.pjcloud.canteen.dto.DailyMenuAll;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
@@ -12,7 +13,27 @@ import java.util.List;
|
||||
public interface CanteenSpuMapper extends PjcloudBaseMapper<CanteenSpuEntity> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新商品 SPU 库存
|
||||
*
|
||||
* @param id 商品 SPU 编号
|
||||
* @param incrCount 增加的库存数量
|
||||
*/
|
||||
default int updateStock(Long id, Integer incrCount) {
|
||||
// 拼接 SQL
|
||||
if (incrCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
String sql;
|
||||
if (incrCount > 0) {
|
||||
sql = " stock = stock + " + incrCount + ", sales_count = sales_count - " + incrCount;
|
||||
} else {
|
||||
sql = " stock = stock - " + Math.abs(incrCount) + ", sales_count = sales_count + " + Math.abs(incrCount);
|
||||
}
|
||||
// 执行更新
|
||||
LambdaUpdateWrapper<CanteenSpuEntity> updateWrapper = new LambdaUpdateWrapper<CanteenSpuEntity>()
|
||||
.setSql(sql)
|
||||
.eq(CanteenSpuEntity::getId, id);
|
||||
return update(null, updateWrapper);
|
||||
}
|
||||
}
|
||||
+10
@@ -28,4 +28,14 @@ public interface CanteenDailyMenuService extends IService<CanteenDailyMenuEntity
|
||||
|
||||
|
||||
void saveToday(CanteenDailyMenuEntity canteenDailyMenu);
|
||||
|
||||
|
||||
/**
|
||||
* ad机获取每次菜品
|
||||
* @param day
|
||||
* @param hourType
|
||||
* @param categoryId
|
||||
* @return
|
||||
*/
|
||||
Object getCanteenMenuList(String day, Integer hourType, Long categoryId);
|
||||
}
|
||||
+9
@@ -2,8 +2,10 @@ package com.bsd.pjcloud.canteen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.DailyMenuAll;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,4 +20,11 @@ public interface CanteenSpuService extends IService<CanteenSpuEntity> {
|
||||
Object selectFoodList(LambdaQueryWrapper<CanteenSpuEntity> wrapper);
|
||||
|
||||
|
||||
/**
|
||||
* 更新库存
|
||||
* @param updateStockReqDTO
|
||||
* @return
|
||||
*/
|
||||
R updateSkuStock(CanteenSpuUpdateStockReqDTO updateStockReqDTO);
|
||||
|
||||
}
|
||||
+7
@@ -88,4 +88,11 @@ public class CanteenDailyMenuServiceImpl extends ServiceImpl<CanteenDailyMenuMap
|
||||
// CookbookProductEvent productEvent = new CookbookProductEvent(this, eventDto);
|
||||
// eventPublisher.publishEvent(productEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object getCanteenMenuList(String day, Integer hourType, Long categoryId) {
|
||||
return baseMapper.getCanteenMenuList(day, hourType, categoryId,DataScope.of());
|
||||
}
|
||||
}
|
||||
+26
@@ -2,14 +2,20 @@ package com.bsd.pjcloud.canteen.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.DailyMenuAll;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.mapper.CanteenSpuMapper;
|
||||
import com.bsd.pjcloud.canteen.service.CanteenDailyMenuService;
|
||||
import com.bsd.pjcloud.canteen.service.CanteenSpuService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,11 +26,31 @@ import java.util.List;
|
||||
* @date 2024-12-10 12:51:53
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, CanteenSpuEntity> implements CanteenSpuService {
|
||||
|
||||
private final CanteenDailyMenuService coupleDailyMenuService;
|
||||
@Override
|
||||
public Object selectFoodList(LambdaQueryWrapper<CanteenSpuEntity> wrapper) {
|
||||
return baseMapper.selectListByScope(wrapper, DataScope.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public R updateSkuStock(CanteenSpuUpdateStockReqDTO updateStockReqDTO) {
|
||||
// 更新 SKU 库存
|
||||
updateStockReqDTO.getItems().forEach(item -> {
|
||||
int i = baseMapper.updateStock(item.getId(), item.getIncrCount());
|
||||
if (item.getIncrCount() < 0) {
|
||||
if (i == 0) {
|
||||
R.failed("商品库存不足");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+38
@@ -17,6 +17,18 @@
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="adCanteenDailyMenuListVO" type="com.bsd.pjcloud.canteen.vo.ADCanteenDailyMenuListVO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="spuId" column="spu_id"/>
|
||||
<result property="hourType" column="hour_type"/>
|
||||
<result property="price" column="price"/>
|
||||
<result property="categoryId" column="category_id"/>
|
||||
<result property="picUrl" column="pic_url"/>
|
||||
<result property="stock" column="stock"/>
|
||||
<result property="hourType" column="hour_type"/>
|
||||
</resultMap>
|
||||
<select id="selectTimeFood" resultType="com.bsd.pjcloud.canteen.vo.DailyMenuVO">
|
||||
SELECT
|
||||
sp.id,
|
||||
@@ -37,4 +49,30 @@
|
||||
And t.del_flag = 0
|
||||
</where>
|
||||
</select>
|
||||
<select id="getCanteenMenuList" resultType="java.lang.Object">
|
||||
SELECT
|
||||
sp.id as spuId,
|
||||
t.id,
|
||||
sp.name,
|
||||
sp.pic_url,
|
||||
t.hour_type,
|
||||
sp.price,
|
||||
sp.stock,
|
||||
sp.category_id
|
||||
FROM canteen_daily_menu t
|
||||
LEFT JOIN canteen_spu sp
|
||||
on t.spu_id=sp.id
|
||||
<where>
|
||||
sp.del_flag = 0 and t.del_flag = 0
|
||||
<if test="categoryId != null">
|
||||
AND sp.category_id = #{categoryId}
|
||||
</if>
|
||||
<if test="hourType != null">
|
||||
AND t.hour_type = #{hourType}
|
||||
</if>
|
||||
<if test="day != null">
|
||||
AND t.start_time = #{day}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
+20
-6
@@ -17,6 +17,8 @@
|
||||
package com.bsd.pjcloud.common.security.service;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.app.api.dto.AppUserInfo;
|
||||
import com.bsd.pjcloud.app.api.entity.AppUser;
|
||||
import com.bsd.pjcloud.app.api.feign.RemoteAppUserService;
|
||||
@@ -57,6 +59,8 @@ public class PjcloudTocDefaultUserDetailsServiceImpl implements PjcloudUserDetai
|
||||
|
||||
private final Optional<RemoteAppUserService> remoteAppUserServiceOptional;
|
||||
|
||||
private final RemoteUserService remoteUserService;
|
||||
|
||||
/**
|
||||
* 用户密码登录
|
||||
*
|
||||
@@ -66,16 +70,26 @@ public class PjcloudTocDefaultUserDetailsServiceImpl implements PjcloudUserDetai
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS_MINI);
|
||||
// Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS_MINI);
|
||||
// if (Objects.nonNull(cache) && Objects.nonNull(cache.get(username))) {
|
||||
// AppUserInfo appUserInfo = cache.get(username, AppUserInfo.class);
|
||||
// return getUserDetailsAppUser(R.ok(appUserInfo));
|
||||
// }
|
||||
//
|
||||
// R<AppUserInfo> result = remoteAppUserServiceOptional.get().info(username);
|
||||
// Optional<AppUserInfo> userInfoOptional = RetOps.of(result).getData();
|
||||
// userInfoOptional.ifPresent(userInfo -> Objects.requireNonNull(cache).put(username, userInfo));
|
||||
// return getUserDetailsAppUser(result);
|
||||
|
||||
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
|
||||
if (Objects.nonNull(cache) && Objects.nonNull(cache.get(username))) {
|
||||
AppUserInfo appUserInfo = cache.get(username, AppUserInfo.class);
|
||||
return getUserDetailsAppUser(R.ok(appUserInfo));
|
||||
return getUserDetails(Optional.ofNullable(cache.get(username, UserInfo.class)));
|
||||
}
|
||||
|
||||
R<AppUserInfo> result = remoteAppUserServiceOptional.get().info(username);
|
||||
Optional<AppUserInfo> userInfoOptional = RetOps.of(result).getData();
|
||||
R<UserInfo> result = remoteUserService.info(username);
|
||||
Optional<UserInfo> userInfoOptional = RetOps.of(result).getData();
|
||||
userInfoOptional.ifPresent(userInfo -> Objects.requireNonNull(cache).put(username, userInfo));
|
||||
return getUserDetailsAppUser(result);
|
||||
return getUserDetails(userInfoOptional);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
+2
@@ -310,9 +310,11 @@ public class SupermarketSpuEntity extends Model<SupermarketSpuEntity> {
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "辅助条码集合对象")
|
||||
@TableField(exist = false)
|
||||
private List<SupermarketAuxiliaryCodeEntity> supermarketAuxiliaryCodeEntityList;
|
||||
|
||||
@Schema(description = "包装对象集合对象")
|
||||
@TableField(exist = false)
|
||||
private List<SupermarketUnitEntity> supermarketUnitEntityList;
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user