| | |
| | | public ResultObject transferExtendtoGather(WalletGather walletGather,WalletExtend walletExtend,String currency,double amount){ |
| | | ResultObject resultObject = new ResultObject(); |
| | | resultObject.setCode("0"); |
| | | if(new BigDecimal(walletExtend.getAmount()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | if("usdt".equals(currency)){ |
| | | walletGather.setUsdtMoney(Arith.add(walletGather.getUsdtMoney(), amount)); |
| | | }else if("btc".equals(currency)){ |
| | | walletGather.setBtcMoney(Arith.add(walletGather.getBtcMoney(), amount)); |
| | | }else if("eth".equals(currency)){ |
| | | walletGather.setEthMoney(Arith.add(walletGather.getEthMoney(), amount)); |
| | | }else if("usdc".equals(currency)){ |
| | | walletGather.setUsdcMoney(Arith.add(walletGather.getUsdcMoney(), amount)); |
| | | if("usdt".equals(currency)){ |
| | | Wallet wallet = walletService.saveWalletByPartyId(walletExtend.getPartyId()); |
| | | if(wallet.getMoney() < amount){ |
| | | resultObject.setCode("1"); |
| | | resultObject.setMsg("划转资金不足"); |
| | | return resultObject; |
| | | } |
| | | walletGather.setUsdtMoney(Arith.add(walletGather.getUsdtMoney(), amount)); |
| | | }else { |
| | | resultObject.setCode("1"); |
| | | resultObject.setMsg("划转资金不足"); |
| | | return resultObject; |
| | | if(new BigDecimal(walletExtend.getAmount()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | if("btc".equals(currency)){ |
| | | walletGather.setBtcMoney(Arith.add(walletGather.getBtcMoney(), amount)); |
| | | }else if("eth".equals(currency)){ |
| | | walletGather.setEthMoney(Arith.add(walletGather.getEthMoney(), amount)); |
| | | }else if("usdc".equals(currency)){ |
| | | walletGather.setUsdcMoney(Arith.add(walletGather.getUsdcMoney(), amount)); |
| | | } |
| | | }else { |
| | | resultObject.setCode("1"); |
| | | resultObject.setMsg("划转资金不足"); |
| | | return resultObject; |
| | | } |
| | | } |
| | | |
| | | |
| | | ApplicationUtil.executeUpdate(walletGather); |
| | | redisHandler.setAsyn(WalletRedisKeys.WALLET_GATHER_PARTY_ID + walletGather.getPartyId().toString(),walletGather); |
| | |
| | | return resultObject; |
| | | } |
| | | }else if("btc".equals(currency)){ |
| | | if(new BigDecimal(walletGather.getUsdtMoney()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | if(new BigDecimal(walletGather.getBtcMoney()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | walletGather.setBtcMoney(Arith.sub(walletGather.getBtcMoney(), amount)); |
| | | }else { |
| | | resultObject.setCode("1"); |
| | |
| | | return resultObject; |
| | | } |
| | | }else if("eth".equals(currency)){ |
| | | if(new BigDecimal(walletGather.getUsdtMoney()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | if(new BigDecimal(walletGather.getEthMoney()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | walletGather.setEthMoney(Arith.sub(walletGather.getEthMoney(), amount)); |
| | | }else { |
| | | resultObject.setCode("1"); |
| | |
| | | return resultObject; |
| | | } |
| | | }else if("usdc".equals(currency)){ |
| | | if(new BigDecimal(walletGather.getUsdtMoney()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | if(new BigDecimal(walletGather.getUsdcMoney()).compareTo(new BigDecimal(amount)) >= 0){ |
| | | walletGather.setUsdcMoney(Arith.sub(walletGather.getUsdcMoney(), amount)); |
| | | }else { |
| | | resultObject.setCode("1"); |