Commit f0d8a186 by 吕明尚

修改下单和退款自动升级和降级

parent fc72dcec
package share.quartz.task; package share.quartz.task;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
...@@ -520,6 +521,9 @@ public class RedisTask { ...@@ -520,6 +521,9 @@ public class RedisTask {
List<MemberProgressLog> list = memberProgressLogService.list(new LambdaQueryWrapper<MemberProgressLog>() List<MemberProgressLog> list = memberProgressLogService.list(new LambdaQueryWrapper<MemberProgressLog>()
.gt(MemberProgressLog::getExpirationTime, new Date()) .gt(MemberProgressLog::getExpirationTime, new Date())
); );
if (CollectionUtil.isEmpty(list)) {
return;
}
list.sort(Comparator.comparing(MemberProgressLog::getOperationType).reversed()); list.sort(Comparator.comparing(MemberProgressLog::getOperationType).reversed());
//获得list的consumerId //获得list的consumerId
List<Long> consumerIds = list.stream().map(MemberProgressLog::getConsumerId).distinct().collect(Collectors.toList()); List<Long> consumerIds = list.stream().map(MemberProgressLog::getConsumerId).distinct().collect(Collectors.toList());
......
...@@ -1109,21 +1109,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1109,21 +1109,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
integralLog.setConsumerId(sOrder.getConsumerId()); integralLog.setConsumerId(sOrder.getConsumerId());
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral()); integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
BigDecimal integral; BigDecimal integral;
Long membershipProgress; BigDecimal membershipProgress;
if (ObjectUtil.isNotEmpty(coupon) && !coupon.getPlatformType().equals(PlatformTypeEnum.SELF.getCode()) && coupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) { if (ObjectUtil.isNotEmpty(coupon) && !coupon.getPlatformType().equals(PlatformTypeEnum.SELF.getCode()) && coupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
integral = consumerWallet.getRemainingIntegral().add(coupon.getCouponPayPrice()).add(sOrder.getBalance()); integral = consumerWallet.getRemainingIntegral().add(coupon.getCouponPayPrice()).add(sOrder.getBalance());
membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance()) membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance())
.add(coupon.getCouponPayPrice()).longValue(); .add(coupon.getCouponPayPrice());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
integral = integral.add(sOrder.getPayPrice()); integral = integral.add(sOrder.getPayPrice());
membershipProgress = BigDecimal.valueOf(membershipProgress).add(sOrder.getPayPrice()).longValue(); membershipProgress = membershipProgress.add(sOrder.getPayPrice());
} }
} else { } else {
integral = consumerWallet.getRemainingIntegral().add(sOrder.getBalance()); integral = consumerWallet.getRemainingIntegral().add(sOrder.getBalance());
membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance()).longValue(); membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) {
integral = integral.add(sOrder.getPayPrice()); integral = integral.add(sOrder.getPayPrice());
membershipProgress = BigDecimal.valueOf(membershipProgress).add(sOrder.getPayPrice()).longValue(); membershipProgress = membershipProgress.add(sOrder.getPayPrice());
} }
} }
integralLog.setVariableIntegral(integral.subtract(consumerWallet.getRemainingIntegral())); integralLog.setVariableIntegral(integral.subtract(consumerWallet.getRemainingIntegral()));
...@@ -1136,19 +1136,31 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1136,19 +1136,31 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
MemberProgressLog memberProgressLog = new MemberProgressLog(); MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId()); memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress()); memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId());
if (ObjectUtil.isNotEmpty(memberConfig)) {
//判断是否升级
if (membershipProgress.compareTo(BigDecimal.valueOf(memberConfig.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(memberConfig.getId());
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
}
}
} else {
//查询当前会员类型和下一级的会员配置 //查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L)); .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L));
if (ObjectUtil.isNotEmpty(one)) { if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级 //判断是否升级
if (membershipProgress.compareTo(one.getLimitRequirements()) >= 0) { if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(one.getId()); consumerMember.setMemberConfigId(one.getId());
} }
} }
consumerMember.setMembershipProgress(BigDecimal.valueOf(membershipProgress)); }
memberProgressLog.setVariableProgress(BigDecimal.valueOf(membershipProgress)); consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setVariableProgress(membershipProgress.subtract(consumerMember.getMembershipProgress()));
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
...@@ -1880,7 +1892,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1880,7 +1892,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
MemberProgressLog memberProgressLog = new MemberProgressLog(); MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId()); memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress()); memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
Long membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance()).longValue(); BigDecimal membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance());
//查询当前会员类型和当前等级的会员配置 //查询当前会员类型和当前等级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
...@@ -1888,13 +1900,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1888,13 +1900,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (ObjectUtil.isNotEmpty(one)) { if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级 //判断是否升级
if (membershipProgress.compareTo(one.getLimitRequirements()) < 0) { if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(one.getId()); 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());
} else {
consumerMember.setMemberType(MemberTypeEnum.NORMAL.getIndex());
}
} }
} }
memberProgressLog.setVariableProgress(sOrder.getBalance()); memberProgressLog.setVariableProgress(sOrder.getBalance());
consumerMember.setMembershipProgress(BigDecimal.valueOf(membershipProgress)); consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.no.getIndex()); memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod(); Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod();
...@@ -1907,15 +1927,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1907,15 +1927,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
integralLog.setConsumerId(sOrder.getConsumerId()); integralLog.setConsumerId(sOrder.getConsumerId());
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral()); integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
BigDecimal integral; BigDecimal integral;
Long membershipProgress; BigDecimal membershipProgress;
if (ObjectUtil.isNotEmpty(coupon) && !coupon.getPlatformType().equals(PlatformTypeEnum.SELF.getCode()) && coupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) { if (ObjectUtil.isNotEmpty(coupon) && !coupon.getPlatformType().equals(PlatformTypeEnum.SELF.getCode()) && coupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getPayPrice()) integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getPayPrice())
.subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice()); .subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice());
membershipProgress = consumerMember.getMembershipProgress() membershipProgress = consumerMember.getMembershipProgress()
.subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice()).longValue(); .subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice());
} else { } else {
integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()); integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance());
membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()).longValue(); membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance());
} }
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral().subtract(integral)); integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral().subtract(integral));
...@@ -1933,13 +1953,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1933,13 +1953,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())); .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (ObjectUtil.isNotEmpty(one)) { if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级 //判断是否升级
if (membershipProgress.compareTo(one.getLimitRequirements()) < 0) { if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(one.getId()); 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(BigDecimal.valueOf(membershipProgress))); memberProgressLog.setVariableProgress(consumerMember.getMembershipProgress().subtract(membershipProgress));
consumerMember.setMembershipProgress(BigDecimal.valueOf(membershipProgress)); consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.no.getIndex()); memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod(); Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod();
......
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