| | |
| | | PoolEnum.COIN_A_PRICE.getType(), |
| | | PoolEnum.COIN_A_PRICE.getCode() |
| | | ); |
| | | BigDecimal coinAPrice = new BigDecimal(StrUtil.isEmpty(coinAPriceDic.getValue()) ? "0" : coinAPriceDic.getValue()).setScale(8,BigDecimal.ROUND_DOWN); |
| | | BigDecimal coinAPrice = new BigDecimal(StrUtil.isEmpty(coinAPriceDic.getValue()) ? "0" : coinAPriceDic.getValue()).setScale(12,BigDecimal.ROUND_DOWN); |
| | | /** |
| | | * 会员充值USDT买入A币记录的ID |
| | | */ |
| | |
| | | BigDecimal amountPerk = dappUsdtPerkEntity.getAmount(); |
| | | amountPerk = amountPerk.add(amount.multiply(new BigDecimal(3))); |
| | | dappUsdtPerkEntity.setAmount(amountPerk); |
| | | //生成一条金本位的三倍额度的资金流水记录 |
| | | DappFundFlowEntity amountPerkFundFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | amount.multiply(new BigDecimal(3)), |
| | | FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(amountPerkFundFlow); |
| | | |
| | | //增加业绩 |
| | | BigDecimal achieveAmount = dappUsdtPerkEntity.getAchieveAmount(); |
| | | achieveAmount = achieveAmount.add(amount); |
| | |
| | | PoolEnum.USDT_A_PERCENT.getType(), |
| | | PoolEnum.USDT_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal usdtAPercent = new BigDecimal(StrUtil.isEmpty(usdtAPercentDic.getValue()) ? "0.9" : usdtAPercentDic.getValue()); |
| | | BigDecimal usdtAPercent = new BigDecimal(StrUtil.isEmpty(usdtAPercentDic.getValue()) ? "0.7" : usdtAPercentDic.getValue()); |
| | | BigDecimal usdtAAmount = amount.multiply(usdtAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | //生成一条进行中的90%进入A币底池的资金流水记录 |
| | | //生成一条进行中的70%进入A币底池的资金流水记录 |
| | | DappFundFlowEntity fundFlowToA = new DappFundFlowEntity( |
| | | 1L, |
| | | usdtAAmount, |
| | |
| | | dappFundFlowDao.insert(fundFlowToA); |
| | | //90%进入A币底池 |
| | | chainProducer.sendAntACoinInAPoolMsg(fundFlowToA.getId()); |
| | | |
| | | BigDecimal usdtWAmount = amount.multiply(new BigDecimal(0.2)).setScale(4, BigDecimal.ROUND_DOWN); |
| | | //生成一条进行中的20%进入A币底池的资金流水记录 |
| | | DappFundFlowEntity fundFlowToW = new DappFundFlowEntity( |
| | | 1L, |
| | | usdtWAmount, |
| | | FundFlowEnum.USDT_IN_W_POOL.getCode(), |
| | | 1, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(fundFlowToW); |
| | | |
| | | DataDictionaryCustom usdtBPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.USDT_B_PERCENT.getType(), |
| | |
| | | coinAUsdtPriceDic.setValue(coinAUsdtPriceDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic); |
| | | |
| | | BigDecimal divide = coinAUsdtPriceDicCnt.divide(coinACntDicCnt, 8, BigDecimal.ROUND_DOWN); |
| | | BigDecimal divide = coinAUsdtPriceDicCnt.divide(coinACntDicCnt, 12, BigDecimal.ROUND_DOWN); |
| | | coinAPriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAPriceDic); |
| | | |
| | |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(poolAllMemberAFundFlow); |
| | | |
| | | nodePoolPerk(poolAllMemberAPercentCnt, MemberLevelEnum.MEMBER.getType(), FundFlowEnum.POOL_MEMBER_A_CNT.getCode()); |
| | | // BigDecimal poolAllMemberAPercentCntAva = nodePoolPerk(poolAllMemberAPercentCnt, MemberLevelEnum.MEMBER.getType(), FundFlowEnum.POOL_MEMBER_A_CNT.getCode()); |
| | | /** |
| | | * 20%全网加权平分,按照个人投资占比全网的比例去平分 |
| | | */ |
| | | BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode()); |
| | | DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | FundFlowEnum.POOL_MEMBER_A_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(poolAllMemberAFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | 294L,1); |
| | | |
| | | /** |
| | | * 10%直推 |
| | | */ |
| | |
| | | //用户的A币账户增加directAPercentCnt数量 |
| | | dappWalletService.updateWalletMineWithLock(directAPercentFundFlowToMemberFlag,directMemberEntity.getId(),1); |
| | | } |
| | | if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){ |
| | | DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity( |
| | | 294L, |
| | | directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | FundFlowEnum.DIRECT_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(directAPercentFundFlowToMemberAva); |
| | | dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | 294L,1); |
| | | } |
| | | } |
| | | /** |
| | | * 5%节点 |
| | |
| | | nodeAPercentPoolDic.setValue(nodeAPercentPoolDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(nodeAPercentPoolDic); |
| | | |
| | | superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode()); |
| | | BigDecimal nodeAPercentCntAva = superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode()); |
| | | |
| | | if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | 294L,1); |
| | | } |
| | | /** |
| | | * 5%基金会 |
| | | */ |
| | |
| | | |
| | | //生成一条5%基金会的资金流水记录 |
| | | DappFundFlowEntity foundationAPercentFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | 295L, |
| | | foundationAPercentCnt, |
| | | FundFlowEnum.FOUNDATION_A_PERCENT.getCode(), |
| | | 2, |
| | |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(foundationAPercentFundFlow); |
| | | //用户的A币账户增加memberGetACnt数量 |
| | | dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,1L,1); |
| | | dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,295L,1); |
| | | /** |
| | | * 10%级差奖 |
| | | */ |
| | |
| | | dappFundFlowDao.insert(levelAPercentCntFundFlow); |
| | | chainProducer.sendAntACoinInLevelMsg(levelAPercentCntFundFlow.getId()); |
| | | |
| | | /** |
| | | * 更新用户为有效用户 |
| | | */ |
| | | dappMemberDao.updateMemberActiveStatus(1,memberId); |
| | | |
| | | } |
| | | |
| | | private BigDecimal allMemberPerk(BigDecimal poolAllMemberAPercentCnt, int code) { |
| | | |
| | | BigDecimal realPerkAmount = BigDecimal.ZERO; |
| | | /** |
| | | * 查询总业绩 |
| | | */ |
| | | List<DappChargeUsdtEntity> dappChargeUsdtEntities = dappChargeUsdtMapper.selectList(null); |
| | | if(CollUtil.isEmpty(dappChargeUsdtEntities)){ |
| | | return realPerkAmount; |
| | | } |
| | | //总入金 |
| | | BigDecimal amountAll = dappChargeUsdtEntities.stream().map(DappChargeUsdtEntity::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if(BigDecimal.ZERO.compareTo(amountAll) >= 0){ |
| | | return realPerkAmount; |
| | | } |
| | | /** |
| | | * 每个人入金的总额 |
| | | */ |
| | | Map<Long, BigDecimal> amountMap = dappChargeUsdtEntities.stream().collect( |
| | | Collectors.groupingBy(DappChargeUsdtEntity::getMemberId, |
| | | Collectors.reducing(BigDecimal.ZERO, DappChargeUsdtEntity::getAmount, BigDecimal::add))); |
| | | /** |
| | | * 入金1U分的代币个数 |
| | | */ |
| | | BigDecimal usdtOfCnt = poolAllMemberAPercentCnt.divide(amountAll, 8, BigDecimal.ROUND_DOWN); |
| | | |
| | | for (Map.Entry<Long, BigDecimal> entry : amountMap.entrySet()) { |
| | | Long memberId = entry.getKey(); |
| | | //当前会员的入金总和 |
| | | BigDecimal amount = entry.getValue(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >= 0){ |
| | | continue; |
| | | } |
| | | //应该平分到的数量 |
| | | BigDecimal memberCnt = amount.multiply(usdtOfCnt).setScale(8,BigDecimal.ROUND_DOWN); |
| | | BigDecimal fundFlowToMemberFlag = this.getAndUpdateMemberPerk(memberId, memberCnt); |
| | | if(fundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){ |
| | | //生成一条50%客户秒到的资金流水记录 |
| | | DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity( |
| | | memberId, |
| | | fundFlowToMemberFlag, |
| | | code, |
| | | 2, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(fundFlowToMember); |
| | | //用户的A币账户增加memberGetACnt数量 |
| | | dappWalletService.updateWalletMineWithLock(fundFlowToMemberFlag,memberId,1); |
| | | |
| | | realPerkAmount = realPerkAmount.add(fundFlowToMemberFlag); |
| | | } |
| | | } |
| | | return realPerkAmount; |
| | | } |
| | | |
| | | @Override |
| | |
| | | BigDecimal amount = dappFundFlowEntity.getAmount(); |
| | | //目标地址 |
| | | String address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | if(5 == dappFundFlowEntity.getType()){ |
| | | address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | }else if(34 == dappFundFlowEntity.getType() ){ |
| | | address = ChainEnum.BSC_USDT_W_POOL.getAddress(); |
| | | }else{ |
| | | return; |
| | | } |
| | | /** |
| | | * 发起USDT转账 |
| | | */ |
| | |
| | | dappFundFlowEntity.setStatus(2); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // String address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | // /** |
| | | // * 发起USDT转账 |
| | | // */ |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(address, new BigDecimal("0.01")); |
| | | // } |
| | | |
| | | @Override |
| | | public void AntACoinBPollInMsg(Long id) { |
| | |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | BigDecimal subtract = amountTC.subtract(teamIncomePerkTotal); |
| | | //用户的A币账户增加divide数量 |
| | | dappWalletService.updateWalletMineWithLock(subtract,1L,1); |
| | | if(amountTC.compareTo(teamIncomePerkTotal) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | subtract, |
| | | FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(subtract, |
| | | 294L,1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | BigDecimal averagePerk = nodePerk.getAveragePerk(); |
| | | BigDecimal averagePerkCnt = amountTC.multiply(averagePerk).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | nodePoolPerk(averagePerkCnt, MemberLevelEnum.NODE_3.getType(), FundFlowEnum.DAO_3_NODE_PERK.getCode()); |
| | | BigDecimal averagePerkCntAva = nodePoolPerk(averagePerkCnt, MemberLevelEnum.NODE_3.getType(), FundFlowEnum.DAO_3_NODE_PERK.getCode()); |
| | | |
| | | //用户的A币账户增加divide数量 |
| | | if(averagePerkCnt.compareTo(averagePerkCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | averagePerkCnt.subtract(averagePerkCntAva), |
| | | FundFlowEnum.DAO_3_NODE_PERK.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(averagePerkCnt.subtract(averagePerkCntAva), |
| | | 294L,1); |
| | | } |
| | | //生成流水记录 |
| | | DappFundFlowEntity nodeThreeFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | |
| | | BigDecimal averagePerkFour = nodeFourDicPerk.getAveragePerk(); |
| | | BigDecimal averagePerkFourCnt = amountTC.multiply(averagePerkFour).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | nodePoolPerk(averagePerkFourCnt, MemberLevelEnum.NODE_4.getType(), FundFlowEnum.DAO_4_NODE_PERK.getCode()); |
| | | BigDecimal averagePerkFourCntAva = nodePoolPerk(averagePerkFourCnt, MemberLevelEnum.NODE_4.getType(), FundFlowEnum.DAO_4_NODE_PERK.getCode()); |
| | | //用户的A币账户增加divide数量 |
| | | if(averagePerkFourCnt.compareTo(averagePerkFourCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | averagePerkFourCnt.subtract(averagePerkFourCntAva), |
| | | FundFlowEnum.DAO_4_NODE_PERK.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(averagePerkFourCnt.subtract(averagePerkFourCntAva), |
| | | 294L,1); |
| | | } |
| | | DappFundFlowEntity nodeFourFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | averagePerkFourCnt, |
| | |
| | | BigDecimal averagePerkFive = nodeFiveDicPerk.getAveragePerk(); |
| | | BigDecimal averagePerkFiveCnt = amountTC.multiply(averagePerkFive).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | nodePoolPerk(averagePerkFiveCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_PERK.getCode()); |
| | | BigDecimal averagePerkFiveCntAva = nodePoolPerk(averagePerkFiveCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_PERK.getCode()); |
| | | //用户的A币账户增加divide数量 |
| | | if(averagePerkFiveCnt.compareTo(averagePerkFiveCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | averagePerkFiveCnt.subtract(averagePerkFiveCntAva), |
| | | FundFlowEnum.DAO_5_NODE_PERK.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(averagePerkFiveCnt.subtract(averagePerkFiveCntAva), |
| | | 294L,1); |
| | | } |
| | | DappFundFlowEntity nodeFiveFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | averagePerkFiveCnt, |
| | |
| | | BigDecimal nodeFiveEquals = new BigDecimal(nodeFiveEqualsDic.getValue()); |
| | | BigDecimal nodeFiveEqualsCnt = amountTC.multiply(nodeFiveEquals).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | nodePoolEqualsPerk(nodeFiveEqualsCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode()); |
| | | BigDecimal nodeFiveEqualsCntAva = nodePoolEqualsPerk(nodeFiveEqualsCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode()); |
| | | //用户的A币账户增加divide数量 |
| | | if(nodeFiveEqualsCnt.compareTo(nodeFiveEqualsCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva), |
| | | FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva), |
| | | 294L,1); |
| | | } |
| | | DappFundFlowEntity nodeFiveEqualsFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | nodeFiveEqualsCnt, |
| | |
| | | //获取type级别的会员 |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectMemberByAccountTypeAnd(type); |
| | | //每日补贴总数 |
| | | BigDecimal nodePerk = nodeFivePoolDicCnt.multiply(AppContants.NODE_PERK_PERCENT); |
| | | // BigDecimal nodePerk = nodeFivePoolDicCnt.multiply(AppContants.NODE_PERK_PERCENT); |
| | | BigDecimal nodePerk = nodeFivePoolDicCnt; |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | //每人的补贴 |
| | | BigDecimal averagePerk = nodePerk.divide(new BigDecimal(dappMemberEntities.size()), 4, BigDecimal.ROUND_DOWN); |
| | |
| | | public BigDecimal superNodePoolPerk(BigDecimal nodeFivePoolDicCnt, String code, int code1) { |
| | | BigDecimal realPerkAmount = BigDecimal.ZERO; |
| | | //获取type级别的会员 |
| | | List<DappMemberNodeEntity> dappMemberNodeEntities = dappMemberNodeMapper.selectNodeByNodeCode(NodeCodeEnum.SUPER_NODE.getCode()); |
| | | // List<DappMemberNodeEntity> dappMemberNodeEntities = dappMemberNodeMapper.selectNodeByNodeCode(NodeCodeEnum.SUPER_NODE.getCode()); |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectByNodetype(); |
| | | //每日补贴总数 |
| | | // BigDecimal nodePerk = nodeFivePoolDicCnt.multiply(AppContants.NODE_PERK_PERCENT); |
| | | BigDecimal nodePerk = nodeFivePoolDicCnt; |
| | | if(CollUtil.isNotEmpty(dappMemberNodeEntities)){ |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | //每人的补贴 |
| | | BigDecimal averagePerk = nodePerk.divide(new BigDecimal(dappMemberNodeEntities.size()), 4, BigDecimal.ROUND_DOWN); |
| | | BigDecimal averagePerk = nodePerk.divide(new BigDecimal(dappMemberEntities.size()), 4, BigDecimal.ROUND_DOWN); |
| | | |
| | | for(DappMemberNodeEntity dappMemberNodeEntity : dappMemberNodeEntities){ |
| | | for(DappMemberEntity dappMemberEntitie : dappMemberEntities){ |
| | | |
| | | DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity( |
| | | dappMemberNodeEntity.getMemberId(), |
| | | dappMemberEntitie.getId(), |
| | | averagePerk, |
| | | code1, |
| | | 2, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(fundFlowToMember); |
| | | //用户的A币账户增加memberGetACnt数量 |
| | | dappWalletService.updateWalletMineWithLock(averagePerk,dappMemberNodeEntity.getMemberId(),1); |
| | | dappWalletService.updateWalletMineWithLock(averagePerk,dappMemberEntitie.getId(),1); |
| | | |
| | | realPerkAmount = realPerkAmount.add(averagePerk); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void selectAndInsertDics() { |
| | | selectAndInsertDic(PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getType(),PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getCode(),"0.2","ANDAO互转20%"); |
| | | selectAndInsertDic(PoolEnum.TRANSFER_A_AUSD_PRICE.getType(),PoolEnum.TRANSFER_A_AUSD_PRICE.getCode(),"0.01","AUSD价格"); |
| | | selectAndInsertDic(PoolEnum.TRANSFER_A_AUSD_PERCENT.getType(),PoolEnum.TRANSFER_A_AUSD_PERCENT.getCode(),"0.1","买入A,10%的AUSD比例"); |
| | | selectAndInsertDic(PoolEnum.WALLET_COIN_OUT_PERCENT.getType(),PoolEnum.WALLET_COIN_OUT_PERCENT.getCode(),"0.3","30%回流底池溢价"); |
| | |
| | | return; |
| | | } |
| | | //金额 |
| | | BigDecimal amount = dappFundFlowEntity.getAmount(); |
| | | BigDecimal amount = dappFundFlowEntity.getAmount().setScale(4,BigDecimal.ROUND_DOWN).negate(); |
| | | log.info("amount:{}",amount); |
| | | if(BigDecimal.ZERO.compareTo(amount) >= 0){ |
| | | return; |
| | | } |
| | | |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | |
| | | * 发起USDT转账 |
| | | */ |
| | | log.info("amount:{},address:{}",amount,address); |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transfer(address, amount); |
| | | // if(StrUtil.isEmpty(hash)){ |
| | | // return; |
| | | // } |
| | | // log.info("{},{}",id,hash); |
| | | // dappFundFlowEntity.setFromHash(hash); |
| | | // dappFundFlowEntity.setStatus(2); |
| | | // dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transfer(address, amount); |
| | | if(StrUtil.isEmpty(hash)){ |
| | | return; |
| | | } |
| | | log.info("{},{}",id,hash); |
| | | dappFundFlowEntity.setFromHash(hash); |
| | | dappFundFlowEntity.setStatus(2); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | } |
| | | |
| | | @Override |
| | |
| | | DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_PRICE.getType(), |
| | | PoolEnum.COIN_A_PRICE.getCode()); |
| | | BigDecimal coinAPrice = coinAUsdt.divide(coinACnt,8,BigDecimal.ROUND_DOWN); |
| | | |
| | | BigDecimal coinAPrice = coinAUsdt.divide(coinACnt,12,BigDecimal.ROUND_DOWN); |
| | | coinAPriceDic.setValue(coinAPrice.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAPriceDic); |
| | | /** |
| | | * 增加K线数据 |
| | | */ |
| | | DappAKlineEntity dappAKlineEntity = new DappAKlineEntity(); |
| | | dappAKlineEntity.setType(0); |
| | | /** |
| | | * 获取最新一条小时或者分钟的数据 |
| | | */ |
| | | DappAKlineEntity oldOne = dappAKlineMapper.selectOneByType(); |
| | | if(ObjectUtil.isNotEmpty(oldOne)){ |
| | | dappAKlineEntity.setOpenPrice(oldOne.getClosePrice()); |
| | | dappAKlineEntity.setLowestPrice(oldOne.getClosePrice()); |
| | | }else{ |
| | | dappAKlineEntity.setOpenPrice(coinAPrice); |
| | | dappAKlineEntity.setLowestPrice(coinAPrice); |
| | | } |
| | | dappAKlineEntity.setHighestPrice(coinAPrice); |
| | | dappAKlineEntity.setClosePrice(coinAPrice); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |
| | | |
| | | chainProducer.sendAntKLineMsg(0); |
| | | |
| | | List<cn.hutool.json.JSONObject> objects = new ArrayList<>(); |
| | | List<AKLineLimitVo> akLineLimitVos = dappAKlineMapper.selectListByTypeAndLimit(0, AppContants.K_LINE_LIMIT); |
| | | if(CollUtil.isNotEmpty(akLineLimitVos)) { |
| | | Collections.reverse(akLineLimitVos); |
| | | for (AKLineLimitVo akLineLimitVo : akLineLimitVos) { |
| | | cn.hutool.json.JSONObject parseObj = JSONUtil.parseObj(akLineLimitVo); |
| | | objects.add(parseObj); |
| | | } |
| | | redisUtils.del(AppContants.K_LINE_NOW); |
| | | redisUtils.set(AppContants.K_LINE_NOW, objects.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | ); |
| | | |
| | | BigDecimal coinAPrice = new BigDecimal(dataDictionaryCustom.getValue()); |
| | | DateTime dateTime = DateUtil.offsetHour(DateUtil.date(), -1); |
| | | String format = DateUtil.format(dateTime, "yyyy-MM-dd HH"); |
| | | List<String> dataDayStrList = new ArrayList<>(); |
| | | dataDayStrList.add(format); |
| | | List<DappAKlineEntity> dappAKlineEntities = dappAKlineMapper.selectListByTypeAndHour(dataDayStrList); |
| | | /** |
| | | * 查询出上一条更新的小时数据 |
| | | */ |
| | | DappAKlineEntity minRecord = dappAKlineMapper.selectOneHourByType(); |
| | | if(ObjectUtil.isEmpty(minRecord)){ |
| | | minRecord = dappAKlineMapper.selectOneByTypeAsc(); |
| | | } |
| | | DappAKlineEntity maxRecord = dappAKlineMapper.selectOneByType(); |
| | | List<DappAKlineEntity> dappAKlineEntities = dappAKlineMapper.selectListByIds(minRecord.getId(),maxRecord.getId()); |
| | | |
| | | DappAKlineEntity dappAKlineEntity = new DappAKlineEntity(); |
| | | dappAKlineEntity.setType(1); |
| | |
| | | dappAKlineEntity.setHighestPrice(coinAPrice); |
| | | dappAKlineEntity.setLowestPrice(coinAPrice); |
| | | } |
| | | DappAKlineEntity oldOne = dappAKlineMapper.selectOneByType(); |
| | | if(ObjectUtil.isNotEmpty(oldOne)){ |
| | | dappAKlineEntity.setClosePrice(oldOne.getClosePrice()); |
| | | }else{ |
| | | dappAKlineEntity.setClosePrice(coinAPrice); |
| | | } |
| | | dappAKlineEntity.setClosePrice(coinAPrice); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |
| | | |
| | | chainProducer.sendAntKLineMsg(1); |
| | |
| | | redisKey = AppContants.K_LINE_MONTH; |
| | | }else if(0 == type){ |
| | | createKDate(); |
| | | return; |
| | | redisKey = AppContants.K_LINE_NOW; |
| | | }else{ |
| | | return; |
| | | } |
| | |
| | | redisUtils.set(redisKey, objects.toString()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @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 if(34 == dappFundFlowEntity.getType()){ |
| | | address = ChainEnum.BSC_USDT_W_POOL.getAddress(); |
| | | }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); |
| | | dappFundFlow.setStatus(2); |
| | | dappFundFlowDao.updateById(dappFundFlow); |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(ChainEnum.BSC_USDT_W_POOL.getAddress()); |
| | | } |
| | | |
| | | /** |
| | |
| | | DappAKlineEntity oldOne = dappAKlineMapper.selectOneByType(); |
| | | if(ObjectUtil.isNotEmpty(oldOne)){ |
| | | dappAKlineEntity.setOpenPrice(oldOne.getClosePrice()); |
| | | dappAKlineEntity.setLowestPrice(oldOne.getClosePrice()); |
| | | }else{ |
| | | dappAKlineEntity.setOpenPrice(coinAPrice); |
| | | dappAKlineEntity.setLowestPrice(coinAPrice); |
| | | } |
| | | dappAKlineEntity.setOpenPrice(coinAPrice); |
| | | dappAKlineEntity.setLowestPrice(coinAPrice); |
| | | dappAKlineEntity.setHighestPrice(coinAPrice); |
| | | dappAKlineEntity.setClosePrice(coinAPrice); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | int month = DateUtil.dayOfMonth(DateUtil.date()); |
| | | String s = DateUtil.dayOfWeekEnum(DateUtil.date()).toChinese(); |
| | | System.out.println(s); |
| | | System.out.println(month); |
| | | } |
| | | // public static void main(String[] args) { |
| | | // |
| | | // int month = DateUtil.dayOfMonth(DateUtil.date()); |
| | | // String s = DateUtil.dayOfWeekEnum(DateUtil.date()).toChinese(); |
| | | // System.out.println(s); |
| | | // System.out.println(month); |
| | | // } |
| | | |
| | | /** |
| | | * 判断直推人数是否达标 |