Helius
2021-05-24 b8376677b0c6a1c537bbb7bc4bb730201b16dd61
src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
@@ -110,7 +110,12 @@
            }
        }
        BigDecimal needPower = basicLevelSetting.getCalculationPower().multiply(BigDecimal.valueOf(1024));
        BigDecimal needPower = BigDecimal.ZERO;
        if ("P".equals(basicLevelSetting.getUnit())) {
            needPower = basicLevelSetting.getCalculationPower().multiply(BigDecimal.valueOf(1024));
        } else {
            needPower = basicLevelSetting.getCalculationPower();
        }
        return totalPower.compareTo(needPower) > 0;
    }
@@ -167,23 +172,23 @@
        List<String> inviteIds = StrUtil.split(memberEntity.getRefererIds(), ',');
        List<MemberEntity> agents = memberDao.selectYdParentAgent(inviteIds);
        if (CollUtil.isNotEmpty(agents)) {
            Map<Long, BigDecimal> returnRatio = buildReturnRatioObj(agents, 1);
            for (Map.Entry<Long, BigDecimal> entry : returnRatio.entrySet()) {
                String conent = "USDT返利";
                BigDecimal amount = order.getAmount().multiply(entry.getValue());
                LogRecordUtils.insertMemberAccountMoneyChangeWithId(entry.getKey(), conent, amount, "USDT", 1, 6, order.getId());
                MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(entry.getKey(), "USDT");
                memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), amount, BigDecimal.ZERO, 0);
            }
            YdOrderEntity updateOrder = new YdOrderEntity();
            updateOrder.setReturnState(2);
            updateOrder.setId(order.getId());
            ydOrderDao.updateById(updateOrder);
        }
//        if (CollUtil.isNotEmpty(agents)) {
//            Map<Long, BigDecimal> returnRatio = buildReturnRatioObj(agents, 1);
//
//            for (Map.Entry<Long, BigDecimal> entry : returnRatio.entrySet()) {
//                String conent = "USDT返利";
//                BigDecimal amount = order.getAmount().multiply(entry.getValue());
//                LogRecordUtils.insertMemberAccountMoneyChangeWithId(entry.getKey(), conent, amount, "USDT", 1, 6, order.getId());
//                MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(entry.getKey(), "USDT");
//
//                memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), amount, BigDecimal.ZERO, 0);
//            }
//
//            YdOrderEntity updateOrder = new YdOrderEntity();
//            updateOrder.setReturnState(2);
//            updateOrder.setId(order.getId());
//            ydOrderDao.updateById(updateOrder);
//        }
        // 合伙人分红
        List<MemberEntity> partners = memberDao.selectPartnerMemberList();
@@ -194,9 +199,8 @@
            for (MemberEntity partner : partners) {
                String conent = "合伙人USDT分红";
                LogRecordUtils.insertMemberAccountMoneyChangeWithId(partner.getId(), conent, returnAmount, "USDT", 1, 9, order.getId());
                MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(partner.getId(), "USDT");
                memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), returnAmount, BigDecimal.ZERO, 0);
//                MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(partner.getId(), "USDT");
//                memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), returnAmount, BigDecimal.ZERO, 0);
            }
        }
@@ -218,6 +222,7 @@
    private Map<Long, BigDecimal> buildReturnRatioObj(List<MemberEntity> agents, int type) {
        Map<Long, BigDecimal> returnRatio = new HashMap<Long, BigDecimal>();
        Long lastId = null;
        int i = 0;
        for (MemberEntity agent : agents) {
            YdBasicLevelSettingEntity settingEntity = agent.getYdBasicLevelSettingEntity();
@@ -229,12 +234,20 @@
            }
            if(settingEntity.getLevel() == 1) {
                if (CollUtil.isNotEmpty(returnRatio)) {
                    BigDecimal lastRatio = returnRatio.get(lastId);
                    returnRatio.put(agent.getId(), ratio.subtract(lastRatio));
                    if (i != 0) {
                        returnRatio.put(agent.getId(), BigDecimal.valueOf(0.01));
                    } else {
                        BigDecimal lastRatio = returnRatio.get(lastId);
                        returnRatio.put(agent.getId(), ratio.subtract(lastRatio));
                    }
                } else {
                    returnRatio.put(agent.getId(), ratio);
                }
                break;
                if (i >= 1) {
                    break;
                }
                i++;
            }
            if (CollUtil.isEmpty(returnRatio)) {
@@ -282,6 +295,8 @@
                    if ("P".equals(order.getYdProductEntity().getProUnit())) {
                        count = count.multiply(BigDecimal.valueOf(1024));
                    }
                    // 订单总收益
                    BigDecimal orderProfit = count.multiply(unitProfit);
                    BigDecimal remainProfit = orderProfit;
                    if (CollUtil.isNotEmpty(agents)) {