From 411814a852dd16cd634b79eceeff5d5aa9483d96 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 05 Jun 2020 16:17:28 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin.git --- src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 34 +++++++++++++++++++++------------- 1 files changed, 21 insertions(+), 13 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 f6ca013..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 @@ -182,7 +182,7 @@ } } //回报率 - BigDecimal returnRate = profitLossPrice.divide((order.getPrePaymentAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); + BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); contractOrderEntity.setRewardAmount(profitLossPrice); contractOrderEntity.setRewardRatio(returnRate); contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount()); @@ -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, "止盈平仓"); @@ -270,7 +270,7 @@ } } //回报率 - BigDecimal returnRate = profitLossPrice.divide((order.getPrePaymentAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); + BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); contractOrderEntity.setRewardAmount(profitLossPrice); contractOrderEntity.setRewardRatio(returnRate); contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount()); @@ -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, "止盈平仓"); @@ -361,7 +361,7 @@ } } //回报率 - BigDecimal returnRate = profitLossPrice.divide((order.getPrePaymentAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); + BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); contractOrderEntity.setRewardAmount(profitLossPrice); contractOrderEntity.setRewardRatio(returnRate); contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount()); @@ -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, "开多止损平仓"); @@ -448,7 +453,7 @@ } } //回报率 - BigDecimal returnRate = profitLossPrice.divide((order.getPrePaymentAmount().subtract(contractOrderEntity.getClosingFeeAmount())), 8, BigDecimal.ROUND_DOWN); + BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); contractOrderEntity.setRewardAmount(profitLossPrice); contractOrderEntity.setRewardRatio(returnRate); contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount()); @@ -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, "开空止损平仓"); @@ -563,7 +571,7 @@ // 扣除手续费 BigDecimal totalBalance = openFeePrice.negate(); contractEntrustOrderService.removeById(coinsCoinsOrder.getId()); - memberWalletContractService.increaseWalletContractBalanceById(null, totalBalance, null, wallet.getId()); + memberWalletContractService.increaseWalletContractBalanceById(null, totalBalance, coinsCoinsOrder.getBondAmount().negate(), wallet.getId()); //返佣 ThreadPoolUtils.calReturnMoney(memberEntity.getId(), openFeePrice, contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN); @@ -617,10 +625,10 @@ //更新主表订单状态位为“已平仓” contractOrderEntity.setId(null); - contractOrderEntity.setClosingPrice(BigDecimal.ZERO); contractOrderEntity.setClosingPrice(nowPrice); contractOrderEntity.setClosingTime(new Date()); - contractOrderEntity.setRewardAmount(coinsOrder.getPrePaymentAmount().negate()); + contractOrderEntity.setClosingFeeAmount(coinsOrder.getOpeningFeeAmount()); + contractOrderEntity.setRewardAmount(coinsOrder.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount()).negate()); contractOrderService.save(contractOrderEntity); //更新用户钱包数据 @@ -628,7 +636,7 @@ // 减去的时候用负数 BigDecimal totalPrice = coinsOrder.getBondAmount().negate(); - memberWalletContractService.increaseWalletContractBalanceById(null, totalPrice, totalPrice, usdt.getId()); + memberWalletContractService.increaseWalletContractBalanceById(null, totalPrice, null, usdt.getId()); // 流水记录 TODO MemberAccountFlowEntity record = new MemberAccountFlowEntity(); record.setCreateTime(new Date()); -- Gitblit v1.9.1