| | |
| | | } |
| | | |
| | | 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(); |
| | |
| | | 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、类型、状态去查询资金流水记录 |
| | |
| | | |
| | | void antKLineMsg(int type); |
| | | |
| | | void antKLineABMsg(Long id); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | @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 |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | @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%所有人平分的底池 |
| | | */ |
| | |
| | | * 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"; |
| | | } |
| | |
| | | @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), |
| | |
| | | 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 === |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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} |