fix
Hentua
2023-04-25 2ccfd486a7e82b71bbac81d121a7c5dae752db4d
fix
3 files modified
77 ■■■■ changed files
src/main/java/cc/mrbird/febs/mall/dto/MallGoodsUpdateDto.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java 67 ●●●● patch | view | raw | blame | history
src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html 2 ●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/dto/MallGoodsUpdateDto.java
@@ -98,5 +98,13 @@
    private Integer goodsLevel;
    /**
     * 普通商品分红百分比
     */
    private Integer normalPer;
    /**
     * 普通商品分红百分比
     */
    private Integer normalBonus;
}
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -78,67 +78,25 @@
        if(ObjectUtil.isEmpty(mallMemberBank.getSubbranchName())){
            throw new FebsException("请填写所属支行");
        }
        if(ObjectUtil.isEmpty(mallMemberBank.getDigitalNo())){
            throw new FebsException("请填写数字货币账号");
        }
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
        BigDecimal serviceFeePercent = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
        BigDecimal serviceFee = serviceFeePercent.multiply(withdrawalDto.getAmount());
        // 可提现
        BigDecimal canMoney = wallet.getBalance();
        BigDecimal canMoney = wallet.getCommission();
        if (profit != null) {
            if(canMoney.subtract(serviceFee).compareTo(BigDecimal.ZERO) > 0) {
                canMoney = canMoney.subtract(profit);
            }
        }
        if(withdrawalDto.getAmount().compareTo(canMoney) > 0) {
            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);
                DataDictionaryCustom scorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                        GreenScoreEnum.SCORE_PRICE.getType(),
                        GreenScoreEnum.SCORE_PRICE.getCode());
                BigDecimal scorePrice = new BigDecimal(scorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN);
                voucherPercentNeed = voucherPercentNeed.divide(scorePrice,2,BigDecimal.ROUND_DOWN);
//                BigDecimal voucherCnt = wallet.getVoucherCnt();
                BigDecimal voucherFireCnt = wallet.getVoucherFireCnt();
                if(voucherFireCnt.compareTo(voucherPercentNeed) < 0){
                    throw new FebsException("能量不足");
                }
//                walletService.reduce(voucherCntDto, memberId, "voucherCnt");
                walletService.reduce(voucherCntDto, memberId, "voucherFireCnt");
                serviceFee = voucherCntDto;
                remark = AppContants.MEMBER_WITHDRAW_VOUCHER;
            }
        }
        walletService.reduce(withdrawalDto.getAmount(), memberId, "balance");
        walletService.reduce(withdrawalDto.getAmount().add(serviceFee), memberId, "commission");
        String orderNo = MallUtils.getOrderNum("W");
        MallMemberWithdraw withdraw = new MallMemberWithdraw();
@@ -147,10 +105,9 @@
        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().add(serviceFee).negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.BALANCE.getValue());
    }
}
src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html
@@ -145,7 +145,7 @@
                                        <div class="layui-form-item normal-set">
                                            <label class="layui-form-label febs-form-item-require">分红比例(%)</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="normalPer" placeholder="请输入分红比例"
                                                <input type="text" name="normalBonus" placeholder="请输入分红比例"
                                                       autoComplete="off" class="layui-input">
                                                <div class="layui-form-mid layui-word-aux">普通商品分红,输入0则不分红。</div>
                                            </div>