From 35aee14a86318c162aa484845cf973d11e122719 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 03 Aug 2023 16:07:48 +0800
Subject: [PATCH] 数据修改

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java |  110 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 94 insertions(+), 16 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
index 2671904..6deb364 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -25,6 +25,7 @@
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.Week;
+import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
@@ -64,7 +65,6 @@
     private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
     private final DappSystemProfitDao dappSystemProfitDao;
     private final ChainProducer chainProducer;
-    private final ContractMain contractMain;
 
     private final DappMemberNodeMapper dappMemberNodeMapper;
     private final DappChargeUsdtMapper dappChargeUsdtMapper;
@@ -1679,8 +1679,9 @@
          * 发起USDT转账
          */
         log.info("amount:{},address:{}",amount,address);
-
-        String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount);
+        ThreadUtil.sleep(5000);
+//        String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount);
+        String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transferUSDT(address, amount);
         if(StrUtil.isEmpty(hash)){
 //            hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transfer(address, amount);
             return;
@@ -1697,17 +1698,17 @@
     /**
      * 紧急提现方法
      */
-    public static void main(String[] args) {
-        BigDecimal amount = new BigDecimal("1");
-        String address = "0xB3cF9669F398f444DfCAebbAd2A49bF32ba41fE3";
-
-        String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount);
-
-        System.out.println(hash);
-
-
-//        int i = ChainService.getInstance(ChainEnum.BSC_TFC.name()).allowanceCnt("0x80098f854950f9327C4F4E747d285Fd2d41fbf3e");
-    }
+//    public static void main(String[] args) {
+//        BigDecimal amount = new BigDecimal("0.01");
+//        String address = "0xB3cF9669F398f444DfCAebbAd2A49bF32ba41fE3";
+//
+//        String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount);
+//
+//        System.out.println(hash);
+//
+//
+////        int i = ChainService.getInstance(ChainEnum.BSC_TFC.name()).allowanceCnt("0x80098f854950f9327C4F4E747d285Fd2d41fbf3e");
+//    }
 
     @Override
     public void aCoinFire() {
@@ -1752,7 +1753,7 @@
                 PoolEnum.COIN_A_CNT.getType(),
                 PoolEnum.COIN_A_CNT.getCode());
         BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
-        coinACnt = coinACnt.subtract(totalCnt);
+        coinACnt = coinACnt.subtract(totalCnt.multiply(new BigDecimal(0.65)));
         coinACntDic.setValue(coinACnt.toString());
         dataDictionaryCustomMapper.updateById(coinACntDic);
 
@@ -2145,6 +2146,9 @@
         if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == flow.getStatus()){
             return;
         }
+        if(FundFlowEnum.BUY_A_COIN.getCode() != flow.getType()){
+            return;
+        }
         DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
         if(ObjectUtil.isEmpty(dappMemberEntity)){
             return;
@@ -2180,6 +2184,58 @@
         flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
         dappFundFlowDao.updateById(flow);
 
+
+        BigDecimal amount = flow.getAmount();
+        /**
+         * 90%进入A币底池 10%进入B币LP薄饼底池
+         */
+        DataDictionaryCustom usdtAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                PoolEnum.USDT_A_PERCENT.getType(),
+                PoolEnum.USDT_A_PERCENT.getCode()
+        );
+        BigDecimal usdtAPercent = new BigDecimal(StrUtil.isEmpty(usdtAPercentDic.getValue()) ? "0.7" : usdtAPercentDic.getValue());
+        BigDecimal usdtAAmount = amount.multiply(usdtAPercent).setScale(4, BigDecimal.ROUND_DOWN);
+
+        //生成一条进行中的70%进入A币底池的资金流水记录
+        DappFundFlowEntity fundFlowToA = new DappFundFlowEntity(
+                1L,
+                usdtAAmount,
+                FundFlowEnum.USDT_IN_A_POOL.getCode(),
+                1,
+                BigDecimal.ZERO,
+                null,
+                dappChargeUsdtEntity.getId());
+        dappFundFlowDao.insert(fundFlowToA);
+
+        BigDecimal usdtWAmount = amount.multiply(new BigDecimal(0.2)).setScale(4, BigDecimal.ROUND_DOWN);
+//        //生成一条进行中的20%进入A币底池的资金流水记录
+//        DappFundFlowEntity fundFlowToW = new DappFundFlowEntity(
+//                1L,
+//                usdtWAmount,
+//                FundFlowEnum.USDT_IN_W_POOL.getCode(),
+//                1,
+//                BigDecimal.ZERO,
+//                null,
+//                dappChargeUsdtEntity.getId());
+//        dappFundFlowDao.insert(fundFlowToW);
+
+        DataDictionaryCustom usdtBPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                PoolEnum.USDT_B_PERCENT.getType(),
+                PoolEnum.USDT_B_PERCENT.getCode()
+        );
+        BigDecimal usdtBPercent = new BigDecimal(StrUtil.isEmpty(usdtBPercentDic.getValue()) ? "0.1" : usdtBPercentDic.getValue());
+        BigDecimal usdtBAmount = amount.multiply(usdtBPercent).setScale(4, BigDecimal.ROUND_DOWN);
+        //生成一条进行中的10%进入B币底池的资金流水记录
+        DappFundFlowEntity fundFlowToB = new DappFundFlowEntity(
+                1L,
+                usdtBAmount,
+                FundFlowEnum.USDT_IN_B_POOL.getCode(),
+                1,
+                BigDecimal.ZERO,
+                null,
+                dappChargeUsdtEntity.getId());
+        dappFundFlowDao.insert(fundFlowToB);
+
         /**
          * 发送消息处理返利逻辑
          */
@@ -2188,6 +2244,24 @@
          * 发送消息处理代理升级
          */
         chainProducer.sendAntMemberLevelMsg(memberId);
+        //90%进入A币底池
+        chainProducer.sendAntACoinInAPoolMsg(fundFlowToA.getId());
+        ThreadUtil.sleep(5000);
+        //10%进入B币LP薄饼底池
+        chainProducer.sendAntACoinInBPoolMsg(fundFlowToB.getId());
+    }
+
+    public static void main(String[] args) {
+
+        System.out.print(1);
+        System.out.print(2);
+//        ThreadUtil.execute(() -> {
+//            //90%进入A币底池
+//            System.out.print(1);
+//            ThreadUtil.sleep(5000);
+//            //10%进入B币LP薄饼底池
+//            System.out.print(2);
+//        });
     }
 
     @Override
@@ -2200,6 +2274,10 @@
             return;
         }
         if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE != dappFundFlowEntity.getStatus()){
+            return;
+        }
+
+        if(FundFlowEnum.BUY_A_COIN.getCode() != dappFundFlowEntity.getType()){
             return;
         }
         Long memberId = dappFundFlowEntity.getMemberId();
@@ -2304,7 +2382,7 @@
         );
         //A币金本位底池-usdt数量
         BigDecimal coinAUsdtPriceDicCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
-        coinAUsdtPriceDicCnt = coinAUsdtPriceDicCnt.add(amount);
+        coinAUsdtPriceDicCnt = coinAUsdtPriceDicCnt.add(amount.multiply(new BigDecimal(0.8)));
         coinAUsdtPriceDic.setValue(coinAUsdtPriceDicCnt.toString());
         dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic);
 

--
Gitblit v1.9.1