From f1f883554a05d7ef93d4095906216aaed537b20e Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 08 Jun 2023 17:38:54 +0800
Subject: [PATCH] twoCoin项目修改
---
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java | 49 +++++++++++++++++++++++++++++--------------------
1 files changed, 29 insertions(+), 20 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 cb58f86..420eca8 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
@@ -36,6 +36,7 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import freemarker.template.utility.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -636,6 +637,9 @@
// System.out.println(2);
// }
// getLocalAddress("0x2bBAD0d2362a8dbdc655fBa5A0cd51d5379e38f7");
+ BigDecimal amountIn = BigDecimal.valueOf(951);
+ BigDecimal result = amountIn.divide(BigDecimal.valueOf(100));
+ System.out.println(result.remainder(BigDecimal.ONE).equals(BigDecimal.ZERO));
}
@Override
@@ -711,8 +715,22 @@
* 每人总共入金100U
*/
BigDecimal amountIn = transferADto.getAmount();
- if(amountIn.compareTo(new BigDecimal(100)) != 0){
- throw new FebsException("Limit per address 100 USDT");
+// if(amountIn.compareTo(new BigDecimal(100)) != 0){
+// throw new FebsException("Limit per address 100 USDT");
+// }
+ /**
+ * 每单金额得大于100 小于1000 限制
+ */
+ if(amountIn.compareTo(new BigDecimal(100)) < 0){
+ throw new FebsException("Min 100");
+ }
+ if(amountIn.compareTo(new BigDecimal(1000)) > 0){
+ throw new FebsException("Max 1000");
+ }
+
+ BigDecimal result = amountIn.divide(BigDecimal.valueOf(100));
+ if(!result.remainder(BigDecimal.ONE).equals(BigDecimal.ZERO)){
+ throw new FebsException("Please enter an integer multiple of 100");
}
// BigDecimal amountInLast = dappChargeUsdtMapper.selectByMaxAmountMemberId(member.getId());
@@ -720,25 +738,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("Limit per address 100 USDT");
+ 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());
}
}
/**
--
Gitblit v1.9.1