| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void agentProfit() { |
| | | public void agentProfit(Integer type) { |
| | | log.info("#####==代理分红==start==#####"); |
| | | if (type == null) { |
| | | return; |
| | | } |
| | | |
| | | MallSystemSetting systemSetting = mallSystemSettingMapper.selectById(1L); |
| | | if (systemSetting == null) { |
| | | log.info("没有系统配置"); |
| | | return; |
| | | } |
| | | |
| | | BigDecimal hundred = BigDecimal.valueOf(100); |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.AGENT_BONUS_RELEASE.getType(), DataDictionaryEnum.AGENT_BONUS_RELEASE.getCode()); |
| | | if (dic == null || StrUtil.isBlank(dic.getValue()) || Integer.parseInt(dic.getValue()) == 0) { |
| | | log.info("不进行全网分红"); |
| | | return; |
| | | } |
| | | |
| | | // 全网分红 |
| | | BigDecimal waitToBonus = systemSetting.getAllBonus().multiply(new BigDecimal(dic.getValue()).divide(hundred, 2, RoundingMode.HALF_UP)); |
| | | |
| | | // 代理 |
| | | List<MallMember> mallMembers = mallMemberMapper.selectAgentOrPartnetMemberList(type); |
| | | if (CollUtil.isEmpty(mallMembers) || waitToBonus.compareTo(BigDecimal.ZERO) < 1) { |
| | | log.info("待分红金额不足或会员不足"); |
| | | return; |
| | | } |
| | | |
| | | BigDecimal perBonus = waitToBonus.divide(new BigDecimal(mallMembers.size()), 2, RoundingMode.HALF_UP); |
| | | mallMembers.forEach(item -> { |
| | | changeScoreAndCommission(item.getId(), perBonus, type.equals(AccountLevelEnums.VVIP.getLevel()) ? MoneyFlowTypeEnum.AGENT_BONUS.getValue() : MoneyFlowTypeEnum.PARTNER_BONUS.getValue(), null); |
| | | }); |
| | | |
| | | log.info("#####==代理分红==end==#####"); |
| | | } |
| | |
| | | for (Map.Entry<String, List<MallMember>> entry : levelMemberMap.entrySet()) { |
| | | BigDecimal levelBonus = levelBonusMap.get(entry.getKey()); |
| | | List<MallMember> memberList = entry.getValue(); |
| | | |
| | | |
| | | if (CollUtil.isEmpty(memberList) || levelBonus.compareTo(BigDecimal.ZERO) < 1) { |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal perBonus = levelBonus.divide(BigDecimal.valueOf(memberList.size()), 2, RoundingMode.HALF_UP); |
| | | memberList.forEach(item -> { |
| | | changeScoreAndCommission(item.getId(), perBonus, 2, null); |
| | | changeScoreAndCommission(item.getId(), perBonus, MoneyFlowTypeEnum.ALL_INTERNET_BONUS.getValue(), null); |
| | | }); |
| | | } |
| | | |