From bad4cadc4c4bc735e97247918a0555bfc1278798 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 24 Oct 2023 17:19:08 +0800
Subject: [PATCH] 版本管理
---
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 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..87f07e9 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));
}
@@ -81,14 +98,14 @@
if(withdrawalDto.getAmount().compareTo(wallet.getBalance()) > 0) {
throw new FebsException("金额不足");
}
- BigDecimal commission = wallet.getCommission();
- if(withdrawalDto.getAmount().compareTo(commission) > 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, "commission");
String orderNo = MallUtils.getOrderNum("W");
MallMemberWithdraw withdraw = new MallMemberWithdraw();
@@ -172,7 +189,7 @@
FlowTypeEnum.SCORE.getValue());
mallMemberService.addMoneyFlow(memberId,
- scoreAmount,
+ scoreAmount.subtract(amountFee),
MoneyFlowTypeEnum.SCORE_TO_CASH.getValue(),
orderNo,
null,
@@ -187,7 +204,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 +225,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