fix: 切换就餐模式不从token获取userid
This commit is contained in:
@@ -118,7 +118,8 @@ public class ProductController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/choseEatModel")
|
@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);
|
List<TbCashierCart> cashierCartList = cartService.choseEatModel(choseEatModelDTO);
|
||||||
BigDecimal amount = BigDecimal.ZERO;
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
BigDecimal memberAmount = BigDecimal.ZERO;
|
BigDecimal memberAmount = BigDecimal.ZERO;
|
||||||
|
|||||||
@@ -17,4 +17,5 @@ public class ChoseEatModelDTO {
|
|||||||
@Min(0)
|
@Min(0)
|
||||||
// 0切换店内 1切换外带
|
// 0切换店内 1切换外带
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
private Integer userId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1479,25 +1479,17 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<TbCashierCart> choseEatModel(ChoseEatModelDTO choseEatModelDTO) {
|
public List<TbCashierCart> choseEatModel(ChoseEatModelDTO choseEatModelDTO) {
|
||||||
Integer userId = TokenUtil.getUserId();
|
|
||||||
List<TbCashierCart> cashierCartList;
|
List<TbCashierCart> cashierCartList;
|
||||||
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseEatModelDTO.getTableId(), choseEatModelDTO.getShopId());
|
||||||
// 外带模式
|
// 外带模式
|
||||||
if (choseEatModelDTO.getType() == 1) {
|
if (choseEatModelDTO.getType() == 1) {
|
||||||
// 查询购物车所有信息
|
cashierCartList = cashierCartService.selectByShopEatTypeInfo(shopEatTypeInfoDTO, choseEatModelDTO.getUserId());
|
||||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
cashierCartList = cashierCartList.stream().filter(item -> !TableConstant.CART_SEAT_ID.equals(item.getProductId())).collect(Collectors.toList());
|
||||||
.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);
|
|
||||||
|
|
||||||
// 计算打包费
|
// 计算打包费
|
||||||
if (cashierCartList.isEmpty()) {
|
if (cashierCartList.isEmpty()) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> productIds = cashierCartList.stream().map(TbCashierCart::getProductId).collect(Collectors.toList());
|
List<String> productIds = cashierCartList.stream().map(TbCashierCart::getProductId).collect(Collectors.toList());
|
||||||
Map<Integer, TbProduct> productMap = productMapper.selectByIds(productIds).stream()
|
Map<Integer, TbProduct> productMap = productMapper.selectByIds(productIds).stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
@@ -1516,7 +1508,6 @@ public class CartService {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 查询购物车所有信息
|
// 查询购物车所有信息
|
||||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseEatModelDTO.getTableId(), choseEatModelDTO.getShopId());
|
|
||||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId())
|
.eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId())
|
||||||
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||||
|
|||||||
Reference in New Issue
Block a user