KKSU
2024-05-07 8ce06347909eaa44482b86a7ec1652aa16d793e1
测试
5 files modified
76 ■■■■ changed files
src/main/java/cc/mrbird/febs/dapp/chain/EthUsdtContract.java 38 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/entity/DappMemberFund.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/BscCoinContractEvent.java 20 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/job/GiveMeMoneyJob.java 8 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/chain/EthUsdtContract.java
@@ -174,25 +174,25 @@
     *            {
     *                 "indexed": false,
     *                 "internalType": "uint256",
     *                 "name": "sameCoin",
     *                 "name": "usdtTarget",
     *                 "type": "uint256"
     *            },
     *            {
     *                 "indexed": false,
     *                 "internalType": "uint256",
     *                 "name": "finxMineCoin",
     *                 "name": "coinTarget",
     *                 "type": "uint256"
     *            },
     *            {
     *                 "indexed": false,
     *                 "internalType": "uint256",
     *                 "name": "usdtCoin",
     *                 "type": "uint256"
     *            },
     *            {
     *                 "indexed": false,
     *                 "internalType": "uint256",
     *                 "name": "lastMineTime",
     *                 "type": "uint256"
     *            },
     *            {
     *                 "indexed": false,
     *                 "internalType": "uint256",
     *                 "name": "thisMineTime",
     *                 "type": "uint256"
     *            }
     *         ],
@@ -410,10 +410,10 @@
                    typedResponse.adr = (String) eventValues.getNonIndexedValues().get(0).getValue();
                    typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
                    typedResponse.price = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
                    typedResponse.sameCoin = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
                    typedResponse.finxMineCoin = (BigInteger) eventValues.getNonIndexedValues().get(4).getValue();
                    typedResponse.lastMineTime = (BigInteger) eventValues.getNonIndexedValues().get(5).getValue();
                    typedResponse.thisMineTime = (BigInteger) eventValues.getNonIndexedValues().get(6).getValue();
                    typedResponse.usdtTarget = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
                    typedResponse.coinTarget = (BigInteger) eventValues.getNonIndexedValues().get(4).getValue();
                    typedResponse.usdtCoin = (BigInteger) eventValues.getNonIndexedValues().get(5).getValue();
                    typedResponse.lastMineTime = (BigInteger) eventValues.getNonIndexedValues().get(6).getValue();
                }
                return typedResponse;
@@ -831,13 +831,13 @@
    }
    public static class CoinRewardEventResponse extends BaseEventResponse {
        public String adr;
        public String adr;//地址
        public BigInteger amount;
        public BigInteger price;
        public BigInteger sameCoin;
        public BigInteger finxMineCoin;
        public BigInteger lastMineTime;
        public BigInteger thisMineTime;
        public BigInteger amount;//总挖矿币量
        public BigInteger price;//挖矿时价格
        public BigInteger usdtTarget;//金本位多少USDT,单位USDT
        public BigInteger coinTarget;//币本位多少币
        public BigInteger usdtCoin;//金本位换算后多少币
        public BigInteger lastMineTime;//上一次挖矿时间
    }
}
src/main/java/cc/mrbird/febs/dapp/entity/DappMemberFund.java
@@ -17,6 +17,9 @@
    public BigDecimal amount;//总挖矿数量
    public BigDecimal price;//价格
    public BigDecimal usdtTarget;//金本位多少USDT,单位USDT
    public BigDecimal coinTarget;//币本位多少币
    public BigDecimal usdtCoin;//金本位换算后多少币
    public BigDecimal sameCoin;//金本位挖矿数量
    public BigDecimal finxMineCoin;//币本位数量
    public String lastMineTime;//上一次挖矿时间
src/main/java/cc/mrbird/febs/dapp/service/impl/BscCoinContractEvent.java
@@ -195,10 +195,10 @@
        int decimals = ChainService.getInstance(ChainEnum.BSC_GFA.name()).decimals();
        BigDecimal amount = new BigDecimal(e.amount.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
        BigDecimal price = new BigDecimal(e.price.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
        BigDecimal sameCoin = new BigDecimal(e.sameCoin.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
        BigDecimal finxMineCoin = new BigDecimal(e.finxMineCoin.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
        BigDecimal usdtTarget = new BigDecimal(e.usdtTarget.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
        BigDecimal coinTarget = new BigDecimal(e.coinTarget.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
        BigDecimal usdtCoin = new BigDecimal(e.usdtCoin.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN);
        BigInteger lastMineTime = e.lastMineTime;
        BigInteger thisMineTime = e.thisMineTime;
        Long memberId = dappMemberEntity.getId();
        DappMemberFund dappMemberFund = new DappMemberFund();
@@ -206,28 +206,28 @@
        dappMemberFund.setAddress(address);
        dappMemberFund.setAmount(amount);
        dappMemberFund.setPrice(price);
        dappMemberFund.setSameCoin(sameCoin);
        dappMemberFund.setFinxMineCoin(finxMineCoin);
        dappMemberFund.setUsdtTarget(usdtTarget);
        dappMemberFund.setCoinTarget(coinTarget);
        dappMemberFund.setUsdtCoin(usdtCoin);
        dappMemberFund.setLastMineTime(lastMineTime.toString());
        dappMemberFund.setThisMineTime(thisMineTime.toString());
        dappMemberFundMapper.insert(dappMemberFund);
        DappFundFlowEntity fundFlowTuiJian1 = new DappFundFlowEntity(
                memberId,
                sameCoin,
                usdtTarget,
                FlowTypeEnum.ZHIYA_CHA_CHU.getValue(),
                DappFundFlowEntity.WITHDRAW_STATUS_AGREE,
                StrUtil.format("金本位{}",sameCoin));
                StrUtil.format("金本位{},价格{}。",usdtTarget,price));
        dappFundFlowDao.insert(fundFlowTuiJian1);
        DappFundFlowEntity fundFlowTuiJian2 = new DappFundFlowEntity(
                memberId,
                finxMineCoin,
                coinTarget,
                FlowTypeEnum.ZHIYA_CHA_CHU.getValue(),
                DappFundFlowEntity.WITHDRAW_STATUS_AGREE,
                StrUtil.format("币本位{},价格{}。",finxMineCoin,price));
                StrUtil.format("币本位{},价格{}。",coinTarget,price));
        dappFundFlowDao.insert(fundFlowTuiJian2);
        log.info("本地交易:{},amount-{},price-{}", e.adr,amount,price);
    }
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -87,10 +87,9 @@
        BigDecimal ccToday = BigDecimal.ZERO;
        if(CollUtil.isNotEmpty(ccTodays)){
            for(DappMemberFund dappMemberFund : ccTodays){
                BigDecimal sameCoin = dappMemberFund.getSameCoin();
                BigDecimal finxMineCoin = dappMemberFund.getFinxMineCoin();
                BigDecimal price = dappMemberFund.getPrice();
                BigDecimal add = sameCoin.divide(price, 8, BigDecimal.ROUND_DOWN).add(finxMineCoin);
                BigDecimal usdtCoin = dappMemberFund.getUsdtCoin();
                BigDecimal coinTarget = dappMemberFund.getCoinTarget();
                BigDecimal add = coinTarget.add(usdtCoin);
                ccToday = ccToday.add(add);
            }
        }
src/main/java/cc/mrbird/febs/job/GiveMeMoneyJob.java
@@ -90,12 +90,12 @@
         */
        log.info("滑点奖励");
        //获取滑点钱包的余额
        BigDecimal coinCnt = ChainService.getInstance(ChainEnum.BSC_GFA.name()).balanceOf("0x1Ea392645f816BF15f1Fc87728eA010585bAAE7D").setScale(8,BigDecimal.ROUND_DOWN);
        BigDecimal coinPrice = ChainService.getInstance(ChainEnum.BSC_GFA.name()).getPrice("0x1Ea392645f816BF15f1Fc87728eA010585bAAE7D").setScale(8,BigDecimal.ROUND_DOWN);
//        BigDecimal coinCnt = ChainService.getInstance(ChainEnum.BSC_GFA.name()).balanceOf("0x1Ea392645f816BF15f1Fc87728eA010585bAAE7D").setScale(8,BigDecimal.ROUND_DOWN);
//        BigDecimal coinPrice = ChainService.getInstance(ChainEnum.BSC_GFA.name()).getPrice("0x1Ea392645f816BF15f1Fc87728eA010585bAAE7D").setScale(8,BigDecimal.ROUND_DOWN);
//        BigDecimal coinCnt = ChainService.getInstance(ChainEnum.BSC_GFA.name()).balanceOf("0xF6b06A30196aA5E318232a3b61319eab0FD4A3bF").setScale(8,BigDecimal.ROUND_DOWN);
//        BigDecimal coinPrice = ChainService.getInstance(ChainEnum.BSC_GFA.name()).getPrice("0xF6b06A30196aA5E318232a3b61319eab0FD4A3bF").setScale(8,BigDecimal.ROUND_DOWN);
        BigDecimal coinCnt = ChainService.getInstance(ChainEnum.BSC_GFA.name()).balanceOf("0x977A9dDFb965a9A3416Fa72cA7F91c4949c18f25").setScale(8,BigDecimal.ROUND_DOWN);
        BigDecimal coinPrice = ChainService.getInstance(ChainEnum.BSC_GFA.name()).getPrice("0x977A9dDFb965a9A3416Fa72cA7F91c4949c18f25").setScale(8,BigDecimal.ROUND_DOWN);
        //获取上一时刻的数据
        BigDecimal coinAmountOld =BigDecimal.ZERO;