| | |
| | | } |
| | | } |
| | | |
| | | // 激活卡牌 |
| | | if (fundFlow.getType() == 8) { |
| | | DappFundFlowEntity finalFundFlow = fundFlow; |
| | | DappMemberEntity member = dappMemberService.getById(fundFlow.getMemberId()); |
| | | |
| | | new Thread(() -> { |
| | | try { |
| | | int count = finalFundFlow.getAmount().intValue(); |
| | | String token = null; |
| | | while (count > 0) { |
| | | token = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).safeMintNFT(member.getAddress()); |
| | | Thread.sleep(5000); |
| | | count--; |
| | | } |
| | | finalFundFlow.setStatus(2); |
| | | finalFundFlow.setToHash(token); |
| | | dappFundFlowDao.updateById(finalFundFlow); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | log.error("发放卡牌错误", ex); |
| | | } |
| | | }).start(); |
| | | |
| | | ChainService.getInstance(ChainEnum.BSC_TFC.name()).transfer(AppContants.DESTROY_ADDRESS, finalFundFlow.getTargetAmount()); |
| | | return; |
| | | } |
| | | |
| | | OnlineTransferUtil.addTransferRecord(e.from, e.to, amount, e.log.getTransactionHash(), DappTransferRecordEntity.TRANSFER_SOURCE_FLAG_APPLICATION, "USDT"); |
| | | |
| | | |
| | | // 这个方法主要是处理,tp钱包在调用transfer时,交易详情中的金额可能因为网速慢而显示晚,从而导致实际转账比记录中的少,顾做此处理 |
| | | BigDecimal realCoin = amount.divide(fundFlow.getNewestPrice(), decimals, RoundingMode.HALF_UP); |
| | | if (fundFlow.getAmount().subtract(new BigDecimal("0.1")).compareTo(realCoin) > 0) { |
| | |
| | | chainProducer.sendNftBoxMsg(fundFlow.getId()); |
| | | } |
| | | } |
| | | |
| | | if ("0x0f71bff5d92cf9de27b711e5a6b888648e5ff6cc".toLowerCase().equals(e.to)) { |
| | | log.info("触发卡牌USDT合约监听事件"); |
| | | redisUtils.set(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM, e.log.getBlockNumber()); |
| | | |
| | | ContractChainService sourceUsdtInstance = ChainService.getInstance(ChainEnum.BSC_USDT.name()); |
| | | int decimals = sourceUsdtInstance.decimals(); |
| | | BigInteger tokens = e.tokens; |
| | | |
| | | BigDecimal amount = new BigDecimal(tokens.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN); |
| | | DappFundFlowEntity fundFlow = dappFundFlowDao.selectByFromHash(e.log.getTransactionHash(), null); |
| | | // 激活卡牌 |
| | | if (fundFlow.getType() == 8) { |
| | | DappFundFlowEntity finalFundFlow = fundFlow; |
| | | DappMemberEntity member = dappMemberService.getById(fundFlow.getMemberId()); |
| | | |
| | | |
| | | int count = finalFundFlow.getAmount().intValue(); |
| | | String token = null; |
| | | while (count > 0) { |
| | | token = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).safeMintNFT(member.getAddress()); |
| | | log.info("激活卡牌:{}", token); |
| | | try { |
| | | Thread.sleep(5000); |
| | | } catch (InterruptedException ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | |
| | | count--; |
| | | } |
| | | finalFundFlow.setStatus(2); |
| | | finalFundFlow.setToHash(token); |
| | | dappFundFlowDao.updateById(finalFundFlow); |
| | | |
| | | ChainService.getInstance(ChainEnum.BSC_TFC.name()).transfer(AppContants.DESTROY_ADDRESS, finalFundFlow.getTargetAmount()); |
| | | return; |
| | | } |
| | | |
| | | OnlineTransferUtil.addTransferRecord(e.from, e.to, amount, e.log.getTransactionHash(), DappTransferRecordEntity.TRANSFER_SOURCE_FLAG_APPLICATION, "USDT"); |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |