From 95e01b8133653f30e3041b30b78dbf215891f324 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Wed, 03 Jul 2024 15:57:18 +0800
Subject: [PATCH] 逻辑

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java |   29 +++++-
 src/main/resources/templates/index.html                                   |    2 
 src/main/java/cc/mrbird/febs/common/runner/FebsStartedUpRunner.java       |    4 
 src/main/resources/templates/error/404.html                               |    2 
 src/main/resources/application-prod.yml                                   |    8 +-
 src/main/java/cc/mrbird/febs/rabbit/producer/ChainProducer.java           |    2 
 src/main/resources/application-test.yml                                   |   31 ++++---
 src/main/resources/application-chain.yml                                  |   12 +-
 src/main/resources/templates/error/403.html                               |    2 
 src/main/java/cc/mrbird/febs/dapp/enumerate/DataDictionaryEnum.java       |    1 
 src/main/java/cc/mrbird/febs/dapp/service/impl/BscCoinContractEvent.java  |   33 +++++++-
 src/test/java/cc/mrbird/febs/MemberTest.java                              |   81 ++++++++-----------
 src/main/resources/application.yml                                        |    2 
 src/main/resources/templates/error/500.html                               |    2 
 src/main/resources/templates/febs/views/layout.html                       |    2 
 src/main/resources/templates/febs/views/login.html                        |    4 
 16 files changed, 125 insertions(+), 92 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/common/runner/FebsStartedUpRunner.java b/src/main/java/cc/mrbird/febs/common/runner/FebsStartedUpRunner.java
index ee9ccea..9a8d530 100644
--- a/src/main/java/cc/mrbird/febs/common/runner/FebsStartedUpRunner.java
+++ b/src/main/java/cc/mrbird/febs/common/runner/FebsStartedUpRunner.java
@@ -44,7 +44,7 @@
             log.error("| |_   / /\\  | | | |");
             log.error("|_|   /_/--\\ |_| |_|__");
             log.error("                        ");
-            log.error("DMD启动失败,{}", e.getMessage());
+            log.error("启动失败,{}", e.getMessage());
             log.error("Redis连接异常,请检查Redis连接配置并确保Redis服务已启动");
             // 关闭 FEBS
             context.close();
@@ -63,7 +63,7 @@
             log.info("/ /`  / / \\ | |\\/| | |_) | |   | |_   | |  | |_  ");
             log.info("\\_\\_, \\_\\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ ");
             log.info("                                                      ");
-            log.info("DMD 权限系统启动完毕,地址:{}", url);
+            log.info(" 权限系统启动完毕,地址:{}", url);
 
             boolean auto = febsProperties.isAutoOpenBrowser();
             if (auto && StringUtils.equalsIgnoreCase(active, FebsConstant.DEVELOP)) {
diff --git a/src/main/java/cc/mrbird/febs/dapp/enumerate/DataDictionaryEnum.java b/src/main/java/cc/mrbird/febs/dapp/enumerate/DataDictionaryEnum.java
index 78321c4..846921c 100644
--- a/src/main/java/cc/mrbird/febs/dapp/enumerate/DataDictionaryEnum.java
+++ b/src/main/java/cc/mrbird/febs/dapp/enumerate/DataDictionaryEnum.java
@@ -4,6 +4,7 @@
 
 @Getter
 public enum DataDictionaryEnum {
+    USDT_BALANCE_TIME("USDT_BALANCE_TIME","USDT_BALANCE_TIME"),
     WITHDRAW_PERCENT("WITHDRAW_PERCENT","WITHDRAW_PERCENT"),
     RELEASE_PERCENT("RELEASE_PERCENT","RELEASE_PERCENT"),
     JILI_CHI("JILI_CHI","JILI_CHI"),
diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/BscCoinContractEvent.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/BscCoinContractEvent.java
index 19f6af0..85ee5f5 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/BscCoinContractEvent.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/BscCoinContractEvent.java
@@ -8,6 +8,7 @@
 import cc.mrbird.febs.dapp.entity.DataDictionaryCustom;
 import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum;
 import cc.mrbird.febs.dapp.mapper.DappFundFlowDao;
+import cc.mrbird.febs.dapp.mapper.DappMemberDao;
 import cc.mrbird.febs.dapp.mapper.DappStorageMapper;
 import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
 import cc.mrbird.febs.dapp.service.DappMemberService;
@@ -30,6 +31,8 @@
     private DappMemberService dappMemberService;
     @Resource
     private DappFundFlowDao dappFundFlowDao;
+    @Resource
+    private DappMemberDao dappMemberDao;
     @Resource
     private DataDictionaryCustomMapper dataDictionaryCustomMapper;
     @Resource
@@ -68,7 +71,7 @@
 //        int decimals = ChainService.getInstance(ChainEnum.BSC_TFC.name()).decimals();
         int decimals = 18;
         BigInteger tokens = e.tokens;
-        BigDecimal amount = new BigDecimal(tokens.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
+        BigDecimal amount = new BigDecimal(tokens.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN).setScale(2,BigDecimal.ROUND_DOWN);
         log.info("触发用户存储:{},金额:{},流水ID:{}",e.from,amount,flowId);
         // 账户是否已经注册
         DappMemberEntity fromMember = dappMemberService.findByAddress(e.from, null);
@@ -84,7 +87,7 @@
         fundFlow.setStatus(2);
         dappFundFlowDao.updateById(fundFlow);
 
-        log.info("触发用户存储:{},金额:{},流水ID:{}",e.from,amount,flowId);
+        log.info("产生用户存储:{},金额:{},流水ID:{}",e.from,amount,flowId);
 
         /**
          * 新增一条记录
@@ -96,11 +99,23 @@
         BigDecimal releasePercent = new BigDecimal(dataDictionaryCustom.getValue());
         DappStorage dappStorage = new DappStorage();
         dappStorage.setState(1);
+        dappStorage.setMemberId(fromMember.getId());
         dappStorage.setAmount(amount);
         dappStorage.setReleasePercent(releasePercent);
         BigDecimal releaseAmount = amount.multiply(releasePercent).setScale(2, BigDecimal.ROUND_DOWN);
         dappStorage.setReleaseAmount(releaseAmount);
         dappStorageMapper.insert(dappStorage);
+
+        DataDictionaryCustom usdtBalanceTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.USDT_BALANCE_TIME.getType(),
+                DataDictionaryEnum.USDT_BALANCE_TIME.getCode()
+        );
+        BigDecimal usdtBalanceTime = new BigDecimal(usdtBalanceTimeDic.getValue());
+        BigDecimal multiply = usdtBalanceTime.multiply(amount);
+        BigDecimal bigDecimal = fromMember.getUsdtBalance().add(multiply).setScale(2, BigDecimal.ROUND_DOWN);
+        fromMember.setUsdtBalance(bigDecimal);
+        fromMember.setActiveStatus(1);
+        dappMemberDao.updateById(fromMember);
 
         Long id = fundFlow.getId();
         Long memberId = fromMember.getId();
@@ -121,10 +136,18 @@
          */
         chainProducer.sendNodePerkMsg(id);
         /**
+         *
+         *   3.  DAO成员团队奖:5%加权分红(people数量)
+         *       DAO1: 加权分红50%
+         *       DAO2:加权分红30%
+         *       DAO3:加权分红20%
+         */
+        chainProducer.sendTeamPerk(id);
+        /**
          *3.  成员升级
-         *      *       DAO1:小区业绩30万/币  加权分红50%
-         *      *       DAO2:小区业绩100万/币 加权分红30%
-         *      *       DAO3:小区业绩500万/币加权分红20%
+         *      *       DAO1:小区业绩30万/币
+         *      *       DAO2:小区业绩100万/币
+         *      *       DAO3:小区业绩500万/币
          */
         chainProducer.sendMemberLevel(memberId);
 
diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
index ca085fa..4b8cb4e 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -635,10 +635,11 @@
             if(1 != activeStatus){
                 continue;
             }
-            //获取上级全部的直推
+            //获取上级全部的激活直推
             String inviteId = dappMemberEntityRef.getInviteId();
             QueryWrapper<DappMemberEntity> memberInviteQuery = new QueryWrapper<>();
             memberInviteQuery.eq("referer_id",inviteId);
+            memberInviteQuery.eq("active_status",1);
             List<DappMemberEntity> memberInviteList = dappMemberDao.selectList(memberInviteQuery);
 
             //如果没有直推,则跳过
@@ -663,7 +664,6 @@
                     perkMemberId,
                     MoneyFlowEnum.DYNAMIC_PERK.getValue(),
                     StrUtil.format(MoneyFlowEnum.DYNAMIC_PERK.getDescrition(),amount,memberInviteList.size(),perkAmount));
-
         }
     }
 
@@ -717,11 +717,25 @@
         }
         BigDecimal daoNodeAmount = daoNodeAmountTotal.divide(new BigDecimal(dappMemberEntities.size()),2,BigDecimal.ROUND_DOWN);
         for(DappMemberEntity nodeMember : dappMemberEntities){
-            this.updateBalanceInsertFlow(
-                    daoNodeAmount,
+//            this.updateBalanceInsertFlow(
+//                    daoNodeAmount,
+//                    nodeMember.getId(),
+//                    MoneyFlowEnum.NODE_PERK.getValue(),
+//                    StrUtil.format(MoneyFlowEnum.NODE_PERK.getDescrition(),amount,dappMemberEntities.size(),daoNodeAmount));
+
+
+
+            //生成一条流水
+            DappFundFlowEntity rePutInFlow = new DappFundFlowEntity(
                     nodeMember.getId(),
+                    daoNodeAmount,
                     MoneyFlowEnum.NODE_PERK.getValue(),
+                    2,
+                    null,
                     StrUtil.format(MoneyFlowEnum.NODE_PERK.getDescrition(),amount,dappMemberEntities.size(),daoNodeAmount));
+            dappFundFlowDao.insert(rePutInFlow);
+            //更新用户的金额
+            dappWalletService.updateWalletCoinWithLock(daoNodeAmount, nodeMember.getId(), 1);
         }
     }
 
@@ -830,6 +844,9 @@
     @Override
     public void teamPerk(Long id) {
         DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id);
+        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
+            return;
+        }
 
         if(MoneyFlowEnum.CUN_CHU.getValue() != dappFundFlowEntity.getType()){
             return;
@@ -874,7 +891,7 @@
         }
 
         QueryWrapper<DappMemberEntity> daoThreeQuery = new QueryWrapper<>();
-        daoThreeQuery.eq("level", MemberLevelEnum.DAO_2.getCode());
+        daoThreeQuery.eq("level", MemberLevelEnum.DAO_3.getCode());
         List<DappMemberEntity> daoThrees = dappMemberDao.selectList(daoThreeQuery);
         if(CollUtil.isNotEmpty(daoThrees)){
             BigDecimal bigDecimal = totalAmount.multiply(new BigDecimal("0.2")).setScale(2, BigDecimal.ROUND_DOWN);
@@ -900,7 +917,7 @@
         }
         //获取全部上级
         ArrayList<DappMemberEntity> activeMembers = new ArrayList<>();
-        List<String> refererIds = Arrays.asList(StrUtil.split(",", dappMemberEntity.getRefererIds()));
+        List<String> refererIds = Arrays.asList(StrUtil.split(dappMemberEntity.getRefererIds(),","));
         for(String inviteId : refererIds){
             DappMemberEntity memberEntity = dappMemberDao.selectMemberInfoByInviteId(inviteId);
             if(ObjectUtil.isNotEmpty(memberEntity)){
diff --git a/src/main/java/cc/mrbird/febs/rabbit/producer/ChainProducer.java b/src/main/java/cc/mrbird/febs/rabbit/producer/ChainProducer.java
index b13b9e6..16423ec 100644
--- a/src/main/java/cc/mrbird/febs/rabbit/producer/ChainProducer.java
+++ b/src/main/java/cc/mrbird/febs/rabbit/producer/ChainProducer.java
@@ -97,7 +97,7 @@
     public void sendMemberLevel(Long id) {
         log.info("发送成员升级,会员ID:{}", id);
         CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
-        rabbitTemplate.convertAndSend(QueueEnum.FPD_TEAM_PERK.getExchange(), QueueEnum.FPD_TEAM_PERK.getRoute(), id, correlationData);
+        rabbitTemplate.convertAndSend(QueueEnum.FPD_MEMBER_LEVEL.getExchange(), QueueEnum.FPD_MEMBER_LEVEL.getRoute(), id, correlationData);
     }
 
 }
diff --git a/src/main/resources/application-chain.yml b/src/main/resources/application-chain.yml
index 90ba829..ad70718 100644
--- a/src/main/resources/application-chain.yml
+++ b/src/main/resources/application-chain.yml
@@ -15,17 +15,17 @@
       datasource:
         # 数据源-1,名称为 base
         base:
-          username: db_sdm
-          password: sdm123!@#
+          username: db_fpd_prd
+          password: db_fpd_prd123!@#
           # 8.210.56.119
           driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://8.210.56.119:3306/db_sdm?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
+          url: jdbc:mysql://127.0.0.1:3306/db_fpd_prd?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
 
   redis:
     # Redis数据库索引(默认为 0)
-    database: 15
+    database: 1
     # Redis服务器地址
-    host: 8.210.56.119
+    host: 127.0.0.1
     # Redis服务器连接端口
     port: 6379
     # Redis 密码
@@ -43,7 +43,7 @@
     # 连接超时时间(毫秒)
     timeout: 5000
   rabbitmq:
-    host: 8.210.56.119
+    host: 127.0.0.1
     port: 5672
     username: xc_rabbit
     password: xuncong123
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index d4ce82e..c33bf3f 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -15,15 +15,15 @@
       datasource:
         # 数据源-1,名称为 base
         base:
-          username: db_sdm
-          password: sdm123!@#
+          username: db_fpd_prd
+          password: db_fpd_prd123!@#
           # 8.210.56.119
           driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://127.0.0.1:3306/db_sdm?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
+          url: jdbc:mysql://127.0.0.1:3306/db_fpd_prd?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
 
   redis:
     # Redis数据库索引(默认为 0)
-    database: 15
+    database: 1
     # Redis服务器地址
     host: 127.0.0.1
     # Redis服务器连接端口
diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml
index 56975be..9def3e3 100644
--- a/src/main/resources/application-test.yml
+++ b/src/main/resources/application-test.yml
@@ -2,7 +2,7 @@
   datasource:
     dynamic:
       # 是否开启 SQL日志输出,生产环境建议关闭,有性能损耗
-      p6spy: true
+      p6spy: false
       hikari:
         connection-timeout: 30000
         max-lifetime: 1800000
@@ -15,20 +15,21 @@
       datasource:
         # 数据源-1,名称为 base
         base:
-          username: ct_test
-          password: 123456
+          username: db_fpd_prd
+          password: db_fpd_prd123!@#
+          # 8.210.56.119
           driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://120.27.238.55:3306/db_sdm?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
+          url: jdbc:mysql://47.238.110.34:3306/db_fpd_prd?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
 
   redis:
     # Redis数据库索引(默认为 0)
-    database: 10
+    database: 1
     # Redis服务器地址
-    host: 120.27.238.55
+    host: 47.238.110.34
     # Redis服务器连接端口
     port: 6379
     # Redis 密码
-    password: xcong123
+    password: 1234!@#$!QAZ
     lettuce:
       pool:
         # 连接池中的最小空闲连接
@@ -42,14 +43,16 @@
     # 连接超时时间(毫秒)
     timeout: 5000
   rabbitmq:
-    host: 120.27.238.55
+    host: 47.238.110.34
     port: 5672
-    username: ct_rabbit
-    password: 123456
+    username: xc_rabbit
+    password: xuncong123
     publisher-confirm-type: correlated
 
+  jackson:
+    date-format: yyyy-MM-dd HH:mm:ss
+    time-zone: GMT+8
+
 system:
-  online-transfer: false
-  chain-listener: false
-  reset-job: false
-  debug: false
+  charge-transfer: false
+  debug: false
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index a55a837..b725ace 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -5,7 +5,7 @@
 
 spring:
   profiles:
-    active: dev
+    active: test
 
   thymeleaf:
     cache: false
diff --git a/src/main/resources/templates/error/403.html b/src/main/resources/templates/error/403.html
index 895ddcb..d7bb931 100644
--- a/src/main/resources/templates/error/403.html
+++ b/src/main/resources/templates/error/403.html
@@ -2,7 +2,7 @@
 <html xmlns:th="http://www.thymeleaf.org">
 <head>
     <meta charset="utf-8">
-    <title>DMD 权限系统</title>
+    <title> 权限系统</title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <meta name="renderer" content="webkit">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
diff --git a/src/main/resources/templates/error/404.html b/src/main/resources/templates/error/404.html
index 21818cd..56a75ba 100644
--- a/src/main/resources/templates/error/404.html
+++ b/src/main/resources/templates/error/404.html
@@ -2,7 +2,7 @@
 <html xmlns:th="http://www.thymeleaf.org">
 <head>
     <meta charset="utf-8">
-    <title>DMD 权限系统</title>
+    <title> 权限系统</title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <meta name="renderer" content="webkit">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
diff --git a/src/main/resources/templates/error/500.html b/src/main/resources/templates/error/500.html
index fd43102..784c461 100644
--- a/src/main/resources/templates/error/500.html
+++ b/src/main/resources/templates/error/500.html
@@ -2,7 +2,7 @@
 <html xmlns:th="http://www.thymeleaf.org">
 <head>
     <meta charset="utf-8">
-    <title>DMD 权限系统</title>
+    <title> 权限系统</title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <meta name="renderer" content="webkit">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
diff --git a/src/main/resources/templates/febs/views/layout.html b/src/main/resources/templates/febs/views/layout.html
index 0f1b7ab..f951b26 100644
--- a/src/main/resources/templates/febs/views/layout.html
+++ b/src/main/resources/templates/febs/views/layout.html
@@ -63,7 +63,7 @@
         <div class="layui-side-scroll">
             <div class="layui-logo" style="cursor: pointer">
                 <img data-th-src="@{febs/images/logo.png}">
-                <span>DMD 权限系统</span>
+                <span> 权限系统</span>
             </div>
             <script
                     type="text/html"
diff --git a/src/main/resources/templates/febs/views/login.html b/src/main/resources/templates/febs/views/login.html
index 0acbe04..ba3ce5e 100644
--- a/src/main/resources/templates/febs/views/login.html
+++ b/src/main/resources/templates/febs/views/login.html
@@ -2,7 +2,7 @@
 <html xmlns:th="http://www.thymeleaf.org">
 <head>
     <meta charset="utf-8">
-    <title>DMD 权限系统</title>
+    <title> 权限系统</title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <meta name="renderer" content="webkit">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@@ -19,7 +19,7 @@
         <div class="layui-container">
             <div class="layui-row">
                 <div class="layui-col-xs12 layui-col-lg4 layui-col-lg-offset4 febs-tc">
-                    <div class="layui-logo"><span><b>DMD</b> 权限系统</span></div>
+                    <div class="layui-logo"><span><b></b> 权限系统</span></div>
                 </div>
                 <div class="layui-col-xs12 layui-col-lg4 layui-col-lg-offset4" id="login-div">
                     <div class="layui-form" lay-filter="login-form">
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
index 1c5d577..39362ae 100644
--- a/src/main/resources/templates/index.html
+++ b/src/main/resources/templates/index.html
@@ -3,7 +3,7 @@
       xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
 <head>
     <meta charset="utf-8">
-    <title>DMD 权限系统</title>
+    <title> 权限系统</title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <meta name="renderer" content="webkit">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
diff --git a/src/test/java/cc/mrbird/febs/MemberTest.java b/src/test/java/cc/mrbird/febs/MemberTest.java
index 3319332..3622285 100644
--- a/src/test/java/cc/mrbird/febs/MemberTest.java
+++ b/src/test/java/cc/mrbird/febs/MemberTest.java
@@ -1,17 +1,18 @@
 package cc.mrbird.febs;
 
-import cc.mrbird.febs.common.contants.AppContants;
-import cc.mrbird.febs.dapp.entity.DappMemberEntity;
-import cc.mrbird.febs.dapp.entity.DataDictionaryCustom;
-import cc.mrbird.febs.dapp.mapper.DappMemberDao;
-import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
+import cc.mrbird.febs.dapp.dto.ConnectDto;
+import cc.mrbird.febs.dapp.entity.DappFundFlowEntity;
+import cc.mrbird.febs.dapp.enumerate.MoneyFlowEnum;
+import cc.mrbird.febs.dapp.mapper.DappFundFlowDao;
+import cc.mrbird.febs.dapp.service.DappMemberService;
+import cc.mrbird.febs.dapp.service.DappSystemService;
 import cn.hutool.core.util.StrUtil;
-import org.apache.commons.lang3.StringUtils;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import java.util.List;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
 
 /**
  * @author wzy
@@ -21,51 +22,39 @@
 public class MemberTest {
 
     @Autowired
-    private DappMemberDao dappMemberDao;
-
+    private DappMemberService dappMemberService;
     @Autowired
-    private DataDictionaryCustomMapper dataDictionaryCustomMapper;
+    private DappFundFlowDao dappFundFlowDao;
+
+    @Resource
+    private DappSystemService dappSystemService;
 
     @Test
-    public void refererIdsTest() {
-        DappMemberEntity member = dappMemberDao.selectById(24);
+    public void register() {//注册
+        ConnectDto connectDto = new ConnectDto();
+        connectDto.setAddress("0x597e5F0EDB294e7d28EB10A95aa2EEcd169a2dd7");
+        connectDto.setInviteId("53609999");
+        dappMemberService.connect(connectDto);
+    }
 
-        boolean flag = false;
-        String parentId = "35087336";
-        String ids = "";
-        String feeProfitIds = "";
+    @Test
+    public void registerV2() {//存储
+        Long memberId = 348L;
+        BigDecimal bigDecimal = new BigDecimal("500");
+        DappFundFlowEntity fundFlow = new DappFundFlowEntity(
+                memberId,
+                bigDecimal.abs(),
+                MoneyFlowEnum.CUN_CHU.getValue(),
+                1,
+                BigDecimal.ZERO,
+                StrUtil.format(MoneyFlowEnum.CUN_CHU.getDescrition(),bigDecimal));
+        dappFundFlowDao.insert(fundFlow);
 
-        int i = 1;
-        List<DataDictionaryCustom> feeProfitDic = dataDictionaryCustomMapper.selectDicByType(AppContants.DIC_TYPE_DISTRIBUTE_PROP);
-        while (!flag && StringUtils.isNotBlank(parentId)) {
-            if (StrUtil.isBlank(ids)) {
-                ids += parentId;
-            } else {
-                ids += ("," + parentId);
-            }
+    }
 
-            if (i <= 4) {
-                if (StrUtil.isBlank(feeProfitIds)) {
-                    feeProfitIds += parentId;
-                } else {
-                    feeProfitIds += ("," + parentId);
-                }
-            }
+    @Test
+    public void registerV3() {//存储
+        dappSystemService.teamPerk(4360L);
 
-            i++;
-            DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(parentId);
-            if (parentMember == null) {
-                break;
-            }
-            parentId = parentMember.getRefererId();
-            if(StringUtils.isBlank(parentId) || "0".equals(parentId)){
-                break;
-            }
-            if (parentMember.getRefererId().equals(parentMember.getInviteId())) {
-                flag = true;
-            }
-        }
-        member.setRefererIds(ids);
-        member.setFeeProfitIds(feeProfitIds);
     }
 }

--
Gitblit v1.9.1