From b5d4e187ab4559a8b637d09a6ceb4c0a9b87605c Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 05 Jun 2020 17:40:03 +0800 Subject: [PATCH] 20200605 代码提交 --- src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 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..21a2833 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,14 @@ 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,7 +287,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, "止盈平仓"); @@ -369,14 +369,19 @@ 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, "开多止损平仓"); @@ -456,6 +461,9 @@ contractOrderEntity.setClosingType(9); BigDecimal totalReturn = BigDecimal.ZERO; contractOrderService.save(contractOrderEntity); + + contractHoldOrderService.removeById(order.getId()); + // 将需要退回的减去手续费 BigDecimal needReturn = prePrice.add(profitLossPrice); //总退回金额=保证金+收益-手续费 @@ -463,7 +471,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, "开空止损平仓"); @@ -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