|
|
@@ -431,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(), payRequest.getIsAcReduce());
|
|
|
- }
|
|
|
-
|
|
|
- if (isSpecificPrice && (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0 || orderDon.getMoney().compareTo(specificPrice) != 0)) {
|
|
|
- throw BusinessRuntimeException.getInstance("专属价格不支持使用其他优惠");
|
|
|
- }
|
|
|
|
|
|
orderDon.setSkuId(payRequest.getSkuId());
|
|
|
orderDon.setRelationId(relationId);
|
|
|
@@ -465,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());
|
|
|
@@ -2090,6 +2090,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//针对设备 满减活动优惠 不支持使用优惠券等优惠
|
|
|
if (isAcReduce != null && isAcReduce && orderDon.getGoodsId() == 15) {
|
|
|
epOrderDonActivityReduce(orderDon);
|
|
|
+ //存在余额
|
|
|
+ deductBalancePayOrderMoney(orderDon, balance, user);
|
|
|
return;
|
|
|
}
|
|
|
//存在优惠券
|
|
|
@@ -2172,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);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -2748,26 +2733,51 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
DateTime now = DateTime.now();
|
|
|
EquipmentActivityReduce equipmentActivityReduce = equipmentActivityReduceMapper.selectOne(Wrappers.lambdaQuery(EquipmentActivityReduce.class)
|
|
|
- .ge(EquipmentActivityReduce::getSt, now)
|
|
|
- .lt(EquipmentActivityReduce::getEt, now)
|
|
|
+ .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.getId(), acReduceMoney.divide(BigDecimal.valueOf(100)));
|
|
|
+ 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.getId(), acReduceMoney.divide(BigDecimal.valueOf(100)));
|
|
|
+ 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.getId(), acReduceMoney.divide(BigDecimal.valueOf(100)));
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|