| | |
| | |
|
| | | // 是否可以分红
|
| | | private boolean isCanDividents(TeamUserLevelStatistic tus) {
|
| | | if (Constant.IS_TEST && tus.getLevel() != UserLevelEnum.daRen && tus.getLevel() != UserLevelEnum.normalVIP)
|
| | | return true;
|
| | | // if (Constant.IS_TEST && tus.getLevel() != UserLevelEnum.daRen && tus.getLevel() != UserLevelEnum.normalVIP)
|
| | | // return true;
|
| | |
|
| | | if (tus != null && (tus.getLevel() == UserLevelEnum.highVIP || tus.getLevel() == UserLevelEnum.superVIP
|
| | | || tus.getLevel() == UserLevelEnum.tearcher)) {
|
| | | if (tus.getLevel() == UserLevelEnum.highVIP) {
|
| | | int vipFirstCount = tus.getNormalFirstCount() + tus.getHighFirstCount() + tus.getSuperFirstCount()
|
| | | + tus.getTearcherFirstCount();
|
| | | if (vipFirstCount >= 3)// 直接粉丝普通会员等级以上的用户>=3
|
| | |
|
| | | if (tus.getLevel() == UserLevelEnum.tearcher) {
|
| | | int firstCount = tus.getSuperFirstCount() + tus.getTearcherFirstCount();
|
| | | int secondCount = tus.getHighSecondCount() + tus.getSuperSecondCount() + tus.getTearcherSecondCount();
|
| | | if (firstCount >= 3 && secondCount >= 3) {// 直接粉丝超级会员等级以上的用户>=3
|
| | | // 间接粉丝普通会员以上等级>=3
|
| | | return true;
|
| | | } else if (tus.getLevel() == UserLevelEnum.superVIP) {
|
| | | } else {
|
| | | // 如果导师不满足条件就需要降级为超级会员
|
| | | tus.setLevel(UserLevelEnum.superVIP);
|
| | | }
|
| | | }
|
| | |
|
| | | if (tus.getLevel() == UserLevelEnum.superVIP) {
|
| | | int firstCount = tus.getSuperFirstCount() + tus.getTearcherFirstCount();
|
| | | int secondCount = tus.getNormalSecondCount() + tus.getHighSecondCount() + tus.getSuperSecondCount()
|
| | | + tus.getTearcherSecondCount();
|
| | | if (firstCount >= 3 && secondCount >= 3) {// 直接粉丝超级会员等级以上的用户>=3
|
| | | // 间接粉丝普通会员以上等级>=3
|
| | | return true;
|
| | | }
|
| | | } else {
|
| | | int firstCount = tus.getSuperFirstCount() + tus.getTearcherFirstCount();
|
| | | int secondCount = tus.getHighSecondCount() + tus.getSuperSecondCount() + tus.getTearcherSecondCount();
|
| | | if (firstCount >= 3 && secondCount >= 3) {// 直接粉丝超级会员等级以上的用户>=3
|
| | | // 间接粉丝高级会员以上等级>=3
|
| | | return true;
|
| | | // 如果超级会员不满足条件就需要降级为高级会员
|
| | | tus.setLevel(UserLevelEnum.highVIP);
|
| | | }
|
| | | }
|
| | |
|
| | | if (tus.getLevel() == UserLevelEnum.highVIP) {
|
| | | int vipFirstCount = tus.getNormalFirstCount() + tus.getHighFirstCount() + tus.getSuperFirstCount()
|
| | | + tus.getTearcherFirstCount();
|
| | | if (vipFirstCount >= 3)// 直接粉丝普通会员等级以上的用户>=3
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | |
| | | if (threeSalesList == null)
|
| | | return;
|
| | |
|
| | | Map<Long, UserLevelEnum> uidLevel = new HashMap<Long, UserLevelEnum>();
|
| | | Map<Long, UserLevelEnum> uidLevelMap = new HashMap<Long, UserLevelEnum>();
|
| | | for (ThreeSale ts : threeSalesList) {
|
| | | if (ts.getBoss() != null) {
|
| | | TeamUserLevelStatistic tus = teamUserLevelStatisticService.selectByUid(ts.getBoss().getId());
|
| | |
| | | tus = teamUserLevelStatisticService.selectByUid(ts.getBoss().getId());
|
| | |
|
| | | if (isCanDividents(tus)) {
|
| | | uidLevel.put(tus.getId(), tus.getLevel());
|
| | | uidLevelMap.put(tus.getId(), tus.getLevel());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 没有参与分红的用户
|
| | | if (uidLevel == null || uidLevel.size() == 0) {
|
| | | if (uidLevelMap == null || uidLevelMap.size() == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | BigDecimal perDivident = computePerDivident(uidLevel, totalMoney);
|
| | | for (Iterator<Long> its = uidLevel.keySet().iterator(); its.hasNext();) {
|
| | | BigDecimal perDivident = computePerDivident(uidLevelMap, totalMoney);
|
| | | for (Iterator<Long> its = uidLevelMap.keySet().iterator(); its.hasNext();) {
|
| | | Long uid = its.next();
|
| | | BigDecimal dividents = computeUserDivident(perDivident, uidLevel.get(uid));
|
| | | BigDecimal dividents = computeUserDivident(perDivident, uidLevelMap.get(uid));
|
| | | // 将资金分配到参与分红的用户
|
| | | TeamDividentsSourceUser teamDividentsSourceUser = new TeamDividentsSourceUser();
|
| | | teamDividentsSourceUser.setDay(day);
|
| | |
| | |
|
| | | // 计算平均分红
|
| | | private BigDecimal computePerDivident(Map<Long, UserLevelEnum> uidLevels, BigDecimal totalMoney) {
|
| | | int count = 0;
|
| | | BigDecimal count = new BigDecimal(0);
|
| | | for (Iterator<Long> its = uidLevels.keySet().iterator(); its.hasNext();) {
|
| | | Long uid = its.next();
|
| | | if (uidLevels.get(uid) == UserLevelEnum.highVIP) {
|
| | | count += 1;
|
| | | count = count.add(new BigDecimal(1));
|
| | | } else if (uidLevels.get(uid) == UserLevelEnum.superVIP) {
|
| | | count += 2;
|
| | | count = count.add(new BigDecimal(2));
|
| | | } else if (uidLevels.get(uid) == UserLevelEnum.tearcher) {
|
| | | count = count.add(new BigDecimal(2.5));
|
| | | }
|
| | | }
|
| | | return MoneyBigDecimalUtil.div(totalMoney, new BigDecimal(count));
|
| | | return MoneyBigDecimalUtil.div(totalMoney, count);
|
| | | }
|
| | |
|
| | | private BigDecimal computeUserDivident(BigDecimal perDivident, UserLevelEnum userLevel) {
|
| | |
| | | } else if (userLevel == UserLevelEnum.superVIP) {
|
| | | return MoneyBigDecimalUtil.mul(perDivident, new BigDecimal(2));
|
| | | } else if (userLevel == UserLevelEnum.tearcher) {
|
| | | return MoneyBigDecimalUtil.mul(perDivident, new BigDecimal(2));
|
| | | return MoneyBigDecimalUtil.mul(perDivident, new BigDecimal(2.5));
|
| | | }
|
| | | return null;
|
| | | }
|