From 8b74444e85757e588b234ef992a205271688795e Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Fri, 12 Jan 2024 16:22:19 +0800
Subject: [PATCH] 套餐
---
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java | 53 +++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
index f001269..d69c527 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -17,6 +17,7 @@
import cc.mrbird.febs.mall.service.IMallMemberWithdrawService;
import cc.mrbird.febs.mall.service.MallMemberService;
import cc.mrbird.febs.mall.vo.CashOutSettingVo;
+import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
@@ -28,6 +29,8 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
/**
* @author wzy
@@ -65,6 +68,20 @@
cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class);
}
+ //每日提现额度上限
+ BigDecimal allCashOut = cashOutSettingVo.getAllCashOut();
+ if(withdrawalDto.getAmount().compareTo(allCashOut) > 0){
+ throw new FebsException("限额:"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN));
+ }
+ List<MallMemberWithdraw> mallMemberWithdrawListDone = this.baseMapper.selectListByMemberIdAndDate(memberId,new Date());
+ if(CollUtil.isNotEmpty(mallMemberWithdrawListDone)){
+ BigDecimal amountTCAll = mallMemberWithdrawListDone.stream().map(MallMemberWithdraw::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+ amountTCAll = amountTCAll.add(withdrawalDto.getAmount());
+ if (amountTCAll.compareTo(allCashOut) > 0) {
+ throw new FebsException("限额:"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN));
+ }
+ }
+
if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) {
throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN));
}
@@ -78,17 +95,26 @@
if(wallet.getBalance().compareTo(BigDecimal.ZERO) <= 0){
throw new FebsException("金额不足");
}
+ if(wallet.getEquityLimit().compareTo(BigDecimal.ZERO) <= 0){
+ throw new FebsException("权益积分不足");
+ }
if(withdrawalDto.getAmount().compareTo(wallet.getBalance()) > 0) {
throw new FebsException("金额不足");
}
- BigDecimal commission = wallet.getCommission();
- if(withdrawalDto.getAmount().compareTo(commission) > 0){
- throw new FebsException("金额不足");
+
+ if(withdrawalDto.getAmount().compareTo(wallet.getEquityLimit()) > 0) {
+ throw new FebsException("权益积分不足");
}
+// BigDecimal commission = wallet.getCommission();
+// if(withdrawalDto.getAmount().compareTo(commission) > 0){
+// throw new FebsException("金额不足");
+// }
+
BigDecimal serviceFee = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
- walletService.reduce(withdrawalDto.getAmount(), memberId, "balance");
- walletService.reduce(withdrawalDto.getAmount(), memberId, "commission");
+ walletService.reduce(withdrawalDto.getAmount(), memberId, "balance");//减少余额
+ walletService.reduce(withdrawalDto.getAmount(), memberId, "equityLimit");//减少权益积分
+// walletService.reduce(withdrawalDto.getAmount(), memberId, "commission");
String orderNo = MallUtils.getOrderNum("W");
MallMemberWithdraw withdraw = new MallMemberWithdraw();
@@ -104,6 +130,16 @@
mallMemberService.addMoneyFlow(memberId,
withdrawalDto.getAmount().negate(),
MoneyFlowTypeEnum.WITHDRAWAL.getValue(),
+ orderNo,
+ null,
+ null,
+ null,
+ 1,
+ FlowTypeEnum.BALANCE.getValue());
+
+ mallMemberService.addMoneyFlow(memberId,
+ withdrawalDto.getAmount().negate(),
+ MoneyFlowTypeEnum.REDUCE_EQUITY_LIMIT.getValue(),
orderNo,
null,
null,
@@ -172,7 +208,7 @@
FlowTypeEnum.SCORE.getValue());
mallMemberService.addMoneyFlow(memberId,
- scoreAmount,
+ scoreAmount.subtract(amountFee),
MoneyFlowTypeEnum.SCORE_TO_CASH.getValue(),
orderNo,
null,
@@ -187,7 +223,8 @@
PerkEnum.POOL_CASH.getCode()
);
BigDecimal poolCash = new BigDecimal(poolCashDic.getValue());
- poolCash = poolCash.add(amountFee);
+ //先减去百分之百的提现金额在加上30%的回流金额
+ poolCash = poolCash.subtract(scoreAmount).add(amountFee);
dataDictionaryCustomMapper.updateDicValueByTypeAndCode(
PerkEnum.POOL_CASH.getType(),
PerkEnum.POOL_CASH.getCode(),
@@ -207,7 +244,7 @@
);
if(poolScore.compareTo(BigDecimal.ZERO) > 0 && poolCash.compareTo(BigDecimal.ZERO) > 0){
- BigDecimal divide = poolCash.divide(poolScore, 4, BigDecimal.ROUND_DOWN);
+ BigDecimal divide = poolCash.divide(poolScore, 8, BigDecimal.ROUND_DOWN);
dataDictionaryCustomMapper.updateDicValueByTypeAndCode(
PerkEnum.POOL_SCORE_PRICE.getType(),
PerkEnum.POOL_SCORE_PRICE.getCode(),
--
Gitblit v1.9.1