5 files modified
1 files added
| | |
| | | |
| | | BigInteger totalSupply(); |
| | | |
| | | BigInteger totalSupplyNFT(); |
| | | |
| | | String safeMintNFT(String address); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BigInteger totalSupplyNFT() { |
| | | try { |
| | | String methodName = "totalSupply"; |
| | | List<Type> inputParameters = new ArrayList<>(); |
| | | List<TypeReference<?>> outputParameters = new ArrayList<>(); |
| | | TypeReference<Uint256> typeReference = new TypeReference<Uint256>() { |
| | | }; |
| | | outputParameters.add(typeReference); |
| | | Function function = new Function(methodName, inputParameters, outputParameters); |
| | | String data = FunctionEncoder.encode(function); |
| | | Transaction transaction = Transaction.createEthCallTransaction(null, contractAddress, data); |
| | | |
| | | EthCall ethCall; |
| | | BigInteger totalSupply = BigInteger.ZERO; |
| | | try { |
| | | ethCall = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).send(); |
| | | List<Type> results = FunctionReturnDecoder.decode(ethCall.getValue(), function.getOutputParameters()); |
| | | totalSupply = (BigInteger) results.get(0).getValue(); |
| | | return totalSupply; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return BigInteger.ZERO; |
| | | } |
| | | |
| | | @Override |
| | | public String safeMintNFT(String toAddress) { |
| | | String gas = getGas(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BigInteger totalSupplyNFT() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String safeMintNFT(String address) { |
| | | return null; |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.dapp.enumerate; |
| | | |
| | | /** |
| | | * 卡牌分期 |
| | | */ |
| | | public enum CardPeriod { |
| | | |
| | | ONE(0,1000, 6), |
| | | TWO(1001,1500, 9), |
| | | THREE(2501,1500, 12); |
| | | |
| | | private int min; |
| | | |
| | | private int cardCnt; |
| | | |
| | | private int recommendCnt; |
| | | |
| | | |
| | | |
| | | CardPeriod(int min, int cardCnt, int recommendCnt) { |
| | | this.min = min; |
| | | this.cardCnt = cardCnt; |
| | | this.recommendCnt = recommendCnt; |
| | | } |
| | | |
| | | public int recommendCnt(int totalSupply) { |
| | | for (CardPeriod value : CardPeriod.values()) { |
| | | if (value.min <= totalSupply && totalSupply < (value.min + value.cardCnt)) { |
| | | return value.recommendCnt; |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.dto.SystemDto; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.CardPeriod; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.dapp.utils.OnlineTransferUtil; |
| | |
| | | return; |
| | | } |
| | | |
| | | DataDictionaryCustom boxRecommendCnt = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_BOX_RECOMMEND_CNT); |
| | | BigInteger totalSupply = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).totalSupplyNFT(); |
| | | int box = 0; |
| | | // 需要第一次购买,才在推荐中加1 |
| | | Object parentRecommend = redisUtils.hget(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress()); |
| | |
| | | int i = (int) parentRecommend; |
| | | |
| | | // 如果超过10个,则新增一个盲盒,并重置推荐人数 |
| | | if (++i == new Integer(boxRecommendCnt.getValue())) { |
| | | if (++i == CardPeriod.ONE.recommendCnt(totalSupply.intValue())) { |
| | | box = 1; |
| | | redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), 0); |
| | | } else { |
| | |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappOnlineTransferEntity; |
| | | import cc.mrbird.febs.dapp.enumerate.CardPeriod; |
| | | import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappOnlineTransferDao; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | |
| | | public void nftBalanceTest() { |
| | | BigDecimal balance = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).balanceOf("0x971c09aa9735eb98459b17ec8b48932d24cbb931"); |
| | | System.out.println(1); |
| | | } |
| | | |
| | | @Test |
| | | public void nftTotalSupplyTest() { |
| | | BigInteger bigInteger = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).totalSupplyNFT(); |
| | | |
| | | int i = CardPeriod.ONE.recommendCnt(bigInteger.intValue()); |
| | | System.out.println(i); |
| | | }} |