| | |
| | | if (ToolUtil.isNotEmpty(data)) { |
| | | String stime = data.split(" - ")[0] + " 00:00:00"; |
| | | String etime = data.split(" - ")[1] + " 23:59:59"; |
| | | vipPaymentLambdaQueryWrapper.between(PaymentCompetition::getInsertTime, stime, etime); |
| | | vipPaymentLambdaQueryWrapper.between(PaymentCompetition::getPayTime, stime, etime); |
| | | } |
| | | vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getCompetitionId, ids); |
| | | vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getPayStatus, 2); |
| | | vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getState, 1); |
| | | ArrayList<Integer> objects = new ArrayList<>(); |
| | | objects.add(1); |
| | | objects.add(2); |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** 门店活动统计:仅统计指定门店的赛事及其报名记录。 */ |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/actStore") |
| | | public HashMap<String, Object> actStore(@RequestBody CompetionVO vo) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | if (vo.getStoreIds() == null || vo.getStoreIds().isEmpty()) { |
| | | vo.setStoreIds(Collections.singletonList(-1)); |
| | | } |
| | | ArrayList<Integer> years = new ArrayList<>(); |
| | | ArrayList<Integer> yearsUser = new ArrayList<>(); |
| | | int year = DateUtil.year(new Date()); |
| | | for (int statisticYear = year - 9; statisticYear <= year; statisticYear++) { |
| | | String dateText = String.valueOf(statisticYear); |
| | | List<Integer> competitionIds = listStoreCompetitionIds(vo, dateText); |
| | | years.add(competitionIds.size()); |
| | | yearsUser.add(countStoreUserCompetitions(dateText, competitionIds)); |
| | | } |
| | | map.put("yearData", years); |
| | | map.put("yearsUser", yearsUser); |
| | | |
| | | ArrayList<Integer> months = new ArrayList<>(); |
| | | ArrayList<Integer> monthsUser = new ArrayList<>(); |
| | | for (int month = 1; month <= 12; month++) { |
| | | String dateText = String.format("%d-%02d", year, month); |
| | | List<Integer> competitionIds = listStoreCompetitionIds(vo, dateText); |
| | | months.add(competitionIds.size()); |
| | | monthsUser.add(countStoreUserCompetitions(dateText, competitionIds)); |
| | | } |
| | | map.put("monthData", months); |
| | | map.put("monthsUser", monthsUser); |
| | | return map; |
| | | } |
| | | |
| | | private List<Integer> listCompetitionIds(CompetionVO vo, String dateText) { |
| | | return cttService.list(buildCompetitionCountWrapper(vo, dateText)) |
| | | .stream() |
| | | .map(Competition::getId) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private List<Integer> listStoreCompetitionIds(CompetionVO vo, String dateText) { |
| | | Set<String> storeIds = vo.getStoreIds().stream() |
| | | .filter(Objects::nonNull) |
| | | .map(String::valueOf) |
| | | .collect(Collectors.toSet()); |
| | | return cttService.list(new LambdaQueryWrapper<Competition>() |
| | | .like(Competition::getInsertTime, dateText)) |
| | | .stream() |
| | | .filter(competition -> containsStoreId(competition.getStoreId(), storeIds)) |
| | | .map(Competition::getId) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private boolean containsStoreId(String competitionStoreIds, Set<String> storeIds) { |
| | | if (competitionStoreIds == null || competitionStoreIds.trim().isEmpty()) { |
| | | return false; |
| | | } |
| | | return Arrays.stream(competitionStoreIds.split(",")) |
| | | .map(String::trim) |
| | | .anyMatch(storeIds::contains); |
| | | } |
| | | |
| | | private int countStoreUserCompetitions(String dateText, List<Integer> competitionIds) { |
| | | if (competitionIds.isEmpty()) { |
| | | return 0; |
| | | } |
| | | return ucttService.count(new LambdaQueryWrapper<UserCompetition>() |
| | | .in(UserCompetition::getCompetitionId, competitionIds) |
| | | .like(UserCompetition::getInsertTime, dateText)); |
| | | } |
| | | |
| | | private int countUserCompetitions(CompetionVO vo, String dateText, List<Integer> competitionIds) { |
| | |
| | | |
| | | private LambdaQueryWrapper<Competition> buildCompetitionCountWrapper(CompetionVO vo, String dateText) { |
| | | LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<Competition>() |
| | | .like(Competition::getInsertTime, dateText) |
| | | .eq(Competition::getOperatorId, vo.getOperatorId()); |
| | | .like(Competition::getInsertTime, dateText); |
| | | // 运营商活动统计以其名下门店为准。历史活动的 operatorId 可能为空或未同步, |
| | | // 不能再以该字段过滤,否则活动管理列表能看到的门店活动会被统计遗漏。 |
| | | appendStoreIdFilter(wrapper, vo.getStoreIds()); |
| | | return wrapper; |
| | | } |
| | |
| | | @ResponseBody |
| | | @PostMapping("/base/competition/queryAppUserId") |
| | | public List<Integer> queryAppUserId(@RequestBody List<Integer> storeIds){ |
| | | List<Competition> list = competitionService.list(new QueryWrapper<Competition>().in("storeId", storeIds).eq("auditStatus", 2).eq("state", 1)); |
| | | if (storeIds == null || storeIds.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<Competition>() |
| | | .eq(Competition::getAuditStatus, 2).eq(Competition::getState, 1); |
| | | appendStoreIdFilter(wrapper, storeIds); |
| | | List<Competition> list = competitionService.list(wrapper); |
| | | List<Integer> collect = list.stream().map(Competition::getId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return new ArrayList<>(); |