xiaoyong931011
2023-05-26 498674e022e83c3c6aafec3ddc8691ad6a2bc309
twoCoin项目修改
11 files modified
108 ■■■■■ changed files
src/main/java/cc/mrbird/febs/dapp/chain/EthService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/mapper/DappFundFlowDao.java 1 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/DappSystemService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java 38 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/job/BnbTransferJob.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/QueueConstants.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/QueueEnum.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/RabbitConfiguration.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/producer/ChainProducer.java 9 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/dapp/DappFundFlowDao.xml 11 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/chain/EthService.java
@@ -257,8 +257,8 @@
    }
    public String tokenTransfer(String privateKey, String fromAddress, String toAddress, String amount) throws ExecutionException, InterruptedException {
//        String gas = getGas();
        String gas = "5";
        String gas = getGas();
//        String gas = "5";
        BigDecimal amountPow = new BigDecimal(amount).multiply(BigDecimal.TEN.pow(decimals()));
        amount = amountPow.toPlainString();
src/main/java/cc/mrbird/febs/dapp/mapper/DappFundFlowDao.java
@@ -37,6 +37,7 @@
    int updateStatusById(@Param("status")int status, @Param("id")Long id);
    DappFundFlowEntity selectByStateAndVersionAndFromHashLimitOne(@Param("status")int withdrawStatusAgree, @Param("version")int withdrawStatusAgree1);
    DappFundFlowEntity selectByStateAndVersionAndFromHashTwoLimitOne(@Param("status")int withdrawStatusAgree, @Param("version")int withdrawStatusAgree1);
    /**
     * 根据会员ID、类型、状态去查询资金流水记录
src/main/java/cc/mrbird/febs/dapp/service/DappSystemService.java
@@ -95,4 +95,5 @@
    void antKLineMsg(int type);
    void antKLineABMsg(Long id);
}
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -1896,6 +1896,44 @@
    }
    @Override
    public void antKLineABMsg(Long id) {
        log.info("{}",id);
        //获取对应的流水记录
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
            return;
        }
        Long memberId = dappFundFlowEntity.getMemberId();
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
        if(ObjectUtil.isEmpty(dappMemberEntity)){
            return;
        }
        DappFundFlowEntity dappFundFlow = dappFundFlowDao.selectById(id);
        //金额
        BigDecimal amount = dappFundFlow.getAmount();
        //目标地址
        String address = null;
        if(5 == dappFundFlowEntity.getType()){
            address = AppContants.ADDRESS_A_POOL_PEOJECT;
        }else if(6 == dappFundFlowEntity.getType()){
            address = AppContants.ADDRESS_B_POOL_PEOJECT;
        }else{
            return;
        }
        /**
         * 发起USDT转账
         */
        String hash = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(address, amount);
        if(StrUtil.isEmpty(hash)){
            return;
        }
        log.info("{},{}",id,hash);
        dappFundFlow.setFromHash(hash);
        dappFundFlowDao.updateById(dappFundFlow);
    }
    /**
     * 生成当前分钟的k线数据,type为0
     */
src/main/java/cc/mrbird/febs/job/BnbTransferJob.java
@@ -46,6 +46,17 @@
        }
    }
    @Scheduled(cron = "0/30 * * * * ? ")
    public void ABTransferAgain() {
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectByStateAndVersionAndFromHashTwoLimitOne(2,2);
        if(ObjectUtil.isNotEmpty(dappFundFlowEntity)){
            Integer isReturn = dappFundFlowEntity.getIsReturn();
            if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == isReturn){
                chainProducer.sendAntKLineABMsg(dappFundFlowEntity.getId());
            }
        }
    }
    /**
     * 20%所有人平分的底池
     */
src/main/java/cc/mrbird/febs/rabbit/QueueConstants.java
@@ -50,4 +50,8 @@
     * A k线数据
     */
    public static final String QUEUE_ANT_K_LINE = "queue_ant_k_line_test";
    /**
     * A k线数据
     */
    public static final String QUEUE_ANT_K_LINE_AB = "queue_ant_k_line_test_ab";
}
src/main/java/cc/mrbird/febs/rabbit/QueueEnum.java
@@ -6,6 +6,8 @@
@Getter
public enum QueueEnum {
    //A k线数据
    ANT_K_LINE_AB("exchange_ant_k_line_test_ab", "route_key_ant_k_line_test_ab", QueueConstants.QUEUE_ANT_K_LINE_AB),
    //A k线数据
    ANT_K_LINE("exchange_ant_k_line_test", "route_key_ant_k_line_test", QueueConstants.QUEUE_ANT_K_LINE),
    //A 会员升级
    ANT_MEMBER_LEVEL("exchange_ant_member_level_test", "route_key_ant_member_level_test", QueueConstants.QUEUE_ANT_MEMBER_LEVEL),
src/main/java/cc/mrbird/febs/rabbit/RabbitConfiguration.java
@@ -340,4 +340,22 @@
        return BindingBuilder.bind(antKLineQueue()).to(antKLineExchange()).with(QueueEnum.ANT_K_LINE.getRoute());
    }
    // === A k线数据  end ===
    // === A k线数据  start ===
    @Bean
    public DirectExchange antKLineABExchange() {
        return new DirectExchange(QueueEnum.ANT_K_LINE_AB.getExchange());
    }
    @Bean
    public Queue antKLineABQueue() {
        return new Queue(QueueEnum.ANT_K_LINE_AB.getQueue());
    }
    @Bean
    public Binding antKLineABBind() {
        return BindingBuilder.bind(antKLineABQueue()).to(antKLineABExchange()).with(QueueEnum.ANT_K_LINE_AB.getRoute());
    }
    // === A k线数据  end ===
}
src/main/java/cc/mrbird/febs/rabbit/consumer/ChainConsumer.java
@@ -170,4 +170,13 @@
        log.info("消费---A k线数据:{}", type);
        dappSystemService.antKLineMsg(type);
    }
    /**转账拨币
     * @param id
     */
    @RabbitListener(queues = QueueConstants.QUEUE_ANT_K_LINE_AB)
    public void antKLineABMsg(Long id) {
        log.info("消费转账拨币第二步:{}", id);
        dappSystemService.antKLineABMsg(id);
    }
}
src/main/java/cc/mrbird/febs/rabbit/producer/ChainProducer.java
@@ -189,4 +189,13 @@
        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend(QueueEnum.ANT_K_LINE.getExchange(), QueueEnum.ANT_K_LINE.getRoute(), type, correlationData);
    }
    /**
     * 转账拨币
     */
    public void sendAntKLineABMsg(Long id) {
        log.info("开始转账拨币第二步:{}", id);
        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend(QueueEnum.ANT_K_LINE_AB.getExchange(), QueueEnum.ANT_K_LINE_AB.getRoute(), id, correlationData);
    }
}
src/main/resources/mapper/dapp/DappFundFlowDao.xml
@@ -134,6 +134,17 @@
            LIMIT 1
    </select>
    <select id="selectByStateAndVersionAndFromHashTwoLimitOne" resultType="cc.mrbird.febs.dapp.entity.DappFundFlowEntity">
        select * from dapp_fund_flow
        where status = #{status}
          and from_hash is null
          and is_return = 2
          and type in (5,6)
        ORDER BY
            id ASC
            LIMIT 1
    </select>
    <select id="selectBymemberIdAndType" resultType="cc.mrbird.febs.dapp.entity.DappFundFlowEntity">
        select * from dapp_fund_flow
        where member_id = #{memberId}