From 499749ed62dcb9186592eec81cd78d8927876427 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 08 Jun 2023 00:12:15 +0800
Subject: [PATCH] twoCoin项目修改

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java |   26 +++++++-------------------
 src/main/resources/mapper/dapp/DappChargeUsdtMapper.xml                   |    7 +++++++
 src/main/java/cc/mrbird/febs/dapp/mapper/DappChargeUsdtMapper.java        |    2 ++
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/mapper/DappChargeUsdtMapper.java b/src/main/java/cc/mrbird/febs/dapp/mapper/DappChargeUsdtMapper.java
index cfbf9e1..e8180c5 100644
--- a/src/main/java/cc/mrbird/febs/dapp/mapper/DappChargeUsdtMapper.java
+++ b/src/main/java/cc/mrbird/febs/dapp/mapper/DappChargeUsdtMapper.java
@@ -11,4 +11,6 @@
     BigDecimal selectByMaxAmountMemberId(@Param("memberId")Long id);
 
     BigDecimal selectBySumAmountMemberId(@Param("memberId")Long id);
+
+    BigDecimal selectBySumAmountMemberIdAndDate(@Param("memberId")Long id, @Param("dateTime")String today);
 }
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 d952e34..b48f141 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
@@ -737,28 +737,16 @@
                  * 限制用户买入总额,
                  *  目前每人限一单,总金额限制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(getLocalAddress(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");
-//                    }
-//                }
+//                BigDecimal amountInLast = dappChargeUsdtMapper.selectBySumAmountMemberId(member.getId());
+                BigDecimal amountInLast = dappChargeUsdtMapper.selectBySumAmountMemberIdAndDate(member.getId(),DateUtil.today());
                 /**
-                 * 每个地址只能使用一次 限制
+                 * 每个地址只能使用一次 限制总额1000U
                  */
+                BigDecimal amountInAll = amountInLast.add(amountIn);
                 if(getLocalAddress(dappMemberEntity.getAddress())){
-                    if(BigDecimal.ZERO.compareTo(amountInLast) < 0){
-                        throw new FebsException("Address can only be used once");
+                    if(amountInAll.compareTo(new BigDecimal(1000)) >= 0){
+                        BigDecimal add = new BigDecimal(1000).subtract(amountInLast).setScale(0, BigDecimal.ROUND_DOWN);
+                        throw new FebsException("Max "+ add.toString());
                     }
                 }
                 /**
diff --git a/src/main/resources/mapper/dapp/DappChargeUsdtMapper.xml b/src/main/resources/mapper/dapp/DappChargeUsdtMapper.xml
index 4eabecc..b1a59c1 100644
--- a/src/main/resources/mapper/dapp/DappChargeUsdtMapper.xml
+++ b/src/main/resources/mapper/dapp/DappChargeUsdtMapper.xml
@@ -14,4 +14,11 @@
         where member_id = #{memberId}
     </select>
 
+    <select id="selectBySumAmountMemberIdAndDate" resultType="java.math.BigDecimal">
+        select ifnull(sum(amount),0)
+        from dapp_charge_usdt
+        where member_id = #{memberId}
+        and date_format(create_time, '%Y-%m-%d') = #{dateTime}
+    </select>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1