| | |
| | | String referrerIds = mallMember.getReferrerIds(); |
| | | List<String> referrerIdList = StrUtil.splitTrim(referrerIds, ","); |
| | | if(CollUtil.isNotEmpty(referrerIdList)){ |
| | | List<MallMember> mallMemberTeamPerk = mallMemberMapper.selectByInviteIds(referrerIdList); |
| | | |
| | | if(CollUtil.isNotEmpty(mallMemberTeamPerk)){ |
| | | String levelNormal = MemberLevelEnum.V1.getType(); |
| | | BigDecimal cashPercentNormal = BigDecimal.ZERO; |
| | | BigDecimal scorePercentNormal = BigDecimal.ZERO; |
| | | String levelNormal = MemberLevelEnum.V1.getType(); |
| | | BigDecimal cashPercentNormal = BigDecimal.ZERO; |
| | | BigDecimal scorePercentNormal = BigDecimal.ZERO; |
| | | |
| | | DataDictionaryCustom poolScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode()); |
| | | BigDecimal poolScorePrice = new BigDecimal(poolScorePriceDic.getValue() == null ? "1" : poolScorePriceDic.getValue()); |
| | | for(MallMember teamPerkMember : mallMemberTeamPerk){ |
| | | String level = teamPerkMember.getLevel(); |
| | | //比较两个级别的大小,level大于levelNormal返回1 |
| | | int compareMin = MemberLevelEnum.V1.compareLevel(level, levelNormal); |
| | | int compareMax = MemberLevelEnum.V1.compareLevel(MemberLevelEnum.V6.getType(), level); |
| | | if(compareMin >= 1 && compareMax >= 1){ |
| | | Long teamPerkMemberId = teamPerkMember.getId(); |
| | | DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "AGENT_PERK_SET", level); |
| | | DataDictionaryCustom poolScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode()); |
| | | BigDecimal poolScorePrice = new BigDecimal(poolScorePriceDic.getValue() == null ? "1" : poolScorePriceDic.getValue()); |
| | | for(String teamPerkMemberInviteId : referrerIdList){ |
| | | MallMember teamPerkMember = mallMemberMapper.selectInfoByInviteId(teamPerkMemberInviteId); |
| | | // for(MallMember teamPerkMember : mallMemberTeamPerk){ |
| | | String level = teamPerkMember.getLevel(); |
| | | //比较两个级别的大小,level大于levelNormal返回1 |
| | | int compareMin = MemberLevelEnum.V1.compareLevel(level, levelNormal); |
| | | int compareMax = MemberLevelEnum.V1.compareLevel(MemberLevelEnum.V6.getType(), level); |
| | | if(compareMin >= 1 && compareMax >= 1){ |
| | | Long teamPerkMemberId = teamPerkMember.getId(); |
| | | DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "AGENT_PERK_SET", level); |
| | | |
| | | AdminAgentInfo adminAgentInfo = JSONObject.parseObject(teamPerkMemberDic.getValue(), AdminAgentInfo.class); |
| | | BigDecimal cashPercent = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | BigDecimal scorePercent = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | //极差 |
| | | cashPercent = cashPercent.subtract(cashPercentNormal); |
| | | scorePercent = scorePercent.subtract(scorePercentNormal); |
| | | AdminAgentInfo adminAgentInfo = JSONObject.parseObject(teamPerkMemberDic.getValue(), AdminAgentInfo.class); |
| | | BigDecimal cashPercent = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | BigDecimal scorePercent = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | //极差 |
| | | cashPercent = cashPercent.subtract(cashPercentNormal); |
| | | scorePercent = scorePercent.subtract(scorePercentNormal); |
| | | |
| | | BigDecimal cashAmount = amountTC.multiply(cashPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal cashAmount = amountTC.multiply(cashPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | //如果是H金劵,除以当前价格,得到数量。 |
| | | BigDecimal scoreCnt = amountTC.multiply(scorePercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | scoreCnt = scoreCnt.divide(poolScorePrice, 2 ,BigDecimal.ROUND_DOWN); |
| | | if(cashAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(cashAmount, |
| | | teamPerkMemberId, |
| | | "balance", |
| | | MoneyFlowTypeEnum.AGENT_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | } |
| | | if(scoreCnt.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(scoreCnt, |
| | | teamPerkMemberId, |
| | | "score", |
| | | MoneyFlowTypeEnum.AGENT_SCORE_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | orderNo); |
| | | } |
| | | levelNormal = level; |
| | | cashPercentNormal = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | scorePercentNormal = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | //如果是H金劵,除以当前价格,得到数量。 |
| | | BigDecimal scoreCnt = amountTC.multiply(scorePercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | scoreCnt = scoreCnt.divide(poolScorePrice, 2 ,BigDecimal.ROUND_DOWN); |
| | | if(cashAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(cashAmount, |
| | | teamPerkMemberId, |
| | | "balance", |
| | | MoneyFlowTypeEnum.AGENT_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | } |
| | | if(scoreCnt.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(scoreCnt, |
| | | teamPerkMemberId, |
| | | "score", |
| | | MoneyFlowTypeEnum.AGENT_SCORE_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | orderNo); |
| | | } |
| | | levelNormal = level; |
| | | cashPercentNormal = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | scorePercentNormal = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | BigDecimal total = new BigDecimal(100000); |
| | | |
| | | BigDecimal amountTotal = BigDecimal.ZERO; |
| | | BigDecimal scoreTotal = BigDecimal.ZERO; |
| | | |
| | | BigDecimal amountBasic = new BigDecimal(100); |
| | | BigDecimal price = new BigDecimal(0.01); |
| | | |
| | | BigDecimal amountPercent = new BigDecimal(0.5); |
| | | BigDecimal scorePercent = new BigDecimal(0.35); |
| | | int times = total.divideToIntegralValue(amountBasic).intValue(); |
| | | |
| | | System.out.println("循环次数:"+times); |
| | | for(int i = 0; i < times; i++){ |
| | | BigDecimal amount = amountBasic.multiply(amountPercent); |
| | | amountTotal = amountTotal.add(amount); |
| | | |
| | | BigDecimal score = amountBasic.multiply(scorePercent).divide(price, 2 ,BigDecimal.ROUND_DOWN); |
| | | scoreTotal = scoreTotal.add(score); |
| | | price = amountTotal.divide(scoreTotal, 7 ,BigDecimal.ROUND_DOWN); |
| | | |
| | | System.out.println("现金池:"+amountTotal+",积分池:"+scoreTotal+",增长现金:"+amount+"增长积分:"+score+",价格:"+price); |
| | | String referrerIds = "23430963,23420267,23330438,23320976,23310921,23290922,23280413,23270439,23250764,23240756,23230123,23210557,23190725,23180251,23170775,23160156,23150596,23130696,23140691,23120183,22990699,22980499,23110722,20656426"; |
| | | List<String> referrerIdList = StrUtil.splitTrim(referrerIds, ","); |
| | | for(String reId : referrerIdList){ |
| | | System.out.println(reId); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |