|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateWallet(WalletWithdrawRecordDTO walletWithdrawRecordDTO) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WalletWithdrawRecordDO withdrawRecordDO = walletWithdrawRecordMapper.selectById(walletWithdrawRecordDTO.getId()); | 
|---|
|  |  |  | if (withdrawRecordDO == null) { | 
|---|
|  |  |  | throw new ValidationException("提现记录信息不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isEmpty(walletWithdrawRecordDTO.getApproveState())) { | 
|---|
|  |  |  | throw new ValidationException("审批状态不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Constants.WALLET_APPROVE_STATE.REJECT.name().equals(walletWithdrawRecordDTO.getApproveState())) { | 
|---|
|  |  |  | if(StringUtils.isEmpty(walletWithdrawRecordDTO.getRejectReason())){ | 
|---|
|  |  |  | throw new ValidationException("不通过理由不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtils.isEmpty(walletWithdrawRecordDTO.getRejectReason())) { | 
|---|
|  |  |  | throw new ValidationException("不通过理由不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BeanUtils.copyProperties(walletWithdrawRecordDTO, withdrawRecordDO); | 
|---|
|  |  |  | withdrawRecordDO.update(SecurityUtils.getUserId()); | 
|---|
|  |  |  | withdrawRecordDO.setApproveState(walletWithdrawRecordDTO.getApproveState()); | 
|---|
|  |  |  | 
|---|
|  |  |  | walletWithdrawRecordMapper.updateById(withdrawRecordDO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //审批通过之后写转账信息 | 
|---|
|  |  |  | if(Constants.WALLET_APPROVE_STATE.APPROVE.name().equals(walletWithdrawRecordDTO.getApproveState())){ | 
|---|
|  |  |  | if (Constants.WALLET_APPROVE_STATE.APPROVE.name().equals(walletWithdrawRecordDTO.getApproveState())) { | 
|---|
|  |  |  | Supplier s = supplierMapper.selectById(withdrawRecordDO.getSupplierId()); | 
|---|
|  |  |  | String name = ""; | 
|---|
|  |  |  | name = "供应商" + s.getName(); | 
|---|
|  |  |  | UserWechat wechat = wechatMapper.selectOne(new QueryWrapper<UserWechat>().eq("user_id", s.getUserId())); | 
|---|
|  |  |  | if(wechat == null){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (wechat == null) { | 
|---|
|  |  |  | String msg = name + "未绑定账号无法结算"; | 
|---|
|  |  |  | log.error(msg); | 
|---|
|  |  |  | throw new ValidationException(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocalDateTime now = LocalDateTime.now(); | 
|---|
|  |  |  | String day = format(now, "yyyy-MM-dd"); | 
|---|
|  |  |  | String remarks = name + "钱包提现"; | 
|---|
|  |  |  | 
|---|
|  |  |  | transferReqDTO.setRemarks(remarks); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //保存账单信息 | 
|---|
|  |  |  | WalletBillRecordDO  walletBillRecordDO = new WalletBillRecordDO(); | 
|---|
|  |  |  | WalletBillRecordDO walletBillRecordDO = new WalletBillRecordDO(); | 
|---|
|  |  |  | walletBillRecordDO.setSupplierId(s.getId()); | 
|---|
|  |  |  | walletBillRecordDO.setType(Constants.BILL_CHANGE_TYPE.withdraw.name()); | 
|---|
|  |  |  | walletBillRecordDO.setMethod(Constants.BILL_CHANGE_METHOD.reduce.name()); | 
|---|
|  |  |  | walletBillRecordDO.setTransferId(transferReqDTO.getAppId()); | 
|---|
|  |  |  | //提现金额 | 
|---|
|  |  |  | BigDecimal withdrawAmount  = withdrawRecordDO.getAmount(); | 
|---|
|  |  |  | if(withdrawAmount.doubleValue() > 0) {//结算金额>0时才去转账 | 
|---|
|  |  |  | BigDecimal withdrawAmount = withdrawRecordDO.getAmount(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (withdrawAmount.doubleValue() > 0) {//结算金额>0时才去转账 | 
|---|
|  |  |  | TransferDetailReqDTO dr = new TransferDetailReqDTO(); | 
|---|
|  |  |  | dr.setId(UUIDGenerator.getUUID()); | 
|---|
|  |  |  | dr.setAmount(withdrawAmount.multiply(new BigDecimal(100)).longValue()); | 
|---|
|  |  |  | 
|---|
|  |  |  | //发起转账 | 
|---|
|  |  |  | paymentV3Service.doBatchTransfer(transferReqDTO, SecurityUtils.getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | walletBillRecordMapper.insert(walletBillRecordDO); | 
|---|
|  |  |  | //不需要更新结算单了,此时提现的金额和计算单上的金额不一致 | 
|---|
|  |  |  |  | 
|---|