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