Commit f677c315 by 吕明尚

修改权益订单回调

parent cbd79471
......@@ -8,6 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -62,7 +63,7 @@ public class ConsumerMember extends BaseEntity {
* 会员进度
*/
@Excel(name = "会员进度")
private Long membershipProgress;
private BigDecimal membershipProgress;
/**
* 是否删除
......
package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.slf4j.Logger;
......@@ -46,6 +47,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
private MemberConfigService memberConfigService;
@Autowired
private ConsumerMemberService consumerMemberService;
@Autowired
private MemberProgressLogService memberProgressLogService;
/**
* 查询会员钱包
......@@ -133,6 +136,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
balanceLog.setVariableAmount(consumerWallet.getBalance());
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
balanceLog.setCreateTime(new Date());
balanceLogService.save(balanceLog);
}
if (consumerWallet.getRemainingDuration().compareTo(new BigDecimal(0)) > 0) {
......@@ -141,6 +145,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
durationLog.setCurrentDuration(new BigDecimal(0));
durationLog.setVariableDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationTime(new Date());
durationLog.setCreateTime(new Date());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLogService.save(durationLog);
}
......@@ -150,8 +155,17 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
integralLog.setCurrentIntegral(new BigDecimal(0));
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral());
integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLogService.save(integralLog);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(consumerWallet.getConsumerId());
memberProgressLog.setCurrentProgress(new BigDecimal(0));
memberProgressLog.setVariableProgress(consumerWallet.getRemainingIntegral());
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setCreateTime(new Date());
memberProgressLogService.save(memberProgressLog);
}
return i == 1;
}
......@@ -164,7 +178,6 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
.eq(MemberConfig::getMembershipLevel, 1L)
.eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex()));
one.setExpirationDate(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue()));
consumerMemberService.updateConsumerMember(one);
logger.debug("修改会员用户");
if (rechargeConf.getGiveType().contains(GiveTypeEnum.AMOUNT.getIndex())) {
BigDecimal balance = consumerWallet.getBalance().add(recharge.getRechargeAmount()).add(rechargeConf.getGiveAmount());
......@@ -179,6 +192,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
BigDecimal Integral = consumerWallet.getRemainingIntegral().add(divide);
consumerWallet.setRemainingIntegral(Integral);
}
int i = updateConsumerWallet(consumerWallet);
if (consumerWallet.getBalance().compareTo(new BigDecimal(0)) > 0) {
......@@ -213,7 +227,29 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
integralLog.setCreateTime(new Date());
integralLogService.save(integralLog);
logger.debug("新增积分日志");
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(consumerWallet.getConsumerId());
memberProgressLog.setCurrentProgress(one.getMembershipProgress());
memberProgressLog.setVariableProgress(divide);
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setCreateTime(new Date());
memberProgressLogService.save(memberProgressLog);
one.setMembershipProgress(one.getMembershipProgress().add(divide));
}
//查询当前会员类型和下一级的会员配置
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, one.getMemberType())
.eq(MemberConfig::getMembershipLevel, one.getMembershipLevel() + 1L));
if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
//判断是否升级
if (one.getMembershipProgress().compareTo(BigDecimal.valueOf(memberConfigServiceOne.getLimitRequirements())) >= 0) {
one.setMembershipLevel(one.getMembershipLevel() + 1L);
one.setMemberConfigId(one.getId());
}
}
consumerMemberService.updateConsumerMember(one);
return i == 1;
}
}
......@@ -26,6 +26,7 @@ import share.system.request.CreateEquityMembersRequest;
import share.system.response.EquityMembersResultResponse;
import share.system.service.*;
import java.math.BigDecimal;
import java.util.*;
/**
......@@ -158,7 +159,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
newConsumerMember.setMemberConfigId(memberConfig.getId());
newConsumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, new Date())),
equityMembersOrderConfig.getValidityPeriod().intValue()));
newConsumerMember.setMembershipProgress(0L);
newConsumerMember.setMembershipProgress(BigDecimal.ZERO);
newConsumerMember.setCreateTime(new Date());
consumerMemberService.save(newConsumerMember);
logger.debug("新增权益会员");
......
......@@ -161,7 +161,7 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
.eq(MemberConfig::getMembershipLevel, 1L)
.eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex()));
consumerMember.setMemberConfigId(memberConfig.getId());
consumerMember.setMembershipProgress(0L);
consumerMember.setMembershipProgress(BigDecimal.ZERO);
consumerMember.setExpirationDate(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue()));
consumerMember.setCreateTime(new Date());
consumerMemberService.save(consumerMember);
......@@ -210,6 +210,7 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
private void extracted(Recharge recharge) {
//新增会员钱包
ConsumerMember one = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, recharge.getConsumerId()));
RechargeConf rechargeConf = rechargeConfService.selectRechargeConfById(recharge.getRechargeConfId());
ConsumerWallet consumerWallet = new ConsumerWallet();
consumerWallet.setConsumerId(recharge.getConsumerId());
......@@ -227,6 +228,7 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
if (rechargeConf.getGiveType().contains(GiveTypeEnum.INTEGRAL.getIndex())) {
BigDecimal Integral = recharge.getRechargeAmount().multiply(rechargeConf.getGiveRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
consumerWallet.setRemainingIntegral(Integral);
one.setMembershipProgress(Integral);
} else {
consumerWallet.setRemainingIntegral(new BigDecimal(0));
}
......
......@@ -1079,8 +1079,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerWalletService.updateById(consumerWallet);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(BigDecimal.valueOf(consumerMember.getMembershipProgress()));
Long membershipProgress = sOrder.getBalance().add(BigDecimal.valueOf(consumerMember.getMembershipProgress())).longValue();
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
Long membershipProgress = sOrder.getBalance().add(consumerMember.getMembershipProgress()).longValue();
//查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
......@@ -1093,7 +1093,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerMember.setMemberConfigId(one.getId());
}
}
consumerMember.setMembershipProgress(membershipProgress);
consumerMember.setMembershipProgress(BigDecimal.valueOf(membershipProgress));
memberProgressLog.setVariableProgress(BigDecimal.valueOf(membershipProgress));
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date());
......@@ -1108,11 +1108,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
Long membershipProgress;
if (ObjectUtil.isNotEmpty(coupon) && !coupon.getPlatformType().equals(PlatformTypeEnum.SELF.getCode()) && coupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
integral = consumerWallet.getRemainingIntegral().add(sOrder.getPayPrice()).add(sOrder.getBalance()).add(coupon.getCouponPayPrice());
membershipProgress = BigDecimal.valueOf(consumerMember.getMembershipProgress()).add(sOrder.getBalance())
membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance())
.add(sOrder.getPayPrice()).add(coupon.getCouponPayPrice()).longValue();
} else {
integral = consumerWallet.getRemainingIntegral().add(sOrder.getPayPrice()).add(sOrder.getBalance());
membershipProgress = BigDecimal.valueOf(consumerMember.getMembershipProgress()).add(sOrder.getBalance()).add(sOrder.getPayPrice()).longValue();
membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance()).add(sOrder.getPayPrice()).longValue();
}
integralLog.setVariableIntegral(integral.subtract(consumerWallet.getRemainingIntegral()));
......@@ -1123,7 +1123,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerWalletService.updateById(consumerWallet);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(BigDecimal.valueOf(consumerMember.getMembershipProgress()));
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
//查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
......@@ -1135,7 +1135,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerMember.setMemberConfigId(one.getId());
}
}
consumerMember.setMembershipProgress(membershipProgress);
consumerMember.setMembershipProgress(BigDecimal.valueOf(membershipProgress));
memberProgressLog.setVariableProgress(BigDecimal.valueOf(membershipProgress));
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date());
......@@ -1862,8 +1862,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerWalletService.updateById(consumerWallet);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(BigDecimal.valueOf(consumerMember.getMembershipProgress()));
Long membershipProgress = BigDecimal.valueOf(consumerMember.getMembershipProgress()).subtract(sOrder.getBalance()).longValue();
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
Long membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance()).longValue();
//查询当前会员类型和当前等级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
......@@ -1877,7 +1877,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
memberProgressLog.setVariableProgress(sOrder.getBalance());
consumerMember.setMembershipProgress(membershipProgress);
consumerMember.setMembershipProgress(BigDecimal.valueOf(membershipProgress));
memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLogService.save(memberProgressLog);
......@@ -1892,11 +1892,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
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 = BigDecimal.valueOf(consumerMember.getMembershipProgress())
membershipProgress = consumerMember.getMembershipProgress()
.subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice()).longValue();
} else {
integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance());
membershipProgress = BigDecimal.valueOf(consumerMember.getMembershipProgress()).subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()).longValue();
membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getPayPrice()).subtract(sOrder.getBalance()).longValue();
}
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral().subtract(integral));
......@@ -1907,7 +1907,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerWalletService.updateById(consumerWallet);
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(BigDecimal.valueOf(consumerMember.getMembershipProgress()));
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
//查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
......@@ -1919,8 +1919,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerMember.setMemberConfigId(one.getId());
}
}
memberProgressLog.setVariableProgress(BigDecimal.valueOf(consumerMember.getMembershipProgress() - membershipProgress));
consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setVariableProgress(consumerMember.getMembershipProgress().subtract(BigDecimal.valueOf(membershipProgress)));
consumerMember.setMembershipProgress(BigDecimal.valueOf(membershipProgress));
memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLogService.save(memberProgressLog);
......
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