From 4d17e9219dfeb41db32e82340ec9af9faedb4ca5 Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期一, 27 十一月 2023 16:06:34 +0800
Subject: [PATCH] 11.27.3

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/TStudentController.java |  288 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 254 insertions(+), 34 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/TStudentController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/TStudentController.java
index 5373667..3e8d1a9 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/TStudentController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/TStudentController.java
@@ -1,13 +1,21 @@
 package com.dsh.guns.modular.system.controller.system;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.dsh.course.dto.*;
+import com.dsh.course.entity.EvaluateStudent;
 import com.dsh.course.feignClient.account.AppUserClient;
+import com.dsh.course.feignClient.account.StudentClient;
 import com.dsh.course.feignClient.account.model.TAppUser;
+import com.dsh.course.feignClient.competition.CompetitionClient;
+import com.dsh.course.feignClient.competition.model.ListQuery;
 import com.dsh.course.feignClient.course.CoursePackageClient;
+import com.dsh.course.feignClient.course.CoursePackagePaymentClient;
 import com.dsh.course.feignClient.course.CourseStuddentClient;
 import com.dsh.course.feignClient.course.model.TCoursePackage;
 import com.dsh.course.feignClient.course.model.TCoursePackagePayment;
+import com.dsh.course.feignClient.other.BallClient;
 import com.dsh.course.feignClient.other.HistoryClient;
 import com.dsh.course.model.MoneyBack;
 import com.dsh.course.model.dto.InsertBackDto;
@@ -16,15 +24,14 @@
 import com.dsh.course.util.HtmlToPdfUtils;
 import com.dsh.guns.config.UserExt;
 import com.dsh.guns.core.base.controller.BaseController;
-import com.dsh.guns.modular.system.model.CourseCounsum;
-import com.dsh.guns.modular.system.model.TStudent;
-import com.dsh.guns.modular.system.model.User;
+import com.dsh.guns.modular.system.model.*;
 import com.dsh.guns.modular.system.model.dto.*;
-import com.dsh.guns.modular.system.service.ITStudentService;
+import com.dsh.guns.modular.system.service.*;
 import com.dsh.guns.modular.system.util.BigDecimalToChineseAmountUtil;
 import com.dsh.guns.modular.system.util.ResultUtil;
 import io.swagger.models.auth.In;
 import org.apache.ibatis.annotations.Param;
+import org.bouncycastle.math.raw.Mod;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpRequest;
 import org.springframework.stereotype.Controller;
@@ -41,10 +48,8 @@
 import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 控制器
@@ -66,7 +71,14 @@
     @Resource
     private HistoryClient historyClient;
 
-
+    @Autowired
+    private IStoreService storeService;
+    @Autowired
+    private CompetitionClient competitionClient;
+    @Autowired
+    private ICityService cityService;
+    @Autowired
+    private CoursePackagePaymentClient coursePackagePaymentClient;
 
     @RequestMapping("download")
     public void down(HttpServletRequest request, HttpServletResponse response) throws IOException {
@@ -104,7 +116,7 @@
      */
     @RequestMapping("/changelist/{payId}")
     @ResponseBody
-    public ResultUtil changelist(@PathVariable("payId") Integer payId, ConsumeQuery consumeQuery) {
+    public ResultUtil changelist(@PathVariable("payId") Long payId, ConsumeQuery consumeQuery) {
         consumeQuery.setPayId(payId);
         System.out.println("=======changelist==========="+consumeQuery);
         List<CourseCounsum> courseCounsums =   courseStuddentClient.queryCounsum(consumeQuery);
@@ -118,7 +130,11 @@
      * 跳转到首页
      */
     @RequestMapping("")
-    public String index() {
+    public String index(Model model) {
+        Integer objectType = UserExt.getUser().getObjectType();
+        model.addAttribute("objectType",objectType);
+        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",list);
         return PREFIX + "tStudent.html";
     }
 
@@ -173,12 +189,11 @@
         model.addAttribute("id", id);
         model.addAttribute("ids", ids);
 
-
         TAppUser tAppUser = appUserClient.queryById(tStudentDto.getAppUserId());
         model.addAttribute("userName",tAppUser.getName());
         model.addAttribute("tStudentDto",tStudentDto);
 
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String formattedDate = dateFormat.format(new Date());
         model.addAttribute("reDate", formattedDate);
 
@@ -194,6 +209,9 @@
             payment.setId(Long.valueOf(tCoursePackage.getId()));
 
             BigDecimal cashPayment = payment.getCashPayment();
+            if (cashPayment==null){
+                cashPayment = BigDecimal.ZERO;
+            }
             Integer totalClassHours = payment.getTotalClassHours();
             BigDecimal result =  new BigDecimal(0);
             if (totalClassHours!=0) {
@@ -242,17 +260,19 @@
         //查询学员信息
         TStudentDto tStudentDto = itStudentService.listOne(tStudentId);
         model.addAttribute("item", tStudentDto);
-        if (tStudentDto.getLateralSurface()!=null) {
+        if (tStudentDto.getLateralSurface()!=null&&!tStudentDto.getLateralSurface().equals("")) {
             String[] pics = tStudentDto.getLateralSurface().split(";");
-            model.addAttribute("pic1", pics[0]);
-            System.out.println("=====pic1==" + pics[0]);
-            if (pics.length > 1) {
-                model.addAttribute("pic2", pics[1]);
-                System.out.println("=====pic2==" + pics[1]);
-            }
-            if (pics.length > 2) {
-                model.addAttribute("pic3", pics[2]);
-                System.out.println("=====pic3==" + pics[2]);
+            if (pics.length>0) {
+                model.addAttribute("pic1", pics[0]);
+                System.out.println("=====pic1==" + pics[0]);
+                if (pics.length > 1) {
+                    model.addAttribute("pic2", pics[1]);
+                    System.out.println("=====pic2==" + pics[1]);
+                }
+                if (pics.length > 2) {
+                    model.addAttribute("pic3", pics[2]);
+                    System.out.println("=====pic3==" + pics[2]);
+                }
             }
         }
 
@@ -274,8 +294,21 @@
         System.out.println("======>t"+tStudentId);
         //查询学员信息
         TStudentDto tStudentDto = itStudentService.listOne(tStudentId);
+        // 查询该学员第一次购买课包的时间
+        String time = coursePackagePaymentClient.getTime(tStudentId);
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            if (time!=null){
+                Date parse = format.parse(time);
+                tStudentDto.setTime(parse);
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+
+
         model.addAttribute("item", tStudentDto);
-        if (tStudentDto.getLateralSurface()!=null) {
+        if (tStudentDto.getLateralSurface()!=null&&!tStudentDto.equals("")) {
             String[] pics = tStudentDto.getLateralSurface().split(";");
             model.addAttribute("pic1", pics[0]);
             System.out.println("=====pic1==" + pics[0]);
@@ -300,6 +333,18 @@
     }
 
 
+    @Autowired
+    private EvaluateStudentService evalstuService;
+
+    @RequestMapping("/tStudent_commite/{tStudentId}")
+    public String tStudent_commite(@PathVariable("tStudentId") Integer tStudentId, Model model) {
+
+        model.addAttribute("id",tStudentId);
+
+        return PREFIX + "tStudent_commite.html";
+    }
+
+
 
 
 //
@@ -317,16 +362,156 @@
         return new ResultUtil<>(0,0,null,map,null);
     }
 
+    @Autowired
+    private ISiteBookingService siteBookingService;
+    @Autowired
+    private BallClient ballClient;
     /**
      * 获取列表
      */
     @RequestMapping("/list")
     @ResponseBody
     public List<TStudentDto> list(StudentSearch search) {
+        List<Integer> ids = new ArrayList<>();
 
+        if(UserExt.getUser().getObjectType()==3){
+            ids = appUserClient.getUserStore(UserExt.getUser().getObjectId());
+            if(ids.size()==0){
+                ids.add(-1);
+            }
+            search.setIds(ids);
+        }
+        if(UserExt.getUser().getObjectType()==2){
+            // 获取运营商下的所有门店id集合
+            List<Integer> storeIds = storeService.list(new QueryWrapper<TStore>()
+                    .eq("operatorId", UserExt.getUser().getObjectId()))
+                    .stream().map(TStore::getId).collect(Collectors.toList());
+            // 根据门店id集合查询 属于该运营商下的门店举办的赛事
+            ListQuery listQuery = new ListQuery();
+            listQuery.setIds(storeIds);
+            // 通过门店ids 获取赛事的支付记录 获取到用户的ids
+            List<Integer> list = competitionClient.getUserIds(listQuery);
+
+            // 获取场地预约记录 拿到用户ids
+            List<Integer> siteUsers = siteBookingService.list(new QueryWrapper<SiteBooking>().in("storeId", storeIds))
+                    .stream().map(SiteBooking::getAppUserId).collect(Collectors.toList());
+            // 获取课程购买记录 拿到用户ids
+            List<Integer> cpUsers = coursePackageClient.getCoursePackageByStoreIds(storeIds);
+            // 获取游戏记录 拿到用户ids
+            List<Integer> gameUsers = ballClient.getGameByStoreIds(storeIds);
+            // 用户ids
+            List<Integer> users = new ArrayList<>();
+            users.addAll(list);
+            users.addAll(siteUsers);
+            users.addAll(cpUsers);
+            users.addAll(gameUsers);
+            // 去重后的用户id
+            List<Integer> collect = users.stream().distinct().collect(Collectors.toList());
+            ids = appUserClient.getUserYYs(UserExt.getUser().getObjectId());
+            ids.addAll(collect);
+            List<Integer> collect1 = ids.stream().distinct().collect(Collectors.toList());
+            if(ids.size()==0){
+                ids.add(-1);
+            }
+            search.setIds(collect1);
+        }
         System.out.println("============学员查询接口=========");
         return itStudentService.listAll(search);
     }
+
+
+
+
+    @Autowired
+    private  EvaluateStudentService evaluateStudentService;
+
+    @Resource
+    private StudentClient studentClient;
+    /**
+     * 获取列表
+     */
+    @RequestMapping("/listcom/{id}")
+    @ResponseBody
+    public List<Map<String,Object>> listcom(@PathVariable("id") Integer id) {
+
+        List<Map<String,Object>> maps =   studentClient.listCom(id);
+
+        return maps;
+    }
+
+
+    @RequestMapping("/addcom/{id}")
+    @ResponseBody
+    public ResultUtil addcom(@PathVariable("id") Integer id,String content,String image) {
+
+        EvaluateStudent evaluateStudent = new EvaluateStudent();
+        evaluateStudent.setStudentId(id);
+        evaluateStudent.setContent(content);
+        evaluateStudent.setImgs(image);
+//        evaluateStudent.setInsertTime(new Date());
+
+        User user = UserExt.getUser();
+        evaluateStudent.setCoachId(user.getId());
+        appUserClient.save(evaluateStudent);
+//        evaluateStudentService.save(evaluateStudent);
+
+
+
+        return new ResultUtil<>(0,0,"保存成功",null,null);
+    }
+
+
+
+    @RequestMapping("/updatecom")
+    @ResponseBody
+    public ResultUtil updatecom(@RequestBody StudentPingYuDTO dto) {
+
+        EvaluateStudent evaluateStudent = new EvaluateStudent();
+        evaluateStudent.setId(dto.getId());
+        evaluateStudent.setContent(dto.getContent());
+        evaluateStudent.setImgs(dto.getImages());
+        appUserClient.save(evaluateStudent);
+
+//        evaluateStudentService.updateById(evaluateStudent);
+
+
+
+        return new ResultUtil<>(0,0,"修改成功",null,null);
+    }
+
+
+    @RequestMapping("/comdel/{id}")
+    @ResponseBody
+    public ResultUtil comdel(@PathVariable("id") Integer id) {
+
+
+        appUserClient.comdel(id);
+
+//        evaluateStudentService.removeById(id);
+
+
+
+        return new ResultUtil<>(0,0,"删除成功",null,null);
+    }
+
+
+    @RequestMapping("/frozen")
+    @ResponseBody
+
+    public ResultUtil forzen(Integer id,Integer state){
+
+            TStudent student = new TStudent();
+            student.setId(id);
+            student.setState(state);
+
+
+            studentClient.frozen(student);
+
+
+            return ResultUtil.success();
+
+    }
+
 
     /**
      * 获取列表
@@ -334,7 +519,16 @@
     @RequestMapping("/classList/{tStudentId}")
     @ResponseBody
     public ResultUtil listClass(@PathVariable("tStudentId") Integer tStudentId) {
+        // 需要过滤体验课
         List<ClassListDto> classListDtos = courseStuddentClient.listClass(tStudentId);
+        for (ClassListDto classListDto : classListDtos) {
+            classListDto.setHasClassHours(classListDto.getTotalClassHours()-classListDto.getLaveClassHours());
+            if (classListDto.getClassType()==2){
+                classListDto.setTotalClassHours(null);
+                classListDto.setHasClassHours(null);
+                classListDto.setLaveClassHours(null);
+            }
+        }
         Map<String,List<ClassListDto>> map = new HashMap<>();
         map.put("items",classListDtos);
         return new ResultUtil<>(0,0,null,map,null);
@@ -360,6 +554,8 @@
         return ResultUtil.success();
     }
 
+//同意退款
+
     @RequestMapping("/changeStatus/{id}")
     @ResponseBody
     public ResultUtil changeStatus(@PathVariable Integer id) {
@@ -375,6 +571,21 @@
         return new ResultUtil<>(0,0,"同意成功",null,null);
     }
 
+    @RequestMapping("/noStatus/{id}")
+    @ResponseBody
+    public ResultUtil noStatus(@PathVariable Integer id) {
+//        InsertBackDto insertBackDto= new InsertBackDto();
+//        insertBackDto.setId(id);
+////        insertBackDto.setIds(ids);
+//        System.out.println("=====insertBackDto========"+insertBackDto);
+
+        courseStuddentClient.noStatus(id);
+        courseStuddentClient.backStausClass(id);
+//        courseStuddentClient.zeroClass(id);
+
+        System.out.println("============学员查询接口=========");
+        return new ResultUtil<>(0,0,"同意成功",null,null);
+    }
 
     /**
      * 学员修改
@@ -430,7 +641,7 @@
         historyClient.createHistory(historyDto);
 
 
-        return ResultUtil.success();
+        return new ResultUtil<>(0,0,"更改成功",null,null);
 
     }
 
@@ -453,7 +664,7 @@
      */
     @RequestMapping(value = "/getUserSlect/{id}")
     @ResponseBody
-    public ResultUtil getUserSlect(@PathVariable("id") Integer payId) {
+    public ResultUtil getUserSlect(@PathVariable("id") Long payId) {
 
        List<SelectDto>  selectDtos =  courseStuddentClient.getSelect(payId);
         Map<String,List<SelectDto>> map = new HashMap<>();
@@ -466,7 +677,7 @@
      */
     @RequestMapping(value = "/toClass")
     @ResponseBody
-    public ResultUtil toClass( Integer id,Integer toStudentId) {
+    public ResultUtil toClass( Long id,Integer toStudentId) {
         ToClassDto toClassDto = new ToClassDto();
         toClassDto.setToStudentId(toStudentId);
         toClassDto.setId(id);
@@ -486,7 +697,16 @@
     public ResultUtil giftSelect(GiftSearchDto giftSearchDto) {
 
         List<SelectDto>  selectDtos =  appUserClient.giftSelect(giftSearchDto);
+        // 只查询当前用户下 同时也报名了该课程的学员
+        for (SelectDto selectDto : selectDtos) {
+            // 获取课包id
+            TCoursePackagePayment tCoursePackagePayment = coursePackagePaymentClient.queryCoursePackagePaymentById(giftSearchDto.getId());
 
+            Integer coursePackageId = tCoursePackagePayment.getCoursePackageId();
+            // 学员id 拿到学员id 判断当前学员是否报名了这门课程
+            Long id = selectDto.getId();
+            //
+        }
         Map<String,List<SelectDto>> map = new HashMap<>();
         map.put("options",selectDtos);
 //        Map<String,List<SelectDto>> map = new HashMap<>();
@@ -536,10 +756,11 @@
         System.out.println("========ToHoliDto========="+resultUtil);
 
 
-        if (resultUtil==""){
+        if (resultUtil==""||resultUtil==null){
             return new ResultUtil<>(0,0,"报名成功");
-        }else
-        return new ResultUtil<>(0,0,"报名成功,以下学员剩余课时不足"+resultUtil);
+        }else{
+        return new ResultUtil<>(0,0,"报名成功,以下学员剩余课时不足"+resultUtil);}
+
     }
 
 
@@ -562,19 +783,18 @@
 
         if (resultUtil==""){
             return new ResultUtil<>(0,0,"报名成功");
-        }else
-            return new ResultUtil<>(0,0,"报名成功,以下学员剩余课时不足"+resultUtil);
+        }else{
+            return new ResultUtil<>(0,0,"报名成功,以下学员剩余课时不足"+resultUtil);}
     }
 
     //赠课
 
     @RequestMapping(value = "/giftTo")
     @ResponseBody
-    public ResultUtil toClagiftToss( Integer id,Integer toStudentId) {
+    public ResultUtil toClagiftToss( Long id,Integer toStudentId) {
         ToClassDto toClassDto = new ToClassDto();
         toClassDto.setToStudentId(toStudentId);
         toClassDto.setId(id);
-
         courseStuddentClient.toClass(toClassDto);
 
 //        Map<String,List<SelectDto>> map = new HashMap<>();

--
Gitblit v1.7.1