| | |
| | | log.info("=============111111===>"+walletType); |
| | | walletExtend.setAmount(Arith.add(walletExtend.getAmount(), amount)); |
| | | if (!walletExtendService.updateById(walletExtend)) { |
| | | throw new YamiShopBindException("操作钱包失败!"); |
| | | throw new YamiShopBindException("Wallet operation failed!"); |
| | | } |
| | | redisTemplate.opsForValue().set(WalletRedisKeys.WALLET_EXTEND_PARTY_ID + partyId.toString() + walletType, walletExtend); |
| | | |
| | |
| | | |
| | | wallet.setMoney(wallet.getMoney().add(money)); |
| | | if(wallet.getMoney().compareTo(BigDecimal.ZERO) < 0){ |
| | | wallet.setMoney(BigDecimal.ZERO); |
| | | throw new YamiShopBindException("Insufficient balance"); |
| | | } |
| | | wallet.setUpdateTime(now); |
| | | if (wallet.getMoney().doubleValue() <= 0) { |
| | | throw new YamiShopBindException("余额不足"); |
| | | } |
| | | /*if (wallet.getMoney().doubleValue() < 0) { |
| | | throw new YamiShopBindException("Insufficient balance"); |
| | | }*/ |
| | | updateById(wallet); |
| | | // 账变日志 |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | |
| | | close = realtimes.get(0).getClose().doubleValue(); |
| | | } else { |
| | | close = 0; |
| | | //throw new YamiShopBindException("参数错误"); |
| | | //throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | return close; |
| | | } |
| | |
| | | |
| | | BigDecimal orderVolume = BigDecimal.ONE; |
| | | |
| | | if (order.getLeverRate() != null && order.getLeverRate().compareTo(BigDecimal.ZERO) != 0) { |
| | | if (order.getLeverRate() != null && order.getLeverRate().compareTo(BigDecimal.ZERO) != 0 |
| | | && order.getVolumeOpen() != null) { |
| | | orderVolume = order.getVolumeOpen().divide(order.getLeverRate(), 2, BigDecimal.ROUND_HALF_UP); |
| | | } else { |
| | | } else if (order.getVolumeOpen() != null) { |
| | | orderVolume = order.getVolumeOpen(); |
| | | } |
| | | BigDecimal moneyContract = orderVolume.multiply(order.getUnitAmount()).add(order.getProfit()); |
| | | BigDecimal moneyContractDeposit = order.getDeposit(); |
| | | BigDecimal moneyContractProfit = order.getProfit(); |
| | | BigDecimal unitAmount = order.getUnitAmount() != null ? order.getUnitAmount() : BigDecimal.ZERO; |
| | | BigDecimal profit = order.getProfit() != null ? order.getProfit() : BigDecimal.ZERO; |
| | | BigDecimal moneyContract = orderVolume.multiply(unitAmount).add(profit); |
| | | BigDecimal moneyContractDeposit = order.getDeposit() != null ? order.getDeposit() : BigDecimal.ZERO; |
| | | BigDecimal moneyContractProfit = profit; |
| | | |
| | | |
| | | moneysContract.put("money_contract", moneyContract); |
| | |
| | | Wallet wallet = findByUserId(userId); |
| | | wallet.setMoney(new BigDecimal(Arith.add(wallet.getMoney().doubleValue(), amount))); |
| | | if (!updateById(wallet)) { |
| | | throw new YamiShopBindException("操作钱包失败!"); |
| | | throw new YamiShopBindException("Wallet operation failed!"); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | if (!updateById(wallet)) { |
| | | throw new YamiShopBindException("操作钱包失败!"); |
| | | throw new YamiShopBindException("Wallet operation failed!"); |
| | | } |
| | | return wallet; |
| | | } |