From c611dbf70f2af43b69ece998622a503e1723197f Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Fri, 05 Jun 2020 17:42:12 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java index 9cc6764..f63eb5a 100644 --- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java @@ -191,14 +191,15 @@ 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, "止盈平仓"); @@ -287,8 +288,8 @@ // 更新钱包 // 总的是收益-平仓手续费 BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); - memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); + memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId()); insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓"); @@ -369,6 +370,8 @@ contractOrderEntity.setClosingType(8); BigDecimal totalReturn = BigDecimal.ZERO; contractOrderService.save(contractOrderEntity); + + contractHoldOrderService.removeById(order.getId()); // 将需要退回的减去手续费 BigDecimal needReturn = prePrice.add(profitLossPrice); //总退回金额=保证金+收益-手续费 @@ -376,7 +379,8 @@ // 更新钱包 // 总的是收益-平仓手续费 BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); - memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); + + memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId()); insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓"); @@ -420,7 +424,7 @@ String symbol = order.getSymbol(); Long memberId = order.getMemberId(); // 本次需要退回的预付款 - BigDecimal prePrice = order.getPrePaymentAmount(); + BigDecimal prePrice = order.getBondAmount(); MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memberId, "USDT"); if (wallet != null) { @@ -456,6 +460,9 @@ contractOrderEntity.setClosingType(9); BigDecimal totalReturn = BigDecimal.ZERO; contractOrderService.save(contractOrderEntity); + + contractHoldOrderService.removeById(order.getId()); + // 将需要退回的减去手续费 BigDecimal needReturn = prePrice.add(profitLossPrice); //总退回金额=保证金+收益-手续费 @@ -463,7 +470,7 @@ // 更新钱包 // 总的是收益-平仓手续费 BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); - memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); + memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId()); insertAccountFlow(order, wallet, profitLossPrice, "开空止损平仓"); @@ -547,6 +554,7 @@ contractOrderEntity.setEntrustOpeningPrice(coinsCoinsOrder.getEntrustPrice()); contractOrderEntity.setEntrustTime(coinsCoinsOrder.getCreateTime()); contractOrderEntity.setOpeningTime(new Date()); + contractOrderEntity.setId(null); contractOrderService.save(contractOrderEntity); // 发送爆仓的队列 @@ -617,9 +625,9 @@ //更新主表订单状态位为“已平仓” 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); -- Gitblit v1.9.1