| | |
| | | BigDecimal profit = settle(order, order.getVolume()); |
| | | |
| | | Wallet wallet = walletService.findByUserId(order.getPartyId()); |
| | | |
| | | if (wallet.getMoney().add(profit).compareTo(BigDecimal.ZERO) < 0) { |
| | | // 如果结果是负数,就归零 |
| | | if (wallet.getMoney().compareTo(BigDecimal.ZERO) < 0) { |
| | |
| | | * 合约产品平仓后添加当前流水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){ |
| | | profit = order.getDepositOpen().multiply(new BigDecimal((order.getProfitLossRatio()/100))).setScale(2, RoundingMode.DOWN); |
| | | } |
| | | BigDecimal rentalProfit = order.getDeposit().add(profit); |
| | | BigDecimal rate = volume.divide(order.getVolumeOpen(), 2, RoundingMode.HALF_UP); |
| | | order.setAmountClose(order.getAmountClose().add(profit)); |
| | |
| | | map.put("fee", order.getFee()); |
| | | map.put("deposit", order.getDeposit()); |
| | | map.put("deposit_open", order.getDepositOpen()); |
| | | map.put("change_ratio", order.getChangeRatio()); |
| | | map.put("change_ratio", order.getChangeRatio().setScale(2, RoundingMode.HALF_UP)); |
| | | |
| | | if(order.getProfit()!=null){ |
| | | map.put("profit", order.getProfit().setScale(4, RoundingMode.HALF_UP)); |
| | | map.put("profit", order.getProfit().setScale(2, RoundingMode.HALF_UP)); |
| | | }else{ |
| | | map.put("profit", order.getProfit()); |
| | | } |