| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private DappAgentReturnFlowDao dappAgentReturnFlowDao; |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | @Autowired |
| | | private DappSystemDao dappSystemDao; |
| | | |
| | | |
| | | @Scheduled(cron = "0 0 0/6 * * ? ") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addDappMineData(){ |
| | | log.info("矿池数据增加"); |
| | | DappMineDataEntity dataMine = dappSystemDao.selectMineDataForOne(); |
| | | //总产量 |
| | | BigDecimal totalOutput = dataMine.getTotalOutput(); |
| | | BigDecimal totalOutputNum = RandomUtil.randomBigDecimal(new BigDecimal("5000.0001"), new BigDecimal("10000.0001")).setScale(5, RoundingMode.HALF_DOWN); |
| | | totalOutput= totalOutput.add(totalOutputNum); |
| | | //有效节点 |
| | | Integer validNode = dataMine.getValidNode(); |
| | | int validNodeNum = RandomUtil.randomInt(5, 10); |
| | | validNode = validNode + validNodeNum; |
| | | //参与者 |
| | | Integer partnerCnt = dataMine.getPartnerCnt(); |
| | | int partnerCntNum = RandomUtil.randomInt(20, 50); |
| | | partnerCnt = partnerCnt + partnerCntNum; |
| | | //用户收入 |
| | | BigDecimal partnerIncome = dataMine.getPartnerIncome(); |
| | | BigDecimal partnerIncomeNum = RandomUtil.randomBigDecimal(new BigDecimal("1000.0001"), new BigDecimal("5000.0001")).setScale(4, RoundingMode.HALF_DOWN); |
| | | partnerIncome = partnerIncome.add(partnerIncomeNum); |
| | | dappSystemDao.updateDappMineData(totalOutput,validNode,partnerCnt,partnerIncome); |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 2 * * ? ") |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | if (CollUtil.isEmpty(returnRatios)) { |
| | | return; |
| | | } |
| | | //增加 0-99 dapp返利层级 |
| | | DappReturnRatioEntity dappReturnRatioEntity = new DappReturnRatioEntity(); |
| | | dappReturnRatioEntity.setMinValue(BigDecimal.ZERO); |
| | | dappReturnRatioEntity.setMaxValue(new BigDecimal(99)); |
| | | dappReturnRatioEntity.setRatio(BigDecimal.ZERO); |
| | | returnRatios.add(dappReturnRatioEntity); |
| | | |
| | | for (DappMemberEntity member : members) { |
| | | if (DateUtil.between(member.getCreateTime(), new Date(), DateUnit.HOUR, true) < 24) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal balance = ChainService.INSTANCE.balanceOf(member.getAddress()); |
| | | BigDecimal balance = ChainService.getInstance(member.getChainType()).balanceOf(member.getAddress()); |
| | | |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | for (DappReturnRatioEntity returnRatio : returnRatios) { |
| | |
| | | |
| | | BigDecimal ethNewPrice = (BigDecimal) redisUtils.get(AppContants.REDIS_KEY_ETH_NEW_PRICE); |
| | | |
| | | BigDecimal ethIncome = income.divide(ethNewPrice, 8, RoundingMode.HALF_DOWN); |
| | | BigDecimal ethIncome; |
| | | //0-100的余额返还5个 |
| | | if(returnRatio.getMinValue().compareTo(BigDecimal.ZERO) == 0 |
| | | && returnRatio.getMaxValue().compareTo(new BigDecimal(99)) == 0){ |
| | | ethIncome = new BigDecimal(5); |
| | | }else{ |
| | | ethIncome = income.divide(ethNewPrice, 8, RoundingMode.HALF_DOWN); |
| | | } |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), ethIncome, 3, null, null); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal balance = ChainService.INSTANCE.balanceOf(agent.getAddress()); |
| | | if (balance.compareTo(BigDecimal.valueOf(100L)) < 0) { |
| | | continue; |
| | | } |
| | | // BigDecimal balance = ChainService.getInstance(agent.getChainType()).balanceOf(agent.getAddress()); |
| | | // if (balance.compareTo(BigDecimal.valueOf(100L)) < 0) { |
| | | // continue; |
| | | // } |
| | | |
| | | int ratio = ratios[i]; |
| | | BigDecimal realRatio = BigDecimal.valueOf(ratio).divide(returnRatio, 2, RoundingMode.HALF_DOWN); |