fix: 取消券同时置空购物车券

This commit is contained in:
张松
2024-11-22 14:41:35 +08:00
parent 836b384f9c
commit 976ce313c5
3 changed files with 14 additions and 4 deletions

View File

@@ -135,6 +135,7 @@ public class TbOrderInfo implements Serializable {
private BigDecimal productCouponDiscountAmount; private BigDecimal productCouponDiscountAmount;
private String couponInfoList; private String couponInfoList;
private int isPostpaid; private int isPostpaid;
private Object useCouponInfo;
public void setDescription(String shopName) { public void setDescription(String shopName) {
this.shopName = shopName; this.shopName = shopName;

View File

@@ -1305,7 +1305,7 @@ public class CartService {
} else { } else {
if (!TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) { if (!TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) {
TbProductSkuWithBLOBs sku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(tbCashierCart.getSkuId())); TbProductSkuWithBLOBs sku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(tbCashierCart.getSkuId()));
tbCashierCart.setIsMember(sku.getMemberPrice() != null && sku.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0); tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : 1);
} }
} }
tbCashierCart.resetTotalAmount(); tbCashierCart.resetTotalAmount();
@@ -1534,7 +1534,7 @@ public class CartService {
private void returnCoupon(TbOrderInfo orderInfo) { private void returnCoupon(TbOrderInfo orderInfo) {
// 返还优惠券 // 返还优惠券
PayService.returnCoupon(orderInfo, shopCouponService); PayService.returnCoupon(orderInfo, shopCouponService, mpCashierCartMapper);
} }
private void consumeCoupon(List<TbActivateOutRecord> outRecordList, Integer memberId, TbOrderInfo orderInfo) { private void consumeCoupon(List<TbActivateOutRecord> outRecordList, Integer memberId, TbOrderInfo orderInfo) {

View File

@@ -419,7 +419,7 @@ public class PayService {
} }
// 返还优惠券 // 返还优惠券
returnCoupon(orderInfo, shopCouponService); returnCoupon(orderInfo, shopCouponService, mpCashierCartMapper);
BigDecimal shouldPayAmount = orderInfo.getOriginAmount().multiply(BigDecimal.valueOf(freeDineConfig.getRechargeTimes())); BigDecimal shouldPayAmount = orderInfo.getOriginAmount().multiply(BigDecimal.valueOf(freeDineConfig.getRechargeTimes()));
@@ -491,7 +491,7 @@ public class PayService {
return shouldPayAmount; return shouldPayAmount;
} }
static void returnCoupon(TbOrderInfo orderInfo, TbShopCouponService shopCouponService) { static void returnCoupon(TbOrderInfo orderInfo, TbShopCouponService shopCouponService, MpCashierCartMapper cashierCartMapper) {
if (StrUtil.isNotBlank(orderInfo.getCouponInfoList())) { if (StrUtil.isNotBlank(orderInfo.getCouponInfoList())) {
OrderCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderCouponInfoDTO.class); OrderCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderCouponInfoDTO.class);
// 券返还 // 券返还
@@ -502,6 +502,15 @@ public class PayService {
shopCouponService.refund(couponInfoDTO.getOutRecordList()); shopCouponService.refund(couponInfoDTO.getOutRecordList());
couponInfoDTO.setOutRecordList(new ArrayList<>()); couponInfoDTO.setOutRecordList(new ArrayList<>());
orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO)); orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO));
orderInfo.setUserCouponId(null);
orderInfo.setUseCouponInfo(null);
// 修改购物车券信息
cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getOrderId, orderInfo.getId())
.set(TbCashierCart::getUserCouponId, null)
.set(TbCashierCart::getUseCouponInfo, null));
} }
} }
} }