fix
Hentua
2023-04-25 05c40a68b5664c5ed41dbaa57ba30f0c73757b26
src/main/java/cc/mrbird/febs/mall/service/impl/ScoreServiceImpl.java
@@ -35,8 +35,10 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author wzy
@@ -58,6 +60,7 @@
    private final MallMemberBankMapper mallMemberBankMapper;
    private final MallMemberWithdrawMapper mallMemberWithdrawMapper;
    private final IApiMallMemberService mallMemberService;
    private final MallMoneyFlowMapper mallMoneyFlowMapper;
    @Override
    public ScoreSignVo scoreSign() {
@@ -78,7 +81,7 @@
        DataDictionaryCustom signScpreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SCORE_SIGN_SETTING.getType(), DataDictionaryEnum.SCORE_SIGN_SETTING.getCode());
        if (signScpreDic != null) {
            scoreSign.setSetting(Integer.parseInt(signScpreDic.getValue()));
            scoreSign.setSetting(JSONObject.parseObject(signScpreDic.getValue(), ScoreSettingDto.class));
        }
        return scoreSign;
    }
@@ -274,7 +277,6 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void withdrawal(WithdrawalDto withdrawalDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = mallMemberMapper.selectById(memberId);
        if (StrUtil.isBlank(mallMember.getTradePassword())) {
@@ -292,7 +294,7 @@
        }
        if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) {
            throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN));
            throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2, RoundingMode.DOWN));
        }
        MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(withdrawalDto.getBankId());
@@ -301,14 +303,24 @@
        }
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        // 可提现
        BigDecimal canMoney = wallet.getVoucherAmount();
        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
        BigDecimal canMoney = wallet.getCommission();
        if (profit != null) {
            if(canMoney.compareTo(BigDecimal.ZERO) > 0) {
                canMoney = canMoney.subtract(profit);
            }
        }
        if(withdrawalDto.getAmount().compareTo(canMoney) > 0) {
            throw new FebsException("金额不足");
        }
        walletService.reduce(withdrawalDto.getAmount(), memberId, "voucherAmount");
        int flag = walletService.reduce(withdrawalDto.getAmount(), memberId, "commission");
        if (flag == 2) {
            throw new FebsException("请刷新页面后重新提现");
        }
        String orderNo = MallUtils.getOrderNum("W");
        MallMemberWithdraw withdraw = new MallMemberWithdraw();
@@ -317,11 +329,10 @@
        withdraw.setAmount(withdrawalDto.getAmount());
        withdraw.setStatus(1);
        withdraw.setAmountFee(BigDecimal.ZERO);
        withdraw.setRemark(AppContants.MEMBER_WITHDRAW_VOUCHER_AMOUNT);
        withdraw.setWtihdrawTypeId(mallMemberBank.getId());
        mallMemberWithdrawMapper.insert(withdraw);
        mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.VOUCHER_AMOUNT.getValue());
        mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.COMMISSION.getValue());
    }
    @Override