| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.utils.AppContants; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | |
| | | try { |
| | | walletService.reduce(goodsProfit, member.getId(), "score"); |
| | | } catch (Exception e) { |
| | | log.info("减少积分失败异常:{}, {}", goodsProfit, member.getId()); |
| | | log.info("静态分红异常:{}, {}", goodsProfit, member.getId()); |
| | | break; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 直推20%,隔代收益为直推奖励金额的30%,a_b_c_d,d购买1000套餐,c得200,b得200*30%=60元,a得60*30%=18元。。。 |
| | | * 以此类推,结算到一元为止。 |
| | | * @param orderId |
| | | */ |
| | | @Override |
| | | public void dynamicProfit(Long orderId) { |
| | | log.info("######直推奖励, 订单ID:{}######", orderId); |
| | |
| | | return; |
| | | } |
| | | |
| | | // 隔代比例 |
| | | BigDecimal indrectDicProp = new BigDecimal(indrectDic.getValue()); |
| | | |
| | | // 隔代推荐奖 |
| | | BigDecimal direct = dynamicProfit.divide(indrectDicProp, 2, RoundingMode.HALF_UP); |
| | | for (MallMember parentMember : members) { |
| | | if (parent.equals(parentMember.getInviteId())) { |
| | |
| | | try { |
| | | walletService.reduce(direct, parentMember.getId(), "score"); |
| | | } catch (Exception e) { |
| | | log.info("减少积分失败异常:{}, {}", direct, parentMember.getId()); |
| | | log.info("隔代推荐奖异常:{}, {}", direct, parentMember.getId()); |
| | | 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.negate(), MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | |
| | | if (direct.compareTo(BigDecimal.ONE) < 1) { |
| | | break; |
| | | } |
| | | direct = direct.divide(indrectDicProp, 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | try { |
| | | walletService.reduce(dynamicProfit, member.getId(), "score"); |
| | | } catch (Exception e) { |
| | | log.info("减少积分失败异常:{}, {}", dynamicProfit, member.getId()); |
| | | log.info("直推奖励异常:{}, {}", dynamicProfit, member.getId()); |
| | | continue; |
| | | } |
| | | walletService.add(dynamicProfit, member.getId(), "commission"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void agentProfit() { |
| | | log.info("#####==代理分红==#####"); |
| | | Date profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1); |
| | | BigDecimal totalIncome = mallOrderInfoMapper.selectTotalAmountForDate(profitDate, null); |
| | | |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.AGENT_BONUS.getType(), DataDictionaryEnum.AGENT_BONUS.getCode()); |
| | | BigDecimal profit = totalIncome.divide(new BigDecimal(dic.getValue()),2, RoundingMode.HALF_UP); |
| | | BigDecimal preProfit = profit.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); |
| | | |
| | | List<MallMember> agentMembers = mallMemberMapper.selectByIdAndNoLevel(null, AgentLevelEnum.FIRST_LEVEL.name()); |
| | | if (CollUtil.isEmpty(agentMembers)) { |
| | | return; |
| | | } |
| | | |
| | | for (MallMember agentMember : agentMembers) { |
| | | DataDictionaryCustom agentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.AGENT_LEVEL_REQUIRE, agentMember.getLevel()); |
| | | |
| | | // TODO |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void rankProfit() { |
| | | log.info("######==排名分红==####"); |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1)); |
| | | } |