Commit 89fa8e3b by 吕明尚

修改充值支付回调

parent 1830afdf
package share.common.enums;
public enum GiveTypeEnum {
//金额
AMOUNT("1", "金额"),
//时长
DURATION("2", "时长"),
//积分
INTEGRAL("3", "积分"),
;
private String index;
private String name;
GiveTypeEnum(String index, String name) {
this.index = index;
this.name = name;
}
GiveTypeEnum() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIndex() {
return index;
}
public void setIndex(String index) {
this.index = index;
}
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.enums.GiveTypeEnum;
import share.common.enums.MemberTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils;
......@@ -122,71 +123,90 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
@Override
public boolean addConsumerWallet(ConsumerWallet consumerWallet) {
int i = consumerWalletMapper.insertConsumerWallet(consumerWallet);
BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(consumerWallet.getConsumerId());
balanceLog.setCurrentBalance(new BigDecimal(0));
balanceLog.setVariableAmount(consumerWallet.getBalance());
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
balanceLogService.save(balanceLog);
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setCurrentDuration(new BigDecimal(0));
durationLog.setVariableDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationTime(new Date());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLogService.save(durationLog);
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(new BigDecimal(0));
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral());
integralLog.setOperationTime(new Date());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLogService.save(integralLog);
if (consumerWallet.getBalance().compareTo(new BigDecimal(0)) > 0) {
BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(consumerWallet.getConsumerId());
balanceLog.setCurrentBalance(new BigDecimal(0));
balanceLog.setVariableAmount(consumerWallet.getBalance());
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
balanceLogService.save(balanceLog);
}
if (consumerWallet.getRemainingDuration().compareTo(new BigDecimal(0)) > 0) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setCurrentDuration(new BigDecimal(0));
durationLog.setVariableDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationTime(new Date());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLogService.save(durationLog);
}
if (consumerWallet.getRemainingIntegral().compareTo(new BigDecimal(0)) > 0) {
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(new BigDecimal(0));
integralLog.setVariableIntegral(consumerWallet.getRemainingIntegral());
integralLog.setOperationTime(new Date());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLogService.save(integralLog);
}
return i == 1;
}
@Override
public boolean editConsumerWallet(ConsumerWallet consumerWallet, Recharge recharge, ConsumerMember one) {
BigDecimal divide = new BigDecimal(0);
RechargeConf rechargeConf = rechargeConfService.selectRechargeConfById(recharge.getRechargeConfId());
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, 1L)
.eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex()));
one.setExpirationDate(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue()));
consumerMemberService.updateConsumerMember(one);
BigDecimal balance = consumerWallet.getBalance().add(recharge.getRechargeAmount()).add(rechargeConf.getGiveAmount());
consumerWallet.setBalance(balance);
BigDecimal duration = consumerWallet.getRemainingDuration().add(rechargeConf.getGiveDuration());
consumerWallet.setRemainingDuration(duration);
BigDecimal divide = recharge.getRechargeAmount().multiply(rechargeConf.getGiveRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
BigDecimal Integral = consumerWallet.getRemainingIntegral().add(divide);
consumerWallet.setRemainingIntegral(Integral);
if (rechargeConf.getGiveType().contains(GiveTypeEnum.AMOUNT.getIndex())) {
BigDecimal balance = consumerWallet.getBalance().add(recharge.getRechargeAmount()).add(rechargeConf.getGiveAmount());
consumerWallet.setBalance(balance);
}
if (rechargeConf.getGiveType().contains(GiveTypeEnum.DURATION.getIndex())) {
BigDecimal duration = consumerWallet.getRemainingDuration().add(rechargeConf.getGiveDuration());
consumerWallet.setRemainingDuration(duration);
}
if (rechargeConf.getGiveType().contains(GiveTypeEnum.INTEGRAL.getIndex())) {
divide = recharge.getRechargeAmount().multiply(rechargeConf.getGiveRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
BigDecimal Integral = consumerWallet.getRemainingIntegral().add(divide);
consumerWallet.setRemainingIntegral(Integral);
}
int i = updateConsumerWallet(consumerWallet);
BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(consumerWallet.getConsumerId());
balanceLog.setCurrentBalance(consumerWallet.getBalance());
balanceLog.setVariableAmount(recharge.getRechargeAmount().add(rechargeConf.getGiveAmount()));
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
balanceLog.setCreateTime(new Date());
balanceLogService.save(balanceLog);
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setVariableDuration(rechargeConf.getGiveDuration());
durationLog.setOperationTime(new Date());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setCreateTime(new Date());
durationLogService.save(durationLog);
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
integralLog.setVariableIntegral(divide);
integralLog.setOperationTime(new Date());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setCreateTime(new Date());
integralLogService.save(integralLog);
if (consumerWallet.getBalance().compareTo(new BigDecimal(0)) > 0) {
BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(consumerWallet.getConsumerId());
balanceLog.setCurrentBalance(consumerWallet.getBalance());
balanceLog.setVariableAmount(recharge.getRechargeAmount().add(rechargeConf.getGiveAmount()));
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
balanceLog.setCreateTime(new Date());
balanceLogService.save(balanceLog);
}
if (consumerWallet.getRemainingDuration().compareTo(new BigDecimal(0)) > 0) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setVariableDuration(rechargeConf.getGiveDuration());
durationLog.setOperationTime(new Date());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setCreateTime(new Date());
durationLogService.save(durationLog);
}
if (consumerWallet.getRemainingIntegral().compareTo(new BigDecimal(0)) > 0) {
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(consumerWallet.getConsumerId());
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
integralLog.setVariableIntegral(divide);
integralLog.setOperationTime(new Date());
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setCreateTime(new Date());
integralLogService.save(integralLog);
}
return i == 1;
}
}
......@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import share.common.enums.GiveTypeEnum;
import share.common.enums.MemberTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
......@@ -199,11 +200,23 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
RechargeConf rechargeConf = rechargeConfService.selectRechargeConfById(recharge.getRechargeConfId());
ConsumerWallet consumerWallet = new ConsumerWallet();
consumerWallet.setConsumerId(recharge.getConsumerId());
BigDecimal balance = recharge.getRechargeAmount().add(rechargeConf.getGiveAmount());
consumerWallet.setBalance(balance);
consumerWallet.setRemainingDuration(rechargeConf.getGiveDuration());
BigDecimal Integral = recharge.getRechargeAmount().multiply(rechargeConf.getGiveRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
consumerWallet.setRemainingIntegral(Integral);
if (rechargeConf.getGiveType().contains(GiveTypeEnum.AMOUNT.getIndex())) {
BigDecimal balance = recharge.getRechargeAmount().add(rechargeConf.getGiveAmount());
consumerWallet.setBalance(balance);
} else {
consumerWallet.setBalance(new BigDecimal(0));
}
if (rechargeConf.getGiveType().contains(GiveTypeEnum.DURATION.getIndex())) {
consumerWallet.setRemainingDuration(rechargeConf.getGiveDuration());
} else {
consumerWallet.setRemainingDuration(new BigDecimal(0));
}
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);
} else {
consumerWallet.setRemainingIntegral(new BigDecimal(0));
}
consumerWallet.setCreateTime(new Date());
consumerWalletService.addConsumerWallet(consumerWallet);
}
......
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