Commit 8c855714 by 吕明尚

修改退款日志

parent 2d91f978
......@@ -1185,6 +1185,156 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private void refundExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember) {
if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(sOrder.getConsumerId());
durationLog.setVariableDuration(sOrder.getDuration());
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(new Date());
durationLogService.save(durationLog);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().add(sOrder.getDuration()));
consumerWalletService.updateById(consumerWallet);
}
if (ObjectUtil.isNotEmpty(sOrder.getBalance()) && sOrder.getBalance().compareTo(BigDecimal.ZERO) > 0) {
BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(sOrder.getConsumerId());
balanceLog.setVariableAmount(sOrder.getBalance());
balanceLog.setCurrentBalance(consumerWallet.getBalance());
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
balanceLogService.save(balanceLog);
consumerWallet.setBalance(consumerWallet.getBalance().add(sOrder.getBalance()));
consumerWalletService.updateById(consumerWallet);
}
}
if (ObjectUtil.isNotEmpty(consumerMember)) {
// if (consumerMember.getMemberType().equals(MemberTypeEnum.RECHARGE.getIndex())) {
// IntegralLog integralLog = new IntegralLog();
// integralLog.setConsumerId(sOrder.getConsumerId());
// integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
// BigDecimal integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getBalance());
// consumerWallet.setRemainingIntegral(integral);
// integralLog.setVariableIntegral(sOrder.getBalance());
// integralLog.setOperationType(YesNoEnum.no.getIndex());
// integralLog.setOperationTime(new Date());
// integralLogService.save(integralLog);
// consumerWalletService.updateById(consumerWallet);
// MemberProgressLog memberProgressLog = new MemberProgressLog();
// memberProgressLog.setConsumerId(sOrder.getConsumerId());
// memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
// BigDecimal membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance());
// //查询当前会员类型和当前等级的会员配置
// MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
// .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
// .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
//
// if (ObjectUtil.isNotEmpty(one)) {
// //判断是否升级
// if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
// consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
// MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
// .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
// .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
// if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
// consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
// }
// }
// }
// memberProgressLog.setVariableProgress(sOrder.getBalance());
// consumerMember.setMembershipProgress(membershipProgress);
// memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
// memberProgressLog.setOperationTime(new Date());
// Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod();
// memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), validityPeriod.intValue()));
// memberProgressLogService.save(memberProgressLog);
// consumerMemberService.updateConsumerMember(consumerMember);
// } else if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
SConsumerCoupon coupon = consumerCouponService.getById(sOrder.getCouponId());
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(sOrder.getConsumerId());
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
BigDecimal integral;
BigDecimal membershipProgress;
if (ObjectUtil.isNotEmpty(coupon) && !coupon.getPlatformType().equals(PlatformTypeEnum.SELF.getCode()) && coupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
integral = consumerWallet.getRemainingIntegral()
.subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice());
membershipProgress = consumerMember.getMembershipProgress()
.subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
integral = integral.subtract(sOrder.getPayPrice());
membershipProgress = membershipProgress.subtract(sOrder.getPayPrice());
}
} else {
integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getBalance());
membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
integral = integral.subtract(sOrder.getPayPrice());
membershipProgress = membershipProgress.subtract(sOrder.getPayPrice());
}
}
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral().subtract(integral));
consumerWallet.setRemainingIntegral(integral);
integralLog.setOperationType(YesNoEnum.no.getIndex());
integralLog.setOperationTime(new Date());
integralLogService.save(integralLog);
consumerWalletService.updateById(consumerWallet);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() - 1L));
if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(one.getId());
}
} else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() - 1L));
if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(one.getId());
}
}
} else {
//查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() - 1L));
if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级
if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(one.getId());
}
}
}
memberProgressLog.setVariableProgress(consumerMember.getMembershipProgress().subtract(membershipProgress));
consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date());
Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod();
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), validityPeriod.intValue()));
if (!consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
memberProgressLogService.save(memberProgressLog);
consumerMemberService.updateConsumerMember(consumerMember);
}
}
// }
}
private String lockOrder(CreateOrderRequest request) throws BaseException {
try {
//自旋10次,每次等待1秒
......@@ -1894,125 +2044,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return Boolean.TRUE;
}
private void refundExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember) {
if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(sOrder.getConsumerId());
durationLog.setVariableDuration(sOrder.getDuration());
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(new Date());
durationLogService.save(durationLog);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().add(sOrder.getDuration()));
consumerWalletService.updateById(consumerWallet);
}
if (ObjectUtil.isNotEmpty(sOrder.getBalance()) && sOrder.getBalance().compareTo(BigDecimal.ZERO) > 0) {
BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(sOrder.getConsumerId());
balanceLog.setVariableAmount(sOrder.getBalance());
balanceLog.setCurrentBalance(consumerWallet.getBalance());
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
balanceLogService.save(balanceLog);
consumerWallet.setBalance(consumerWallet.getBalance().add(sOrder.getBalance()));
consumerWalletService.updateById(consumerWallet);
}
}
if (ObjectUtil.isNotEmpty(consumerMember)) {
if (consumerMember.getMemberType().equals(MemberTypeEnum.RECHARGE.getIndex())) {
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(sOrder.getConsumerId());
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
BigDecimal integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getBalance());
consumerWallet.setRemainingIntegral(integral);
integralLog.setVariableIntegral(sOrder.getBalance());
integralLog.setOperationType(YesNoEnum.no.getIndex());
integralLog.setOperationTime(new Date());
integralLogService.save(integralLog);
consumerWalletService.updateById(consumerWallet);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
BigDecimal membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance());
//查询当前会员类型和当前等级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级
if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
}
}
}
memberProgressLog.setVariableProgress(sOrder.getBalance());
consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date());
Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod();
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), validityPeriod.intValue()));
memberProgressLogService.save(memberProgressLog);
consumerMemberService.updateConsumerMember(consumerMember);
} else if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
SConsumerCoupon coupon = consumerCouponService.getById(sOrder.getCouponId());
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(sOrder.getConsumerId());
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
BigDecimal integral;
BigDecimal membershipProgress;
if (ObjectUtil.isNotEmpty(coupon) && !coupon.getPlatformType().equals(PlatformTypeEnum.SELF.getCode()) && coupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getPayPrice())
.subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice());
membershipProgress = consumerMember.getMembershipProgress()
.subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice());
} else {
integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance());
membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance());
}
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral().subtract(integral));
consumerWallet.setRemainingIntegral(integral);
integralLog.setOperationType(YesNoEnum.no.getIndex());
integralLog.setOperationTime(new Date());
integralLogService.save(integralLog);
consumerWalletService.updateById(consumerWallet);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
//查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级
if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
}
}
}
memberProgressLog.setVariableProgress(consumerMember.getMembershipProgress().subtract(membershipProgress));
consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date());
Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod();
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), validityPeriod.intValue()));
memberProgressLogService.save(memberProgressLog);
consumerMemberService.updateConsumerMember(consumerMember);
}
}
}
@Override
public List<SOrder> payedUnrefundListByUserId(Long userId) {
......
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