From ddbb38c54db9c3670e5ff53f4bf713525de1099d Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期二, 14 十一月 2023 09:12:10 +0800
Subject: [PATCH] 后台bug修改

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/TStudentController.java |  526 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 511 insertions(+), 15 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 47961f2..004fad5 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,32 +1,56 @@
 package com.dsh.guns.modular.system.controller.system;
 
 
+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.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;
 import com.dsh.course.model.dto.StudentClassInfo;
+import com.dsh.course.util.ChineseMoneyUtils;
+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.TStudent;
-import com.dsh.guns.modular.system.model.User;
-import com.dsh.guns.modular.system.model.dto.SelectDto;
+import com.dsh.guns.modular.system.model.*;
+import com.dsh.guns.modular.system.model.dto.*;
+import com.dsh.guns.modular.system.service.EvaluateStudentService;
+import com.dsh.guns.modular.system.service.ISiteBookingService;
+import com.dsh.guns.modular.system.service.IStoreService;
 import com.dsh.guns.modular.system.service.ITStudentService;
+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;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigDecimal;
+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;
 
 /**
  * 控制器
@@ -48,18 +72,82 @@
     @Resource
     private HistoryClient historyClient;
 
+    @Autowired
+    private IStoreService storeService;
+    @Autowired
+    private CompetitionClient competitionClient;
 
+    @RequestMapping("download")
+    public void down(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        // Get the InputStream from a file or any other source
+        InputStream inputStream = request.getInputStream(); // Obtain the InputStream
 
+        // Set the content type of the response
+        response.setContentType("application/octet-stream");
 
+        // Set the headers for file download
+        response.setHeader("Content-Disposition", "attachment; filename=\"filename.extension\"");
 
+        // Get the OutputStream from the response
+        OutputStream outputStream = response.getOutputStream();
+
+        // Copy the data from InputStream to OutputStream
+        byte[] buffer = new byte[1024];
+        int bytesRead;
+        while ((bytesRead = inputStream.read(buffer)) != -1) {
+            outputStream.write(buffer, 0, bytesRead);
+        }
+
+        HtmlToPdfUtils.convertToPdf(inputStream,null,outputStream);
+
+        // Close the streams
+        inputStream.close();
+        outputStream.close();
+    }
+
+    /**
+     * 获取变更列表
+     */
+    /**
+     * 获取有效期
+     */
+    @RequestMapping("/changelist/{payId}")
+    @ResponseBody
+    public ResultUtil changelist(@PathVariable("payId") Long payId, ConsumeQuery consumeQuery) {
+        consumeQuery.setPayId(payId);
+        System.out.println("=======changelist==========="+consumeQuery);
+        List<CourseCounsum> courseCounsums =   courseStuddentClient.queryCounsum(consumeQuery);
+        Map<String,List<CourseCounsum>> map = new HashMap<>();
+        map.put("items",courseCounsums);
+
+        return new ResultUtil<>(0,0,null,map,null);
+    }
 
     /**
      * 跳转到首页
      */
     @RequestMapping("")
-    public String index() {
+    public String index(Model model) {
+        Integer objectType = UserExt.getUser().getObjectType();
+        model.addAttribute("objectType",objectType);
         return PREFIX + "tStudent.html";
     }
+
+    @RequestMapping("TTT")
+    public String index1() {
+        return PREFIX + "tStudentEditTTT.html";
+    }
+
+    @RequestMapping("openAddCoursePackage")
+    public String index3() {
+        return PREFIX + "classelct.html";
+    }
+
+    @RequestMapping("trans")
+    public String index2() {
+        return PREFIX + "trans.html";
+    }
+
 
     /**
      * 跳转到添加
@@ -69,6 +157,93 @@
         return PREFIX + "tStudent_add.html";
     }
 
+    @Resource
+    private CoursePackageClient coursePackageClient;
+
+
+    /**
+     * 获取有效期
+     */
+    @RequestMapping("/getBackList/{tStudentId}")
+    @ResponseBody
+    public ResultUtil getBackList(@PathVariable("tStudentId") Integer tStudentId) {
+
+        List<MoneyBack> moneyBacks  = courseStuddentClient.getMoneyBack(tStudentId);
+        Map<String, List<MoneyBack>> map = new HashMap<>();
+        map.put("items",moneyBacks);
+
+        return new ResultUtil<>(0,0,null,map,null);
+    }
+    /**
+     * 跳转到退款
+     */
+    @RequestMapping("/backmoney")
+    public String backmoney(Integer id,String ids,Model model) {
+
+        TStudentDto tStudentDto = appUserClient.queryOneWebUser(id);
+        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");
+        String formattedDate = dateFormat.format(new Date());
+        model.addAttribute("reDate", formattedDate);
+
+        List<TCoursePackagePayment> coursePackagePayments =  courseStuddentClient.queryByIds(ids);
+
+        BigDecimal countAll = new BigDecimal(0);
+
+        for (TCoursePackagePayment payment : coursePackagePayments){
+
+            //课包名称
+            TCoursePackage tCoursePackage = coursePackageClient.queryById(payment.getCoursePackageId());
+            payment.setName(tCoursePackage.getName());
+            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) {
+                result = cashPayment.divide(BigDecimal.valueOf(totalClassHours), 2, RoundingMode.HALF_UP);
+            }
+
+
+
+            //单价
+            payment.setOnePrice(result);
+
+            int has = payment.getTotalClassHours() - payment.getLaveClassHours();
+            //剩余课时
+            payment.setHasHours(has);
+
+
+            BigDecimal onePrice = payment.getOnePrice();
+            Integer laveClassHours = payment.getLaveClassHours();
+            BigDecimal result1 = onePrice.multiply(BigDecimal.valueOf(laveClassHours));
+            //总价
+            payment.setRestPrice(result1);
+            System.out.println("======="+result1);
+            countAll = countAll.add(result1);
+
+        }
+        //中文总价
+//        String allprice = BigDecimalToChineseAmountUtil.convertToChineseAmount(countAll);
+        String allprice = ChineseMoneyUtils.toChineseMoney(countAll);
+        model.addAttribute("countAll", countAll);
+        model.addAttribute("allprice", allprice);
+        model.addAttribute("coursePackagePayments", coursePackagePayments);
+
+        model.addAttribute("index",1);
+
+        System.out.println("=====ids========"+ids);
+        return PREFIX + "banckmoney.html";
+    }
     /**
      * 跳转到修改
      */
@@ -88,7 +263,7 @@
                 model.addAttribute("pic2", pics[1]);
                 System.out.println("=====pic2==" + pics[1]);
             }
-            if (pics.length > 3) {
+            if (pics.length > 2) {
                 model.addAttribute("pic3", pics[2]);
                 System.out.println("=====pic3==" + pics[2]);
             }
@@ -121,7 +296,7 @@
                 model.addAttribute("pic2", pics[1]);
                 System.out.println("=====pic2==" + pics[1]);
             }
-            if (pics.length > 3) {
+            if (pics.length > 2) {
                 model.addAttribute("pic3", pics[2]);
                 System.out.println("=====pic3==" + pics[2]);
             }
@@ -135,6 +310,18 @@
 
         System.out.println("=======controller====studentClassInfo==="+studentClassInfo);
         return PREFIX + "tStudentEdit.html";
+    }
+
+
+    @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";
     }
 
 
@@ -155,16 +342,157 @@
         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());
+
+
+        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();
+
+    }
+
 
     /**
      * 获取列表
@@ -180,12 +508,55 @@
 
 
 
+
+//保存退款记录
     @RequestMapping("/ttt")
     @ResponseBody
-    public ResultUtil list1(StudentSearch search) {
+    public ResultUtil list1(Integer id, String ids) {
+        InsertBackDto insertBackDto= new InsertBackDto();
+        insertBackDto.setId(id);
+        insertBackDto.setIds(ids);
+        System.out.println("=====insertBackDto========"+insertBackDto);
 
+        courseStuddentClient.insertBack(insertBackDto);
+
+        //取消排课
+        courseStuddentClient.cancel(ids);
         System.out.println("============学员查询接口=========");
         return ResultUtil.success();
+    }
+
+//同意退款
+
+    @RequestMapping("/changeStatus/{id}")
+    @ResponseBody
+    public ResultUtil changeStatus(@PathVariable Integer id) {
+//        InsertBackDto insertBackDto= new InsertBackDto();
+//        insertBackDto.setId(id);
+////        insertBackDto.setIds(ids);
+//        System.out.println("=====insertBackDto========"+insertBackDto);
+
+        courseStuddentClient.changeStatus(id);
+        courseStuddentClient.zeroClass(id);
+
+        System.out.println("============学员查询接口=========");
+        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.changeStatus(id);
+        courseStuddentClient.backStausClass(id);
+//        courseStuddentClient.zeroClass(id);
+
+        System.out.println("============学员查询接口=========");
+        return new ResultUtil<>(0,0,"同意成功",null,null);
     }
 
     /**
@@ -194,8 +565,10 @@
     @RequestMapping(value = "/update")
     @ResponseBody
 
-    public ResultUtil update(@RequestBody TStudent tStudent, String image1, String image2, String image3 ) {
-        String lateralSurface = image1+";"+image2+";"+image3;
+    public ResultUtil update(@RequestBody TStudent tStudent) {
+        String lateralSurface = tStudent.getImage1()+";"+tStudent.getImage2()+";"+tStudent.getImage3();
+
+        System.out.println("=======lateralSurface======>?"+lateralSurface);
         tStudent.setLateralSurface(lateralSurface);
         System.out.println("学员体测表的值"+lateralSurface);
         itStudentService.update(tStudent);
@@ -240,7 +613,7 @@
         historyClient.createHistory(historyDto);
 
 
-        return ResultUtil.success();
+        return new ResultUtil<>(0,0,"更改成功",null,null);
 
     }
 
@@ -263,11 +636,134 @@
      */
     @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<>();
         map.put("options",selectDtos);
         return new ResultUtil(0,0,"编辑成功",map,"");
     }
+
+    /**
+     * 学员转移课程
+     */
+    @RequestMapping(value = "/toClass")
+    @ResponseBody
+    public ResultUtil toClass( Long id,Integer toStudentId) {
+        ToClassDto toClassDto = new ToClassDto();
+        toClassDto.setToStudentId(toStudentId);
+        toClassDto.setId(id);
+
+        courseStuddentClient.toClass(toClassDto);
+
+//        Map<String,List<SelectDto>> map = new HashMap<>();
+//        map.put("options",selectDtos);
+        return new ResultUtil(0,0,"编辑成功",1,"");
+    }
+
+    /**
+     * 赠送课时下拉框
+     */
+    @RequestMapping(value = "/giftSelect")
+    @ResponseBody
+    public ResultUtil giftSelect(GiftSearchDto giftSearchDto) {
+
+        List<SelectDto>  selectDtos =  appUserClient.giftSelect(giftSearchDto);
+
+        Map<String,List<SelectDto>> map = new HashMap<>();
+        map.put("options",selectDtos);
+//        Map<String,List<SelectDto>> map = new HashMap<>();
+//        map.put("options",selectDtos);
+        return new ResultUtil(0,0,"编辑成功",map,"");
+    }
+
+
+    //获取可报名假期课程下拉框
+    @RequestMapping(value = "/getholi/{id}")
+    @ResponseBody
+    public ResultUtil giftSelect(@PathVariable("id") Integer id) {
+        List<SelectDto>  selectDtos =  courseStuddentClient.getGiftSelect(id);
+
+        Map<String,List<SelectDto>> map = new HashMap<>();
+        map.put("options",selectDtos);
+
+        return new ResultUtil(0,0,"编辑成功",map,"");
+    }
+
+    //获取可转换常规课程下拉框
+    @RequestMapping(value = "/gettrans/{id}")
+    @ResponseBody
+    public ResultUtil gettrans(@PathVariable("id") Integer id) {
+        List<SelectDto>  selectDtos =  courseStuddentClient.getTransSelect(id);
+
+        Map<String,List<SelectDto>> map = new HashMap<>();
+        map.put("options",selectDtos);
+
+        return new ResultUtil(0,0,"编辑成功",map,"");
+    }
+    //消耗时长可报名假期课程
+    @RequestMapping(value = "/Toholi")
+    @ResponseBody
+    public ResultUtil Toholi(Integer id,String ids,Integer holiId,Integer classNum) {
+
+        String[] stringArray = ids.split(",");
+
+        ToHoliDto toHoliDto  = new ToHoliDto();
+        toHoliDto.setId(id);
+        toHoliDto.setIds(stringArray);
+        toHoliDto.setClassNum(classNum);
+        toHoliDto.setClassId(holiId);
+
+
+        String resultUtil = courseStuddentClient.toHoli(toHoliDto);
+        System.out.println("========ToHoliDto========="+resultUtil);
+
+
+        if (resultUtil==""||resultUtil==null){
+            return new ResultUtil<>(0,0,"报名成功");
+        }else{
+        return new ResultUtil<>(0,0,"报名成功,以下学员剩余课时不足"+resultUtil);}
+
+    }
+
+
+    @RequestMapping(value = "/ToTrans")
+    @ResponseBody
+    public ResultUtil Totans(Integer id,String ids,Integer holiId,Integer classNum) {
+
+        String[] stringArray = ids.split(",");
+
+        ToHoliDto toHoliDto  = new ToHoliDto();
+        toHoliDto.setId(id);
+        toHoliDto.setIds(stringArray);
+        toHoliDto.setClassNum(classNum);
+        toHoliDto.setClassId(holiId);
+
+
+        String resultUtil = courseStuddentClient.toTrans(toHoliDto);
+        System.out.println("========ToHoliDto========="+resultUtil);
+
+
+        if (resultUtil==""){
+            return new ResultUtil<>(0,0,"报名成功");
+        }else{
+            return new ResultUtil<>(0,0,"报名成功,以下学员剩余课时不足"+resultUtil);}
+    }
+
+    //赠课
+
+    @RequestMapping(value = "/giftTo")
+    @ResponseBody
+    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<>();
+//        map.put("options",selectDtos);
+        return new ResultUtil(0,0,"编辑成功",1,"");
+    }
+
 }

--
Gitblit v1.7.1