From a8b2538db7172cc108b0a5387ea7c0da18046049 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Sat, 15 May 2021 15:01:30 +0800
Subject: [PATCH] Merge branch 'yunding' of http://120.27.238.55:7000/r/exchange into yunding

---
 src/test/java/com/xcong/excoin/XchTest.java                                           |    2 +-
 src/main/resources/application-test.yml                                               |    2 +-
 src/main/java/com/xcong/excoin/modules/yunding/entity/YdBasicSettingEntity.java       |    4 ++++
 src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java |   16 ++++++++++++++++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/yunding/entity/YdBasicSettingEntity.java b/src/main/java/com/xcong/excoin/modules/yunding/entity/YdBasicSettingEntity.java
index 5b50120..87a6046 100644
--- a/src/main/java/com/xcong/excoin/modules/yunding/entity/YdBasicSettingEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/yunding/entity/YdBasicSettingEntity.java
@@ -42,5 +42,9 @@
      * XCH兑换USDT手续费
      */
     private BigDecimal changeXch;
+    /**
+     * 直推返利
+     */
+    private BigDecimal parentRatio;
 
 }
diff --git a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
index 3b8ef4d..3dc38f1 100644
--- a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
@@ -4,6 +4,7 @@
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
+import com.xcong.excoin.common.contants.AppContants;
 import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
 import com.xcong.excoin.modules.member.dao.MemberDao;
 import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
@@ -18,6 +19,7 @@
 import com.xcong.excoin.modules.yunding.entity.YdOrderEntity;
 import com.xcong.excoin.modules.yunding.entity.YdProductEntity;
 import com.xcong.excoin.modules.yunding.service.XchProfitService;
+import com.xcong.excoin.netty.common.Contans;
 import com.xcong.excoin.rabbit.producer.YunDingProducter;
 import com.xcong.excoin.utils.LogRecordUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -183,6 +185,7 @@
             ydOrderDao.updateById(updateOrder);
         }
 
+        // 合伙人分红
         List<MemberEntity> partners = memberDao.selectPartnerMemberList();
         YdBasicSettingEntity setting = ydBasicSettingDao.selectById(1L);
         if (CollUtil.isNotEmpty(partners)) {
@@ -197,6 +200,19 @@
             }
         }
 
+        if(!AppContants.SYSTEM_REFERER.equals(memberEntity.getRefererId())) {
+            // 直推返利
+            MemberEntity parentNode = memberDao.selectMemberInfoByInviteId(memberEntity.getRefererId());
+            if (parentNode != null) {
+                BigDecimal parentAmount = order.getAmount().multiply(setting.getParentRatio());
+
+                String conent = "直推USDT返利";
+                LogRecordUtils.insertMemberAccountMoneyChangeWithId(parentNode.getId(), conent, parentAmount, "USDT", 1, 10, order.getId());
+                MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(parentNode.getId(), "USDT");
+
+                memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), parentAmount, BigDecimal.ZERO, 0);
+            }
+        }
     }
 
     private Map<Long, BigDecimal> buildReturnRatioObj(List<MemberEntity> agents, int type) {
diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml
index 6f0a502..b7c1130 100644
--- a/src/main/resources/application-test.yml
+++ b/src/main/resources/application-test.yml
@@ -48,7 +48,7 @@
   ## redis配置
   redis:
     ## Redis数据库索引(默认为0)
-    database: 3
+    database: 4
     ## Redis服务器地址
     host: 121.37.162.173
     ## Redis服务器连接端口
diff --git a/src/test/java/com/xcong/excoin/XchTest.java b/src/test/java/com/xcong/excoin/XchTest.java
index 39bd254..b3438a9 100644
--- a/src/test/java/com/xcong/excoin/XchTest.java
+++ b/src/test/java/com/xcong/excoin/XchTest.java
@@ -60,7 +60,7 @@
 
     @Test
     public void orderUsdtProfitTest() {
-        xchProfitService.usdtProfitDistributorByOrderId(1L);
+        xchProfitService.usdtProfitDistributorByOrderId(17L);
     }
 //
 //    @Autowired

--
Gitblit v1.9.1