feat: 添加购物车简化修改
This commit is contained in:
@@ -380,7 +380,6 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(masterId)) {
|
if (StringUtils.isEmpty(masterId)) {
|
||||||
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@@ -396,99 +395,86 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Objects.nonNull(cart) && cart.getGroupType() != null && cart.getGroupType() == 0) {
|
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
||||||
//查询现有规格商品
|
|
||||||
cart.setNumber(number);
|
TbCashierCart cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO);
|
||||||
cart.setIsGift(isGift);
|
if (type.equals("add") || cashierCart == null || (cart != null && cart.getGroupType() != null && cart.getGroupType() == 1)) {
|
||||||
cart.setIsPack(isPack);
|
cashierCart = new TbCashierCart();
|
||||||
cart.setTotalNumber(number);
|
cashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||||
cart.resetTotalAmount();
|
if (product != null) {
|
||||||
cart.setUuid(uuid);
|
cashierCart.setCoverImg(product.getCoverImg());
|
||||||
cart.setIsPrint(isPrint);
|
cashierCart.setIsSku(product.getTypeEnum());
|
||||||
|
cashierCart.setName(product.getName());
|
||||||
|
cashierCart.setCategoryId(product.getCategoryId());
|
||||||
|
cashierCart.setTypeEnum(product.getTypeEnum());
|
||||||
|
cashierCart.setGroupType(product.getGroupType());
|
||||||
|
}
|
||||||
|
cashierCart.setCreatedAt(System.currentTimeMillis());
|
||||||
|
cashierCart.setMasterId(masterId);
|
||||||
|
cashierCart.setUuid(uuid);
|
||||||
|
cashierCart.setMerchantId(userId);
|
||||||
|
cashierCart.setProductId(productId == null ? null : productId.toString());
|
||||||
|
if (skuWithBLOBs != null) {
|
||||||
|
cashierCart.setSalePrice(skuWithBLOBs.getSalePrice());
|
||||||
|
cashierCart.setSkuId(skuWithBLOBs.getId().toString());
|
||||||
|
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
|
||||||
|
cashierCart.setMemberPrice(skuWithBLOBs.getMemberPrice());
|
||||||
|
cashierCart.setIsMember(0);
|
||||||
|
}
|
||||||
|
cashierCart.setIsPrint(isPrint);
|
||||||
|
cashierCart.setShopId(shopId.toString());
|
||||||
|
cashierCart.setTradeDay(DateUtils.getDay());
|
||||||
|
cashierCart.setStatus("create");
|
||||||
|
cashierCart.setIsPack(isPack);
|
||||||
|
cashierCart.setIsGift(isGift);
|
||||||
|
if (isGift.equals("false")) {
|
||||||
|
if (isSeatCart) {
|
||||||
|
cashierCart.setTotalAmount(number.multiply(cashierCart.getSalePrice()));
|
||||||
|
} else {
|
||||||
|
cashierCart.setTotalAmount(number.multiply(skuWithBLOBs.getSalePrice()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
if (isPack.equals("false")) {
|
||||||
|
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||||
|
} else {
|
||||||
|
if (!isSeatCart) {
|
||||||
|
cashierCart.setPackFee(number.multiply(product == null ? BigDecimal.ZERO : product.getPackFee()));
|
||||||
|
}
|
||||||
|
cashierCart.setTotalAmount(cashierCart.getTotalAmount().add(cashierCart.getPackFee()));
|
||||||
|
|
||||||
|
}
|
||||||
|
cashierCart.setTotalNumber(number);
|
||||||
|
cashierCart.setUserId(Integer.valueOf(userId));
|
||||||
|
cashierCart.setNumber(number);
|
||||||
|
cashierCart.setUuid(uuid);
|
||||||
|
cashierCart.setTableId(tableId);
|
||||||
|
cashierCart.setPlatformType(OrderPlatformTypeEnum.CASH.getValue());
|
||||||
|
if (product != null) {
|
||||||
|
resetGroupProductCart(groupProductIdList, product, cashierCart);
|
||||||
|
}
|
||||||
|
list.add(cashierCart);
|
||||||
|
mpCashierCartMapper.insert(cashierCart);
|
||||||
|
}else {
|
||||||
|
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) {
|
if (product != null) {
|
||||||
resetGroupProductCart(groupProductIdList, product, cart);
|
resetGroupProductCart(groupProductIdList, product, cart);
|
||||||
}
|
}
|
||||||
cashierCartMapper.updateByPrimaryKeySelective(cart);
|
|
||||||
} else {
|
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
|
||||||
TbCashierCart cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO);
|
|
||||||
// 不存在新增
|
|
||||||
if (Objects.isNull(cashierCart) || (cart != null && cart.getGroupType() != null && cart.getGroupType() == 1)) {
|
|
||||||
cashierCart = new TbCashierCart();
|
|
||||||
cashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
|
||||||
if (product != null) {
|
|
||||||
cashierCart.setCoverImg(product.getCoverImg());
|
|
||||||
cashierCart.setIsSku(product.getTypeEnum());
|
|
||||||
cashierCart.setName(product.getName());
|
|
||||||
cashierCart.setCategoryId(product.getCategoryId());
|
|
||||||
cashierCart.setTypeEnum(product.getTypeEnum());
|
|
||||||
cashierCart.setGroupType(product.getGroupType());
|
|
||||||
}
|
|
||||||
cashierCart.setCreatedAt(System.currentTimeMillis());
|
|
||||||
cashierCart.setMasterId(masterId);
|
|
||||||
cashierCart.setUuid(uuid);
|
|
||||||
cashierCart.setMerchantId(userId);
|
|
||||||
cashierCart.setProductId(productId == null ? null : productId.toString());
|
|
||||||
if (skuWithBLOBs != null) {
|
|
||||||
cashierCart.setSalePrice(skuWithBLOBs.getSalePrice());
|
|
||||||
cashierCart.setSkuId(skuWithBLOBs.getId().toString());
|
|
||||||
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
|
|
||||||
cashierCart.setMemberPrice(skuWithBLOBs.getMemberPrice());
|
|
||||||
cashierCart.setIsMember(0);
|
|
||||||
}
|
|
||||||
cashierCart.setIsPrint(isPrint);
|
|
||||||
cashierCart.setShopId(shopId.toString());
|
|
||||||
cashierCart.setTradeDay(DateUtils.getDay());
|
|
||||||
cashierCart.setStatus("create");
|
|
||||||
cashierCart.setIsPack(isPack);
|
|
||||||
cashierCart.setIsGift(isGift);
|
|
||||||
if (isGift.equals("false")) {
|
|
||||||
if (isSeatCart) {
|
|
||||||
cashierCart.setTotalAmount(number.multiply(cashierCart.getSalePrice()));
|
|
||||||
} else {
|
|
||||||
cashierCart.setTotalAmount(number.multiply(skuWithBLOBs.getSalePrice()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
|
||||||
}
|
|
||||||
if (isPack.equals("false")) {
|
|
||||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
|
||||||
} else {
|
|
||||||
if (!isSeatCart) {
|
|
||||||
cashierCart.setPackFee(number.multiply(product == null ? BigDecimal.ZERO : product.getPackFee()));
|
|
||||||
}
|
|
||||||
cashierCart.setTotalAmount(cashierCart.getTotalAmount().add(cashierCart.getPackFee()));
|
|
||||||
|
|
||||||
}
|
mpCashierCartMapper.updateById(cashierCart);
|
||||||
cashierCart.setTotalNumber(number);
|
|
||||||
cashierCart.setUserId(Integer.valueOf(userId));
|
|
||||||
cashierCart.setNumber(number);
|
|
||||||
cashierCart.setUuid(uuid);
|
|
||||||
cashierCart.setTableId(tableId);
|
|
||||||
cashierCart.setPlatformType(OrderPlatformTypeEnum.CASH.getValue());
|
|
||||||
if (product != null) {
|
|
||||||
resetGroupProductCart(groupProductIdList, product, cashierCart);
|
|
||||||
}
|
|
||||||
list.add(cashierCart);
|
|
||||||
mpCashierCartMapper.insert(cashierCart);
|
|
||||||
} else {
|
|
||||||
if (type.equals("add")) {
|
|
||||||
cashierCart.setNumber(cashierCart.getNumber().add(number));
|
|
||||||
} else {
|
|
||||||
cashierCart.setNumber(number);
|
|
||||||
}
|
|
||||||
if (product != null) {
|
|
||||||
resetGroupProductCart(groupProductIdList, product, cashierCart);
|
|
||||||
}
|
|
||||||
cashierCart.setIsPrint(isPrint);
|
|
||||||
cashierCart.resetTotalAmount();
|
|
||||||
mpCashierCartMapper.updateById(cashierCart);
|
|
||||||
}
|
|
||||||
|
|
||||||
cart = cashierCart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), true);
|
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), true);
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||||
|
|||||||
Reference in New Issue
Block a user