44323
2023-11-27 aa45df63fa01b2f010560e4157f00bec5150a1fb
cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java
@@ -186,10 +186,14 @@
//        integers.add(2);
        integers.add(3);
        ArrayList<Integer> pays = new ArrayList<>();
        pays.add(2);
        pays.add(3);
        return paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
                .in("payType",integers)
                .eq("appUserId",appUserId)
                .eq("payStatus",2));
                .in("payStatus",pays));
    }
@@ -284,7 +288,11 @@
    public ResultUtil<List<CompetitionListVo>> queryCompetitionList(String cityCode, String content, Integer registerCondition, String heat){
        try {
            List<CompetitionListVo> competitionListVos = cttService.queryCompetitionList(cityCode, content, registerCondition, heat);
            return ResultUtil.success(competitionListVos);
            List<CompetitionListVo> filteredList = competitionListVos.stream()
                    .filter(vo -> vo.getStatus() == 1 || vo.getStatus() == 2)
                    .collect(Collectors.toList());
            return ResultUtil.success(filteredList);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
@@ -309,6 +317,19 @@
                return ResultUtil.tokenErr();
            }
            CompetitionInfo competitionInfo = cttService.queryCompetitionInfo(uid, id, lon, lat);
            String dateString = competitionInfo.getRegisterEndTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Date date = sdf.parse(dateString);
            if (new Date().after(date)){
                competitionInfo.setHasPass(1);
            }else {
                competitionInfo.setHasPass(0);
            }
            return ResultUtil.success(competitionInfo);
        }catch (Exception e){
            e.printStackTrace();
@@ -348,7 +369,7 @@
                return ResultUtil.tokenErr();
            }
            if (byId.getRegisterCondition()==3){
             Integer counts =    coursePackagePaymentClient.isHave(uid);
             Integer counts =    coursePackagePaymentClient.isHave(paymentCompetitionVo.getIds());
                if (counts==0){
                    return new ResultUtil(0,"当前赛事仅限已购课学员报名");
                }
@@ -446,7 +467,6 @@
            if(null != map){
                String code = map.get("out_trade_no");
                String trade_no = map.get("trade_no");
                PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 2));
                if(paymentCompetition.getPayStatus() == 1){
                    paymentCompetition.setAppUserId(null);
@@ -454,7 +474,6 @@
                    paymentCompetition.setPayTime(new Date());
                    paymentCompetition.setPayOrderNo(trade_no);
                    paymentCompetitionService.updateById(paymentCompetition);
                    Competition competition = cttService.getById(paymentCompetition.getCompetitionId());
                    competition.setApplicantsNumber(competition.getApplicantsNumber() + 1);
                    cttService.updateById(competition);
@@ -600,16 +619,29 @@
                wrapper.lt(Competition::getStartTime,listQuery.getTime().split(" - ")[0]+" 00:00:00");
                wrapper.gt(Competition::getEndTime,listQuery.getTime().split(" - ")[1]+" 23:59:59");
            }
            if(ToolUtil.isNotEmpty(listQuery.getRegisterCondition())){
                wrapper.eq(Competition::getRegisterCondition,listQuery.getRegisterCondition());
            }
            // 平台查询审核通过的赛事
            if (listQuery.getObj()==1){
                wrapper.eq(Competition::getAuditStatus,2);
            }
            // 赛事审核
            if (listQuery.getObj()==-1){
                wrapper.ne(Competition::getAuditStatus,2);
            }
            wrapper.in(Competition::getStoreId,listQuery.getIds());
            wrapper.eq(Competition::getAuditStatus,2);
            wrapper.orderByDesc(Competition::getInsertTime);
            Page<Competition> page = cttService.page(competitionPage, wrapper);
            for (Competition record : page.getRecords()) {
                // 查询当前赛事有多少人报名了
                List<UserCompetition> competitionId = ucttService.list(new QueryWrapper<UserCompetition>()
                        .eq("competitionId", record.getId()));
                // 报名数量
                int temp = competitionId.size();
                String value = String.valueOf(temp);
                record.setCount(record.getApplicantsNumber()+"-"+value);
            }
            return page;
        }catch (Exception e){
            e.printStackTrace();
@@ -655,6 +687,16 @@
    @PostMapping("/base/competition/add")
    public void add(@RequestBody Competition competition){
        try {
            if (competition.getStartTime().after(new Date())){
                competition.setStatus(1);
            }
            if (competition.getStartTime().before(new Date())){
                if (competition.getEndTime().after(new Date())){
                    competition.setStatus(2);
                }else{
                    competition.setStatus(3);
                }
            }
            competition.setInsertTime(new Date());
            cttService.save(competition);
        }catch (Exception e){
@@ -665,6 +707,16 @@
    @PostMapping("/base/competition/update")
    public void update(@RequestBody Competition competition){
        try {
            if (competition.getStartTime().after(new Date())){
                competition.setStatus(1);
            }
            if (competition.getStartTime().before(new Date())){
                if (competition.getEndTime().after(new Date())){
                    competition.setStatus(2);
                }else{
                    competition.setStatus(3);
                }
            }
            cttService.updateById(competition);
        }catch (Exception e){
            e.printStackTrace();