陶杰
2024-10-28 021496babb52a859294a8475ffef330009b0167c
src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java
@@ -117,29 +117,21 @@
                    // 1.新增一条余额提现记录
                    WalletWithdrawRecordDO withdrawRecordDO = new WalletWithdrawRecordDO();
                    //原金额
                    withdrawRecordDO.setOriginalAmount(walletDO.getWithdrawableAmount());
                    // 变动金额
                    withdrawRecordDO.setChangeAmount(dto.getAmount());
                    // 余额
                    withdrawRecordDO.setBalance(walletDO.getWithdrawableAmount().subtract(dto.getAmount()));
                    withdrawRecordDO.setAmount(dto.getAmount());
                    withdrawRecordDO.setSupplierId(supplierDTO.getId());
                    withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.WAITING.name());
                    withdrawRecordDO.setMethod(Constants.WALLET_WITHDRAW_METHOD.WEIXIN.name());
                    withdrawRecordDO.setWithdrawType(Constants.WALLET_WITHDRAW_TYPE.BALANCE.name());
                    withdrawRecordDO.create(SecurityUtils.getUserId());
                    // 保存余额提现记录
                    save(withdrawRecordDO);
                    /*
                    // 2.新增一条账单明细
                    WalletBillRecordDO walletBillRecordDO=new WalletBillRecordDO();
                    walletBillRecordDO.setSupplierId(supplierDTO.getId());
                    walletBillRecordDO.setWalletId(walletDO.getId());
                    // 提现
                    walletBillRecordDO.setType(Constants.BILL_CHANGE_TYPE.withdraw.name());
                    walletBillRecordDO.setMethod(Constants.BILL_CHANGE_METHOD.add.name());
                    walletBillRecordDO.setOriginalAmount(walletDO.getWithdrawableAmount());
                    walletBillRecordDO.setChangeAmount(dto.getAmount());
                    walletBillRecordDO.setBalance(walletDO.getWithdrawableAmount().subtract(dto.getAmount()));
                    // 保存账单明细
                    walletBillRecordService.save(walletBillRecordDO);
*/
                    // 3. 钱包更新
                    // 钱包可提现的钱等于当前钱包可提现的钱-提现的钱
@@ -192,6 +184,10 @@
        withdrawRecordDO.setApproveState(walletWithdrawRecordDTO.getApproveState());
        withdrawRecordDO.setApproveBy(SecurityUtils.getUserId());
        withdrawRecordDO.setApproveTime(LocalDateTime.now());
        if(Constants.WALLET_APPROVE_STATE.REJECT.name().equals(walletWithdrawRecordDTO.getApproveState())){
            //如果拒绝直接提现失败
            withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.FAILURE.name());
        }
        walletWithdrawRecordMapper.updateById(withdrawRecordDO);
        //审批通过之后写转账信息
@@ -202,7 +198,7 @@
            UserWechat wechat = wechatMapper.selectOne(new QueryWrapper<UserWechat>().eq("user_id", s.getUserId()));
            if (wechat == null) {
                String msg = name + "未绑定账号无法结算";
                String msg = name + "未绑定账号无法提现";
                log.error(msg);
                throw new ValidationException(msg);
            }
@@ -222,7 +218,9 @@
            walletBillRecordDO.setSupplierId(s.getId());
            walletBillRecordDO.setType(Constants.BILL_CHANGE_TYPE.withdraw.name());
            walletBillRecordDO.setMethod(Constants.BILL_CHANGE_METHOD.reduce.name());
            walletBillRecordDO.setTransferId(transferReqDTO.getAppId());
            walletBillRecordDO.setTransferId(transferReqDTO.getId());
            walletBillRecordDO.setWithdrawRecordId(withdrawRecordDO.getId());
            walletBillRecordDO.create();
            //提现金额
            BigDecimal withdrawAmount = withdrawRecordDO.getAmount();