fix
wzy
2022-11-06 420efcecbc5b9b17f96b9c0a37d9bc3a5f1afccd
fix
4 files modified
1 files added
107 ■■■■■ changed files
src/main/java/cc/mrbird/febs/dapp/chain/ChainEnum.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java 49 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java 18 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/job/ChainListenerJob.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/tree/TreeConstants.java 17 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/chain/ChainEnum.java
@@ -33,15 +33,6 @@
            ""),
    /**
     * 卡牌
     */
    BSC_NFT_SDC("BSC", "0x3afD1Bf0994214DBe5ccfA7d8643261B195532c2",
            "0x07ee6de0ca4b289f8e69484f70d09988c6df6697f411dc623179930a3578994f",
            "https://bsc-dataseed1.ninicoin.io",
            "0xb7FDE337f2236F78B2823d9F97eAB03ce893CC3D",
            ""),
    /**
     * 币安 usdt合约
     * 0x55d398326f99059fF775485246999027B3197955
     * 测试链 0x337610d27c682E347C9cD60BD4b3b107C9d34dDd
@@ -62,17 +53,9 @@
            "0x7bee8cf9441800655376ba95729c0807231367cf75702dd3b17fa5290196bb87",
            "https://bsc-dataseed1.ninicoin.io",
            "0xb27e44f98543e480dbd071b6605005e3d99b3dd4",
            ""),
    /**
     * 多余手续费收集地址
     */
    BSC_TFC_FEE("BSC", "0x8084Cf691B69c70De8A7c345E63CaA740B730FA5",
            "0x7bee8cf9441800655376ba95729c0807231367cf75702dd3b17fa5290196bb87",
            "https://bsc-dataseed1.ninicoin.io",
            "0xb27e44f98543e480dbd071b6605005e3d99b3dd4",
            "");
    private String chain;
    private String address;
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -14,6 +14,7 @@
import cc.mrbird.febs.rabbit.producer.ChainProducer;
import cc.mrbird.febs.tree.MatrixTree;
import cc.mrbird.febs.tree.MemberNode;
import cc.mrbird.febs.tree.TreeConstants;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
@@ -178,58 +179,40 @@
            /**
             * 复投后,推一个拿一轮,推两个拿两轮,推三个后终身有效。
             * 按规则每轮未能提取的奖金分配:
             * 50%直接进入TFC底池
             * 20%给到推荐人
             * 30%留下待提。
             * 200u单。
             * 无直推则收益200U
             * 一人加一轮400u,二人二轮
             * 三人永久。
             */
            if (directCnt.size() < 3 && member.getOutCnt() != 0 && member.getOutCnt() - 1 == directCnt.size()) {
                BigDecimal amount = new BigDecimal("190");
                BigDecimal sourcePool = amount.multiply(new BigDecimal("0.5"));
                BigDecimal directAmount = amount.multiply(new BigDecimal("0.2"));
                BigDecimal remain = amount.subtract(sourcePool).subtract(directAmount);
                new Thread(() -> {
                    ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer("0xb06cc3dAF362a1670F12eBD0242022b538Ca72ef", sourcePool);
                }).start();
                if (parent != null) {
                    dappWalletService.updateWalletCoinWithLock(directAmount, parent.getId(), 1);
                    DappFundFlowEntity direct = new DappFundFlowEntity(parent.getId(), directAmount, 3, 2, null, null);
                    dappFundFlowDao.insert(direct);
                return;
            } else {
                BigDecimal amount = null;
                if (directCnt.size() < 1) {
                    amount = TreeConstants.PUT_IN_AMOUNT;
                } else {
                    amount = TreeConstants.FULL_PROFIT_AMOUNT;
                }
                dappWalletService.addFrozenAmountWithLock(remain, memberId);
            } else {
                dappWalletService.releaseFrozenAmountWithLock(memberId);
                member.setOutCnt(member.getOutCnt() + 1);
                dappMemberDao.updateById(member);
                dappWalletService.updateWalletCoinWithLock(new BigDecimal(190), member.getId(), 1);
                dappWalletService.updateWalletCoinWithLock(amount, member.getId(), 1);
                DappFundFlowEntity matrixProfitFlow = new DappFundFlowEntity(memberId, new BigDecimal("190"), 2, 2, null, null);
                DappFundFlowEntity matrixProfitFlow = new DappFundFlowEntity(memberId, amount, 2, 2, null, null);
                dappFundFlowDao.insert(matrixProfitFlow);
            }
            DappFundFlowEntity rePutInFlow = new DappFundFlowEntity(memberId, new BigDecimal("100").negate(), 1, 2, null, null);
            DappFundFlowEntity rePutInFlow = new DappFundFlowEntity(memberId, TreeConstants.PUT_IN_AMOUNT.negate(), 1, 2, null, null);
            dappFundFlowDao.insert(rePutInFlow);
            DappFundFlowEntity safePoolFlow = new DappFundFlowEntity(memberId, new BigDecimal("10").negate(), 4, 2, null, null);
            dappFundFlowDao.insert(safePoolFlow);
            DappMineDataEntity mineData = dappSystemDao.selectMineDataForOne();
            mineData.setSafePool(mineData.getSafePool().add(BigDecimal.TEN));
            dappSystemDao.updateMineData(mineData);
        }
    }
    @Override
    public void tfcNewPrice(String data) {
        redisUtils.set(AppContants.REDIS_KEY_TFC_NEW_PRICE, new BigDecimal(data));
//        redisUtils.set(AppContants.REDIS_KEY_TFC_NEW_PRICE, new BigDecimal(data));
    }
    @Override
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -206,18 +206,18 @@
        DappFundFlowEntity feeFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getFee().negate(), 7, 2, null, null);
        dappFundFlowDao.insert(feeFlow);
        DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getAmount().negate(), 5, 2, withdrawDto.getFee(), null);
        DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getAmount().negate(), 5, 1, withdrawDto.getFee(), null);
        dappFundFlowDao.insert(fundFlow);
        String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(member.getAddress(), withdrawDto.getAmount());
        fundFlow.setToHash(hash);
        dappFundFlowDao.updateById(fundFlow);
//        String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(member.getAddress(), withdrawDto.getAmount());
//        fundFlow.setToHash(hash);
//        dappFundFlowDao.updateById(fundFlow);
        Map<String, Object> map = new HashMap<>();
        map.put("fee", withdrawDto.getFee());
        map.put("address", ChainEnum.BSC_TFC_FEE.getAddress());
        map.put("flow", feeFlow.getId());
        chainProducer.sendTfcFee(JSONObject.toJSONString(map));
//        Map<String, Object> map = new HashMap<>();
//        map.put("fee", withdrawDto.getFee());
//        map.put("address", ChainEnum.BSC_TFC_FEE.getAddress());
//        map.put("flow", feeFlow.getId());
//        chainProducer.sendTfcFee(JSONObject.toJSONString(map));
    }
    @Override
src/main/java/cc/mrbird/febs/job/ChainListenerJob.java
@@ -85,7 +85,7 @@
            new Thread(() -> {
                log.info("监听:[{} - {}]", finalBlock, end);
                ChainService.contractEventListener(finalBlock, end, bscUsdtContractEvent, ChainEnum.BSC_USDT_LISTENER.name());
                ChainService.contractEventListener(finalBlock, end, bscCoinContractEvent, ChainEnum.BSC_TFC_FEE.name());
                ChainService.contractEventListener(finalBlock, end, bscCoinContractEvent, ChainEnum.BSC_TFC_LISTENER.name());
            }).start();
            block = block.add(section);
@@ -94,7 +94,7 @@
            }
        }
        ChainService.contractEventListener(block, bscUsdtContractEvent, ChainEnum.BSC_USDT_LISTENER.name());
        ChainService.contractEventListener(block, bscCoinContractEvent, ChainEnum.BSC_TFC_FEE.name());
        ChainService.contractEventListener(block, bscCoinContractEvent, ChainEnum.BSC_TFC_LISTENER.name());
        long end = System.currentTimeMillis();
        log.info("区块链监听启动完成, 消耗时间{}", end - start);
src/main/java/cc/mrbird/febs/tree/TreeConstants.java
New file
@@ -0,0 +1,17 @@
package cc.mrbird.febs.tree;
import java.math.BigDecimal;
public interface TreeConstants {
    /**
     * 投入金额
     */
    BigDecimal PUT_IN_AMOUNT = new BigDecimal("200");
    /**
     * 满收益(至少推荐一人)
     */
    BigDecimal FULL_PROFIT_AMOUNT = new BigDecimal("400");
}