| | |
| | | |
| | | Wallet wallet = walletService.findByUserId(order.getPartyId()); |
| | | if (wallet.getMoney().add(profit).compareTo(BigDecimal.ZERO) < 0) { |
| | | // 如果结果是负数,就归零 |
| | | /*// 如果结果是负数,就归零 |
| | | if (wallet.getMoney().compareTo(BigDecimal.ZERO) < 0) { |
| | | profit = BigDecimal.ZERO; |
| | | } |
| | | }*/ |
| | | profit = wallet.getMoney().negate(); |
| | | } |
| | | |
| | | walletService.updateMoney(order.getSymbol(), partyId, profit, BigDecimal.ZERO, |
| | |
| | | * 合约产品平仓后添加当前流水setWithdraw_limit_now_amount |
| | | */ |
| | | User party = userService.getById(order.getPartyId()); |
| | | if (party.getWithdrawLimitNowAmount() == null) { |
| | | party.setWithdrawLimitNowAmount(BigDecimal.ZERO); |
| | | } |
| | | party.setWithdrawLimitNowAmount(party.getWithdrawLimitNowAmount().add(order.getDepositOpen())); |
| | | userService.updateById(party); |
| | | if (ObjectUtils.isEmpty(order.getCloseAvgPrice())) { |
| | |
| | | BigDecimal close = realtime.getClose(); |
| | | BigDecimal point = close.subtract(order.getTradeAvgPrice()); |
| | | BigDecimal profit = point.multiply(new BigDecimal("0.01")).multiply(order.getVolumeOpen()).setScale(4, BigDecimal.ROUND_DOWN);; |
| | | if(null != order.getProfitLossRatio() || order.getProfitLossRatio() > 0){ |
| | | if(null != order.getProfitLossRatio() && order.getProfitLossRatio() > 0){ |
| | | profit = order.getDepositOpen().multiply(new BigDecimal((order.getProfitLossRatio()/100))).setScale(2, RoundingMode.DOWN); |
| | | } |
| | | BigDecimal rentalProfit = order.getDeposit().add(profit).add(order.getAddDepositOpen()); |
| | |
| | | BigDecimal earnings = BigDecimal.ZERO; |
| | | if(order.getLocationType() == 1){//全仓 |
| | | // 获取当前账户余额并加到收益中 |
| | | Map<String, Object> moneyAll = walletService.getMoneyAll(order.getPartyId()); |
| | | earnings = order.getDepositOpen().add(new BigDecimal(moneyAll.get("money_all_coin").toString())); |
| | | //Map<String, Object> moneyAll = walletService.getMoneyAll(order.getPartyId()); |
| | | //earnings = order.getDepositOpen().add(new BigDecimal(moneyAll.get("money_wallet").toString())); |
| | | Wallet wallet = walletService.saveWalletByPartyId(order.getPartyId()); |
| | | earnings = order.getDepositOpen().add(earnings.add(wallet.getMoney())); |
| | | }else{ |
| | | earnings = order.getDepositOpen().add(order.getAddDepositOpen()); |
| | | } |