| | |
| | | BigDecimal totalReturn = BigDecimal.ZERO; |
| | | contractOrderService.save(contractOrderEntity); |
| | | |
| | | contractEntrustOrderService.removeById(order.getId()); |
| | | contractHoldOrderService.removeById(order.getId()); |
| | | // 将需要退回的减去手续费 |
| | | BigDecimal needReturn = prePrice.add(profitLossPrice); |
| | | //总退回金额=保证金+收益-手续费 |
| | | totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | // 总的是收益-平仓手续费 |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId()); |
| | | |
| | | // 流水记录 TODO 531e |
| | | insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓"); |
| | |
| | | // 更新钱包 |
| | | // 总的是收益-平仓手续费 |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId()); |
| | | |
| | | |
| | | insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓"); |
| | |
| | | contractOrderEntity.setClosingType(8); |
| | | BigDecimal totalReturn = BigDecimal.ZERO; |
| | | contractOrderService.save(contractOrderEntity); |
| | | |
| | | contractHoldOrderService.removeById(order.getId()); |
| | | log.info("保证金:{}", prePrice); |
| | | log.info("盈亏:{}", profitLossPrice); |
| | | // 将需要退回的减去手续费 |
| | | BigDecimal needReturn = prePrice.add(profitLossPrice); |
| | | log.info("退回的钱:{}", needReturn); |
| | | //总退回金额=保证金+收益-手续费 |
| | | totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | // 更新钱包 |
| | | // 总的是收益-平仓手续费 |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId()); |
| | | |
| | | insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓"); |
| | | |
| | |
| | | contractOrderEntity.setClosingType(9); |
| | | BigDecimal totalReturn = BigDecimal.ZERO; |
| | | contractOrderService.save(contractOrderEntity); |
| | | |
| | | contractHoldOrderService.removeById(order.getId()); |
| | | |
| | | // 将需要退回的减去手续费 |
| | | BigDecimal needReturn = prePrice.add(profitLossPrice); |
| | | //总退回金额=保证金+收益-手续费 |
| | |
| | | // 更新钱包 |
| | | // 总的是收益-平仓手续费 |
| | | BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); |
| | | memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId()); |
| | | |
| | | insertAccountFlow(order, wallet, profitLossPrice, "开空止损平仓"); |
| | | |
| | |
| | | |
| | | //更新主表订单状态位为“已平仓” |
| | | contractOrderEntity.setId(null); |
| | | contractOrderEntity.setClosingPrice(BigDecimal.ZERO); |
| | | contractOrderEntity.setClosingPrice(nowPrice); |
| | | contractOrderEntity.setClosingTime(new Date()); |
| | | contractOrderEntity.setClosingFeeAmount(coinsOrder.getOpeningFeeAmount()); |
| | | contractOrderEntity.setRewardAmount(coinsOrder.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount()).negate()); |
| | | contractOrderService.save(contractOrderEntity); |
| | | |