| | |
| | | // 年 |
| | | ArrayList<Integer> years = new ArrayList<>(); |
| | | ArrayList<Integer> yearsUser = new ArrayList<>(); |
| | | Integer operatorId = vo.getOperatorId(); |
| | | List<Integer> operatorId1 = cttService.list(new QueryWrapper<Competition>().eq("operatorId", operatorId)) |
| | | .stream().map(Competition::getId).collect(Collectors.toList()); |
| | | for (Object o : collect) { |
| | | String s = o.toString(); |
| | | int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).eq(Competition::getOperatorId, vo.getOperatorId())); |
| | | int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime, s)); |
| | | List<Integer> competitionIds = listCompetitionIds(vo, s); |
| | | int count = competitionIds.size(); |
| | | int count1 = countUserCompetitions(vo, s, competitionIds); |
| | | years.add(count); |
| | | yearsUser.add(count1); |
| | | } |
| | |
| | | m = "0" + i; |
| | | } |
| | | String s = year + "-" + m; |
| | | int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).eq(Competition::getOperatorId, operatorId)); |
| | | int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime, s)); |
| | | List<Integer> competitionIds = listCompetitionIds(vo, s); |
| | | int count = competitionIds.size(); |
| | | int count1 = countUserCompetitions(vo, s, competitionIds); |
| | | months.add(count); |
| | | monthsUser.add(count1); |
| | | } |
| | |
| | | return map; |
| | | } |
| | | |
| | | private List<Integer> listCompetitionIds(CompetionVO vo, String dateText) { |
| | | return cttService.list(buildCompetitionCountWrapper(vo, dateText)) |
| | | .stream() |
| | | .map(Competition::getId) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private int countUserCompetitions(CompetionVO vo, String dateText, List<Integer> competitionIds) { |
| | | if (competitionIds.isEmpty()) { |
| | | return 0; |
| | | } |
| | | return ucttService.count(new LambdaQueryWrapper<UserCompetition>() |
| | | .in(UserCompetition::getAppUserId, vo.getIds()) |
| | | .in(UserCompetition::getCompetitionId, competitionIds) |
| | | .like(UserCompetition::getInsertTime, dateText)); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<Competition> buildCompetitionCountWrapper(CompetionVO vo, String dateText) { |
| | | LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<Competition>() |
| | | .like(Competition::getInsertTime, dateText) |
| | | .eq(Competition::getOperatorId, vo.getOperatorId()); |
| | | appendStoreIdFilter(wrapper, vo.getStoreIds()); |
| | | return wrapper; |
| | | } |
| | | |
| | | private void appendStoreIdFilter(LambdaQueryWrapper<Competition> wrapper, List<Integer> storeIds) { |
| | | if (storeIds == null || storeIds.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | List<Integer> validStoreIds = storeIds.stream() |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | if (validStoreIds.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | wrapper.and(item -> { |
| | | item.apply("FIND_IN_SET({0}, storeId)", validStoreIds.get(0)); |
| | | for (int i = 1; i < validStoreIds.size(); i++) { |
| | | item.or().apply("FIND_IN_SET({0}, storeId)", validStoreIds.get(i)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/queryAppUserId") |