feat: 添加购物车修改
This commit is contained in:
@@ -266,6 +266,7 @@ public class OrderService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result createCart(String masterId, Integer productId, Integer shopId, Integer skuId, BigDecimal number,
|
||||
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid,
|
||||
@@ -291,7 +292,6 @@ public class OrderService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String finalMasterId = masterId;
|
||||
LambdaQueryWrapper<TbCashierCart> cartQuery = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopId)
|
||||
@@ -354,11 +354,13 @@ public class OrderService {
|
||||
}
|
||||
}
|
||||
boolean needNew = false;
|
||||
boolean isGroup = false;
|
||||
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
||||
TbCashierCart cashierCart = null;
|
||||
if (type.equals("edit")) {
|
||||
cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId);
|
||||
if (cashierCart == null) {
|
||||
isGroup = cashierCart != null && cashierCart.getGroupType() != null && cashierCart.getGroupType() == 1;
|
||||
if (cashierCart == null || isGroup) {
|
||||
needNew = true;
|
||||
} else {
|
||||
// 校验是否是代客下单往期订单
|
||||
@@ -418,6 +420,62 @@ public class OrderService {
|
||||
}
|
||||
|
||||
if (type.equals("add") || needNew) {
|
||||
cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId);
|
||||
if (cashierCart != null && !isGroup) {
|
||||
// 校验是否是代客下单往期订单
|
||||
if (shopEatTypeInfoDTO.isDineInAfter() && cashierCart.getPlaceNum() != null && !isSeatCart) {
|
||||
return Result.fail("后付费已下单订单仅支持退款");
|
||||
}
|
||||
|
||||
if (skuWithBLOBs != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number.compareTo(BigDecimal.valueOf(skuWithBLOBs.getSuit())) < 0) {
|
||||
delCart(masterId, cartId);
|
||||
if (cashierCart.getOrderId() != null && StrUtil.isNotBlank(cashierCart.getTableId())) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
|
||||
.eq(TbCashierCart::getShopId, cashierCart.getShopId());
|
||||
|
||||
TbCashierCart finalCart = cashierCart;
|
||||
queryWrapper.eq(TbCashierCart::getTableId, cashierCart.getTableId())
|
||||
.and(q -> q.or(
|
||||
query -> query.eq(TbCashierCart::getMasterId, finalCart.getMasterId())
|
||||
.or()
|
||||
.isNull(TbCashierCart::getMasterId)
|
||||
.or()
|
||||
.eq(TbCashierCart::getMasterId, "")
|
||||
)
|
||||
.or(query -> query.eq(TbCashierCart::getOrderId, finalCart.getOrderId())
|
||||
.or()
|
||||
.isNull(TbCashierCart::getOrderId)));
|
||||
|
||||
List<TbCashierCart> list1 = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
|
||||
|
||||
if (list1.isEmpty()) {
|
||||
tbOrderInfoMapper.deleteByPrimaryKey(cashierCart.getOrderId());
|
||||
}
|
||||
}
|
||||
|
||||
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cashierCart), false);
|
||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||
}
|
||||
|
||||
cashierCart.setNumber(number);
|
||||
if (product != null) {
|
||||
resetGroupProductCart(groupProductIdList, product, cashierCart);
|
||||
}
|
||||
cashierCart.setTotalNumber(number);
|
||||
cashierCart.setIsPrint(isPrint);
|
||||
cashierCart.setIsPack(isPack);
|
||||
cashierCart.resetTotalAmount();
|
||||
cashierCart.setUuid(uuid);
|
||||
cashierCart.setIsPrint(isPrint);
|
||||
cashierCart.resetTotalAmount();
|
||||
if (product != null) {
|
||||
resetGroupProductCart(groupProductIdList, product, cashierCart);
|
||||
}
|
||||
|
||||
mpCashierCartMapper.updateById(cashierCart);
|
||||
} else {
|
||||
|
||||
cashierCart = new TbCashierCart();
|
||||
cashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||
if (product != null) {
|
||||
@@ -477,6 +535,7 @@ public class OrderService {
|
||||
}
|
||||
list.add(cashierCart);
|
||||
mpCashierCartMapper.insert(cashierCart);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1185,6 +1244,7 @@ public class OrderService {
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, orderInfo);
|
||||
}
|
||||
|
||||
private void updateOrderDetailCanReturn(List<TbOrderDetail> orderDetailList, TbOrderInfo orderInfo) {
|
||||
orderDetailList = orderDetailList.stream().filter(item -> TableConstant.OrderInfo.Status.UNPAID.equalsVals(item.getStatus())).collect(Collectors.toList());
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
|
||||
Reference in New Issue
Block a user