| | |
| | | if (StrUtil.isBlank(member.getReferrerId())) { |
| | | return; |
| | | } |
| | | |
| | | // 直推奖励字典 |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.DYNAMIC_BONUS.getType(), DataDictionaryEnum.DYNAMIC_BONUS.getCode()); |
| | | // 隔代字典 |
| | | DataDictionaryCustom indrectDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.INDRECT_BONUS.getType(), DataDictionaryEnum.INDRECT_BONUS.getCode()); |
| | | |
| | | // 直接父级 |
| | | MallMember parent = mallMemberMapper.selectInfoByInviteId(member.getReferrerId()); |
| | | |
| | |
| | | BigDecimal amount = item.getPrice().subtract(item.getCostPrice()).multiply(BigDecimal.valueOf(item.getCnt())); |
| | | if (amount.compareTo(BigDecimal.ZERO) < 1) { |
| | | continue; |
| | | } |
| | | |
| | | Integer isReturn = null; |
| | | if (item.getIsNormal() == 1) { |
| | | isReturn = 2; |
| | | } |
| | | |
| | | // =======直推返利== start ===== |
| | |
| | | |
| | | walletService.add(dynamicProfit, parent.getId(), "commission"); |
| | | |
| | | moneyFlowService.addMoneyFlow(parent.getId(), dynamicProfit, MoneyFlowTypeEnum.DYNAMIC_ACHIEVE.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), dynamicProfit, MoneyFlowTypeEnum.DYNAMIC_ACHIEVE.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue(), isReturn); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), dynamicProfit.negate(), MoneyFlowTypeEnum.DYNAMIC_ACHIEVE.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | // =======直推返利== end ===== |
| | | |
| | |
| | | if (CollUtil.isEmpty(members)) { |
| | | return; |
| | | } |
| | | // 隔代比例 |
| | | BigDecimal indrectDicProp = new BigDecimal(indrectDic.getValue()); |
| | | |
| | | // 隔代推荐奖 收益 |
| | | BigDecimal direct = dynamicProfit.divide(indrectDicProp, 2, RoundingMode.HALF_UP); |
| | | |
| | | // direct 收益小于1,则跳出 |
| | | if (direct.compareTo(BigDecimal.ONE) < 1) { |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal direct = dynamicProfit; |
| | | for (MallMember parentMember : members) { |
| | | if (parent.getInviteId().equals(parentMember.getInviteId())) { |
| | | continue; |
| | | } |
| | | |
| | | // 直推数量 |
| | | Integer directCnt = mallMemberMapper.selectOwnCntByInviteId(member.getReferrerId()); |
| | | List<DataDictionaryCustom> dataDices = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.INDIRECT_BONUS_SETTING.getType()); |
| | | |
| | | directCnt = directCnt == null ? 0 :directCnt; |
| | | // 隔代字典 |
| | | DataDictionaryCustom indrectDic = new DataDictionaryCustom(); |
| | | for (DataDictionaryCustom dataDic : dataDices) { |
| | | if (directCnt > Integer.parseInt(dataDic.getValue())) { |
| | | indrectDic = dataDic; |
| | | } |
| | | } |
| | | |
| | | // 隔代比例 |
| | | BigDecimal indrectDicProp = new BigDecimal(indrectDic.getValue()); |
| | | |
| | | // 隔代推荐奖 收益 |
| | | direct = direct.divide(indrectDicProp, 2, RoundingMode.HALF_UP); |
| | | |
| | | // direct 收益小于1,则跳出 |
| | | if (direct.compareTo(BigDecimal.ONE) < 1) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | walletService.add(direct, parentMember.getId(), "commission"); |
| | | moneyFlowService.addMoneyFlow(parentMember.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(parentMember.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue(), isReturn); |
| | | moneyFlowService.addMoneyFlow(parentMember.getId(), direct.negate(), MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | |
| | | direct = direct.divide(indrectDicProp, 2, RoundingMode.HALF_UP); |
| | | } |
| | | // =======隔代奖== end ===== |
| | | } |