| | |
| | | private final IMallMoneyFlowService moneyFlowService; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | private final IMallAchieveService mallAchieveService; |
| | | private final MallAchieveRecordMapper mallAchieveRecordMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | Date profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1); |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | // BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = mallAchieveRecordMapper.selectAchieveTotal("D", profitDate); |
| | | |
| | | if (totalIncome.compareTo(BigDecimal.ZERO) == 0) { |
| | | return; |
| | |
| | | profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1); |
| | | } |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | // BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = mallAchieveRecordMapper.selectAchieveTotal("D", profitDate); |
| | | |
| | | 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); |
| | | BigDecimal profit = totalIncome.multiply(new BigDecimal(dic.getValue()).divide(new BigDecimal("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()); |
| | | |
| | | if (agentDic == null) { |
| | | continue; |
| | | } |
| | | |
| | | List<DataDictionaryCustom> dics = dataDictionaryCustomMapper.selectDicByType(AppContants.AGENT_LEVEL_REQUIRE); |
| | | for (DataDictionaryCustom agentDic : dics) { |
| | | JSONObject jsonObject = JSONObject.parseObject(agentDic.getValue()); |
| | | BigDecimal profitProp = jsonObject.getBigDecimal("profitProp"); |
| | | BigDecimal income = preProfit.multiply(profitProp); |
| | | BigDecimal profitProp = jsonObject.getBigDecimal("profitProp").divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP); |
| | | |
| | | int reduce = walletService.reduce(income, agentMember.getId(), "score"); |
| | | if (reduce == 2) { |
| | | List<MallMember> agentMemberList = mallMemberMapper.selectMemberWithLevel(agentDic.getCode()); |
| | | if (CollUtil.isEmpty(agentMemberList)) { |
| | | continue; |
| | | } |
| | | |
| | | walletService.add(income, agentMember.getId(), "commission"); |
| | | BigDecimal income = profit.multiply(profitProp).divide(BigDecimal.valueOf(agentMemberList.size()), 2, RoundingMode.HALF_UP); |
| | | |
| | | moneyFlowService.addMoneyFlow(agentMember.getId(), income, MoneyFlowTypeEnum.AGENT_BONUS.getValue(), null, FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(agentMember.getId(), income.negate(), MoneyFlowTypeEnum.AGENT_BONUS.getValue(), null, FlowTypeEnum.SCORE.getValue()); |
| | | for (MallMember agentMember : agentMemberList) { |
| | | int reduce = walletService.reduce(income, agentMember.getId(), "score"); |
| | | if (reduce == 2) { |
| | | continue; |
| | | } |
| | | |
| | | walletService.add(income, agentMember.getId(), "commission"); |
| | | |
| | | moneyFlowService.addMoneyFlow(agentMember.getId(), income, MoneyFlowTypeEnum.AGENT_BONUS.getValue(), null, FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(agentMember.getId(), income.negate(), MoneyFlowTypeEnum.AGENT_BONUS.getValue(), null, FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | } |
| | | |
| | | log.info("#####==代理分红==end==#####"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "M", 2); |
| | | // BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "M", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "M", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | // BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "M", 1); |
| | | BigDecimal totalIncome = mallAchieveRecordMapper.selectAchieveTotal("D", profitDate); |
| | | |
| | | List<DataDictionaryCustom> rankAward = dataDictionaryCustomMapper.selectDicByType("RANK_AWARD"); |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.RANK_BONUS.getType(), DataDictionaryEnum.RANK_BONUS.getCode()); |
| | |
| | | profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1); |
| | | } |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | // BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = mallAchieveRecordMapper.selectAchieveTotal("D", profitDate); |
| | | |
| | | // 董事 |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.DIRECTOR_BONUS.getType(), DataDictionaryEnum.DIRECTOR_BONUS.getCode()); |