From a723f687ea40161699b85a91e610ac79da1c2392 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 03 Aug 2023 15:35:22 +0800
Subject: [PATCH] 数据修改
---
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java | 205 ++++++++++++++++++++++++++++++---------------------
1 files changed, 120 insertions(+), 85 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 d952e34..ec99d73 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;
@@ -363,6 +364,11 @@
* A币卖币规则,卖出100%销毁,30%回流底池溢价
*/
DappMemberEntity member = LoginUserUtil.getAppUser();
+ DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
+ Integer activeStatus = dappMemberEntity.getActiveStatus();
+ if(1 != activeStatus){
+ throw new FebsException("Not yet open");
+ }
DataDictionaryCustom systemStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
PoolEnum.SYSTEM.getType(),
@@ -445,14 +451,15 @@
/**
* A币卖币规则,卖出100%销毁,30%回流底池溢价
*/
- coinUsdtAmount = coinUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN);
+ BigDecimal coinUsdtAmountFee = coinUsdtAmount.multiply(new BigDecimal(0.2)).setScale(4,BigDecimal.ROUND_DOWN);
+// coinUsdtAmount = coinUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN);
//金本位底池数量
DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
PoolEnum.COIN_A_USDT_PRICE.getType(),
PoolEnum.COIN_A_USDT_PRICE.getCode()
);
BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
- coinAUsdtCnt = coinAUsdtCnt.add(coinUsdtAmount).setScale(4,BigDecimal.ROUND_DOWN);
+ coinAUsdtCnt = coinAUsdtCnt.subtract(coinUsdtAmount).add(coinUsdtAmountFee).setScale(4,BigDecimal.ROUND_DOWN);
coinAUsdtPriceDic.setValue(coinAUsdtCnt.toString());
dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic);
//币本位底池数量
@@ -629,16 +636,23 @@
}
public static void main(String[] args) {
- String ss = "0x2bBAD0d2362a8dbdc655fBa5A0cd51d5379e38f7,0xd5c13dc4372d1e02b93add9dcca901bef51168be,0xe22bb5fB2e0F8ED9366785dADD33cA19355d037c,0x7685E62E679886494E3cdc3DE7103E026f815AF0,0x6893bE8F4fb73595A13f32bA5e1d198Ab135516C";
+// String ss = "0x2bBAD0d2362a8dbdc655fBa5A0cd51d5379e38f7,0xd5c13dc4372d1e02b93add9dcca901bef51168be,0xe22bb5fB2e0F8ED9366785dADD33cA19355d037c,0x7685E62E679886494E3cdc3DE7103E026f815AF0,0x6893bE8F4fb73595A13f32bA5e1d198Ab135516C";
// if(ss.contains("0xd5c13dc4372d1e02b93add9dcca901bef51168be")){
// System.out.println(1);
// }else{
// 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));
+// BigDecimal amountIn = BigDecimal.valueOf(951);
+// BigDecimal result = amountIn.divide(BigDecimal.valueOf(100));
+// System.out.println(result.remainder(BigDecimal.ONE).equals(BigDecimal.ZERO));
+ Long memberId = 3067L;
+ if(AppContants.YL_MEMBER_ID.equals(memberId)){
+ System.out.println(1);
+ }else{
+ System.out.println(2);
+ }
+
}
@Override
@@ -723,8 +737,8 @@
if(amountIn.compareTo(new BigDecimal(100)) < 0){
throw new FebsException("Min 100");
}
- if(amountIn.compareTo(new BigDecimal(1000)) > 0){
- throw new FebsException("Max 1000");
+ if(amountIn.compareTo(new BigDecimal(100000)) > 0){
+ throw new FebsException("Max 100000");
}
BigDecimal result = amountIn.divide(BigDecimal.valueOf(100));
@@ -737,28 +751,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(100000)) > 0){
+ BigDecimal add = new BigDecimal(100000).subtract(amountInLast).setScale(0, BigDecimal.ROUND_DOWN);
+ throw new FebsException("Max "+ add.toString());
}
}
/**
@@ -805,6 +807,15 @@
1,
ausdAmountNeed,
transferADto.getTxHash());
+
+
+// DappFundFlowEntity fundFlow = new DappFundFlowEntity(
+// member.getId(),
+// transferADto.getAmount(),
+// type,
+// 1,
+// new BigDecimal("1"),
+// transferADto.getTxHash());
dappFundFlowDao.insert(fundFlow);
return fundFlow.getId();
}
@@ -814,44 +825,52 @@
if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == flow.getStatus()){
throw new FebsException("请勿重复提交");
}
- /**
- * 生成会员入金买A币的记录
- */
- DappChargeUsdtEntity dappChargeUsdtEntity = new DappChargeUsdtEntity(
- member.getId(),
- dappMemberEntity.getAddress(),
- transferADto.getTxHash(),
- 2,
- transferADto.getAmount(),
- BigDecimal.ZERO,
- BigDecimal.ZERO);
- dappChargeUsdtMapper.insert(dappChargeUsdtEntity);
- /**
- * 减少用户的AUSD数量
- */
- DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(member.getId());
- BigDecimal ausdAmount = dappUsdtPerkEntity.getAusdAmount();
- ausdAmount = ausdAmount.subtract(flow.getFee()).setScale(4,BigDecimal.ROUND_DOWN);
- dappUsdtPerkEntity.setAusdAmount(ausdAmount);
- dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity);
- /**
- * 流水关联用户购买记录
- */
- flow.setSystemProfitId(dappChargeUsdtEntity.getId());
+
/**
* 链上转账的hash值
*/
flow.setFromHash(transferADto.getTxHash());
- flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
dappFundFlowDao.updateById(flow);
- /**
- * 发送消息处理返利逻辑
- */
- chainProducer.sendAntACoinInMsg(flow.getId());
- /**
- * 发送消息处理代理升级
- */
- chainProducer.sendAntMemberLevelMsg(member.getId());
+ chainProducer.sendContractAnDao(flow.getId());
+
+// /**
+// * 生成会员入金买A币的记录
+// */
+// DappChargeUsdtEntity dappChargeUsdtEntity = new DappChargeUsdtEntity(
+// member.getId(),
+// dappMemberEntity.getAddress(),
+// transferADto.getTxHash(),
+// 2,
+// transferADto.getAmount(),
+// BigDecimal.ZERO,
+// BigDecimal.ZERO);
+// dappChargeUsdtMapper.insert(dappChargeUsdtEntity);
+// /**
+// * 减少用户的AUSD数量
+// */
+// DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(member.getId());
+// BigDecimal ausdAmount = dappUsdtPerkEntity.getAusdAmount();
+// ausdAmount = ausdAmount.subtract(flow.getFee()).setScale(4,BigDecimal.ROUND_DOWN);
+// dappUsdtPerkEntity.setAusdAmount(ausdAmount);
+// dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity);
+// /**
+// * 流水关联用户购买记录
+// */
+// flow.setSystemProfitId(dappChargeUsdtEntity.getId());
+// /**
+// * 链上转账的hash值
+// */
+// flow.setFromHash(transferADto.getTxHash());
+// flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
+// dappFundFlowDao.updateById(flow);
+// /**
+// * 发送消息处理返利逻辑
+// */
+// chainProducer.sendAntACoinInMsg(flow.getId());
+// /**
+// * 发送消息处理代理升级
+// */
+// chainProducer.sendAntMemberLevelMsg(member.getId());
} else {
DappFundFlowEntity flow = dappFundFlowDao.selectById(transferADto.getId());
if (flow.getStatus() == 1) {
@@ -1126,6 +1145,10 @@
BigDecimal feePercent = new BigDecimal(StrUtil.isEmpty(dic.getValue()) ? "0.2" : dic.getValue());
//手续费
BigDecimal feeCnt = coinCnt.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN);
+ if(AppContants.YL_MEMBER_ID.equals(member.getId())
+ || AppContants.YL_MEMBER_ID_TWO.equals(member.getId())){
+ feeCnt = BigDecimal.ZERO;
+ }
//闪对钱包获取的
BigDecimal aCoinCntReal = coinCnt.subtract(feeCnt).setScale(4, BigDecimal.ROUND_DOWN);
//增加闪对钱包
@@ -1142,33 +1165,34 @@
dappMemberEntity.getId());
dappFundFlowDao.insert(dappFundFlowEntity);
- //金本位底池数量
- DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
- PoolEnum.COIN_A_USDT_PRICE.getType(),
- PoolEnum.COIN_A_USDT_PRICE.getCode()
- );
- BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
- //币本位底池数量
- DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
- PoolEnum.COIN_A_CNT.getType(),
- PoolEnum.COIN_A_CNT.getCode()
- );
- BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
- coinACnt = coinACnt.subtract(feeCnt).setScale(4,BigDecimal.ROUND_DOWN);
- coinACntDic.setValue(coinACnt.toString());
- dataDictionaryCustomMapper.updateById(coinACntDic);
+ if(BigDecimal.ZERO.compareTo(feeCnt) < 0){
+ //金本位底池数量
+ DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+ PoolEnum.COIN_A_USDT_PRICE.getType(),
+ PoolEnum.COIN_A_USDT_PRICE.getCode()
+ );
+ BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
+ //币本位底池数量
+ DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+ PoolEnum.COIN_A_CNT.getType(),
+ PoolEnum.COIN_A_CNT.getCode()
+ );
+ BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
+ coinACnt = coinACnt.subtract(feeCnt).setScale(4,BigDecimal.ROUND_DOWN);
+ coinACntDic.setValue(coinACnt.toString());
+ dataDictionaryCustomMapper.updateById(coinACntDic);
- DataDictionaryCustom aCoinPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
- PoolEnum.COIN_A_PRICE.getType(),
- PoolEnum.COIN_A_PRICE.getCode()
- );
- BigDecimal coinAPrice = new BigDecimal(aCoinPriceDic.getValue());
- coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
- aCoinPriceDic.setValue(coinAPrice.toString());
- dataDictionaryCustomMapper.updateById(aCoinPriceDic);
+ DataDictionaryCustom aCoinPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+ PoolEnum.COIN_A_PRICE.getType(),
+ PoolEnum.COIN_A_PRICE.getCode()
+ );
+ BigDecimal coinAPrice = new BigDecimal(aCoinPriceDic.getValue());
+ coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
+ aCoinPriceDic.setValue(coinAPrice.toString());
+ dataDictionaryCustomMapper.updateById(aCoinPriceDic);
- chainProducer.sendAntKLineMsg(0);
-
+ chainProducer.sendAntKLineMsg(0);
+ }
}
@Override
@@ -1183,6 +1207,17 @@
throw new FebsException("请输入正确的地址");
}
+ /**
+ * 转ausdt,只能推广线上
+ */
+ String refererIdsDone = dappMemberEntity.getRefererIds();
+ String inviteIdDone = dappMemberEntity.getInviteId();
+ String refererIdsOther = memberParent.getRefererIds();
+ String inviteId1Other = memberParent.getInviteId();
+ if(!(StrUtil.contains(refererIdsOther,inviteIdDone) || StrUtil.contains(refererIdsDone,inviteId1Other))){
+ throw new FebsException("不满足互转规则");
+ }
+
BigDecimal coinCnt = roundCoinDto.getCoinCnt();
if(BigDecimal.ZERO.compareTo(coinCnt) >= 0){
throw new FebsException("输入正确的数量");
--
Gitblit v1.9.1