From 232d3efb20f87f9c60faeda7bae4bc96e5687bd3 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期三, 11 十月 2023 19:19:47 +0800
Subject: [PATCH] 10.12

---
 cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java |  232 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 206 insertions(+), 26 deletions(-)

diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java b/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java
index 4e90260..b03f406 100644
--- a/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java
+++ b/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java
@@ -1,6 +1,7 @@
 package com.dsh.competition.controller;
 
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,9 +12,7 @@
 import com.dsh.competition.feignclient.account.AppUserClient;
 import com.dsh.competition.feignclient.account.model.AppUser;
 import com.dsh.competition.feignclient.model.*;
-import com.dsh.competition.model.CompetitionInfo;
-import com.dsh.competition.model.CompetitionListVo;
-import com.dsh.competition.model.PaymentCompetitionVo;
+import com.dsh.competition.model.*;
 import com.dsh.competition.service.CompetitionService;
 import com.dsh.competition.service.IParticipantService;
 import com.dsh.competition.service.IPaymentCompetitionService;
@@ -32,10 +31,8 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.PrintWriter;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.concurrent.CompletionService;
 import java.util.stream.Collectors;
 
 /**
@@ -75,29 +72,67 @@
     private AppUserClient appUserClient;
 
 
+    /**
+     * 获取赛事报名记录
+     */
+    @ResponseBody
+    @RequestMapping("/base/competition/listAllPayment")
+    public List<PaymentCompetition> listAllPayment(@RequestBody CompetitionQuery query){
+        List<PaymentCompetition> paymentCompetitions = paymentCompetitionService.listAll(query);
+        List<PaymentCompetition> result = new ArrayList<>();
+        if (query.getOperatorId()!=null){
+            for (PaymentCompetition paymentCompetition : paymentCompetitions) {
+                Integer competitionId = paymentCompetition.getCompetitionId();
+                Competition byId = cttService.getById(competitionId);
+                if (byId!=null){
+                    Integer operatorId = byId.getOperatorId();
+                    if (operatorId!=null){
+                        if (operatorId == query.getOperatorId()){
+                            result.add(paymentCompetition);
+                        }
+                    }
+                }
+            }
+            return result;
+        }else if (query.getStoreId()!=null){
+            for (PaymentCompetition paymentCompetition : paymentCompetitions) {
+                Integer competitionId = paymentCompetition.getCompetitionId();
+                Competition byId = cttService.getById(competitionId);
+                if (byId!=null){
+                    String storeId = byId.getStoreId();
+                    if (storeId.contains(query.getStoreId().toString())){
+                            result.add(paymentCompetition);
+                    }
+                }
+            }
+            return result;
+        }
+        return paymentCompetitions;
+    }
+    @ResponseBody
     @PostMapping("/base/competition/getPayedCompetitions")
-    public List<PaymentCompetition> getAllCompetitionPayRecord(@RequestBody BillingDataRequestVo requestVo){
-        List<Integer> integers = new ArrayList<>();
-        integers.add(1);
-        integers.add(2);
-        return paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
-                .in("payType",integers)
-                .eq("appUserId",requestVo.getAppUserId())
-                .eq("payStatus",2)
-                .between("payTime",requestVo.getMonthStart(),requestVo.getMonthEnd()));
+    public BillingRequestVo getAllCompetitionPayRecord(@RequestBody BillingDataRequestVo requestVo){
+        BillingRequestVo billingRequestVo = new BillingRequestVo();
+        List<BillingRequest> integers = new ArrayList<>();
+        integers = paymentCompetitionService.queryDatas(requestVo.getAppUserId(),requestVo.getMonthStart(),requestVo.getMonthEnd());
+        System.out.println(integers);
+        if (integers.size() > 0 ){
+            billingRequestVo.setRequests(integers);
+        }
+        return billingRequestVo;
     }
 
-
+    @ResponseBody
     @PostMapping("/base/competition/getCancelOrderOfUserPay")
-    public List<PaymentCompetition> getCancelOrderOfUserPayRecord(@RequestBody BillingDataRequestVo requestVo){
-        List<Integer> integers = new ArrayList<>();
-        integers.add(1);
-        integers.add(2);
-        return paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
-                .in("payType",integers)
-                .eq("appUserId",requestVo.getAppUserId())
-                .eq("payStatus",3)
-                .between("refundTime",requestVo.getMonthStart(),requestVo.getMonthEnd()));
+    public BillingRequestVo getCancelOrderOfUserPayRecord(@RequestBody BillingDataRequestVo requestVo){
+        BillingRequestVo billingRequestVo = new BillingRequestVo();
+        List<BillingRequest> integers = new ArrayList<>();
+        integers = paymentCompetitionService.queryCancelDatas(requestVo.getAppUserId(),requestVo.getMonthStart(),requestVo.getMonthEnd());
+        System.out.println(integers);
+        if (integers.size() > 0 ){
+            billingRequestVo.setRequests(integers);
+        }
+        return billingRequestVo;
     }
 
 
@@ -111,6 +146,14 @@
                 .eq("appUserId",appUserId)
                 .eq("payStatus",3));
     }
+
+
+    @PostMapping("/base/competition/queryByCode")
+    public Integer queryByCode(@RequestBody String code){
+
+        return paymentCompetitionService.queryByCode(code);
+    }
+
 
 
 
@@ -203,6 +246,7 @@
     @ApiOperation(value = "赛事报名", tags = {"APP-赛事活动列表"})
     @ApiImplicitParams({
             @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+
     })
     public ResultUtil paymentCompetition(PaymentCompetitionVo paymentCompetitionVo){
         try {
@@ -211,6 +255,27 @@
                 return ResultUtil.tokenErr();
             }
             return cttService.paymentCompetition(uid, paymentCompetitionVo);
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultUtil.runErr();
+        }
+    }
+
+
+    @ResponseBody
+    @PostMapping("/api/competition/paymentCompetitionCourseList")
+    @ApiOperation(value = "赛事报名--支付可用课时列表", tags = {"APP-赛事活动列表"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+            @ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true),
+    })
+    public ResultUtil paymentCompetitionCourseList(Integer id){
+        try {
+            Integer uid = tokenUtil.getUserIdFormRedis();
+            if(null == uid){
+                return ResultUtil.tokenErr();
+            }
+            return cttService.paymentCompetitionCourseList(uid, id);
         }catch (Exception e){
             e.printStackTrace();
             return ResultUtil.runErr();
@@ -441,6 +506,40 @@
             return new Page<Competition>();
         }
     }
+    @PostMapping("/base/competition/listAudit")
+    public Page<Competition> listAudit(@RequestBody ListQuery listQuery){
+        try {
+            Page<Competition> competitionPage = new Page<>(listQuery.getOffset(),listQuery.getLimit());
+            LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<>();
+            if(ToolUtil.isNotEmpty(listQuery.getProvinceCode())){
+                wrapper.eq(Competition::getProvinceCode,listQuery.getProvinceCode());
+            }
+            if(ToolUtil.isNotEmpty(listQuery.getCityCode())){
+                wrapper.eq(Competition::getProvinceCode,listQuery.getCityCode());
+            }
+            if(ToolUtil.isNotEmpty(listQuery.getEventName())){
+                wrapper.like(Competition::getName,listQuery.getEventName());
+            }
+            if(ToolUtil.isNotEmpty(listQuery.getState())){
+                wrapper.eq(Competition::getAuditStatus,listQuery.getState());
+            }
+            if(ToolUtil.isNotEmpty(listQuery.getRegisterCondition())){
+                wrapper.eq(Competition::getRegisterCondition,listQuery.getRegisterCondition());
+            }
+            wrapper.in(Competition::getStoreId,listQuery.getIds());
+            ArrayList<Integer> integers = new ArrayList<>();
+            integers.add(1);
+            integers.add(3);
+            wrapper.in(Competition::getAuditStatus,integers);
+            wrapper.orderByDesc(Competition::getInsertTime);
+
+            Page<Competition> page = cttService.page(competitionPage, wrapper);
+            return page;
+        }catch (Exception e){
+            e.printStackTrace();
+            return new Page<Competition>();
+        }
+    }
 
 
     @PostMapping("/base/competition/add")
@@ -486,5 +585,86 @@
         }
     }
 
+
+
+    @PostMapping("/base/competition/queryFee")
+    public Double queryFee(@RequestBody QueryDataFee queryDataFee){
+        HashMap<String, Object> map = new HashMap<>();
+        String data = queryDataFee.getData();
+        List<Integer> ids = queryDataFee.getIds();
+        if(ids.size()==0){
+            ids.add(-1);
+        }
+        LambdaQueryWrapper<PaymentCompetition> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        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.in(PaymentCompetition::getAppUserId,ids);
+        vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getPayStatus,2);
+        ArrayList<Integer> objects = new ArrayList<>();
+        objects.add(1);
+        objects.add(2);
+        vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getPayType,objects);
+        List<PaymentCompetition> list = paymentCompetitionService.list(vipPaymentLambdaQueryWrapper);
+        double sum = list.stream().mapToDouble(PaymentCompetition::getAmount).sum();
+        return sum;
+    }
+
+
+
+    @ResponseBody
+    @PostMapping("/base/competition/actPt")
+    public HashMap<String, Object> actPt(@RequestBody List<Integer> ids){
+        HashMap<String, Object> map = new HashMap<>();
+        if(ids.size()==0){
+            ids.add(-1);
+        }
+        ArrayList<Object> integers = new ArrayList<>();
+        int year = DateUtil.year(new Date());
+
+        for (int i = 0; i < 10; i++) {
+            integers.add(year-i);
+        }
+        List<Object> collect = integers.stream().sorted().collect(Collectors.toList());
+        // 年
+        ArrayList<Integer> years = new ArrayList<>();
+        ArrayList<Integer> yearsUser = new ArrayList<>();
+        for (Object o : collect) {
+            String s = o.toString();
+            int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s));
+            int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime,s));
+            years.add(count);
+            yearsUser.add(count1);
+        }
+        map.put("yearData",years);
+        map.put("yearsUser",yearsUser);
+        // 月
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        ArrayList<Integer> months = new ArrayList<>();
+        ArrayList<Integer> monthsUser = new ArrayList<>();
+        for (int i = 1; i <= 12; i++) {
+            double sum=0.0;
+            String m=i+"";
+            if(i<10){
+                m="0"+i;
+            }
+            String s = year + "-" + m;
+            int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s));
+            int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime,s));
+            months.add(count);
+            monthsUser.add(count1);
+        }
+        map.put("monthData",months);
+        map.put("monthsUser",monthsUser);
+
+        return map;
+
+
+
+    }
+
 }
 

--
Gitblit v1.7.1