From 5fcbc587a07aefa3eb450e9ec83089f8c567df1c Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 26 Feb 2024 17:13:17 +0800
Subject: [PATCH] 抽奖
---
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java | 87 ++++++++++++++++---------------------------
1 files changed, 32 insertions(+), 55 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 1f3041f..c7d109f 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
@@ -1,9 +1,6 @@
package cc.mrbird.febs.mall.service.impl;
-import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
-import cc.mrbird.febs.common.enumerates.FlowTypeEnum;
-import cc.mrbird.febs.common.enumerates.GreenScoreEnum;
-import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
+import cc.mrbird.febs.common.enumerates.*;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.AppContants;
import cc.mrbird.febs.common.utils.LoginUserUtil;
@@ -16,6 +13,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;
@@ -27,6 +25,8 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
/**
* @author wzy
@@ -50,13 +50,6 @@
public void withdrawal(WithdrawalDto withdrawalDto) {
Long memberId = LoginUserUtil.getLoginUser().getId();
MallMember mallMember = mallMemberService.getById(memberId);
- if (StrUtil.isBlank(mallMember.getTradePassword())) {
- throw new FebsException("未设置支付密码");
- }
-
- if (!mallMember.getTradePassword().equals(SecureUtil.md5(withdrawalDto.getTradePwd()))) {
- throw new FebsException("支付密码错误");
- }
CashOutSettingVo cashOutSettingVo = new CashOutSettingVo();
DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.CASHOUT_SETTING.getType(), DataDictionaryEnum.CASHOUT_SETTING.getCode());
@@ -64,9 +57,23 @@
cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class);
}
- if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) {
- throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN));
- }
+// //每日提现额度上限
+// 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));
+// }
MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(withdrawalDto.getBankId());
if(ObjectUtil.isEmpty(mallMemberBank)){
@@ -78,49 +85,11 @@
BigDecimal canMoney = wallet.getBalance();
if(withdrawalDto.getAmount().compareTo(canMoney) > 0) {
- throw new FebsException("提现金额不足");
+ throw new FebsException("金额不足");
}
BigDecimal serviceFeePercent = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
BigDecimal serviceFee = serviceFeePercent.multiply(withdrawalDto.getAmount());
- String remark = AppContants.MEMBER_WITHDRAW_NORMAL;
- DataDictionaryCustom voucherOnOffDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
- GreenScoreEnum.VOUCHER_ON_OFF.getType(),
- GreenScoreEnum.VOUCHER_ON_OFF.getCode()
- );
- if(ObjectUtil.isNotEmpty(voucherOnOffDic)){
- String voucherOnOff = voucherOnOffDic.getValue();
- /**
- * 绿色凭证提现开关 1:开启 2:关闭
- * 验证账户凭证数量
- * 不需要手续费
- * 减少用户的凭证数量
- */
- if("1".equals(voucherOnOff)){
- BigDecimal voucherCntDto = withdrawalDto.getVoucherCnt();
- if(voucherCntDto.compareTo(BigDecimal.ZERO) <= 0){
- throw new FebsException("红豆不足");
- }
- //提现需要的凭证数量 = 提现金额 * 余额提现需要绿色凭证比例
- DataDictionaryCustom voucherPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
- GreenScoreEnum.VOUCHER_PERCENT.getType(),
- GreenScoreEnum.VOUCHER_PERCENT.getCode()
- );
- BigDecimal voucherPercent = new BigDecimal(voucherPercentDic.getValue() == null ? "0" : voucherPercentDic.getValue()).multiply(new BigDecimal(0.01));
- BigDecimal voucherPercentNeed = withdrawalDto.getAmount().multiply(voucherPercent).setScale(2,BigDecimal.ROUND_DOWN);
-
- BigDecimal voucherCnt = wallet.getVoucherCnt();
- if(voucherCnt.compareTo(voucherPercentNeed) < 0){
- throw new FebsException("红豆不足");
- }
-
- walletService.reduce(voucherCntDto, memberId, "voucherCnt");
- serviceFee = voucherCntDto;
- remark = AppContants.MEMBER_WITHDRAW_VOUCHER;
- }
- }
-
-
walletService.reduce(withdrawalDto.getAmount(), memberId, "balance");
String orderNo = MallUtils.getOrderNum("W");
@@ -130,10 +99,18 @@
withdraw.setAmount(withdrawalDto.getAmount());
withdraw.setStatus(1);
withdraw.setAmountFee(serviceFee);
- withdraw.setRemark(remark);
withdraw.setWtihdrawTypeId(mallMemberBank.getId());
this.baseMapper.insert(withdraw);
- mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.BALANCE.getValue());
+ mallMemberService.addMoneyFlow(
+ memberId,
+ withdrawalDto.getAmount().negate(),
+ MoneyFlowTypeNewEnum.RANK_BONUS.getValue(),
+ orderNo,
+ MoneyFlowTypeNewEnum.RANK_BONUS.getDescription(),
+ null,
+ null,
+ 1,
+ FlowTypeEnum.BALANCE.getValue());
}
}
--
Gitblit v1.9.1