删除优惠卷

新版优惠卷
This commit is contained in:
wuchunlei
2024-09-25 16:00:51 +08:00
parent 872718e01a
commit d8acf99237
43 changed files with 421 additions and 1526 deletions

View File

@@ -56,10 +56,6 @@ public class BuyOrderController {
@Autowired
private BuyOrderDetailService buyOrderDetailService;
@Autowired
private CouponService couponService;
@Autowired
private CouponHistoryService couponHistoryService;
@Autowired
private OrderCartService orderCartService;
@Autowired
private MyUserService myUserService;
@@ -241,7 +237,7 @@ public class BuyOrderController {
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
}
//商品价格减去优惠券的优惠金额
totalPrice = totalPrice.subtract(useCouponAmount(buyOrder));
// totalPrice = totalPrice.subtract(0);
//加上运费金额
totalPrice = totalPrice.add(getShoppingAmount(buyOrder));
@@ -467,12 +463,6 @@ public class BuyOrderController {
if (buyOrder == null) {
return R.error("订单不存在");
}
if (buyOrder.getCouponId() != null) {
Integer couponId = buyOrder.getCouponId();
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
couponHistory.setUseStatus(0);
couponHistoryService.updateById(couponHistory);
}
// 库存回滚
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId());
@@ -519,14 +509,6 @@ public class BuyOrderController {
//1. 判断订单状态
BuyOrder byId = buyOrderService.getById(orderId);
if (byId != null) {
//2. 判断当前订单是否存在优惠券 进行 回显
Integer couponId = byId.getCouponId();
if (couponId != null) {
CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
byId1.setUseStatus(0);
couponHistoryService.updateById(byId1);
}
// 库存回滚
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
.eq("order_id", byId.getOrderId()));
@@ -832,26 +814,6 @@ public class BuyOrderController {
return true;
}
/**
* 使用优惠券
*
* @param buyOrder
* @return
*/
private BigDecimal useCouponAmount(BuyOrder buyOrder) {
Integer couponId = buyOrder.getCouponId();
if (couponId != null&&couponId!=0) {
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
couponHistory.setUseStatus(1);
couponHistory.setUseTime(new Date());
couponHistory.setOrderId(Long.valueOf(buyOrder.getOrderId()));
couponHistory.setOrderSn(buyOrder.getOrderSn());
CouponEntity coupon = couponService.getById(couponHistory.getCouponId());
return coupon.getCouponAmount();
}
return BigDecimal.ZERO;
}
/**