xiaoyong931011
2021-03-25 3371b4051957c1dde8c6fa83cacbc934b9b81580
src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
@@ -215,7 +215,7 @@
                    followOrderOperationService.closingFollowOrders(holdOrderEntity.getOrderNo());
                } else {
                    followFollowerProfitDao.updateFollowerProfitByTradeMemberId(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()), profitOrLoss, traderInfoEntity.getMemberId(), memberEntity.getId());
                    LogRecordUtils.insertFollowerNotice(memberEntity.getId(), NoticeConstant.CLOSE_ORDER_TITLE, StrUtil.format(NoticeConstant.CLOSE_ORDER_CONTENT, contractOrderEntity.getSymbol(), contractOrderEntity.getClosingPrice(), profitOrLoss, traderInfoEntity.getNickname()));
                    LogRecordUtils.insertFollowerNotice(memberEntity.getId(), NoticeConstant.CLOSE_ORDER_TITLE, StrUtil.format(NoticeConstant.CLOSE_ORDER_CONTENT, contractOrderEntity.getSymbol(), contractOrderEntity.getClosingPrice(), profitOrLoss.setScale(2, BigDecimal.ROUND_HALF_UP).toString(), traderInfoEntity.getNickname()));
                }
            }
        }
@@ -302,6 +302,7 @@
            }
            log.info("profitOrLoss:{}", profitOrLoss);
            BigDecimal rewardRatio = profitOrLoss.divide(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()), 4, BigDecimal.ROUND_DOWN);
            // 保证金
            BigDecimal bondAmount = CalculateUtil.getBondAmount(holdOrderEntity.getOpeningPrice(), lotNumber, closeCnt, holdOrderEntity.getLeverRatio());
@@ -323,6 +324,7 @@
            contractOrderEntity.setClosingType(closingType);
            contractOrderEntity.setSymbolCnt(closeCnt);
            contractOrderEntity.setRewardAmount(profitOrLoss);
            contractOrderEntity.setRewardRatio(rewardRatio);
            contractOrderEntity.setBondAmount(bondAmount.add(fee));
            contractOrderEntity.setClosingFeeAmount(fee);
            contractOrderEntity.setClosingTime(new Date());
@@ -445,11 +447,13 @@
        contractOrderEntity.setEntrustOpeningPrice(newPrice);
        contractOrderEntity.setEntrustTime(new Date());
        contractOrderEntity.setClosingPrice(newPrice);
        contractOrderEntity.setOrderType(orderType);
        contractOrderEntity.setTradeType(ContractOrderEntity.TRADE_TYPE_LIMIT_PRICE);
        contractOrderEntity.setOrderType(entrustOrder.getEntrustType());
        contractOrderEntity.setClosingType(closingType);
        contractOrderEntity.setSymbolCnt(closeCnt);
        contractOrderEntity.setRewardAmount(profitOrLoss);
        contractOrderEntity.setBondAmount(bondAmount);
        contractOrderEntity.setClosingTime(new Date());
        contractOrderEntity.setClosingFeeAmount(fee);
        contractOrderDao.insert(contractOrderEntity);
@@ -495,7 +499,7 @@
                    continue;
                }
                holdOrderEntity.setForceClosingPrice(getForceSetPrice(wholePriceData, holdOrderEntity, holdOrderDataModel.getSymbol()));
//                holdOrderEntity.setForceClosingPrice(getForceSetPrice(wholePriceData, holdOrderEntity, holdOrderDataModel.getSymbol()));
                contractHoldOrderDao.deleteById(holdOrderDataModel.getId());
                ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity);
@@ -510,6 +514,7 @@
                contractOrderEntity.setRewardRatio(rewardRatio);
                contractOrderEntity.setRewardAmount(holdOrderDataModel.getRewardAmount().add(contractOrderEntity.getHoldBond().negate()));
                contractOrderEntity.setClosingPrice(holdOrderDataModel.getClosingPrice());
                contractOrderEntity.setForceClosingPrice(holdOrderDataModel.getClosingPrice());
                // 订单状态转换
                if (ContractOrderEntity.ORDER_TYPE_OPEN_MORE == contractOrderEntity.getOrderType()) {
@@ -526,7 +531,7 @@
            BigDecimal totalAmount = BigDecimal.ZERO;
            if (CollUtil.isNotEmpty(entrustOrder)) {
                for (ContractEntrustOrderEntity contractEntrustOrderEntity : entrustOrder) {
                    totalAmount.add(contractEntrustOrderEntity.getEntrustAmount());
                    totalAmount = totalAmount.add(contractEntrustOrderEntity.getEntrustAmount());
                }
            }