xiaoyong931011
2023-05-19 595bd69cc70996087f499956840552aebc3d28b7
twoCoin项目修改
3 files modified
84 ■■■■ changed files
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java 50 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/job/BnbTransferJob.java 24 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java 10 ●●●● patch | view | raw | blame | history
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) {
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());
            }
        }
    }
}
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