From 011f596d2a72c8532940d4d1033a3da52df76f57 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 03 Aug 2020 15:53:39 +0800
Subject: [PATCH] modify

---
 src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 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 2bff1e0..467c1ec 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
@@ -178,7 +178,7 @@
                             if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
                                 profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
                             } else {
-                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
+//                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
                             }
                         }
                         //回报率
@@ -268,7 +268,7 @@
                             if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
                                 profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
                             } else {
-                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
+//                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
                             }
                         }
                         //回报率
@@ -278,7 +278,7 @@
                         contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
                         contractOrderEntity.setClosingPrice(closePrice);
                         contractOrderEntity.setClosingType(7);
-                        contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
+                        contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_LESS);
                         BigDecimal totalReturn = BigDecimal.ZERO;
                         contractOrderService.save(contractOrderEntity);
 
@@ -360,7 +360,7 @@
                             if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
                                 profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
                             } else {
-                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
+//                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
                             }
                         }
                         //回报率
@@ -451,7 +451,7 @@
                             if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
                                 profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
                             } else {
-                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
+//                                profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
                             }
                         }
                         //回报率
@@ -551,6 +551,7 @@
                 contractHoldOrderEntity.setLeverRatio(coinsCoinsOrder.getLeverRatio());
                 contractHoldOrderEntity.setOpeningPrice(entrustPrice);
                 contractHoldOrderEntity.setTradeType(ContractHoldOrderEntity.TRADE_TYPE_LIMIT);
+                contractHoldOrderEntity.setOperateNo(1);
                 contractHoldOrderService.save(contractHoldOrderEntity);
 
                 // 需要一个历史插入
@@ -662,12 +663,17 @@
     }
 
     public void calYj(Long mid, BigDecimal money, ContractOrderEntity order, int type) {
+        PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
         if (money != null) {
-            money = money.multiply(new BigDecimal(0.7868));
+            money = money.multiply(tradeSetting.getFeeSpreadRatio());
         }
         MemberEntity member = memberService.getById(mid);
         String[] referenceIds = member.getRefererIds().split(",");
         List<String> ids = Arrays.asList(referenceIds);
+
+        if (MemberEntity.ACCOUNT_TYPE_TEST.equals(member.getAccountType())) {
+            return;
+        }
 
         // 判断该用户是否为代理商
         NeedMoneyMemberVo needMoneyMember = memberService.selectFriendRelationUserByMemberId(mid);
@@ -693,24 +699,28 @@
 
 
         // 存放uid以及对应uid用户的佣金
-        Map<String, BigDecimal> map = new HashMap<>();
+        Map<String, Map<String, BigDecimal>> map = new HashMap<>();
         Iterator<Map.Entry<Integer, NeedMoneyMemberVo>> it = treeMap.entrySet().iterator();
         BigDecimal lastRate = BigDecimal.ZERO;
         BigDecimal lastYj = BigDecimal.ZERO;
         while (it.hasNext()) {
             Map.Entry<Integer, NeedMoneyMemberVo> entry = it.next();
             NeedMoneyMemberVo member1 = entry.getValue();
+            Map<String, BigDecimal> returnValue = new HashMap<>();
+            returnValue.put("ratio", member1.getReturnRatio());
+            returnValue.put("lastRate", lastRate);
             // 上下级佣金比率相减后乘以手续费 -- 即用户所得佣金
             lastYj = (member1.getReturnRatio().subtract(lastRate)).multiply(money);
             lastRate = member1.getReturnRatio();
-            map.put(member1.getInviteId(), lastYj);
+            returnValue.put("returnMoney", lastYj);
+            map.put(member1.getInviteId(), returnValue);
         }
 
         // 输出对应佣金是否正确
-        Iterator<Map.Entry<String, BigDecimal>> it1 = map.entrySet().iterator();
+        Iterator<Map.Entry<String, Map<String, BigDecimal>>> it1 = map.entrySet().iterator();
         List<AgentReturnEntity> agentList = new ArrayList<AgentReturnEntity>();
         while (it1.hasNext()) {
-            Map.Entry<String, BigDecimal> entry = it1.next();
+            Map.Entry<String, Map<String, BigDecimal>> entry = it1.next();
             // System.out.println(entry.getKey() + "-----" + entry.getValue());
             MemberEntity agentMember = memberService.selectMemberInfoByInviteId(entry.getKey());
             AgentReturnEntity agent = new AgentReturnEntity();
@@ -721,7 +731,9 @@
             agent.setOrderType(order.getOrderType());
             agent.setReturnSymbol(order.getSymbol());
             agent.setIsReturn(0);
-            agent.setReturnAmount(entry.getValue());
+            agent.setReturnAmount(entry.getValue().get("returnMoney"));
+            agent.setChildReturnRatio(entry.getValue().get("lastRate"));
+            agent.setReturnRatio(entry.getValue().get("ratio"));
             agent.setClosingType(order.getClosingType());
             if (type == 1) {//开仓
                 agent.setOpeningFeeAmount(order.getOpeningFeeAmount());

--
Gitblit v1.9.1