fix: 优惠券使用修改
This commit is contained in:
@@ -1231,7 +1231,12 @@ public class CartService {
|
|||||||
});
|
});
|
||||||
HashMap<String, List<TbUserCouponVo>> usedCouponMap = new HashMap<>();
|
HashMap<String, List<TbUserCouponVo>> usedCouponMap = new HashMap<>();
|
||||||
ArrayList<TbActivateOutRecord> outRecords = new ArrayList<>();
|
ArrayList<TbActivateOutRecord> outRecords = new ArrayList<>();
|
||||||
|
ArrayList<TbCashierCart> resetCouponList = new ArrayList<>();
|
||||||
for (TbCashierCart cashierCart : cartInfoDTO.getNewCashierCarts()) {
|
for (TbCashierCart cashierCart : cartInfoDTO.getNewCashierCarts()) {
|
||||||
|
if (!couponMap.isEmpty()) {
|
||||||
|
resetCouponList.add(cashierCart);
|
||||||
|
cashierCart.setUserCouponId(null);
|
||||||
|
}
|
||||||
discountAmount = reduceProCoupon(couponMap, cashierCart, usedCouponMap, discountAmount, balanceCartList, outRecords, memberId);
|
discountAmount = reduceProCoupon(couponMap, cashierCart, usedCouponMap, discountAmount, balanceCartList, outRecords, memberId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1241,6 +1246,20 @@ public class CartService {
|
|||||||
cashierCartService.saveBatch(balanceCartList);
|
cashierCartService.saveBatch(balanceCartList);
|
||||||
}
|
}
|
||||||
// 更新购物车信息
|
// 更新购物车信息
|
||||||
|
if (!resetCouponList.isEmpty()) {
|
||||||
|
// 取消之前使用的历史券
|
||||||
|
ArrayList<Integer> resetCartIds = new ArrayList<>();
|
||||||
|
resetCouponList.forEach(item -> {
|
||||||
|
if (item.getUserCouponId() == null) {
|
||||||
|
resetCartIds.add(item.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!resetCartIds.isEmpty()) {
|
||||||
|
cashierCartService.update(new LambdaUpdateWrapper<TbCashierCart>()
|
||||||
|
.in(TbCashierCart::getId, resetCartIds)
|
||||||
|
.set(TbCashierCart::getUserCouponId, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
cashierCartService.updateBatchById(cartInfoDTO.getNewCashierCarts());
|
cashierCartService.updateBatchById(cartInfoDTO.getNewCashierCarts());
|
||||||
|
|
||||||
couponInfoDTO.setOutRecordList(outRecords);
|
couponInfoDTO.setOutRecordList(outRecords);
|
||||||
|
|||||||
Reference in New Issue
Block a user