From d9222d7f94695b4cc7cb10be5010f6bfd24aeebf Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 14 Nov 2022 10:48:24 +0800
Subject: [PATCH] 20221114,内转改成不需要审核

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java |  249 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 176 insertions(+), 73 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
index f6a7c93..931ef7a 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -22,6 +22,7 @@
 import cc.mrbird.febs.dapp.vo.ActiveNftListVo;
 import cc.mrbird.febs.dapp.vo.ApiMemberWalletCoinVo;
 import cc.mrbird.febs.dapp.vo.WalletInfoVo;
+import cc.mrbird.febs.rabbit.producer.UsdtUpdateProducer;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateTime;
@@ -69,6 +70,7 @@
     private final MemberCoinWithdrawDao memberCoinWithdrawDao;
     private final IgtOnHookPlanOrderItemDao igtOnHookPlanOrderItemdao;
     private final DappBankDao dappBankDao;
+    private final UsdtUpdateProducer usdtUpdateProducer;
 
     private final RedisTemplate<String, Object> redisTemplate;
 
@@ -597,7 +599,7 @@
          * 否则,计算收益占本金的比例。符合条件允许提现
          */
         //获取用户的总收益
-        BigDecimal totalProfitOut = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberIdOut,1,2);
+        BigDecimal totalProfitOut = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberIdOut,2);
         if(balance.compareTo(totalProfitOut) > 0){
             BigDecimal totalAmount = dappWalletCoinEntityOut.getTotalAmount();
             //用户总收益率
@@ -628,9 +630,55 @@
         memberCoinWithdrawEntity.setFeeAmount(BigDecimal.ZERO);
         memberCoinWithdrawEntity.setSymbol("USDT");
         memberCoinWithdrawEntity.setMemberId(memberIdOut);
-        memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING);
+        memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_YES);
         memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_YES);
         memberCoinWithdrawDao.insert(memberCoinWithdrawEntity);
+
+//        usdtUpdateProducer.sendMemberCoinInside(memberCoinWithdrawEntity.getId());
+        //转出账户,总额减少,冻结减少
+        dappWalletCoinDao.delTotalAndDelFrozenById(dappWalletCoinEntityOut.getId(),balance);
+
+        String isInside = memberCoinWithdrawEntity.getIsInside();
+        String content = "";
+        Integer type = 0;
+        if(MemberCoinWithdrawEntity.ISINSIDE_NO.equals(isInside)){
+            content = "提现";
+            type = 2;
+        }else{
+            content = "转账";
+            type = 4;
+        }
+        //转出账户生成一条账户资金变化记录
+        DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityOut = new DappAccountMoneyChangeEntity(memberIdOut,
+                dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN),
+                balance.negate(),
+                dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).subtract(balance),
+                content,
+                type);
+        dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityOut);
+
+        //转入账户,总额增加,余额增加
+        //转账
+        if(MemberCoinWithdrawEntity.ISINSIDE_YES.equals(isInside)){
+            String addressIn = memberCoinWithdrawEntity.getAddress();
+            DappMemberEntity dappMemberEntityIn = dappMemberDao.selectMemberInfoByInviteId(addressIn);
+            if(ObjectUtil.isEmpty(dappMemberEntityIn)){
+                throw new FebsException(MessageSourceUtils.getString("Operation_002"));
+            }
+            DappWalletCoinEntity dappWalletCoinEntityIn = dappWalletCoinDao.selectByMemberId(dappMemberEntityIn.getId());
+            Integer countIn = dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntityIn.getId(), memberCoinWithdrawEntity.getAmount());
+            if(1 != countIn){
+                throw new FebsException(MessageSourceUtils.getString("Operation_002"));
+            }
+            //生成流水记录
+            DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityIn = new DappAccountMoneyChangeEntity(dappMemberEntityIn.getId(),
+                    dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN),
+                    balance,
+                    dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).add(balance),
+                    "转账",
+                    4);
+            dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityIn);
+        }
         return new FebsResponse().success().message(MessageSourceUtils.getString("Operation_001"));
     }
 
@@ -707,7 +755,7 @@
          * 否则,计算收益占本金的比例。符合条件允许提现
          */
         //获取用户的总收益
-        BigDecimal totalProfit = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberId,1,2);
+        BigDecimal totalProfit = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberId,2);
         if(balance.compareTo(totalProfit) >= 0){
             BigDecimal totalAmount = dappWalletCoinEntity.getTotalAmount();
             //用户总收益率
@@ -897,11 +945,15 @@
             if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
                 BigDecimal multiply = totalProfit.multiply(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
                 DappMemberEntity dappMemberEntityLEVEL_IB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_IB);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_IB.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_IB.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_IB.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_IB.getId(),multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_IB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply),"盈利分成", 8,id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
             String LEVEL_FIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_FIB.getCode());
             if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
@@ -914,11 +966,15 @@
 
                 multiply = totalProfit.multiply(multiply);
                 DappMemberEntity dappMemberEntityLEVEL_FIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_FIB);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_FIB.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_FIB.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_FIB.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_FIB.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_FIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
             String LEVEL_CIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_CIB.getCode());
             if(!DataDictionaryEnum.LEVEL_CIB.getCode().equals(LEVEL_CIB)){
@@ -932,11 +988,15 @@
                 }
                 multiply = totalProfit.multiply(multiply);
                 DappMemberEntity dappMemberEntityLEVEL_CIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_CIB);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_CIB.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_CIB.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_CIB.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_CIB.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_CIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
             String LEVEL_AIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_AIB.getCode());
             if(!DataDictionaryEnum.LEVEL_AIB.getCode().equals(LEVEL_AIB)){
@@ -952,11 +1012,15 @@
                 }
                 multiply = totalProfit.multiply(multiply);
                 DappMemberEntity dappMemberEntityLEVEL_AIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_AIB);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_AIB.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_AIB.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_AIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
             String LEVEL_GIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GIB.getCode());
             if(!DataDictionaryEnum.LEVEL_GIB.getCode().equals(LEVEL_GIB)){
@@ -974,11 +1038,15 @@
                 }
                 multiply = totalProfit.multiply(multiply);
                 DappMemberEntity dappMemberEntityLEVEL_GIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GIB);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_GIB.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GIB.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_GIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
             String LEVEL_BP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_BP.getCode());
             if(!DataDictionaryEnum.LEVEL_BP.getCode().equals(LEVEL_BP)){
@@ -998,11 +1066,15 @@
                 }
                 multiply = totalProfit.multiply(multiply);
                 DappMemberEntity dappMemberEntityLEVEL_BP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_BP);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_BP.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_BP.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_BP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
             String LEVEL_SP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_SP.getCode());
             if(!DataDictionaryEnum.LEVEL_SP.getCode().equals(LEVEL_SP)){
@@ -1024,11 +1096,15 @@
                 }
                 multiply = totalProfit.multiply(multiply);
                 DappMemberEntity dappMemberEntityLEVEL_SP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_SP);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_SP.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_SP.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_SP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
             String LEVEL_GP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GP.getCode());
             if(!DataDictionaryEnum.LEVEL_GP.getCode().equals(LEVEL_GP)){
@@ -1052,11 +1128,15 @@
                 }
                 multiply = totalProfit.multiply(multiply);
                 DappMemberEntity dappMemberEntityLEVEL_GP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GP);
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_GP.getId(), multiply, "盈利分成", 8,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GP.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_GP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
 
 
@@ -1068,11 +1148,15 @@
                 BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_AIB.getCode()));
                 DappMemberEntity dappMemberEntityLEVEL_AIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_AIB);
 
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_AIB.getId(), multiply, "流水佣金", 7,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_AIB.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_AIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
 
             String LEVEL_GIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GIB.getCode());
@@ -1080,11 +1164,15 @@
                 BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_GIB.getCode()));
                 DappMemberEntity dappMemberEntityLEVEL_GIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GIB);
 
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_GIB.getId(), multiply, "流水佣金", 7,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GIB.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_GIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
 
             String LEVEL_BP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_BP.getCode());
@@ -1092,11 +1180,15 @@
                 BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_BP.getCode()));
                 DappMemberEntity dappMemberEntityLEVEL_BP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_BP);
 
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_BP.getId(), multiply, "流水佣金", 7,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_BP.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_BP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
 
             String LEVEL_SP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_SP.getCode());
@@ -1104,11 +1196,15 @@
                 BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_SP.getCode()));
                 DappMemberEntity dappMemberEntityLEVEL_SP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_SP);
 
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_SP.getId(), multiply, "流水佣金", 7,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_SP.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_SP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
 
             String LEVEL_GP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GP.getCode());
@@ -1116,11 +1212,15 @@
                 BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_GP.getCode()));
                 DappMemberEntity dappMemberEntityLEVEL_GP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GP);
 
-                dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(),multiply);
-                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
-                        dappMemberEntityLEVEL_GP.getId(), multiply, "流水佣金", 7,id);
-                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-                profitSharingTotal = profitSharingTotal.add(multiply);
+                DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GP.getId());
+                if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0) {
+                    dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(), multiply);
+                    DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+                            dappMemberEntityLEVEL_GP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+                            multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+                    dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+                    profitSharingTotal = profitSharingTotal.add(multiply);
+                }
             }
         }
         return profitSharingTotal;
@@ -1131,11 +1231,10 @@
         if(BigDecimal.ZERO.compareTo(totalProfit)>=0){
             return BigDecimal.ZERO;
         }
-        BigDecimal multiply = totalProfit.multiply(new BigDecimal(0.05));
         DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(65L,
-                multiply.negate(), "系统", 9,id);
+                totalProfit, "系统", 9,id);
         dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
-        return multiply;
+        return totalProfit;
     }
 
     @Override
@@ -1155,8 +1254,12 @@
 
     public static void main(String[] args) {
 
-        String num = StrUtil.subSuf("01234",1);
-        System.out.print(num);
+        DateTime date = DateUtil.date();
+        DateTime endTime = DateUtil.parseTimeToday("09:08:03");
+        if(DateUtil.compare(date,endTime)>=0){
+            //
+            System.out.print(endTime);
+        }
     }
 
     private String isIdentity(List<String> refererIds,String levelCode){

--
Gitblit v1.9.1