From 595bd69cc70996087f499956840552aebc3d28b7 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 19 May 2023 18:17:11 +0800
Subject: [PATCH] twoCoin项目修改

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java |   50 +++++++++++-------------
 src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java           |   10 ++--
 src/main/java/cc/mrbird/febs/job/BnbTransferJob.java                      |   24 ++++++------
 3 files changed, 40 insertions(+), 44 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 e7926ba..4a13495 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
@@ -564,40 +564,36 @@
 
     @Override
     public void bnbTransferTest(Long id) {
-        DappFundFlowEntity dappFundFlow = dappFundFlowDao.selectById(id);
-        if(ObjectUtil.isEmpty(dappFundFlow)){
+        log.info("{}",id);
+        //获取对应的流水记录
+        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
+        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
             return;
         }
-        if(DappFundFlowEntity.WITHDRAW_STATUS_ING != dappFundFlow.getIsReturn()){
-            return;
-        }
-        /**
-         * 用户是否已经生成节点购买记录
-         */
-        DappMemberNodeEntity dappMemberNodeEntity = dappMemberNodeMapper.selectById(dappFundFlow.getSystemProfitId() == null ? 0L : dappFundFlow.getSystemProfitId());
-        if(ObjectUtil.isEmpty(dappMemberNodeEntity)){
-            return;
-        }
-        //金额
-        BigDecimal amount = dappFundFlow.getAmount();
-        //目标地址
-        Long memberId = dappFundFlow.getMemberId();
+        Long memberId = dappFundFlowEntity.getMemberId();
         DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
         if(ObjectUtil.isEmpty(dappMemberEntity)){
             return;
         }
-        String address = dappMemberEntity.getAddress();
-        log.info("{}",address);
-//        BigInteger bigInteger = new BigInteger(Convert.toWei("0.000001", Convert.Unit.ETHER).setScale(0).toString());
-        BigInteger bigInteger = new BigInteger(Convert.toWei(amount.toString(), Convert.Unit.ETHER).setScale(0).toString());
-        log.info("{}",bigInteger);
-        String hash = contractMain.trans(bigInteger,address);
-        if(StrUtil.isEmpty(hash)){
-            return;
-        }
+        Integer count = dappFundFlowDao.updateStatusById(DappFundFlowEntity.WITHDRAW_STATUS_AGREE,dappFundFlowEntity.getId());
+        if(count > 0){
+            DappFundFlowEntity dappFundFlow = dappFundFlowDao.selectById(id);
+            //金额
+            BigDecimal amount = dappFundFlow.getAmount();
+            //目标地址
+            String address = dappMemberEntity.getAddress();
+            /**
+             * 发起USDT转账
+             */
+            String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount);
+            if(StrUtil.isEmpty(hash)){
+                return;
+            }
+            log.info("{},{}",id,hash);
+            dappFundFlow.setFromHash(hash);
+            dappFundFlowDao.updateById(dappFundFlow);
 
-        dappFundFlow.setFromHash(hash);
-        dappFundFlowDao.updateById(dappFundFlow);
+        }
     }
 
 //    public static void main(String[] args) {
diff --git a/src/main/java/cc/mrbird/febs/job/BnbTransferJob.java b/src/main/java/cc/mrbird/febs/job/BnbTransferJob.java
index 13c08a9..018a747 100644
--- a/src/main/java/cc/mrbird/febs/job/BnbTransferJob.java
+++ b/src/main/java/cc/mrbird/febs/job/BnbTransferJob.java
@@ -21,17 +21,17 @@
     @Autowired
     private ChainProducer chainProducer;
 
-//    @Scheduled(cron = "0/10 * * * * ? ")
-//    public void BnbTransferAgain() {
-//        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectByStateAndVersionAndFromHashLimitOne(2,2);
-//        if(ObjectUtil.isNotEmpty(dappFundFlowEntity)){
-//            Integer isReturn = dappFundFlowEntity.getIsReturn();
-//            if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == isReturn){
-//                dappFundFlowEntity.setIsReturn(1);
-//                dappFundFlowDao.updateById(dappFundFlowEntity);
-//                chainProducer.sendBnbTransferTestMsg(dappFundFlowEntity.getId());
-//            }
-//        }
-//    }
+    @Scheduled(cron = "0/10 * * * * ? ")
+    public void BnbTransferAgain() {
+        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectByStateAndVersionAndFromHashLimitOne(2,2);
+        if(ObjectUtil.isNotEmpty(dappFundFlowEntity)){
+            Integer isReturn = dappFundFlowEntity.getIsReturn();
+            if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == isReturn){
+                dappFundFlowEntity.setIsReturn(1);
+                dappFundFlowDao.updateById(dappFundFlowEntity);
+                chainProducer.sendBnbTransferTestMsg(dappFundFlowEntity.getId());
+            }
+        }
+    }
 
 }
diff --git a/src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java b/src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java
index 038a434..bd2471e 100644
--- a/src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java
+++ b/src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java
@@ -76,11 +76,11 @@
     /**转账拨币
      * @param id
      */
-//    @RabbitListener(queues = QueueConstants.QUEUE_BNB_TRANSFER_TEST)
-//    public void bnbTransferTest(Long id) {
-//        log.info("消费转账拨币第二步:{}", id);
-//        dappSystemService.bnbTransferTest(id);
-//    }
+    @RabbitListener(queues = QueueConstants.QUEUE_BNB_TRANSFER_TEST)
+    public void bnbTransferTest(Long id) {
+        log.info("消费转账拨币第二步:{}", id);
+        dappSystemService.bnbTransferTest(id);
+    }
 //
 //    /**代理升级
 //     * @param id

--
Gitblit v1.9.1