Merge remote-tracking branch 'origin/BNBWEB' into BNBWEB
| | |
| | | } |
| | | |
| | | // 区块链节点地址 TODO |
| | | private static String blockchainNode = "https://bsc-dataseed.binance.org"; |
| | | // private static String blockchainNode = "https://bsc-dataseed.binance.org"; |
| | | private static String blockchainNode = "https://bsc-dataseed1.ninicoin.io"; |
| | | |
| | | // 合约地址 TODO |
| | | private static String contractAddr = "0x7FDD62bA4451ABB40d72C6690088755115bFf9d7"; |
| | |
| | | // 更新区块编号 TODO |
| | | redisService.set("BNB_BLOCK_NUMBER",e.log.getBlockNumber().intValue()); |
| | | //投注人 |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectByAddress(from, "BSC"); |
| | | if(ObjectUtil.isNotEmpty(dappMemberEntity)){ |
| | | //投注人是否加入 |
| | | DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(dappMemberEntity.getId(), DappSystemProfit.STATE_IN); |
| | | if(ObjectUtil.isNotEmpty(dappSystemProfit)){ |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByState(DappFundFlowEntity.WITHDRAW_STATUS_ING); |
| | | if(CollUtil.isNotEmpty(dappFundFlowEntities)){ |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | |
| | | //发送转币消息 |
| | | chainProducer.sendBnbTransferMsg(dappFundFlowEntity.getId()); |
| | | // DappMemberEntity dappMember = dappMemberDao.selectById(dappFundFlowEntity.getMemberId()); |
| | | // trans(new BigInteger(dappFundFlowEntity.getAmount().toString()),dappMember.getAddress()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectByAddress(from, "BSC"); |
| | | // if(ObjectUtil.isNotEmpty(dappMemberEntity)){ |
| | | // //投注人是否加入 |
| | | // DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(dappMemberEntity.getId(), DappSystemProfit.STATE_IN); |
| | | // if(ObjectUtil.isNotEmpty(dappSystemProfit)){ |
| | | // List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByState(DappFundFlowEntity.WITHDRAW_STATUS_ING); |
| | | // if(CollUtil.isNotEmpty(dappFundFlowEntities)){ |
| | | // for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | // //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(dappFundFlowEntity.getId()); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | }catch (Exception exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | return transactionHash; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | ContractMain contractMain = new ContractMain(); |
| | | |
| | | String address = "0xd9076245473060dda1a65f5f3d89a4d0598995e6"; |
| | | BigInteger bigInteger = new BigInteger(Convert.toWei("0.00105", Convert.Unit.ETHER).setScale(0).toString()); |
| | | String hash = contractMain.trans(bigInteger,address); |
| | | System.out.println(hash); |
| | | } |
| | | } |
| | |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 状态 1-已发送 2-未发送消息 |
| | | */ |
| | | private Integer isReturn; |
| | | |
| | | @TableField(exist = false) |
| | | private String address; |
| | | |
| | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(refererMember.getId(), memberLevelProfit, 4, 1, BigDecimal.ZERO,null,dappSystemProfit.getId()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | systemProfitTotal = systemProfitTotal.add(memberLevelProfit); |
| | | } |
| | | } |
| | | //如果还有剩余给技术方 |
| | | if(levelProfitTotal.compareTo(systemProfitTotal) > 0){ |
| | | BigDecimal avaProfit = levelProfitTotal.subtract(systemProfitTotal); |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(1L, avaProfit, 5, 1, BigDecimal.ZERO,null,dappSystemProfit.getId()); |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(2L, avaProfit, 5, 1, BigDecimal.ZERO,null,dappSystemProfit.getId()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | } |
| | | |
| | | dappSystemProfitDao.updateLevelProfitById(DappSystemProfit.ENUM_YES,dappSystemProfit.getId()); |
| | |
| | | DappSystemProfit dappSystemProfitNow = dappSystemProfitDao.selectByIdForUpdate(dappSystemProfit.getId(),DappSystemProfit.STATE_IN); |
| | | dappSystemProfitDao.updateStateById(DappSystemProfit.STATE_OUT,dappSystemProfitNow.getId()); |
| | | |
| | | //todo 直接拿走0.95ge |
| | | // 直接拿走0.95ge |
| | | |
| | | DataDictionaryCustom investAmountProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.INVEST_AMOUNT_PROFIT.getType(), DataDictionaryEnum.INVEST_AMOUNT_PROFIT.getCode()); |
| | | BigDecimal investAmountProfit = new BigDecimal(investAmountProfitSet.getValue()); |
| | |
| | | if(ObjectUtil.isEmpty(dappFundFlow)){ |
| | | return; |
| | | } |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_ING != dappFundFlow.getIsReturn()){ |
| | | return; |
| | | } |
| | | //用户已经加入动能队列 |
| | | DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectById(dappFundFlow.getSystemProfitId()==null ? 0L : dappFundFlow.getSystemProfitId()); |
| | | if(ObjectUtil.isEmpty(dappSystemProfit)){ |
| | | return; |
| | | } |
| | | //金额 |
| | | BigDecimal amount = dappFundFlow.getAmount().setScale(BigDecimal.ROUND_DOWN,4); |
| | | BigDecimal amount = dappFundFlow.getAmount(); |
| | | //目标地址 |
| | | Long memberId = dappFundFlow.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | |
| | | } |
| | | 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); |
| | |
| | | DappFundFlowEntity systemProfitFlow = new DappFundFlowEntity(1L, new BigDecimal(systemProfitStr), 2, 1, BigDecimal.ZERO, null,dappSystemProfit.getId()); |
| | | dappFundFlowDao.insert(systemProfitFlow); |
| | | //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(systemProfitFlow.getId()); |
| | | chainProducer.sendBnbTransferMsg(systemProfitFlow.getId()); |
| | | //直接返利30%给直接上级 |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId()); |
| | | String refererId = dappMemberEntity.getRefererId(); |
| | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(refererMember.getId(), directProfit, 3, 1, BigDecimal.ZERO, null,dappSystemProfit.getId()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | //层级奖励30% |
| | | chainProducer.sendLevelProfitMsg(dappSystemProfit.getId()); |
| | | //发送一个消息,计算当前是否有人可以出局 |
| | |
| | | DappFundFlowEntity systemProfitFlow = new DappFundFlowEntity(1L, new BigDecimal(systemProfitStr), 2, 1, BigDecimal.ZERO, null,dappSystemProfit.getId()); |
| | | dappFundFlowDao.insert(systemProfitFlow); |
| | | //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(systemProfitFlow.getId()); |
| | | chainProducer.sendBnbTransferMsg(systemProfitFlow.getId()); |
| | | //直接返利30%给直接上级 |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId()); |
| | | String refererId = dappMemberEntity.getRefererId(); |
| | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(refererMember.getId(), directProfit, 3, 1, BigDecimal.ZERO, null,dappSystemProfit.getId()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | chainProducer.sendBnbTransferMsg(fundFlow.getId()); |
| | | //层级奖励30% |
| | | chainProducer.sendLevelProfitMsg(dappSystemProfit.getId()); |
| | | //发送一个消息,计算当前是否有人可以出局 |
| | |
| | | @Autowired |
| | | private ChainProducer chainProducer; |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @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()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * 转账拨币 |
| | | */ |
| | | public void sendBnbTransferMsg(Long id) { |
| | | log.info("转账拨币:{}", id); |
| | | log.info("开始转账拨币第一步:{}", id); |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.BNB_TRANSFER.getExchange(), QueueEnum.BNB_TRANSFER.getRoute(), id, correlationData); |
| | | } |
| | |
| | | * 转账拨币 |
| | | */ |
| | | public void sendBnbTransferTestMsg(Long id) { |
| | | log.info("转账拨币:{}", id); |
| | | log.info("开始转账拨币第二步:{}", id); |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.BNB_TRANSFER_TEST.getExchange(), QueueEnum.BNB_TRANSFER_TEST.getRoute(), id, correlationData); |
| | | } |
| | |
| | | datasource: |
| | | dynamic: |
| | | # 是否开启 SQL日志输出,生产环境建议关闭,有性能损耗 |
| | | p6spy: false |
| | | p6spy: true |
| | | hikari: |
| | | connection-timeout: 30000 |
| | | max-lifetime: 1800000 |
| | |
| | | where status = #{status} |
| | | and version = #{version} |
| | | and from_hash is null |
| | | and is_return = 2 |
| | | ORDER BY |
| | | id ASC |
| | | LIMIT 1 |