From 5a84af23dd391b6d7a5f08eec3fc2b0acfd45057 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 07 Jun 2023 10:09:54 +0800
Subject: [PATCH] twoCoin项目修改

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java |   51 +++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 43 insertions(+), 8 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 79fb9e8..0d77aba 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
@@ -704,9 +704,27 @@
                 if(amountIn.compareTo(new BigDecimal(100)) != 0){
                     throw new FebsException("Limit per address 100 USDT");
                 }
-                BigDecimal amountInLast = dappChargeUsdtMapper.selectByMaxAmountMemberId(member.getId());
-                if(BigDecimal.ZERO.compareTo(amountInLast) < 0){
-                    throw new FebsException("Limit per address 100 USDT");
+
+//                BigDecimal amountInLast = dappChargeUsdtMapper.selectByMaxAmountMemberId(member.getId());
+                /**
+                 * 限制用户买入总额,
+                 *  目前每人限一单,总金额限制100U
+                 */
+                BigDecimal amountInLast = dappChargeUsdtMapper.selectBySumAmountMemberId(member.getId());
+                DataDictionaryCustom systemAddressDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                        PoolEnum.SYSTEM_ADDRESS.getType(),
+                        PoolEnum.SYSTEM_ADDRESS.getCode()
+                );
+                if(StrUtil.isNotEmpty(systemAddressDic.getValue())){
+                    if(!systemAddressDic.getValue().contains(dappMemberEntity.getAddress())){
+                        if(BigDecimal.ZERO.compareTo(amountInLast) < 0){
+                            throw new FebsException("Limit per address 100 USDT");
+                        }
+                    }
+                }else{
+                    if(BigDecimal.ZERO.compareTo(amountInLast) < 0){
+                        throw new FebsException("Limit per address 100 USDT");
+                    }
                 }
                 /**
                  * 验证账户是否有入金金额的10%的AUSD
@@ -1038,7 +1056,10 @@
                 coinCnt.negate(),
                 FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(),
                 2,
-                BigDecimal.ZERO);
+                BigDecimal.ZERO,
+                dappMemberEntity.getAddress(),
+                memberParent.getAddress(),
+                memberParent.getId());
         dappFundFlowDao.insert(aCoinCntFlow);
         //闪对钱包20% 手续费(扣币)
         DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
@@ -1057,7 +1078,10 @@
                 aCoinCntReal,
                 FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(),
                 2,
-                BigDecimal.ZERO);
+                BigDecimal.ZERO,
+                dappMemberEntity.getAddress(),
+                memberParent.getAddress(),
+                dappMemberEntity.getId());
         dappFundFlowDao.insert(dappFundFlowEntity);
 
         //金本位底池数量
@@ -1119,11 +1143,19 @@
                 coinCnt.negate(),
                 FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(),
                 2,
-                BigDecimal.ZERO);
+                BigDecimal.ZERO,
+                dappMemberEntity.getAddress(),
+                memberParent.getAddress(),
+                memberParent.getId());
         dappFundFlowDao.insert(aCoinCntFlow);
 
         DappUsdtPerkEntity parentEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberParent.getId());
-        BigDecimal availableAmountParent = parentEntity.getAusdAmount();
+        if(ObjectUtil.isEmpty(parentEntity)){
+            parentEntity = new DappUsdtPerkEntity();
+            parentEntity.setMemberId(memberParent.getId());
+            dappUsdtPerkEntityMapper.insert(parentEntity);
+        }
+        BigDecimal availableAmountParent = ObjectUtil.isEmpty(parentEntity.getAusdAmount()) ? BigDecimal.ZERO : parentEntity.getAusdAmount();
         parentEntity.setAusdAmount(availableAmountParent.add(coinCnt));
         dappUsdtPerkEntityMapper.updateById(parentEntity);
         //插入资产闪对的流水
@@ -1132,7 +1164,10 @@
                 coinCnt,
                 FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(),
                 2,
-                BigDecimal.ZERO);
+                BigDecimal.ZERO,
+                dappMemberEntity.getAddress(),
+                memberParent.getAddress(),
+                dappMemberEntity.getId());
         dappFundFlowDao.insert(aCoinCntFlowParent);
     }
 }

--
Gitblit v1.9.1