| | |
| | | log.info("积分订单无返利"); |
| | | return; |
| | | } |
| | | BigDecimal indirectPer = BigDecimal.valueOf(0.25); |
| | | BigDecimal indirectPer2 = BigDecimal.valueOf(0.15); |
| | | |
| | | MallMember member = mallMemberMapper.selectById(orderInfo.getMemberId()); |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | // 父级会员直推人数 |
| | | Integer directCnt = mallMemberMapper.selectOwnCntByInviteIdAndAccountLevel(parentMember.getInviteId(), parentMember.getAccountLevel()); |
| | | // 非代理推代理,非代理上级拿的收益比例 |
| | | DataDictionaryCustom indirectPerDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.UNAGENT_TO_AGENT_PARENT.getType(), DataDictionaryEnum.UNAGENT_TO_AGENT_PARENT.getCode()); |
| | | |
| | | // 非代理推代理,非代理的直推收益比例 |
| | | DataDictionaryCustom unAgentDirectDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.UNAGENT_TO_AGENT.getType(), DataDictionaryEnum.UNAGENT_TO_AGENT.getCode()); |
| | | |
| | | // 父级需要拥有 此会员 对应级别的直推数量 |
| | | Integer directCnt = mallMemberMapper.selectOwnCntByInviteIdAndAccountLevel(parentMember.getInviteId(), member.getAccountLevel()); |
| | | List<DataDictionaryCustom> dataDices = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.DIRECT_BONUS_SETTING.getType()); |
| | | |
| | | directCnt = directCnt == null ? 0 : directCnt; |
| | |
| | | return; |
| | | } |
| | | |
| | | // 推荐奖比例 |
| | | DataDictionaryCustom indrectDicPropDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.RECOMMEND_BONUS.getType(), DataDictionaryEnum.RECOMMEND_BONUS.getCode()); |
| | | |
| | | for (MallOrderItem item : items) { |
| | | // 减去成本后算收益 |
| | | BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt())); |
| | | // 减去成本后算收益 减去积分付款 |
| | | BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt())).subtract(orderInfo.getScoreAmount()); |
| | | if (amount.compareTo(BigDecimal.ZERO) < 1) { |
| | | continue; |
| | | } |
| | |
| | | } else { |
| | | |
| | | // 判断上级是否与自己购买的套餐符合,若符合则走3级直推逻辑,若不符合则另外一个 |
| | | if (parentMember.getAccountLevel().equals(item.getGoodsLevel()) || AccountLevelEnums.VIP.getLevel().equals(parentMember.getAccountLevel())) { |
| | | |
| | | if (parentMember.getAccountLevel() >= item.getGoodsLevel()) { |
| | | for (DataDictionaryCustom dataDic : dataDices) { |
| | | JSONObject jsonObject = JSONObject.parseObject(dataDic.getValue()); |
| | | if (directCnt >= jsonObject.getInteger("pushCnt")) { |
| | |
| | | isSameLevel = 1; |
| | | // 非代理推代理/非股东推股东 |
| | | } else { |
| | | profitPer = BigDecimal.valueOf(10); |
| | | profitPer = new BigDecimal(unAgentDirectDic.getValue()); |
| | | isSameLevel = 2; |
| | | } |
| | | } |
| | |
| | | // 直推奖 |
| | | BigDecimal profit = amount.multiply(profitPer.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)); |
| | | changeScoreAndCommission(parentMember.getId(), profit, MoneyFlowTypeEnum.DIRECT_BONUS.getValue(), orderInfo.getOrderNo()); |
| | | |
| | | // 代理推代理 |
| | | // if (isSameLevel == 1) { |
| | | // MallMember doubleParentMember = mallMemberMapper.selectInfoByInviteId(parentMember.getReferrerId()); |
| | | // if (doubleParentMember == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // BigDecimal doubleParentProfit = profit.multiply(indirectPer); |
| | | // changeScoreAndCommission(doubleParentMember.getId(), doubleParentProfit, MoneyFlowTypeEnum.DIRECT_BONUS.getValue(), orderInfo.getOrderNo()); |
| | | // } |
| | | |
| | | // 非代理推代理 |
| | | if (isSameLevel == 2) { |
| | |
| | | break; |
| | | } |
| | | |
| | | BigDecimal doubleParentProfit = profit.multiply(indirectPer2); |
| | | BigDecimal doubleParentProfit = profit.multiply(new BigDecimal(indirectPerDic.getValue())); |
| | | changeScoreAndCommission(mallMember.getId(), doubleParentProfit, MoneyFlowTypeEnum.DIRECT_BONUS.getValue(), orderInfo.getOrderNo()); |
| | | } |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 隔代比例 |
| | | BigDecimal indrectDicProp = new BigDecimal(20); |
| | | BigDecimal indrectDicProp = new BigDecimal(indrectDicPropDic.getValue()); |
| | | |
| | | // 隔代推荐奖 收益 |
| | | direct = direct.multiply(indrectDicProp.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP)); |
| | |
| | | walletService.add(direct, parent.getId(), "commission"); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), direct.negate(), MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | changeScoreAndCommission(parent.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo()); |
| | | } |
| | | // =======隔代奖== end ===== |
| | | } |
| | |
| | | BigDecimal hundred = new BigDecimal(100); |
| | | for (MallOrderItem item : items) { |
| | | // 减去成本后算收益 |
| | | BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt())); |
| | | BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt())).subtract(orderInfo.getScoreAmount()); |
| | | if (amount.compareTo(BigDecimal.ZERO) < 1) { |
| | | continue; |
| | | } |