Commit 13f950ee by 吕明尚

权益订单回调增加赠送积分的逻辑

parent 2a2b97e0
......@@ -56,6 +56,8 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
private ConsumerWalletService consumerWalletService;
@Autowired
private IntegralLogService integralLogService;
@Autowired
private MemberProgressLogService memberProgressLogService;
/**
* 查询权益会员订单
......@@ -179,20 +181,20 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
newConsumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, new Date())),
equityMembersOrderConfig.getValidityPeriod().intValue()));
newConsumerMember.setMembershipProgress(equityMembersOrderConfig.getGiftPoints());
if (equityMembersOrderConfig.getGiftPoints().compareTo(BigDecimal.ZERO) > 0) {
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(equityMembersOrder.getConsumerId());
memberProgressLog.setCurrentProgress(BigDecimal.ZERO);
memberProgressLog.setVariableProgress(equityMembersOrderConfig.getGiftPoints());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), Math.toIntExact(memberConfig.getValidityPeriod())));
memberProgressLogService.save(memberProgressLog);
}
newConsumerMember.setCreateTime(new Date());
newConsumerMember.setIsRights(YesNoEnum.yes.getIndex());
consumerMemberService.save(newConsumerMember);
//增加积分日志
if (equityMembersOrderConfig.getGiftPoints().compareTo(BigDecimal.ZERO) > 0) {
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(equityMembersOrder.getConsumerId());
integralLog.setCurrentIntegral(BigDecimal.ZERO);
integralLog.setVariableIntegral(equityMembersOrderConfig.getGiftPoints());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date());
integralLogService.save(integralLog);
}
logger.debug("新增权益会员");
Map<String, String> map = new HashMap<>();
map.put("consumerId", String.valueOf(newConsumerMember.getConsumerId()));
......@@ -202,23 +204,24 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
redisUtil.set(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME.getValue() + equityMembersOrder.getConsumerId(), json.toString());
logger.debug("redis新增权益会员有效期");
} else {
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
.eq(MemberConfig::getMemberType, MemberTypeEnum.RIGHTS.getIndex()));
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
//在原来的基础上增加有效期
consumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, consumerMember.getExpirationDate())),
equityMembersOrderConfig.getValidityPeriod().intValue()));
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember);
memberConfigServiceOne.getValidityPeriod().intValue()));
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne);
consumerMemberService.updateConsumerMember(consumerMember);
logger.debug("权益会员原来的基础上增加有效期");
} else {
consumerMember.setIsRights(YesNoEnum.yes.getIndex());
//修改会员类型为权益会员
consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
.eq(MemberConfig::getMemberType, MemberTypeEnum.RIGHTS.getIndex())).getId());
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
consumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, new Date())),
equityMembersOrderConfig.getValidityPeriod().intValue()));
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember);
memberConfigServiceOne.getValidityPeriod().intValue()));
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne);
consumerMemberService.updateConsumerMember(consumerMember);
logger.debug("修改会员类型为权益会员");
}
......@@ -235,23 +238,47 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
consumerWalletOne.setBalance(BigDecimal.ZERO);
consumerWalletOne.setRemainingDuration(BigDecimal.ZERO);
consumerWalletOne.setRemainingIntegral(BigDecimal.ZERO);
if (equityMembersOrderConfig.getGiftPoints().compareTo(BigDecimal.ZERO) > 0) {
consumerWalletOne.setRemainingIntegral(consumerWalletOne.getRemainingIntegral().add(equityMembersOrderConfig.getGiftPoints()));
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(equityMembersOrder.getConsumerId());
integralLog.setCurrentIntegral(BigDecimal.ZERO);
integralLog.setVariableIntegral(equityMembersOrderConfig.getGiftPoints());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date());
integralLogService.save(integralLog);
}
consumerWalletOne.setCreateTime(new Date());
consumerWalletService.save(consumerWalletOne);
}
updateEquityMembersOrder(equityMembersOrder);
}
private void extracted(EquityMembersOrder equityMembersOrder, EquityMembersOrderConfig equityMembersOrderConfig, ConsumerMember consumerMember) {
private void extracted(EquityMembersOrder equityMembersOrder, EquityMembersOrderConfig equityMembersOrderConfig,
ConsumerMember consumerMember, ConsumerWallet consumerWallet, MemberConfig memberConfigServiceOne) {
if (equityMembersOrderConfig.getGiftPoints().compareTo(BigDecimal.ZERO) > 0) {
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(equityMembersOrder.getConsumerId());
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
consumerMember.setMembershipProgress(equityMembersOrderConfig.getGiftPoints().add(consumerMember.getMembershipProgress()));
memberProgressLog.setVariableProgress(equityMembersOrderConfig.getGiftPoints().add(consumerMember.getMembershipProgress()));
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), Math.toIntExact(memberConfigServiceOne.getValidityPeriod())));
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(equityMembersOrder.getConsumerId());
integralLog.setCurrentIntegral(consumerMember.getMembershipProgress());
integralLog.setVariableIntegral(equityMembersOrderConfig.getGiftPoints().add(consumerMember.getMembershipProgress()));
consumerMember.setMembershipProgress(equityMembersOrderConfig.getGiftPoints().add(consumerMember.getMembershipProgress()));
consumerWallet.setRemainingIntegral(consumerWallet.getRemainingIntegral().add(equityMembersOrderConfig.getGiftPoints()));
integralLog.setVariableIntegral(equityMembersOrderConfig.getGiftPoints().add(consumerWallet.getRemainingIntegral()));
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date());
integralLogService.save(integralLog);
memberProgressLogService.save(memberProgressLog);
consumerWalletService.updateById(consumerWallet);
}
//查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
......
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