nickchange
2023-11-29 d4fbea2ac7f7c98ffd83480f8f2535ca92f3baea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
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;
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.*;
import com.dsh.guns.modular.system.model.dto.*;
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;
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.*;
import java.util.stream.Collectors;
 
/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2023-09-12 14:51:26
 */
@Controller
@RequestMapping("/tStudent")
public class TStudentController extends BaseController {
 
    private String PREFIX = "/system/tStudent/";
    @Autowired
    private ITStudentService itStudentService;
 
    @Resource
    private CourseStuddentClient courseStuddentClient;
 
    @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 {
        // 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(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";
    }
 
    @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";
    }
 
 
    /**
     * 跳转到添加
     */
    @RequestMapping("/tStudent_add")
    public String tStudentAdd() {
        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 HH:mm:ss");
        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";
    }
    /**
     * 跳转到修改
     */
    @RequestMapping("/tStudent_update/{tStudentId}")
    public String tStudentUpdate(@PathVariable("tStudentId") Integer tStudentId, Model model) {
 
 
        System.out.println("======>t"+tStudentId);
        //查询学员信息
        TStudentDto tStudentDto = itStudentService.listOne(tStudentId);
        model.addAttribute("item", tStudentDto);
        if (tStudentDto.getLateralSurface()!=null&&!tStudentDto.getLateralSurface().equals("")) {
            String[] pics = tStudentDto.getLateralSurface().split(";");
            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]);
                }
            }
        }
 
 
        //查询课时信息
       StudentClassInfo studentClassInfo = courseStuddentClient.getInfo(tStudentId);
        model.addAttribute("studentClassInfo", studentClassInfo);
 
        //查询课程列表
        List<ClassListDto> classListDtos = courseStuddentClient.listClass(tStudentId);
        model.addAttribute("classListDtos", classListDtos);
 
 
        return PREFIX + "tStudentEdit_first.html";
    }
 
    @RequestMapping("/tStudent_info/{tStudentId}")
    public String tStudentInfo(@PathVariable("tStudentId") Integer tStudentId, Model model) {
        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&&!tStudentDto.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]);
//            }
            model.addAttribute("images",tStudentDto.getLateralSurface());
        }
 
 
        //查询课时信息
        StudentClassInfo studentClassInfo = courseStuddentClient.getInfo(tStudentId);
        model.addAttribute("studentClassInfo", studentClassInfo);
 
 
        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";
    }
 
 
 
 
//
 
    /**
     * 获取有效期
     */
    @RequestMapping("/getUseTime/{tStudentId}")
    @ResponseBody
    public ResultUtil getMax(@PathVariable("tStudentId") Integer tStudentId) {
        Date vali = studentClient.getById(tStudentId);
 
//        Date useTime = courseStuddentClient.getUseTime(tStudentId);
        Map<String, Date> map = new HashMap<>();
        map.put("useTime",vali);
 
        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();
 
    }
 
 
    /**
     * 获取列表
     */
    @RequestMapping("/classList/{tStudentId}")
    @ResponseBody
    public ResultUtil listClass(@PathVariable("tStudentId") Integer tStudentId) {
        // 需要过滤体验课
        List<ClassListDto> classListDtos = courseStuddentClient.listClass(tStudentId);
        for (ClassListDto classListDto : classListDtos) {
            if (classListDto.getClassType()==2){
                classListDto.setTotalClassHours(null);
                classListDto.setHasClassHours(null);
                classListDto.setLaveClassHours(null);
                continue;
            }
            classListDto.setHasClassHours(classListDto.getTotalClassHours()-classListDto.getLaveClassHours());
 
        }
        Map<String,List<ClassListDto>> map = new HashMap<>();
        map.put("items",classListDtos);
        return new ResultUtil<>(0,0,null,map,null);
    }
 
 
 
 
//保存退款记录
    @RequestMapping("/ttt")
    @ResponseBody
    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.noStatus(id);
        courseStuddentClient.backStausClass(id);
//        courseStuddentClient.zeroClass(id);
 
        System.out.println("============学员查询接口=========");
        return new ResultUtil<>(0,0,"同意成功",null,null);
    }
 
    /**
     * 学员修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
 
    public ResultUtil update(@RequestBody TStudent tStudent) {
        List<String> strings = new ArrayList<>();
        if (!tStudent.getImage1().isEmpty()){
            strings.add(tStudent.getImage1());
        }
        if (!tStudent.getImage2().isEmpty()){
            strings.add(tStudent.getImage2());
        }
        if (!tStudent.getImage3().isEmpty()){
            strings.add(tStudent.getImage3());
        }
        String result = String.join(";", strings);
 
 
//
//        String lateralSurface = tStudent.getImage1()+";"+tStudent.getImage2()+";"+tStudent.getImage3();
//
//        System.out.println("=======lateralSurface======>?"+lateralSurface);
        tStudent.setLateralSurface(result);
        System.out.println("学员体测表的值"+result);
        itStudentService.update(tStudent);
//        appUserClient.updateStudent(tStudent);
        return new ResultUtil(0,0,"编辑成功");
    }
 
    @Resource
    private AppUserClient appUserClient;
    /**
     * 学员详情修改有效期
     */
 
    @RequestMapping("/updateClassTime")
    @ResponseBody
    public ResultUtil updateClassTime(@RequestParam("date") String date, @RequestParam("id")Integer id, String passPic, String pleasePic ){
 
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date1;
        try {
            date1 = dateFormat.parse(date);
        } catch (ParseException e) {
            // 处理日期转换异常
            e.printStackTrace();
            return ResultUtil.error("日期格式错误");
        }
 
 
        updateTimeDto updateTimeDto =new updateTimeDto(date1,id);
        System.out.println("======updateTimeDto=====>"+updateTimeDto);
//        courseStuddentClient.updateUseDate(updateTimeDto);
 
        studentClient.update(updateTimeDto);
 
 
        CreateHistoryDto historyDto = new CreateHistoryDto();
        historyDto.setPleasePic(pleasePic);
        historyDto.setPassPic(passPic);
        User user = UserExt.getUser();
        historyDto.setCreateBy(user.getId());
        historyDto.setStudentId(id);
 
//        appUserClient.createHistory(historyDto);
        historyClient.createHistory(historyDto);
 
 
        return new ResultUtil<>(0,0,"更改成功",null,null);
 
    }
 
 
    /**
     * 查询有效期记录
     */
    @RequestMapping(value = "/getHisory/{id}")
    @ResponseBody
    public ResultUtil getHisory(@PathVariable("id") Integer studentId) {
       List<GetHistoryDto> getHistoryDtos =  historyClient.getHisory(studentId);
        Map<String,List<GetHistoryDto>> map = new HashMap<>();
        map.put("items",getHistoryDtos);
 
        return new ResultUtil(0,0,"编辑成功",map,"");
    }
 
    /**
     * 查询有效期记录
     */
    @RequestMapping(value = "/getUserSlect/{id}")
    @ResponseBody
    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);
        return new ResultUtil(0,0,"编辑成功",1,"");
    }
 
    /**
     * 赠送课时下拉框
     */
    @RequestMapping(value = "/giftSelect")
    @ResponseBody
    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<>();
//        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,"");
    }
 
}