Commit af415ead by 吕明尚

修改累计消费进行积分

parent e22fd60d
...@@ -160,7 +160,6 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -160,7 +160,6 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
durationLogService.save(durationLog); durationLogService.save(durationLog);
} }
if (consumerWallet.getRemainingIntegral().compareTo(new BigDecimal(0)) > 0) { if (consumerWallet.getRemainingIntegral().compareTo(new BigDecimal(0)) > 0) {
accumulatedConsumptionStatistics(consumerWallet, one, memberConfig);
IntegralLog integralLog = new IntegralLog(); IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId()); integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(new BigDecimal(0)); integralLog.setCurrentIntegral(new BigDecimal(0));
...@@ -186,6 +185,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -186,6 +185,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
one.setMemberConfigId(newOne.getId()); one.setMemberConfigId(newOne.getId());
consumerMemberService.updateConsumerMember(one); consumerMemberService.updateConsumerMember(one);
} }
logger.debug("统计累计积分");
accumulatedConsumptionStatistics(consumerWallet, one, memberConfig);
} }
return i == 1; return i == 1;
} }
...@@ -278,6 +279,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -278,6 +279,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
private void accumulatedConsumptionStatistics(ConsumerWallet consumerWallet, ConsumerMember one, MemberConfig memberConfig) { private void accumulatedConsumptionStatistics(ConsumerWallet consumerWallet, ConsumerMember one, MemberConfig memberConfig) {
logger.debug("统计累计积分开始");
final BigDecimal[] consumption = {BigDecimal.ZERO}; final BigDecimal[] consumption = {BigDecimal.ZERO};
//查询含当天23:59:59以及往前90天的00:00:00整天的订单 //查询含当天23:59:59以及往前90天的00:00:00整天的订单
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
...@@ -303,6 +305,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -303,6 +305,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
.in(SOrder::getStatus, OrderStatusEnum.getValidOrderStatus()) .in(SOrder::getStatus, OrderStatusEnum.getValidOrderStatus())
.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex())); .eq(SOrder::getIsDelete, YesNoEnum.no.getIndex()));
if (CollectionUtil.isEmpty(orderList)) { if (CollectionUtil.isEmpty(orderList)) {
logger.debug("订单为为空");
return; return;
} }
Map<Long, SCoupon> sCouponMap = sCouponService.list().stream().collect(Collectors.toMap(SCoupon::getId, Function.identity())); Map<Long, SCoupon> sCouponMap = sCouponService.list().stream().collect(Collectors.toMap(SCoupon::getId, Function.identity()));
...@@ -317,23 +320,25 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -317,23 +320,25 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
consumption[0] = consumption[0].add(sCouponMap.get(item.getCouponId()).getCouponPayPrice()); consumption[0] = consumption[0].add(sCouponMap.get(item.getCouponId()).getCouponPayPrice());
} }
}); });
logger.debug("优惠券购买金额:" + consumption[0]);
if (one.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (one.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
//orderList累加payPrice //orderList累加payPrice
consumption[0] = consumption[0].add(orderList.stream().map(SOrder::getPayPrice).reduce(BigDecimal.ZERO, BigDecimal::add)); consumption[0] = consumption[0].add(orderList.stream().map(SOrder::getPayPrice).reduce(BigDecimal.ZERO, BigDecimal::add));
logger.debug("订单实付金额:" + consumption[0]);
} }
if (consumption[0].compareTo(BigDecimal.ZERO) != 0) { if (consumption[0].compareTo(BigDecimal.ZERO) != 0) {
IntegralLog integralLog = new IntegralLog(); IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId()); integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(new BigDecimal(0)); integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral()); integralLog.setVariableIntegral(consumption[0]);
integralLog.setOperationTime(new Date()); integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date()); integralLog.setCreateTime(new Date());
integralLog.setOperationType(YesNoEnum.yes.getIndex()); integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLogService.save(integralLog); integralLogService.save(integralLog);
MemberProgressLog memberProgressLog = new MemberProgressLog(); MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(consumerWallet.getConsumerId()); memberProgressLog.setConsumerId(consumerWallet.getConsumerId());
memberProgressLog.setCurrentProgress(new BigDecimal(0)); memberProgressLog.setCurrentProgress(one.getMembershipProgress());
memberProgressLog.setVariableProgress(consumerWallet.getRemainingIntegral()); memberProgressLog.setVariableProgress(consumption[0]);
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment