fix: 切换就餐模式不从token获取userid

This commit is contained in:
张松
2024-11-09 11:01:41 +08:00
parent e9161dbda9
commit 2cde014953
3 changed files with 6 additions and 13 deletions

View File

@@ -118,7 +118,8 @@ public class ProductController {
}
@PostMapping("/choseEatModel")
public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) {
public Result choseEatModel(@RequestHeader("id") Integer userId, @Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) {
choseEatModelDTO.setUserId(userId);
List<TbCashierCart> cashierCartList = cartService.choseEatModel(choseEatModelDTO);
BigDecimal amount = BigDecimal.ZERO;
BigDecimal memberAmount = BigDecimal.ZERO;

View File

@@ -17,4 +17,5 @@ public class ChoseEatModelDTO {
@Min(0)
// 0切换店内 1切换外带
private Integer type;
private Integer userId;
}

View File

@@ -1479,25 +1479,17 @@ public class CartService {
}
public List<TbCashierCart> choseEatModel(ChoseEatModelDTO choseEatModelDTO) {
Integer userId = TokenUtil.getUserId();
List<TbCashierCart> cashierCartList;
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseEatModelDTO.getTableId(), choseEatModelDTO.getShopId());
// 外带模式
if (choseEatModelDTO.getType() == 1) {
// 查询购物车所有信息
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.isNull(TbCashierCart::getOrderId)
.ne(TbCashierCart::getProductId, "-999")
.eq(TbCashierCart::getStatus, "create");
queryWrapper.eq(TbCashierCart::getUserId, userId);
cashierCartList = mpCashierCartMapper.selectList(queryWrapper);
cashierCartList = cashierCartService.selectByShopEatTypeInfo(shopEatTypeInfoDTO, choseEatModelDTO.getUserId());
cashierCartList = cashierCartList.stream().filter(item -> !TableConstant.CART_SEAT_ID.equals(item.getProductId())).collect(Collectors.toList());
// 计算打包费
if (cashierCartList.isEmpty()) {
return new ArrayList<>();
}
List<String> productIds = cashierCartList.stream().map(TbCashierCart::getProductId).collect(Collectors.toList());
Map<Integer, TbProduct> productMap = productMapper.selectByIds(productIds).stream()
.collect(Collectors.toMap(
@@ -1516,7 +1508,6 @@ public class CartService {
} else {
// 查询购物车所有信息
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseEatModelDTO.getTableId(), choseEatModelDTO.getShopId());
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())