| | |
| | | // walletService.update(wallet.getUserId().toString(), |
| | | // Arith.add(withdraw.getAmount(), withdraw.getAmountFee())); |
| | | |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, wallet.getUserId().toString()).last(" limit 1 ")); |
| | | if(ObjectUtil.isEmpty(capitaltWallet)){ |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, wallet.getUserId().toString()).last(" limit 1 ")); |
| | | // if(ObjectUtil.isEmpty(capitaltWallet)){ |
| | | // throw new YamiShopBindException("用户资金账户不存在!"); |
| | | // } |
| | | // capitaltWalletService.update(new LambdaUpdateWrapper<CapitaltWallet>() |
| | | // .set(CapitaltWallet::getMoney,new BigDecimal(Arith.add(capitaltWallet.getMoney(), withdraw.getVolume()))) |
| | | // .eq(CapitaltWallet::getUserId,wallet.getUserId())); |
| | | |
| | | Wallet wallet1 = walletService.getOne(new LambdaQueryWrapper<>(Wallet.class) |
| | | .eq(Wallet::getUserId, wallet.getUserId().toString()).last(" limit 1 ")); |
| | | if(ObjectUtil.isEmpty(wallet1)){ |
| | | throw new YamiShopBindException("用户资金账户不存在!"); |
| | | } |
| | | capitaltWalletService.update(new LambdaUpdateWrapper<CapitaltWallet>() |
| | | .set(CapitaltWallet::getMoney,new BigDecimal(Arith.add(capitaltWallet.getMoney(), withdraw.getVolume()))) |
| | | .eq(CapitaltWallet::getUserId,wallet.getUserId())); |
| | | walletService.update(new LambdaUpdateWrapper<Wallet>() |
| | | .set(Wallet::getMoney,new BigDecimal(Arith.add(wallet1.getMoney(), withdraw.getVolume()))) |
| | | .eq(Wallet::getUserId,wallet.getUserId())); |
| | | |
| | | |
| | | |
| | | /* |
| | |
| | | throw new YamiShopBindException("Your account has been frozen"); |
| | | } |
| | | |
| | | // Wallet wallet = walletService.saveWalletByPartyId(withdraw.getUserId()); |
| | | Wallet wallet = walletService.saveWalletByPartyId(withdraw.getUserId()); |
| | | |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, withdraw.getUserId()).last(" limit 1 ")); |
| | | if (capitaltWallet.getMoney().doubleValue() < withdraw.getVolume().doubleValue()) { |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, withdraw.getUserId()).last(" limit 1 ")); |
| | | if (wallet.getMoney().doubleValue() < withdraw.getVolume().doubleValue()) { |
| | | throw new YamiShopBindException("not sufficient funds"); |
| | | } |
| | | // 手续费(USDT) |
| | |
| | | */ |
| | | String withdraw_qr = qRGenerateService.generateWithdraw(withdraw.getOrderNo(), withdraw.getAddress()); |
| | | withdraw.setQdcode(withdraw_qr); |
| | | double amount_before = capitaltWallet.getMoney().doubleValue(); |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | |
| | | |
| | | |
| | | // walletService.update(wallet.getUserId().toString(), Arith.sub(0, withdraw.getVolume().doubleValue())); |
| | | |
| | | |
| | | if(ObjectUtil.isEmpty(capitaltWallet)){ |
| | | if(ObjectUtil.isEmpty(wallet)){ |
| | | throw new YamiShopBindException("The user's funds account does not exist!"); |
| | | } |
| | | capitaltWalletService.update(capitaltWallet,-withdraw.getVolume().doubleValue()); |
| | | walletService.update(wallet.getUserId(),-withdraw.getVolume().doubleValue()); |
| | | |
| | | save(withdraw); |
| | | |
| | |
| | | moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN); |
| | | moneyLog.setAmountBefore(new BigDecimal(amount_before)); |
| | | moneyLog.setAmount(new BigDecimal(Arith.sub(0, withdraw.getVolume().doubleValue()))); |
| | | moneyLog.setAmountAfter(capitaltWallet.getMoney()); |
| | | moneyLog.setAmountAfter(wallet.getMoney()); |
| | | moneyLog.setLog("提现订单[" + withdraw.getOrderNo() + "]"); |
| | | // moneyLog.setExtra(withdraw.getOrder_no()); |
| | | moneyLog.setUserId(withdraw.getUserId()); |