fix: 可选套餐商品每次新增数据
This commit is contained in:
@@ -82,6 +82,8 @@ public class TbCashierCart implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String useCouponInfo;
|
||||
private String proGroupInfo;
|
||||
private String typeEnum;
|
||||
private Integer groupType;
|
||||
|
||||
public String getSkuName() {
|
||||
if(StringUtils.isNotBlank(skuName)){
|
||||
|
||||
@@ -347,6 +347,25 @@ public class CartService {
|
||||
}
|
||||
}
|
||||
|
||||
private TbCashierCart getCartByCache(String shopId, String tableId, String userId, String skuId) {
|
||||
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
|
||||
if (!redisUtil.exists(tableCartKey)) {
|
||||
return null;
|
||||
}
|
||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject object = array.getJSONObject(i);
|
||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
|
||||
|
||||
if (cashierCart.getSkuId().equals(skuId)) {
|
||||
return cashierCart;
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入购物车
|
||||
*
|
||||
@@ -420,6 +439,7 @@ public class CartService {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
BigDecimal memberAmount = BigDecimal.ZERO;
|
||||
try {
|
||||
// 存在缓存
|
||||
if (redisUtil.exists(tableCartKey)) {
|
||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
||||
if (Objects.isNull(array) || array.isEmpty()) {
|
||||
@@ -444,8 +464,7 @@ public class CartService {
|
||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
|
||||
|
||||
if (cashierCart.getSkuId().equals(skuId)) {
|
||||
|
||||
if (cashierCart.getSkuId().equals(skuId) && (cashierCart.getGroupType() == null || cashierCart.getGroupType() == 0)) {
|
||||
resetGroupProductCart(groupProductIdList, cashierCart);
|
||||
|
||||
cashierCart.setTotalNumber(buyNum);
|
||||
@@ -475,11 +494,7 @@ public class CartService {
|
||||
product.getPackFee().multiply(BigDecimal.valueOf(buyNum)) : BigDecimal.ZERO);
|
||||
|
||||
}
|
||||
// if (isVip != null && isVip == 1) {
|
||||
// cashierCart.setTotalAmount(BigDecimal.ZERO);
|
||||
// } else {
|
||||
cashierCart.resetTotalAmount();
|
||||
// }
|
||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
mpCashierCartMapper.updateById(cashierCart);
|
||||
} else {
|
||||
@@ -494,10 +509,6 @@ public class CartService {
|
||||
BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 &&
|
||||
cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice();
|
||||
memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee()));
|
||||
|
||||
if ("-999".equals(cashierCart.getProductId())) {
|
||||
hasSeat = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag && type == 1) {
|
||||
@@ -512,6 +523,8 @@ public class CartService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 不存在缓存
|
||||
} else {
|
||||
if (type == 1) {
|
||||
TbCashierCart cashierCart = addCart(productId, skuId,
|
||||
@@ -685,6 +698,8 @@ public class CartService {
|
||||
cashierCart.setNumber(num);
|
||||
cashierCart.setTotalNumber(num);
|
||||
}
|
||||
cashierCart.setTypeEnum(product.getTypeEnum());
|
||||
cashierCart.setGroupType(product.getGroupType());
|
||||
cashierCart.setNote(note);
|
||||
cashierCart.setProductId(productId);
|
||||
cashierCart.setSkuId(skuId);
|
||||
|
||||
Reference in New Issue
Block a user