puzhibing
2023-12-04 3ad6b6ba2ba56fc0bcd2130e47190779c6e15acc
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
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
package com.dsh.guns.modular.system.controller.code;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.course.feignClient.account.CityManagerClient;
import com.dsh.course.feignClient.account.CoachClient;
import com.dsh.course.feignClient.account.model.CityManager;
import com.dsh.course.feignClient.account.model.Coach;
import com.dsh.course.feignClient.account.model.CoachSerchVO;
import com.dsh.course.feignClient.course.*;
import com.dsh.course.feignClient.course.model.*;
import com.dsh.course.feignClient.other.model.Site;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.core.util.ToolUtil;
import com.dsh.guns.modular.system.model.*;
import com.dsh.guns.modular.system.model.dto.SelectDto;
import com.dsh.guns.modular.system.service.*;
import com.dsh.guns.modular.system.util.ResultUtil;
import io.swagger.models.auth.In;
import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @author zhibing.pu
 * @Date 2023/8/1 11:50
 */
@Controller
@RequestMapping("/coursePackage")
public class TCoursePackageController extends BaseController {
 
    private String PREFIX = "/system/coursePackage/";
 
    @Autowired
    private ICoursePackageService coursePackageService;
 
    @Resource
    private CoursePackageTypeClient coursePackageTypeClient;
 
    @Autowired
    private IStoreService storeService;
 
    @Resource
    private CityManagerClient cityManagerClient;
 
    @Autowired
    private ITSiteService siteService;
 
    @Resource
    private CoachClient coachClient;
 
    @Resource
    private CoursePackagePaymentConfigClient coursePackagePaymentConfigClient;
 
    @Resource
    private CoursePackageDiscountClient coursePackageDiscountClient;
 
    @Resource
    private CoursePackageClient coursePackageClient;
 
    @Autowired
    private TOperatorService tOperatorService;
    @Autowired
    private TOperatorCityService tOperatorCityService;
 
 
    /**
     * 根据门店获取课程
     */
    @ResponseBody
    @RequestMapping("/getCoursePackageByStoreId")
    public List<TCoursePackageType> getCoursePackageByStoreId(Integer storeId){
        List<TCoursePackage> list = coursePackageClient.getCoursePackageByStoreId(storeId);
        List<Integer> ids = new ArrayList<>();
        for (TCoursePackage tCoursePackage : list) {
            ids.add(tCoursePackage.getCoursePackageTypeId());
        }
        return coursePackageTypeClient.getByCourseIds(ids);
    }
    /**
     * 根据课包类型获取课包
     */
    @ResponseBody
    @RequestMapping("/getCoursePackageByType")
    public List<TCoursePackage> getCoursePackageByType(Integer storeId,Integer typeId){
        return coursePackageClient.getCoursePackageByType(typeId,storeId);
    }
    /**
     * 跳转到列表页
     * @param model
     * @return
     */
    @GetMapping("/openCoursePackageListPage")
    public String openCoursePackageListPage(Model model){
        Integer objectType = UserExt.getUser().getObjectType();
        Integer objectId = UserExt.getUser().getObjectId();
        List<TCoursePackageType> tCoursePackageTypes = coursePackageTypeClient.queryAllCoursePackageType();
        model.addAttribute("coursePackageType", tCoursePackageTypes);
        String cityCode = null;
        if(objectType == 2){//城市管理员
            CityManager cityManager = cityManagerClient.queryCityManagerById(objectId);
            if (cityManager!=null){
                cityCode = cityManager.getCityCode();
            }
        }
        List<Map<String, Object>> list = storeService.queryProvince(cityCode);
        model.addAttribute("province", list);
        model.addAttribute("objectType", objectType);
        return PREFIX + "coursePackage.html";
    }
 
 
    /**
     * 跳转到添加页
     * @param model
     * @return
     */
    @Autowired
    private ICityService cityService;
    @GetMapping("/openAddCoursePackage")
    public String openAddCoursePackage(Model model,Integer type){
        Integer objectType = UserExt.getUser().getObjectType();
        Integer objectId = UserExt.getUser().getObjectId();
        List<TCoursePackageType> tCoursePackageTypes = coursePackageTypeClient.queryAllCoursePackageType();
        model.addAttribute("coursePackageType", tCoursePackageTypes);
        String cityCode = "";
        if(objectType == 2){//城市管理员
            // 获取到这个运营商下面的所有门店
            List<TStore> operatorId = storeService.list(new QueryWrapper<TStore>().eq("operatorId",objectId));
            model.addAttribute("store", operatorId);
            List<Coach> coach = coachClient.queryCoachByOperatorId(objectId);
            model.addAttribute("coach", coach);
            // 如果该运营商下面没有门店
            if (operatorId.size()==0){
                List<TStore> o = new ArrayList<>();
                List<TSite> tSites = new ArrayList<>();
                model.addAttribute("store", o);
                model.addAttribute("site", tSites);
            }else{
                List<TSite> storeId = siteService.list(new QueryWrapper<TSite>()
                        .eq("storeId", operatorId.get(0).getId()));
                model.addAttribute("site", storeId);
            }
        }else{
            List<Map<String, Object>> list = storeService.queryProvince(cityCode);
            model.addAttribute("province", list);
            Object code = list.get(0).get("code");
            List<Map<String, Object>> list1 = storeService.queryCity(code.toString(), cityCode);
            model.addAttribute("city", list1);
            String code1 = list1.get(0).get("code").toString();
            List<TStore> list2 = storeService.list(new QueryWrapper<TStore>().eq("cityCode", code1).eq("state", 1));
            model.addAttribute("store", list2);
            TStore store = list2.get(0);
            List<TSite> list3 = siteService.list(new QueryWrapper<TSite>().eq("storeId", store.getId()).eq("state", 1));
            model.addAttribute("site", list3);
 
 
            List<Coach> coaches = coachClient.queryCoachByOperatorId(objectId);
            model.addAttribute("coach", coaches);
            System.out.println("========type========"+type);
        }
        model.addAttribute("objectType",objectType);
        model.addAttribute("type",type);
//        if (type ==1){
//            return PREFIX + "coursePackage_edit.html";
//        }
        return PREFIX + "coursePackage_add.html";
    }
 
 
    /**
     * 跳转到编辑页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/openEditCoursePackage")
    public String openEditCoursePackage(Model model, Integer id){
        TCoursePackage tCoursePackage = coursePackageService.queryById(id);
        model.addAttribute("item", tCoursePackage);
        model.addAttribute("type", tCoursePackage.getType());
 
        Integer objectType = UserExt.getUser().getObjectType();
        model.addAttribute("objectType",objectType);
 
        String classStartTime = tCoursePackage.getClassStartTime();
        String classEndTime = tCoursePackage.getClassEndTime();
 
        if (tCoursePackage.getStartTime()!=null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String dateString = sdf.format(tCoursePackage.getStartTime());
            String dateString1 = sdf.format(tCoursePackage.getEndTime());
            model.addAttribute("holi", dateString + " - " + dateString1);
        }
        String[] split1 = classStartTime.split(",");
        String[] split2 = classEndTime.split(",");
 
        List<String> listtime = new ArrayList<>();
 
        for (int i = 0; i < split1.length; i++) {
            String o = split1[i]+"-"+split2[i];
            listtime.add(o);
        }
 
 
        model.addAttribute("time1",listtime.remove(0));
        if (listtime.size()!=0) {
            model.addAttribute("times", listtime);
        }
 
 
 
 
        model.addAttribute("classTime", tCoursePackage.getClassStartTime() + ":00 - " + tCoursePackage.getClassEndTime() + ":00");
        String[] split = tCoursePackage.getClassWeeks().split(";");
        List<String> list5 = Arrays.asList("周一", "周二", "周三", "周四", "周五", "周六", "周日");
        List<Map<String, Object>> classWeeks = new ArrayList<>();
        for (String s : list5) {
            Map<String, Object> map = new HashMap<>();
            map.put("value", s);
            map.put("checked", false);
            for (String s1 : split) {
                if(s.equals(s1)){
                    map.put("checked", true);
                }
            }
            classWeeks.add(map);
        }
        model.addAttribute("classWeeks", classWeeks);
        List<TCoursePackageType> tCoursePackageTypes = coursePackageTypeClient.queryAllCoursePackageType();
        model.addAttribute("coursePackageType", tCoursePackageTypes);
        String cityCode = tCoursePackage.getCityCode();
        String provinceCode = tCoursePackage.getProvinceCode();
        List<Map<String, Object>> list = storeService.queryProvince(cityCode);
        model.addAttribute("province", list);
        List<Map<String, Object>> list1 = storeService.queryCity(provinceCode, cityCode);
        model.addAttribute("city", list1);
        List<TStore> list2 = storeService.list(new QueryWrapper<TStore>().eq("cityCode", cityCode).eq("state", 1));
        model.addAttribute("store", list2);
        List<TSite> list3 = siteService.list(new QueryWrapper<TSite>().eq("storeId", tCoursePackage.getStoreId()).eq("state", 1));
        model.addAttribute("site", list3);
        if (UserExt.getUser().getObjectType() == 2){
            List<Coach> coaches = coachClient.queryCoachByOperatorId(UserExt.getUser().getObjectId());
            model.addAttribute("coach", coaches);
        }else{
            CoachQuery coachQuery = new CoachQuery();
            coachQuery.setProvince(tCoursePackage.getProvince());
            coachQuery.setCity(tCoursePackage.getCity());
            List<CoachSerchVO> coachSerchVOS = coachClient.listAll(coachQuery);
            model.addAttribute("coach",coachSerchVOS);
        }
 
 
        List<CoursePackagePaymentConfig> list4 = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
 
 
        System.out.println("========couponIds=========>"+list4.get(0).getCouponIds());
 
        model.addAttribute("cashPayment", list4.get(0).getCashPayment() == 0 ? false : true);
        model.addAttribute("playPaiCoin", list4.get(0).getPlayPaiCoin() == 0 ? false : true);
 
        model.addAttribute("couponIds", list4.get(0).getCouponIds());
        model.addAttribute("coursePackagePaymentConfig", list4.remove(0));
        for (int i = 0; i < list4.size(); i++) {
            list4.get(i).setId(i+2);
        }
 
        model.addAttribute("coursePackagePaymentConfigs", list4);
        model.addAttribute("index", 1);
                if (list4.size()!=0) {
        CoursePackagePaymentConfig coursePackagePaymentConfig = list4.get(0);
 
            model.addAttribute("cashPayment", coursePackagePaymentConfig.getCashPayment() == 0 ? false : true);
            model.addAttribute("playPaiCoin", coursePackagePaymentConfig.getPlayPaiCoin() == 0 ? false : true);
            System.out.println("=========coursePackagePaymentConfig=============>" + coursePackagePaymentConfig);
//        model.addAttribute("couponIds", "3,2");
        }
 
 
           Integer able  =  coursePackageClient.queryAble(id);
 
        model.addAttribute("able",able);
 
        return PREFIX + "coursePackage_edit.html";
    }
 
 
    /**
     * 跳转详情页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/showCoursePackageDetails")
    public String showCoursePackageDetails(Model model, Integer id){
        TCoursePackage tCoursePackage = coursePackageService.queryById(id);
        model.addAttribute("item", tCoursePackage);
        model.addAttribute("type", tCoursePackage.getType());
 
        String classStartTime = tCoursePackage.getClassStartTime();
        String classEndTime = tCoursePackage.getClassEndTime();
 
        if (tCoursePackage.getStartTime()!=null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String dateString = sdf.format(tCoursePackage.getStartTime());
            String dateString1 = sdf.format(tCoursePackage.getEndTime());
            model.addAttribute("holi", dateString + " - " + dateString1);
        }
        String[] split1 = classStartTime.split(",");
        String[] split2 = classEndTime.split(",");
 
        List<String> listtime = new ArrayList<>();
 
        for (int i = 0; i < split1.length; i++) {
            String o = split1[i]+"-"+split2[i];
            listtime.add(o);
        }
 
 
        model.addAttribute("time1",listtime.remove(0));
        if (listtime.size()!=0) {
            model.addAttribute("times", listtime);
        }
 
 
 
 
        model.addAttribute("classTime", tCoursePackage.getClassStartTime() + ":00 - " + tCoursePackage.getClassEndTime() + ":00");
        String[] split = tCoursePackage.getClassWeeks().split(";");
        List<String> list5 = Arrays.asList("周一", "周二", "周三", "周四", "周五", "周六", "周日");
        List<Map<String, Object>> classWeeks = new ArrayList<>();
        for (String s : list5) {
            Map<String, Object> map = new HashMap<>();
            map.put("value", s);
            map.put("checked", false);
            for (String s1 : split) {
                if(s.equals(s1)){
                    map.put("checked", true);
                }
            }
            classWeeks.add(map);
        }
        model.addAttribute("classWeeks", classWeeks);
        List<TCoursePackageType> tCoursePackageTypes = coursePackageTypeClient.queryAllCoursePackageType();
        model.addAttribute("coursePackageType", tCoursePackageTypes);
        String cityCode = tCoursePackage.getCityCode();
        String provinceCode = tCoursePackage.getProvinceCode();
        List<Map<String, Object>> list = storeService.queryProvince(cityCode);
        model.addAttribute("province", list);
        List<Map<String, Object>> list1 = storeService.queryCity(provinceCode, cityCode);
        model.addAttribute("city", list1);
        List<TStore> list2 = storeService.list(new QueryWrapper<TStore>().eq("cityCode", cityCode).eq("state", 1));
        model.addAttribute("store", list2);
        List<TSite> list3 = siteService.list(new QueryWrapper<TSite>().eq("storeId", tCoursePackage.getStoreId()).eq("state", 1));
        model.addAttribute("site", list3);
        List<Coach> coaches = coachClient.queryCoachByCity(cityCode);
        model.addAttribute("coach", coaches);
        List<CoursePackagePaymentConfig> list4 = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
 
 
        System.out.println("========couponIds=========>"+list4.get(0).getCouponIds());
 
        model.addAttribute("cashPayment", list4.get(0).getCashPayment() == 0 ? false : true);
        model.addAttribute("playPaiCoin", list4.get(0).getPlayPaiCoin() == 0 ? false : true);
 
        model.addAttribute("couponIds", list4.get(0).getCouponIds());
        model.addAttribute("coursePackagePaymentConfig", list4.remove(0));
        for (int i = 0; i < list4.size(); i++) {
            list4.get(i).setId(i+2);
        }
 
        model.addAttribute("coursePackagePaymentConfigs", list4);
        model.addAttribute("index", 1);
        if (list4.size()!=0) {
            CoursePackagePaymentConfig coursePackagePaymentConfig = list4.get(0);
 
            model.addAttribute("cashPayment", coursePackagePaymentConfig.getCashPayment() == 0 ? false : true);
            model.addAttribute("playPaiCoin", coursePackagePaymentConfig.getPlayPaiCoin() == 0 ? false : true);
            System.out.println("=========coursePackagePaymentConfig=============>" + coursePackagePaymentConfig);
//        model.addAttribute("couponIds", "3,2");
        }
 
        return PREFIX + "coursePackage_info.html";
    }
 
 
    /**
     * 跳转到折扣页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/showCoursePackageDiscount")
    public String showCoursePackageDiscount(Model model, Integer id){
        TCoursePackage tCoursePackage = coursePackageService.queryById(id);
        model.addAttribute("item", tCoursePackage);
        List<CoursePackagePaymentConfig> list4 = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
        List<Map<String, Object>> list = new ArrayList<>();
        for (CoursePackagePaymentConfig coursePackagePaymentConfig : list4) {
            if(coursePackagePaymentConfig.getCashPayment() == 0){
                continue;
            }
            Map<String, Object> map = new HashMap<>();
            map.put("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId());
            map.put("classHours", coursePackagePaymentConfig.getClassHours());
            String payment = "";
            if(coursePackagePaymentConfig.getCashPayment() > 0){
                payment += "现金支付";
            }
            if(coursePackagePaymentConfig.getPlayPaiCoin() > 0){
                payment += (ToolUtil.isNotEmpty(payment) ? "、" : "") + "玩湃币支付";
            }
            map.put("payment",  payment);
            map.put("cashPayment", coursePackagePaymentConfig.getCashPayment());
            List<TCoursePackageDiscount> tCoursePackageDiscounts = coursePackageDiscountClient.queryCoursePackageDiscount(coursePackagePaymentConfig.getId());
            map.put("coursePackageDiscount", tCoursePackageDiscounts);
            list.add(map);
        }
        model.addAttribute("role",UserExt.getUser().getObjectType());
        model.addAttribute("type",tCoursePackage.getType());
        List<TCoursePackageDiscount> tCoursePackageDiscounts = coursePackageDiscountClient.queryByCoursePackageId1(tCoursePackage.getId());
        if (tCoursePackageDiscounts.size()>0){
            TCoursePackageDiscount tCoursePackageDiscount = tCoursePackageDiscounts.get(0);
            model.addAttribute("audit",tCoursePackageDiscount.getAuditStatus());
            StringBuilder stringBuilder = new StringBuilder(" ");
            // 如果折扣未通过
            if (tCoursePackageDiscount.getAuditStatus() == 3){
                model.addAttribute("state","未通过");
                for (TCoursePackageDiscount coursePackageDiscount : tCoursePackageDiscounts) {
                    stringBuilder.append(coursePackageDiscount.getAuditRemark()+",");
                }
                if (!stringBuilder.equals("")){
                    String string = stringBuilder.toString();
                    String substring = string.substring(0, string.length() - 1);
                    model.addAttribute("reasons",substring);
                }else{
                    model.addAttribute("reasons",stringBuilder);
                }
            }else{
                model.addAttribute("reasons",stringBuilder);
            }
            if(tCoursePackageDiscount.getAuditStatus() == 2){
                model.addAttribute("state","已通过");
            }
            if (tCoursePackageDiscount.getAuditStatus() == 1){
                model.addAttribute("state","待审核");
            }
        }else{
            model.addAttribute("audit",2);
            model.addAttribute("state",0);
            model.addAttribute("reasons","");
        }
 
        model.addAttribute("coursePackagePaymentConfig", JSON.toJSONString(list));
        return PREFIX + "coursePackageDiscount.html";
    }
 
    /**
     * 跳转到报名列表页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/conpun/{id}")
    public String conpun(@PathVariable Integer id,Model model){
        model.addAttribute("index",id);
        return PREFIX + "TCoupon.html";
    }
 
    @GetMapping("/conpun1/{id}")
    public String conpun1(Model model,@PathVariable Integer id,String conpunids){
        System.out.println("=====model=======conpunids======"+conpunids);
        model.addAttribute("index",id);
 
        model.addAttribute("conpund",conpunids);
 
        if (conpunids!=null){
            return PREFIX + "TCoupon1.html";
        }
 
        return PREFIX + "TCoupon.html";
    }
 
    /**
     * 跳转到优惠券选择表页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/registrationRecord")
    public String registrationRecord(Model model, Integer id,Integer type){
        TCoursePackage tCoursePackage = coursePackageService.queryById(id);
        model.addAttribute("item", tCoursePackage);
        model.addAttribute("type", type);
        if (type ==1){
        return PREFIX + "registrationRecord.html";}
        if (type == 2){
            return PREFIX + "registrationRecord2.html";
        }
        if (type == 3){
            return PREFIX + "registrationRecord3.html";
        }
        return "registrationRecord.html";
    }
 
 
    @Resource
    @Autowired CoursePackagePaymentClient packagePaymentClient;
 
    /**
     * 跳转到上课记录列表页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/openClassRecord")
    public String openClassRecord(Model model, Integer id){
        TCoursePackage tCoursePackage = coursePackageClient.queryById(id);
        String[] start = tCoursePackage.getClassStartTime().split(",");
        String[] end = tCoursePackage.getClassEndTime().split(",");
        Integer counts = packagePaymentClient.queryByClassId(id);
 
 
        List<String> strings = new ArrayList<>();
        for (int i = 0; i <start.length ; i++) {
            String outTime = start[i] +"-" +end[0];
            strings.add(outTime);
        }
 
        TStore store = storeService.getById(tCoursePackage.getStoreId());
        Coach coach = coachClient.queryCoachById(tCoursePackage.getCoachId());
        model.addAttribute("item", tCoursePackage);
        model.addAttribute("store", store);
        model.addAttribute("coach", coach);
        model.addAttribute("times", strings);
        model.addAttribute("counts", counts);
 
 
        return PREFIX + "classRecord.html";
    }
 
    /**
     * 假期跳转到上课记录列表页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/openClassRecord1")
    public String openClassRecord1(Model model, Integer id){
        TCoursePackage tCoursePackage = coursePackageClient.queryById(id);
        String[] start = tCoursePackage.getClassStartTime().split(",");
        String[] end = tCoursePackage.getClassEndTime().split(",");
        Integer counts = packagePaymentClient.queryByClassId(id);
 
 
        List<String> strings = new ArrayList<>();
        for (int i = 0; i <start.length ; i++) {
            String outTime = start[i] +"-" +end[0];
            strings.add(outTime);
        }
 
        TStore store = storeService.getById(tCoursePackage.getStoreId());
        Coach coach = coachClient.queryCoachById(tCoursePackage.getCoachId());
        model.addAttribute("item", tCoursePackage);
        model.addAttribute("store", store);
        model.addAttribute("coach", coach);
        model.addAttribute("times", strings);
        model.addAttribute("counts", counts);
 
        return PREFIX + "classRecord2.html";
    }
 
 
    /**
     * 跳转到查看学员列表
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/openCoursePackageStudent")
    public String openCoursePackageStudent(Model model, Long id){
        model.addAttribute("id", id);
        return PREFIX + "coursePackageStudent.html";
    }
 
 
    /**
     * 跳转到手动预约列表
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/openManualReservation")
    public String openManualReservation(Model model, Long id){
        model.addAttribute("id", id);
        return PREFIX + "manualReservation.html";
    }
 
 
    /**
     * 跳转到课包审核列表页
     * @return
     */
    @GetMapping("/examineCoursePackage")
    public String examineCoursePackage(Model model){
        List<TCoursePackageType> tCoursePackageTypes = coursePackageTypeClient.queryAllCoursePackageType();
        model.addAttribute("coursePackageType", tCoursePackageTypes);
        List<Map<String, Object>> list = storeService.queryProvince(null);
        model.addAttribute("province", list);
        return PREFIX + "examineCoursePackage.html";
    }
 
 
    @GetMapping("/queryProvince")
    @ResponseBody
    public List<Map<String, Object>> queryProvince(){
 
        List<Map<String, Object>> list = storeService.queryProvince(null);
 
        return list;
    }
 
 
    /**
     * 跳转到审核详情页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/showExamineCoursePackageDetails")
    public String showExamineCoursePackageDetails(Model model, Integer id){
        TCoursePackage tCoursePackage = coursePackageService.queryById(id);
        model.addAttribute("item", tCoursePackage);
        System.out.println("============"+ tCoursePackage.getAuditStatus());
            model.addAttribute("auditStatus", tCoursePackage.getAuditStatus());
 
        model.addAttribute("authRemark", tCoursePackage.getAuthRemark());
        String classStartTime = tCoursePackage.getClassStartTime();
        String classEndTime = tCoursePackage.getClassEndTime();
        if (tCoursePackage.getStartTime()!=null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String dateString = sdf.format(tCoursePackage.getStartTime());
            String dateString1 = sdf.format(tCoursePackage.getEndTime());
            model.addAttribute("holi", dateString + " - " + dateString1);
        }
        String[] split1 = classStartTime.split(",");
        String[] split2 = classEndTime.split(",");
 
        List<String> listtime = new ArrayList<>();
 
        for (int i = 0; i < split1.length; i++) {
            String o = split1[i]+"-"+split2[i];
            listtime.add(o);
        }
 
 
        model.addAttribute("time1",listtime.remove(0));
        if (listtime.size()!=0) {
            model.addAttribute("times", listtime);
        }
        model.addAttribute("classTime",
                tCoursePackage.getClassStartTime() + ":00 - "
                        + tCoursePackage.getClassEndTime() + ":00");
        String[] split = tCoursePackage.getClassWeeks().split(";");
        List<String> list5 = Arrays.asList("周一", "周二", "周三", "周四", "周五", "周六", "周日");
        List<Map<String, Object>> classWeeks = new ArrayList<>();
        for (String s : list5) {
            Map<String, Object> map = new HashMap<>();
            map.put("value", s);
            map.put("checked", false);
            for (String s1 : split) {
                if(s.equals(s1)){
                    map.put("checked", true);
                }
            }
            classWeeks.add(map);
        }
        model.addAttribute("classWeeks", classWeeks);
        List<TCoursePackageType> tCoursePackageTypes = coursePackageTypeClient.queryAllCoursePackageType();
        model.addAttribute("coursePackageType", tCoursePackageTypes);
        String cityCode = tCoursePackage.getCityCode();
        String provinceCode = tCoursePackage.getProvinceCode();
        List<Map<String, Object>> list = storeService.queryProvince(cityCode);
        model.addAttribute("province", list);
        List<Map<String, Object>> list1 = storeService.queryCity(provinceCode, cityCode);
        model.addAttribute("city", list1);
        List<TStore> list2 = storeService.list(new QueryWrapper<TStore>().eq("cityCode", cityCode).eq("state", 1));
        model.addAttribute("store", list2);
        List<TSite> list3 = siteService.list(new QueryWrapper<TSite>().eq("storeId", tCoursePackage.getStoreId()).eq("state", 1));
        model.addAttribute("site", list3);
        List<Coach> coaches = coachClient.queryCoachByCity(cityCode);
        model.addAttribute("coach", coaches);
        List<CoursePackagePaymentConfig> list4 = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
        if(list4.size()!=0){
            CoursePackagePaymentConfig coursePackagePaymentConfig = list4.get(0);
            model.addAttribute("cashPayment", coursePackagePaymentConfig.getCashPayment() == 0 ? false : true);
            model.addAttribute("playPaiCoin", coursePackagePaymentConfig.getPlayPaiCoin() == 0 ? false : true);}
        model.addAttribute("coursePackagePaymentConfig", list4.remove(0));
        model.addAttribute("coursePackagePaymentConfigs", list4);
        Integer type = tCoursePackage.getType();
        model.addAttribute("type",type);
        return PREFIX + "examineCoursePackage_info.html";
    }
 
 
 
 
    /**
     * 获取城市列表
     * @param code
     * @return
     */
    @ResponseBody
    @PostMapping("/queryCity")
    public List<Map<String, Object>> queryCity(String code){
        Integer objectType = UserExt.getUser().getObjectType();
        Integer objectId = UserExt.getUser().getObjectId();
        String cityCode = null;
        if(objectType == 2){//城市管理员
            CityManager cityManager = cityManagerClient.queryCityManagerById(objectId);
            cityCode = cityManager.getCityCode();
        }
        System.out.println("======="+storeService.queryCity(code, cityCode));
        return storeService.queryCity(code, cityCode);
    }
 
 
    @ResponseBody
    @PostMapping("/queryCity1/{code}")
    public ResultUtil queryCity1(@PathVariable("code") String code){
        Integer objectType = UserExt.getUser().getObjectType();
        Integer objectId = UserExt.getUser().getObjectId();
        String cityCode = null;
//        if(objectType == 2){//城市管理员
//            CityManager cityManager = cityManagerClient.queryCityManagerById(objectId);
//            cityCode = cityManager.getCityCode();
//        }
        System.out.println("======="+storeService.queryCity(code, cityCode));
//        return storeService.queryCity(code, cityCode);
        return new ResultUtil(0,null,null,storeService.queryCity(code, cityCode),null);
    }
 
    @ResponseBody
    @PostMapping("/queryCity3")
    public ResultUtil queryCity3(){
 
        System.out.println("======="+storeService.queryCity1());
//        return storeService.queryCity(code, cityCode);
        return new ResultUtil(0,null,null,storeService.queryCity1(),null);
    }
 
 
    @ResponseBody
    @PostMapping("/queryCity1/")
    public ResultUtil queryCity2(){
 
        return new ResultUtil(0,null,null,null,null);
    }
 
    /**
     * 根据城市code获取门店
     * @param cityCode
     * @return
     */
    @ResponseBody
    @PostMapping("/queryStore")
    public List<TStore> queryStore(String cityCode){
        List<TStore> list = storeService.list(new QueryWrapper<TStore>().eq("cityCode", cityCode).eq("state", 1));
        System.out.println("====list="+list);
        return list;
    }
 
 
    @ResponseBody
    @PostMapping("/queryStore1/{cityCode}")
    public ResultUtil queryStore1(@PathVariable("cityCode") String cityCode){
        List<TStore> list = storeService.list(new QueryWrapper<TStore>().select("id","name").eq("cityCode", cityCode).eq("state", 1));
//        Map<String,Integer> map = new LinkedHashMap<>();
        List<SelectDto>  selectDtos = new ArrayList<>();
        Map<String,Integer> map = new HashMap<>();
//        for (TStore store : list) {
//            SelectDto selectDto = new SelectDto();
//            selectDto.setId(Long.valueOf(store.getId()));
//            selectDto.setValue(store.getName());
//               selectDtos.add(selectDto);
//
//        }
//        map.put("options",selectDtos);
 
        return new ResultUtil(0,0,null,list,null);
    }
 
    @ResponseBody
    @PostMapping("/queryStore3")
    public ResultUtil queryStore3(){
        List<TStore> list = storeService.list(new QueryWrapper<TStore>().select("id","name").eq("state", 1));
//        Map<String,Integer> map = new LinkedHashMap<>();
        List<SelectDto>  selectDtos = new ArrayList<>();
        Map<String,Integer> map = new HashMap<>();
//        for (TStore store : list) {
//            SelectDto selectDto = new SelectDto();
//            selectDto.setId(Long.valueOf(store.getId()));
//            selectDto.setValue(store.getName());
//               selectDtos.add(selectDto);
//
//        }
//        map.put("options",selectDtos);
 
        return new ResultUtil(0,0,null,list,null);
    }
 
 
    @ResponseBody
    @PostMapping("/queryStore1/")
    public ResultUtil queryStore2(){
//        List<TStore> list = storeService.list(new QueryWrapper<TStore>().select("id","name").eq("cityCode", cityCode).eq("state", 1));
////        Map<String,Integer> map = new LinkedHashMap<>();
//        List<SelectDto>  selectDtos = new ArrayList<>();
//        Map<String,Integer> map = new HashMap<>();
////        for (TStore store : list) {
//            SelectDto selectDto = new SelectDto();
//            selectDto.setId(Long.valueOf(store.getId()));
//            selectDto.setValue(store.getName());
//               selectDtos.add(selectDto);
//
//        }
//        map.put("options",selectDtos);
 
        return new ResultUtil(0,0,null,null,null);
    }
 
 
    /**
     * 根据门店id获取场地
     * @param storeId
     * @return
     */
    @ResponseBody
    @PostMapping("/querySite/{id}")
    public List<TSite> querySite(@PathVariable("id") Integer storeId){
        System.out.println("==storeId==="+storeId);
        List<TSite> list = siteService.list(new QueryWrapper<TSite>().select("id","name").eq("storeId", storeId).eq("state", 1));
        return list;
    }
    /**
     * 根据门店id获取场地
     * @param storeId
     * @return
     */
    @ResponseBody
    @PostMapping("/querySite1")
    public List<TSite> querySite1(Integer storeId,Integer type){
        List<TSite> list = new ArrayList<>();
        if (type==1){
            list = siteService.list(new QueryWrapper<TSite>()
                    .select("id","name")
                    .eq("storeId", storeId)
                    .eq("state", 1)
                    .eq("ishalf",type));
        }else{
            list = siteService.list(new QueryWrapper<TSite>()
                    .select("id","name")
                    .eq("storeId", storeId)
                    .eq("state", 1)
                    );
        }
 
        return list;
    }
 
 
    /**
     * 根据门店id获取场地
     * @param storeId
     * @return
     */
    @ResponseBody
    @PostMapping("/querySite")
    public List<TSite> querySite4(Integer storeId){
        System.out.println("==storeId==="+storeId);
        List<TSite> list = siteService.list(new QueryWrapper<TSite>().select("id","name").eq("storeId", storeId).eq("state", 1));
        return list;
    }
 
 
 
//    @ResponseBody
//    @PostMapping("/querySite")
//    public List<TSite> querySite2(){
//        return null;
//    }
 
    @ResponseBody
    @PostMapping("/querySite/")
    public ResultUtil querySite1(){
         return new ResultUtil(0,0,null,null,null);
    }
    /**
     * 获取城市教练
     * @param cityCode
     * @return
     */
    @ResponseBody
    @PostMapping("/queryCoach")
    public List<Coach> queryCoach(String cityCode){
        List<Coach> coaches = coachClient.queryCoachByCity(cityCode);
        return coaches;
    }
 
 
 
    /**
     * 获取列表数据
     * @param provinceCode
     * @param cityCode
     * @param coursePackageTypeId
     * @param name
     * @param status
     * @param state
     * @return
     */
    @ResponseBody
    @PostMapping("/queryCoursePackageLists")
    public Object queryCoursePackageLists(String provinceCode, String cityCode, Integer coursePackageTypeId, String name, Integer status, Integer state){
        Integer objectType = UserExt.getUser().getObjectType();
        Integer objectId = UserExt.getUser().getObjectId();
        Integer storeId = null;
        List<Integer> storeIds = new ArrayList<>();
 
        if(objectType == 2){// 城市管理员
//            CityManager cityManager = cityManagerClient.queryCityManagerById(objectId);
//            provinceCode = cityManager.getProvinceCode();
//            cityCode = cityManager.getCityCode();
            // 获取运营商下的门店ids
            List<Integer> operatorId = storeService.list(new QueryWrapper<TStore>().eq("operatorId", objectId))
                    .stream().map(TStore::getId).collect(Collectors.toList());
            storeIds = operatorId;
        }
        if(objectType == 3) {// 门店
            storeIds.add(objectId);
        }
        Page<Map<String, Object>> mapPage = coursePackageService.queryCoursePackageLists(provinceCode,
                cityCode, coursePackageTypeId, storeIds, name, status, state);
        return super.packForBT(mapPage);
    }
 
 
    /**
     * 添加课包数据
     * @param coursePackage
     * @param coursePackagePaymentConfig
     * @return
     */
    @ResponseBody
    @PostMapping("/addCoursePackage")
    public ResultUtil addCoursePackage(TCoursePackage coursePackage,
                                       String coursePackagePaymentConfig) throws ParseException {
        String classStartTime = coursePackage.getClassStartTime();
//        String classEndTime = coursePackage.getClassEndTime();
        Date startDate = null;
        Date endDate =null ;
 
 
        String holitime = coursePackage.getHolitime();
        if (holitime!=null&&holitime!="") {
            String[] dateParts = holitime.split(" - ");
            String startDateString = dateParts[0];
            String endDateString = dateParts[1];
 
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            startDate = dateFormat.parse(startDateString);
            endDate = dateFormat.parse(endDateString);
            if (coursePackage.getType() == 2){
                startDate.setHours(0);
                startDate.setMinutes(0);
                startDate.setSeconds(0);
                endDate.setHours(23);
                endDate.setMinutes(59);
                endDate.setSeconds(59);
            }
        }
 
 
        System.out.println("=======getClassStartTime============"+classStartTime);
        String startTime = coursePackage.getClassStartTime();
        JSONArray jsonArray = JSON.parseArray(startTime);
        System.out.println("=======jsonArray==========="+jsonArray);
 
            List<String> first = new ArrayList<>();
            List<String> second = new ArrayList<>();
        for (int i = 0; i < jsonArray.size(); i++) {
//            JSONObject jsonObject = JSON.parseObject(jsonArray.getString(i));
 
            String jsonString = jsonArray.getString(i);
            String[] split = jsonString.split(" - ");
            first.add(split[0]);
            if (split.length>1) {
                second.add(split[1]);
            }
        }
        String firstString = String.join(",",first);
        String secondString = String.join(",",second);
        System.out.println("=========firstString========>"+firstString);
 
        System.out.println("=========secondString========>"+secondString);
 //        classStartTime = classStartTime.substring(0, classStartTime.lastIndexOf(":"));
//        classEndTime = classEndTime.substring(0, classEndTime.lastIndexOf(":"));
 
        coursePackage.setStartTime(startDate);
        coursePackage.setEndTime(endDate);
 
        coursePackage.setClassStartTime(firstString);
        coursePackage.setClassEndTime(secondString);
        coursePackage.setStatus(1);
        coursePackage.setState(1);
        if (UserExt.getUser().getObjectType() == 1){
            coursePackage.setAuditStatus(2);
        }else{
            coursePackage.setAuditStatus(1);
        }
        coursePackage.setInsertTime(new Date());
        Integer objectType = UserExt.getUser().getObjectType();
        Integer objectId = UserExt.getUser().getObjectId();
 
        if (objectType==2){
            Integer storeId = coursePackage.getStoreId();
            TStore store = storeService.getOne(new QueryWrapper<TStore>().eq("id", storeId));
            coursePackage.setProvince(store.getProvince());
            coursePackage.setProvinceCode(store.getProvinceCode());
            coursePackage.setCity(store.getCity());
            coursePackage.setCityCode(store.getCityCode());
            coursePackage.setAuditStatus(1);
        }
 
 
        // 详情多图片
//        String substring = coursePackage.getDetailDrawing().substring(0, coursePackage.getDetailDrawing().length() - 1);
//        coursePackage.setDetailDrawing(substring);
        coursePackageService.addCoursePackage(coursePackage, coursePackagePaymentConfig);
        return ResultUtil.success();
    }
 
 
    /**
     * 修改数据
     * @param coursePackage
     * @param coursePackagePaymentConfig
     * @return
     */
    @ResponseBody
    @PostMapping("/updateCoursePackage")
    public ResultUtil updateCoursePackage(TCoursePackage coursePackage, String coursePackagePaymentConfig){
//        System.out.println("=======getClassStartTime============"+classStartTime);
        String startTime = coursePackage.getClassStartTime();
        String s = startTime.replaceAll(" ", "");
 
        JSONArray jsonArray = JSON.parseArray(s);
        System.out.println("=======jsonArray==========="+jsonArray);
 
        List<String> first = new ArrayList<>();
        List<String> second = new ArrayList<>();
        for (int i = 0; i < jsonArray.size(); i++) {
//          JSONObject jsonObject = JSON.parseObject(jsonArray.getString(i));
 
            String jsonString = jsonArray.getString(i);
            String[] split = jsonString.split("-");
            System.out.println("============"+split);
            if (split.length>1){
            first.add(split[0]);
            second.add(split[1]);}
 
        }
        String firstString = String.join(",",first);
        String secondString = String.join(",",second);
        System.out.println("=========firstString========>"+firstString);
 
        System.out.println("=========secondString========>"+secondString);
//        String classStartTime = coursePackage.getClassStartTime();
//        String classEndTime = coursePackage.getClassEndTime();
//        classStartTime = classStartTime.substring(0, classStartTime.lastIndexOf(":"));
//        classEndTime = classEndTime.substring(0, classEndTime.lastIndexOf(":"));
        coursePackage.setClassStartTime(firstString);
        coursePackage.setClassEndTime(secondString);
        coursePackage.setAuditStatus(2);
        if (UserExt.getUser().getObjectType() != 1){
            coursePackage.setAuditStatus(1);
        }
        coursePackageService.updateCoursePackage(coursePackage, coursePackagePaymentConfig);
        return ResultUtil.success();
    }
 
 
    /**
     * 修改数据状态
     * @param id
     * @param state
     * @return
     */
    @ResponseBody
    @PostMapping("/editCoursePackageState")
    public ResultUtil editCoursePackageState(Integer id, Integer state){
        TCoursePackage coursePackage = new TCoursePackage();
        coursePackage.setId(id);
        coursePackage.setState(state);
        coursePackageService.editCoursePackageState(coursePackage);
        return ResultUtil.success();
    }
 
 
    @ResponseBody
    @PostMapping("/editCoursePackageState1")
    public ResultUtil editCoursePackageState1(Integer id, Integer state){
        TCoursePackage coursePackage = new TCoursePackage();
        coursePackage.setId(id);
        coursePackage.setState(state);
        coursePackageService.editCoursePackageState(coursePackage);
        return ResultUtil.success();
    }
 
    /**
     * 编辑课包折扣
     * @param json
     * @return
     */
    @ResponseBody
    @PostMapping("/setCoursePackageDiscount")
    public ResultUtil setCoursePackageDiscount(Integer id, String json){
        return coursePackageService.setCoursePackageDiscount(id, json);
    }
 
 
    /**
     * 获取课包报名信息列表
     * @param id
     * @param userName
     * @param studentName
     * @return
     */
    @ResponseBody
    @PostMapping("/queryRegistrationRecord")
    public Object queryRegistrationRecord(Integer id, String userName, String studentName){
        Page<Map<String, Object>> mapPage = coursePackageService.queryRegistrationRecord(id, userName, studentName);
        return super.packForBT(mapPage);
    }
 
 
    /**
     * 获取课包排课数据
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/queryClassRecord")
    public Object queryClassRecord(Integer id){
        Page<Map<String, Object>> page = coursePackageService.queryCoursePackageSchedulingList(id);
        return super.packForBT(page);
    }
 
 
    /**
     * 根据排课id获取学员预约数据列表
     * @param id
     * @param userName
     * @param studentName
     * @return
     */
    @ResponseBody
    @PostMapping("/queryCoursePackageStudentList")
    public Object queryCoursePackageStudentList(Long id, String userName, String studentName){
        Page<Map<String, Object>> page = coursePackageService.queryCoursePackageStudentList(id, userName, studentName);
        return super.packForBT(page);
    }
 
 
    /**
     * 取消预约
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/cancelReservation")
    public ResultUtil cancelReservation(Long id){
        return coursePackageService.cancelReservation(id);
    }
 
 
    /**
     * 修改缺席状态
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/setAbsenceStatus")
    public ResultUtil setAbsenceStatus(Long id){
        return coursePackageService.setAbsenceStatus(id);
    }
 
 
    /**
     * 取消排课记录
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/cancelClassSchedule")
    public ResultUtil cancelClassSchedule(Long id){
        return coursePackageService.cancelClassSchedule(id);
    }
 
 
    /**
     * 发布课后练习
     * @param id
     * @param courseId
     * @param integral
     * @return
     */
    @ResponseBody
    @PostMapping("/afterClassExercises")
    public ResultUtil afterClassExercises(Long id, Integer courseId, Integer integral,Integer packId){
        return coursePackageService.afterClassExercises(id, courseId, integral);
    }
 
 
    /**
     * 添加消课凭证
     * @param id
     * @param cancelClasses
     * @param deductClassHour
     * @return
     */
    @ResponseBody
    @PostMapping("/cancellationRecord")
    public ResultUtil cancellationRecord(Long id, String cancelClasses, Integer deductClassHour){
        return coursePackageService.cancellationRecord(id, cancelClasses, deductClassHour);
    }
 
 
    /**
     * 获取未预约排课学员列表
     * @param coursePackageSchedulingId
     * @param userName
     * @param studentName
     * @return
     */
    @ResponseBody
    @PostMapping("/queryWalkInStudentListqueryCoursePackageLists")
    public Object queryWalkInStudentList(Long coursePackageSchedulingId, String userName, String studentName){
        Page<Map<String, Object>> page = coursePackageService.queryWalkInStudentList(coursePackageSchedulingId, userName, studentName);
        return super.packForBT(page);
    }
 
 
    /**
     * 手动预约课程
     * @param coursePackagePaymentId
     * @param coursePackageSchedulingId
     * @return
     */
    @ResponseBody
    @PostMapping("/courseReservation")
    public ResultUtil courseReservation(Long coursePackagePaymentId, Long coursePackageSchedulingId){
        return coursePackageService.courseReservation(coursePackagePaymentId, coursePackageSchedulingId);
    }
 
 
    /**
     * 退课操作
     * @param coursePackagePaymentId
     * @param certificate
     * @return
     */
    @ResponseBody
    @PostMapping("/dropTheClass")
    public ResultUtil dropTheClass(Long coursePackagePaymentId, String certificate){
        return coursePackageService.dropTheClass(coursePackagePaymentId, certificate);
    }
 
 
    /**
     * 补课操作
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/makeUpMissedLessons")
    public ResultUtil makeUpMissedLessons(Integer id){
        System.out.println("==========coursePackage补课PaymentId======"+id);
        return coursePackageService.makeUpMissedLessons(id);
    }
 
 
    /**
     * 获取课包审核列表
     * @param provinceCode
     * @param cityCode
     * @param coursePackageTypeId
     * @param name
     * @param auditStatus
     * @return
     */
    @ResponseBody
    @PostMapping("/queryExamineCoursePackageLists")
    public Object queryExamineCoursePackageLists(String provinceCode, String cityCode, Integer coursePackageTypeId, String name, Integer auditStatus){
        Page<Map<String, Object>> mapPage = coursePackageService.queryExamineCoursePackageLists(provinceCode, cityCode, coursePackageTypeId, name, auditStatus);
        return super.packForBT(mapPage);
    }
 
 
    /**
     * 审核课包
     * @param id
     * @param auditStatus
     * @param authRemark
     * @return
     */
    @ResponseBody
    @PostMapping("/setCoursePackageAuditStatus")
    public ResultUtil setCoursePackageAuditStatus(Integer id, Integer auditStatus, String authRemark){
        return coursePackageService.setCoursePackageAuditStatus(id, auditStatus, authRemark);
    }
}