| | |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.dapp.utils.OnlineTransferUtil; |
| | | import cc.mrbird.febs.dapp.vo.RedisTransferPoolVo; |
| | | import cc.mrbird.febs.dapp.vo.SlipSettingVo; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | |
| | | SystemDto system = new SystemDto(); |
| | | String hasStart = redisUtils.getString(AppContants.SYSTEM_START_FLAG); |
| | | // 启动未启动 |
| | | if (!"start".equals(hasStart)) { |
| | | system.setFeeRatio(BigDecimal.TEN); |
| | | system.setUsdtRemain(BigDecimal.ZERO); |
| | | system.setUsdtTotal(BigDecimal.ZERO); |
| | | system.setSaleRemain(BigDecimal.ZERO); |
| | | system.setSaleTotal(BigDecimal.ZERO); |
| | | Object makePoolObj = redisUtils.get(AppContants.REDIS_KEY_MAKE_POOL_CNT); |
| | | BigDecimal balance; |
| | | if (makePoolObj == null) { |
| | | balance = ChainService.getInstance(ChainEnum.BSC_TFC_MAKE.name()).balanceOf(ChainEnum.BSC_TFC_MAKE.getAddress()); |
| | | redisUtils.set(AppContants.REDIS_KEY_MAKE_POOL_CNT, balance); |
| | | } else { |
| | | balance = (BigDecimal) makePoolObj; |
| | | } |
| | | system.setBuyRemain(balance); |
| | | system.setBuyTotal(balance); |
| | | |
| | | return system; |
| | | } |
| | | |
| | | RedisTransferPoolVo transferPool = (RedisTransferPoolVo) redisUtils.get(AppContants.REDIS_KEY_TRANSFER_POOL_VOL); |
| | | BigDecimal poolRemain = (BigDecimal) redisUtils.get(AppContants.REDIS_KEY_TRANSFER_POOL_VOL_REMAIN); |
| | |
| | | |
| | | // 销毁 |
| | | // instance.transfer(AppContants.DESTROY_ADDRESS, destroy); |
| | | DappOnlineTransferEntity destroyRecord = new DappOnlineTransferEntity(AppContants.DESTROY_ADDRESS, destroy, fundflow.getType(), 3, ChainEnum.BSC_TFC_SOURCE.name(), "TFC", fundflow.getId().toString()); |
| | | dappOnlineTransferDao.insert(destroyRecord); |
| | | OnlineTransferUtil.addTransfer(AppContants.DESTROY_ADDRESS, destroy, fundflow.getType(), 3, ChainEnum.BSC_TFC_SOURCE.name(), AppContants.SYMBOL_COIN, fundflow.getId().toString()); |
| | | |
| | | // 总分发金额 |
| | | BigDecimal distrbAmount = fee.subtract(destroy); |
| | |
| | | DataDictionaryCustom distribDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_DISTRIBUTE_PROP, String.valueOf(i)); |
| | | BigDecimal total = distrbAmount.multiply(new BigDecimal(distribDic.getValue()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)); |
| | | |
| | | DappOnlineTransferEntity distribRecord = new DappOnlineTransferEntity(parent.getAddress(), total, fundflow.getType(), 1, ChainEnum.BSC_TFC_SOURCE.name(), "TFC", fundflow.getId().toString()); |
| | | dappOnlineTransferDao.insert(distribRecord); |
| | | OnlineTransferUtil.addTransfer(parent.getAddress(), total, fundflow.getType(), 1, ChainEnum.BSC_TFC_SOURCE.name(), AppContants.SYMBOL_COIN, fundflow.getId().toString()); |
| | | |
| | | nodeAmount = nodeAmount.subtract(total); |
| | | } |
| | |
| | | techAmount = techAmount.add(nodeAmount); |
| | | // instance.transfer(ChainEnum.BSC_TFC_TECH.getAddress(), techAmount); |
| | | |
| | | DappOnlineTransferEntity techRecord = new DappOnlineTransferEntity(ChainEnum.BSC_TFC_TECH.getAddress(), techAmount, fundflow.getType(), 2, ChainEnum.BSC_TFC_SOURCE.name(), "TFC", fundflow.getId().toString()); |
| | | dappOnlineTransferDao.insert(techRecord); |
| | | OnlineTransferUtil.addTransfer(ChainEnum.BSC_TFC_TECH.getAddress(), techAmount, fundflow.getType(), 2, ChainEnum.BSC_TFC_SOURCE.name(), AppContants.SYMBOL_COIN, fundflow.getId().toString()); |
| | | |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("batchNo", fundflow.getId().toString()); |
| | |
| | | continue; |
| | | } |
| | | |
| | | DappOnlineTransferEntity tfc = new DappOnlineTransferEntity(member.getAddress(), mine, 3, 1, "TFC", ChainEnum.BSC_TFC.name(), batchNo); |
| | | dappOnlineTransferDao.insert(tfc); |
| | | OnlineTransferUtil.addTransfer(member.getAddress(), mine, 3, 1, ChainEnum.BSC_TFC.name(), AppContants.SYMBOL_COIN, batchNo); |
| | | } |
| | | |
| | | Map<String, String> map = new HashMap<>(); |
| | |
| | | } |
| | | |
| | | // TODO 线上转账,已注释 |
| | | // String txHash = ChainService.getInstance(transfer.getFromType()).transfer(transfer.getAddress(), transfer.getAmount()); |
| | | // transfer.setTxHash(txHash); |
| | | String txHash = ChainService.getInstance(transfer.getFromType()).transfer(transfer.getAddress(), transfer.getAmount()); |
| | | transfer.setTxHash(txHash); |
| | | transfer.setHasFinish(1); |
| | | transfer.setUpdateTime(new Date()); |
| | | dappOnlineTransferDao.updateById(transfer); |
| | |
| | | DappFundFlowEntity fundFlow = dappFundFlowDao.selectById(Long.parseLong(batchNo)); |
| | | |
| | | fundFlow.setStatus(3); |
| | | // fundFlow.setToHash(txHash); |
| | | fundFlow.setToHash(txHash); |
| | | |
| | | dappFundFlowDao.updateById(fundFlow); |
| | | } |
| | | |
| | | // 修改剩余量 |
| | | if (AppContants.SYMBOL_COIN.equals(transfer.getSymbol())) { |
| | | |
| | | BigDecimal poolRemain = (BigDecimal) redisUtils.get(AppContants.REDIS_KEY_TRANSFER_POOL_VOL_REMAIN); |
| | | redisUtils.set(AppContants.REDIS_KEY_TRANSFER_POOL_VOL_REMAIN, poolRemain.subtract(transfer.getAmount())); |
| | | } else { |
| | | |
| | | BigDecimal usdtRemain = (BigDecimal) redisUtils.get(AppContants.REDIS_KEY_USDT_OUT_LIMIT_REMAIN); |
| | | usdtRemain = usdtRemain.subtract(transfer.getAmount()); |
| | | if (usdtRemain.compareTo(BigDecimal.ZERO) < 0) { |
| | | usdtRemain = BigDecimal.ZERO; |
| | | } |
| | | redisUtils.set(AppContants.REDIS_KEY_USDT_OUT_LIMIT_REMAIN, usdtRemain); |
| | | } |
| | | } |
| | | } |
| | | } |