| | |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | 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(); |
| | | |
| | |
| | | } |
| | | 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)) { |
| | |
| | | if ("P".equals(order.getYdProductEntity().getProUnit())) { |
| | | count = count.multiply(BigDecimal.valueOf(1024)); |
| | | } |
| | | |
| | | // 订单总收益 |
| | | BigDecimal orderProfit = count.multiply(unitProfit); |
| | | BigDecimal remainProfit = orderProfit; |
| | | if (CollUtil.isNotEmpty(agents)) { |