|
|
@@ -259,6 +259,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
private final UserDistributeSharedRelateUnbindMapper userDistributeSharedRelateUnbindMapper;
|
|
|
|
|
|
+ private final EquipmentActivityReduceMapper equipmentActivityReduceMapper;
|
|
|
+
|
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
|
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@@ -429,14 +431,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (payRequest.getPopularizeId() != null) {
|
|
|
orderDon.setPopularizeId(payRequest.getPopularizeId());
|
|
|
}
|
|
|
- if (sku != null) {
|
|
|
- //扣除使用优惠券、余额的订单金额
|
|
|
- deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon.getType(), payRequest.getGcCash(), payRequest.getGcpIds());
|
|
|
- }
|
|
|
-
|
|
|
- if (isSpecificPrice && (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0 || orderDon.getMoney().compareTo(specificPrice) != 0)) {
|
|
|
- throw BusinessRuntimeException.getInstance("专属价格不支持使用其他优惠");
|
|
|
- }
|
|
|
|
|
|
orderDon.setSkuId(payRequest.getSkuId());
|
|
|
orderDon.setRelationId(relationId);
|
|
|
@@ -463,6 +457,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
throw BusinessRuntimeException.getInstance("车位与车队规格不一致");
|
|
|
}
|
|
|
}
|
|
|
+ if (sku != null) {
|
|
|
+ //扣除使用优惠券、余额的订单金额
|
|
|
+ deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon.getType(), payRequest.getGcCash(), payRequest.getGcpIds(), payRequest.getIsAcReduce());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isSpecificPrice && (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0 || orderDon.getMoney().compareTo(specificPrice) != 0)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("专属价格不支持使用其他优惠");
|
|
|
+ }
|
|
|
orderDon.setPayDesc(goodsDon.getPayDesc());
|
|
|
StringBuilder payTitle = new StringBuilder();
|
|
|
payTitle.append(goodsDon.getTitle());
|
|
|
@@ -957,7 +959,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
orderDon.setRealMoney(orderDon.getMoney());
|
|
|
//扣除使用优惠券、余额的订单金额
|
|
|
- deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon.getType(), payRequest.getGcCash(), payRequest.getGcpIds());
|
|
|
+ deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon.getType(), payRequest.getGcCash(), payRequest.getGcpIds(), false);
|
|
|
this.saveOrUpdate(orderDon);
|
|
|
if (orderDon.getStatus() == OrderDon.Status.noPayment) {
|
|
|
jobManager.addJob(EXPIRY_TIME, () -> {
|
|
|
@@ -2035,7 +2037,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
/**
|
|
|
* 使用优惠营销 订单金额抵扣
|
|
|
*/
|
|
|
- public void deductOrderMoney(OrderDon orderDon, CouponUser couponUser, BigDecimal balance, User user, BigDecimal skuMoney, Integer goodsType, BigDecimal gcCash, List<Long> gcpIds) {
|
|
|
+ public void deductOrderMoney(OrderDon orderDon, CouponUser couponUser, BigDecimal balance, User user, BigDecimal skuMoney, Integer goodsType, BigDecimal gcCash, List<Long> gcpIds, Boolean isAcReduce) {
|
|
|
if (gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0 && couponUser != null) {
|
|
|
throw BusinessRuntimeException.getInstance("现金卡不能与其他优惠叠加使用");
|
|
|
}
|
|
|
@@ -2085,6 +2087,13 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
+ //针对设备 满减活动优惠 不支持使用优惠券等优惠
|
|
|
+ if (isAcReduce != null && isAcReduce && orderDon.getGoodsId() == 15) {
|
|
|
+ epOrderDonActivityReduce(orderDon);
|
|
|
+ //存在余额
|
|
|
+ deductBalancePayOrderMoney(orderDon, balance, user);
|
|
|
+ return;
|
|
|
+ }
|
|
|
//存在优惠券
|
|
|
if (couponUser != null) {
|
|
|
Long couponId = couponUser.getCouponId();
|
|
|
@@ -2165,24 +2174,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
|
|
|
//存在余额
|
|
|
- if (balance != null && balance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- BigDecimal money = orderDon.getMoney();
|
|
|
- //去掉余额 多出的部分
|
|
|
- BigDecimal subBalance = balance;
|
|
|
- orderDon.setMoney(money.subtract(subBalance));
|
|
|
- if (balance.compareTo(money) >= 0) {
|
|
|
- orderDon.setMoney(BigDecimal.ZERO);
|
|
|
- orderDon.setBalance(money);
|
|
|
- subBalance = money;
|
|
|
- orderDon.setType(OrderDon.Type.BALANCE);
|
|
|
- }
|
|
|
- BigDecimal userBalance = user.getBalance();
|
|
|
- //扣除余额 是否成功
|
|
|
- Integer success = userMapper.deductBalance(user.getId(), subBalance, userBalance);
|
|
|
- if (success != 1) throw BusinessRuntimeException.getInstance("您的余额不足!");
|
|
|
- orderDon.setBalance(subBalance);
|
|
|
- userBenefitsService.recordBalanceBySource(user.getId(), BigDecimal.valueOf(-subBalance.longValue()), UserBalanceSourceRecord.Source.payment);
|
|
|
- }
|
|
|
+ deductBalancePayOrderMoney(orderDon, balance, user);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -2734,4 +2726,58 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderRefundService.refundRecord(orderDon, orderRefundReq.getRefundMoney(), null, goodsDon, sku, outNo, orderDon.getType().getType());
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ public void epOrderDonActivityReduce(OrderDon orderDon) {
|
|
|
+ if (orderDon.getMoney().compareTo(Constant.FIVE_HUNDRED) < 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ EquipmentActivityReduce equipmentActivityReduce = equipmentActivityReduceMapper.selectOne(Wrappers.lambdaQuery(EquipmentActivityReduce.class)
|
|
|
+ .le(EquipmentActivityReduce::getSt, now)
|
|
|
+ .gt(EquipmentActivityReduce::getEt, now)
|
|
|
+ .eq(EquipmentActivityReduce::getDeleted, true)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (equipmentActivityReduce == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BigDecimal money = orderDon.getMoney();
|
|
|
+ BigDecimal acReduceMoney = BigDecimal.ZERO;
|
|
|
+ if (money.compareTo(Constant.FIVE_HUNDRED) >= 0 && money.compareTo(Constant.THOUSAND) < 0) {
|
|
|
+ //500-1000
|
|
|
+ acReduceMoney = equipmentActivityReduce.getF();
|
|
|
+ log.info("活动设备订单号:{}达到500元资格,满减金额:{}", orderDon.getOrderNo(), acReduceMoney.divide(BigDecimal.valueOf(100)));
|
|
|
+ } else if (money.compareTo(Constant.THOUSAND) >= 0 && money.compareTo(Constant.TWO_THOUSAND) < 0) {
|
|
|
+ //1000-2000
|
|
|
+ acReduceMoney = equipmentActivityReduce.getQ();
|
|
|
+ log.info("活动设备订单号:{}达到1000元资格,满减金额:{}", orderDon.getOrderNo(), acReduceMoney.divide(BigDecimal.valueOf(100)));
|
|
|
+ } else if (money.compareTo(Constant.TWO_THOUSAND) >= 0) {
|
|
|
+ //2000
|
|
|
+ acReduceMoney = equipmentActivityReduce.getTq();
|
|
|
+ log.info("活动设备订单号:{}达到2000元资格,满减金额:{}", orderDon.getOrderNo(), acReduceMoney.divide(BigDecimal.valueOf(100)));
|
|
|
+ }
|
|
|
+ orderDon.setMoney(orderDon.getMoney().subtract(acReduceMoney));
|
|
|
+ orderDon.setCouponMoney(acReduceMoney);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deductBalancePayOrderMoney(OrderDon orderDon, BigDecimal balance, User user) {
|
|
|
+ //存在余额
|
|
|
+ if (balance != null && balance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ BigDecimal money = orderDon.getMoney();
|
|
|
+ //去掉余额 多出的部分
|
|
|
+ BigDecimal subBalance = balance;
|
|
|
+ orderDon.setMoney(money.subtract(subBalance));
|
|
|
+ if (balance.compareTo(money) >= 0) {
|
|
|
+ orderDon.setMoney(BigDecimal.ZERO);
|
|
|
+ orderDon.setBalance(money);
|
|
|
+ subBalance = money;
|
|
|
+ orderDon.setType(OrderDon.Type.BALANCE);
|
|
|
+ }
|
|
|
+ BigDecimal userBalance = user.getBalance();
|
|
|
+ //扣除余额 是否成功
|
|
|
+ Integer success = userMapper.deductBalance(user.getId(), subBalance, userBalance);
|
|
|
+ if (success != 1) throw BusinessRuntimeException.getInstance("您的余额不足!");
|
|
|
+ orderDon.setBalance(subBalance);
|
|
|
+ userBenefitsService.recordBalanceBySource(user.getId(), BigDecimal.valueOf(-subBalance.longValue()), UserBalanceSourceRecord.Source.payment);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|