无关风月
2025-04-01 562ccac1d78a2dc3e5936ef2c6dd77d22ebbfb0e
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
package com.dsh.guns.modular.system.controller.code;
 
import cn.hutool.crypto.SecureUtil;
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.CityClient;
import com.dsh.course.feignClient.account.model.CityListQuery;
import com.dsh.course.feignClient.account.model.TCityManager;
import com.dsh.course.feignClient.communityWorldCup.Model.WorldCupStore;
import com.dsh.course.feignClient.communityWorldCup.Model.WorldCupStoreVO;
import com.dsh.course.feignClient.communityWorldCup.WorldCupStoreClient;
import com.dsh.course.feignClient.competition.CompetitionClient;
import com.dsh.course.mapper.UserMapper;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.core.base.tips.SuccessTip;
import com.dsh.guns.core.common.constant.factory.PageFactory;
import com.dsh.guns.core.util.ToolUtil;
import com.dsh.guns.modular.system.model.StoreConfig;
import com.dsh.guns.modular.system.model.TCity;
import com.dsh.guns.modular.system.model.TOperator;
import com.dsh.guns.modular.system.model.TOperatorCity;
import com.dsh.guns.modular.system.model.TStore;
import com.dsh.guns.modular.system.model.TStoreListVo;
import com.dsh.guns.modular.system.model.TStoreOther;
import com.dsh.guns.modular.system.model.TStoreOtherConfig;
import com.dsh.guns.modular.system.model.TStoreOtherConfigTrue;
import com.dsh.guns.modular.system.model.TTurn;
import com.dsh.guns.modular.system.model.User;
import com.dsh.guns.modular.system.service.ICityService;
import com.dsh.guns.modular.system.service.IStoreService;
import com.dsh.guns.modular.system.service.ITSiteService;
import com.dsh.guns.modular.system.service.IUserService;
import com.dsh.guns.modular.system.service.StoreConfigService;
import com.dsh.guns.modular.system.service.TOperatorCityService;
import com.dsh.guns.modular.system.service.TOperatorService;
import com.dsh.guns.modular.system.service.TStoreOtherConfigService;
import com.dsh.guns.modular.system.service.TStoreOtherConfigTrueService;
import com.dsh.guns.modular.system.service.TStoreOtherService;
import com.dsh.guns.modular.system.service.TTurnService;
import com.dsh.guns.modular.system.util.HttpRequestUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 车辆管理控制器
 *
 * @author fengshuonan
 * @Date 2020-06-05 17:25:12
 */
@Controller
@RequestMapping("/tShop")
public class TShopController extends BaseController {
 
    private String PREFIX = "/system/tShop/";
 
    @Autowired
    private CompetitionClient competitionClient;
 
    @Autowired
    private CityClient cityClient;
 
    @Autowired
    private IStoreService storeService;
    @Autowired
    private ICityService cityService;
 
    @Resource
    private UserMapper userMapper;
 
    @Resource
    private StoreConfigService storeConfigService;
 
    @Autowired
    private TStoreOtherConfigTrueService tStoreOtherConfigTrueService;
 
    @Autowired
    private TStoreOtherConfigService storeOtherConfigService;
 
    @Autowired
    private TTurnService tTurnService;
 
    @Autowired
    private TStoreOtherService storeOtherService;
 
    @Autowired
    private TOperatorService tOperatorService;
 
    @Autowired
    private ITSiteService siteService;
    @Autowired
    private IUserService userService;
    @Autowired
    private WorldCupStoreClient worldCupStoreClient;
 
 
    // 添加SUTU
    @RequestMapping("/tShop_addDevice/{id}")
    public String addDevice(@PathVariable("id") Integer id,Model model) {
        // 门店id
        model.addAttribute("id",id);
        return PREFIX + "TShop_add_device.html";
    }
 
    @RequestMapping("/addDevice")
    public Object addDevice(Integer id,String device) {
        // 应该是不用他了
        HashMap<String, String> map = new HashMap<>();
        map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
        map.put("space_id",id.toString());
        map.put("name",device);
        map.put("city_code","");
        // 添加门禁
        String s1 = HttpRequestUtil.postRequest
                ("https://try.daowepark.c" +
                        "om/v7/user_api/general/addSpaceSutu", map);
        return SUCCESS_TIP;
    }
 
//    public static void main(String[] args) {
////        HashMap<String, String> map = new HashMap<>();
////        map.put("page","1");
////        map.put("space_id","2010");
////        // 获取门禁列表
////        String s1 = HttpRequestUtil.getRequest
////                ("https://port.daowepark.com/v7/user_api/general/getDevice", map);
////        System.err.println(s1);
//
//        HashMap<String, String> map = new HashMap<>();
//        map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
//        map.put("space_id","1");
//        map.put("device_id","1");
//        map.put("region_id","2010");
//        // 获取门禁列表
//        String s1 = HttpRequestUtil.getRequest
//                ("https://port.daowepark.com/v7/user_api/general/getDevice", map);
//        System.err.println(s1);
//    };
    /**
     * 跳转到车辆管理首页
     */
    @RequestMapping("")
    public String index(Model model) {
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        String roleid = UserExt.getUser().getRoleid();
        model.addAttribute("role",roleid);
        return PREFIX + "TShop.html";
    }
 
    /**
     * 跳转到添加车辆管理
     */
    @RequestMapping("/tShop_add")
    public String tCompetitionAdd(Model model) {
 
        String roleid = UserExt.getUser().getRoleid();
        model.addAttribute("role",roleid);
        List<TOperator> list1 = tOperatorService.list();
        if (UserExt.getUser().getObjectType()==2){
            // 查询这个运营商管理的省
            TOperator id = tOperatorService.getOne(new QueryWrapper<TOperator>().eq("id", UserExt.getUser().getObjectId()));
            if (id.getType()==1){
                // 全国
                List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
                model.addAttribute("list",list);
            }else{
                // 找到他管理的省
                List<TOperatorCity> list = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("operatorId", UserExt.getUser().getObjectId()).eq("pid", 0));
                model.addAttribute("list",list);
            }
        }else{
            List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
            model.addAttribute("list",list);
        }
 
//        if (!roleid.equals("1")){
        TOperator operator1 = tOperatorService.getOne(new QueryWrapper<TOperator>().eq("userId", UserExt.getUser().getId()));
        if(operator1!=null){
            model.addAttribute("operator",operator1.getId());
        }else {
            model.addAttribute("operator",0);
        }
//        }
 
        model.addAttribute("yysList",list1);
        model.addAttribute("objectType",UserExt.getUser().getObjectType());
        return PREFIX + "TShop_add.html";
    }
    // 运营商根据省筛选市区
    @RequestMapping("/getProvinceYys")
    @ResponseBody
    public Object getProvinceYys(Integer operatorId) {
        // 判断当前运营商是管理全国还是指定区域
        TOperator byId = tOperatorService.getById(operatorId);
        // 说明是管理全国
        if (byId.getType()==1){
            List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
            return list;
        }else{
            // 获取运营商管理的所有省
            List<TOperatorCity> list = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("operatorId", operatorId)
                    .eq("pid", 0));
            return list;
        }
 
 
    }
    // 运营商根据省筛选市区
    @RequestMapping("/getCityYys")
    @ResponseBody
    public Object getCityYys(String province,Integer operatorId) {
        if (UserExt.getUser().getObjectType() == 2){
            operatorId = UserExt.getUser().getObjectId();
        }
        // 通过选择的省 获取管理的市
        TOperatorCity byId = operatorCityService.getOne(new QueryWrapper<TOperatorCity>()
                .eq("code",province).eq("operatorId",operatorId));
        // 如果为null 则说明管理的全国
        if (byId == null){
            TCity code = cityService.getOne(new QueryWrapper<TCity>().eq("code", province));
            return cityService.list(new QueryWrapper<TCity>().eq("parent_id",code.getId()));
        }else{
            List<TOperatorCity> list = operatorCityService.list(new QueryWrapper<TOperatorCity>()
                    .eq("operatorId", operatorId)
                    .eq("pid",byId.getId()));
            if (list.size() == 0){
                // 说明管理整个省
                TCity code = cityService.getOne(new QueryWrapper<TCity>().eq("code", byId.getCode()));
                // 获取省下面的所有市
                return cityService.list(new QueryWrapper<TCity>().eq("parent_id", code.getId()));
            }else{
                // 没有管理整个省 获取对应的市
                return list;
            }
        }
    }
    // 运营商赛事添加 根据所选市 获取门店
    @RequestMapping("/getStoresYys")
    @ResponseBody
    public Object getStoresYys(String cityCode) {
        Integer objectId = UserExt.getUser().getObjectId();
        List<TStore> stores = storeService.list(new QueryWrapper<TStore>().eq("operatorId", objectId)
                .eq("cityCode", cityCode));
        return stores;
    }
 
    @RequestMapping("/tShop_add_one")
    public String tCompetitionAddOne(Integer id,Model model) {
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        String roleid = UserExt.getUser().getRoleid();
        model.addAttribute("id",id);
 
        return PREFIX + "TShop_add_one.html";
    }
    @RequestMapping("/tShop_add_two")
    public String tCompetitionAddTwo(Integer id,Model model) {
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        model.addAttribute("id",id);
        String roleid = UserExt.getUser().getRoleid();
        return PREFIX + "TShop_edit_three.html";
    }
    @RequestMapping("/tShop_add_two1")
    public String tCompetitionAddTwo1(Integer id,Model model) {
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        model.addAttribute("id",id);
        String roleid = UserExt.getUser().getRoleid();
        return PREFIX + "TShop_add_two.html";
    }
 
 
    /**
     * 跳转到修改车辆管理
     */
    @RequestMapping("/tShop_update/{id}")
    public String tCityUpdate(@PathVariable Integer id, Model model) {
        TStore byId = storeService.getById(id);
        System.out.println("======byId========="+byId);
        model.addAttribute("item",byId);
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
 
//        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode()));
        List<TOperatorCity> ones = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>()
                .eq(TOperatorCity::getOperatorId, byId.getOperatorId())
                .eq(TOperatorCity::getPid, 0));
 
        if(ones.size()>0){
            model.addAttribute("list",ones);
            TOperatorCity one1 = operatorCityService.getOne(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, byId.getOperatorId()).eq(TOperatorCity::getPid, 0).eq(TOperatorCity::getCode,byId.getProvinceCode()));
            List<TOperatorCity> list3 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().in(TOperatorCity::getPid, one1.getId()).eq(TOperatorCity::getType, 2));
            model.addAttribute("list1",list3);
            System.out.println("===list3======="+list3);
 
        }else {
            List<TCity> list2 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
            model.addAttribute("list",list2);
            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode()));
            List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one1.getId()));
            model.addAttribute("list1",list1);
            System.out.println("===list1======="+list1);
        }
        CityListQuery cityListQuery = new CityListQuery();
        cityListQuery.setOffset(1);
        cityListQuery.setLimit(10000);
        cityListQuery.setCityCode(byId.getCityCode());
        Page<TCityManager> list2 = cityClient.list(cityListQuery);
 
        List<TOperator> list1 = tOperatorService.list();
        model.addAttribute("yysList",list1);
 
        model.addAttribute("list2",list2.getRecords());
        String roleid = UserExt.getUser().getRoleid();
        model.addAttribute("role",roleid);
        model.addAttribute("time",byId.getStartTime()+" - "+byId.getEndTime());
        User byId1 = userMapper.selectById(byId.getStoreStaffId());
        model.addAttribute("city",byId1);
        model.addAttribute("type",1);
        // 如果当前登陆人是运营商
        if (UserExt.getUser().getObjectType()==2){
            // 查询这个运营商管理的省
            TOperator id1 = tOperatorService.getOne(new QueryWrapper<TOperator>().eq("id", UserExt.getUser().getObjectId()));
            if (id1.getType()==1){
                // 全国
                List<TCity> list3 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
                model.addAttribute("list",list3);
            }else{
                // 找到他管理的省
                List<TOperatorCity> list4 = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("operatorId", UserExt.getUser().getObjectId()).eq("pid", 0));
                model.addAttribute("list",list4);
            }
        }
        return PREFIX + "TShop_edit.html";
    }
    @RequestMapping("/tShop_update1/{id}")
    public String tCityUpdate1(@PathVariable Integer id, Model model) {
        TStoreOther byId = storeOtherService.getById(id);
        model.addAttribute("item",byId);
        return PREFIX + "TShop_edit_one.html";
    }
 
 
 
 
    @RequestMapping("/tShop_update_one/{id}")
    public String tCityUpdateOne(@PathVariable Integer id, Model model) {
        TStoreOtherConfig byId = storeOtherConfigService.getById(id);
        TTurn one = tTurnService.getOne(new LambdaQueryWrapper<TTurn>().eq(TTurn::getName, byId.getName()));
        // page list
        if (one!=null) {
            List<TTurn> list = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, one.getId()));
            model.addAttribute("list", list);
        }
        // type list
        List<TTurn> list1 = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, byId.getPageId()));
        model.addAttribute("item",byId);
        model.addAttribute("list1",list1);
 
        return PREFIX + "TShop_edit_two.html";
    }
    @RequestMapping("/tShop_update_one1/{id}")
    public String tCityUpdateOne1(@PathVariable Integer id, Model model) {
        TStoreOtherConfigTrue byId = tStoreOtherConfigTrueService.getById(id);
        TTurn one = tTurnService.getOne(new LambdaQueryWrapper<TTurn>().eq(TTurn::getName, byId.getName()));
        // page list
        List<TTurn> list = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, one.getId()));
        // type list
        List<TTurn> list1 = tTurnService.list(new LambdaQueryWrapper<TTurn>().eq(TTurn::getPid, byId.getPageId()));
        model.addAttribute("item",byId);
        model.addAttribute("list",list);
        model.addAttribute("list1",list1);
 
        return PREFIX + "TShop_add_three.html";
    }
 
 
 
    @RequestMapping("/tShop_info/{id}")
    public String tCityInfo(@PathVariable Integer id, Model model) {
        TStore byId = storeService.getById(id);
        model.addAttribute("item",byId);
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getProvinceCode()));
        List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
        CityListQuery cityListQuery = new CityListQuery();
        cityListQuery.setOffset(1);
        cityListQuery.setLimit(10000);
        cityListQuery.setCityCode(byId.getCityCode());
        model.addAttribute("yysList", tOperatorService.list());
        Page<TCityManager> list2 = cityClient.list(cityListQuery);
        model.addAttribute("list1",list1);
        model.addAttribute("list2",list2.getRecords());
        String roleid = UserExt.getUser().getRoleid();
        model.addAttribute("role",roleid);
        model.addAttribute("time",byId.getStartTime()+" - "+byId.getEndTime());
        User byId1 = userMapper.selectById(byId.getStoreStaffId());
        model.addAttribute("city",byId1);
        model.addAttribute("type",0);
 
        return PREFIX + "TShop_edit.html";
    }
    @RequestMapping("/tShop_gift/{id}")
    public String tCityGift(@PathVariable Integer id, Model model) {
        TStore byId = storeService.getById(id);
        model.addAttribute("welfarePicture",byId.getWelfarePicture());
        model.addAttribute("id",id);
        return PREFIX + "TShop_img.html";
    }
    @RequestMapping("/tShop_indexSet/{id}")
    public String tCityIndexSet(@PathVariable Integer id, Model model) {
        StoreConfig c1 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,1));
        model.addAttribute("c1",c1);
        StoreConfig c2 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,2));
        model.addAttribute("c2",c2);
        StoreConfig c3 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,3));
        model.addAttribute("c3",c3);
        StoreConfig c4 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,4));
        model.addAttribute("c4",c4);
        StoreConfig c5 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,5));
        model.addAttribute("c5",c5);
        StoreConfig c6 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,6));
        model.addAttribute("c6",c6);
        StoreConfig c7 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,7));
        model.addAttribute("c7",c7);
        StoreConfig c8 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,8));
        model.addAttribute("c8",c8);
        model.addAttribute("id",id);
        List<WorldCupStoreVO> worldCupStores = worldCupStoreClient.getWorldCupStoreListByStoreId(id);
        if (CollectionUtils.isEmpty(worldCupStores)){
            model.addAttribute("worldCupStores",new ArrayList<>());
        }else{
            model.addAttribute("worldCupStores",worldCupStores);
        }
        //惠民卡
        StoreConfig c10 = storeConfigService.getOne(new LambdaQueryWrapper<StoreConfig>().eq(StoreConfig::getStoreId, id).eq(StoreConfig::getType,10));
        model.addAttribute("c10",c10);
        return PREFIX + "TShop_imgAll.html";
    }
 
 
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String provinceCode, String cityCode , String name, String phone,String shopName) {
        Page<TStoreListVo> page = new PageFactory<TStoreListVo>().defaultPage();
        String roleid = UserExt.getUser().getRoleid();
        List<TStoreListVo> list =new ArrayList<>();
        if("3".equals(roleid)){
            Integer objectId = UserExt.getUser().getObjectId();
            list = storeService.listAllStore(page,provinceCode,cityCode,name,phone,shopName,objectId);
        }else {
            Integer objectId = UserExt.getUser().getObjectId();
            list = storeService.listAll(page,provinceCode,cityCode,name,phone,shopName,objectId);
        }
        page.setRecords(list);
        return  super.packForBT(page);
    }
    @RequestMapping(value = "/listOne")
    @ResponseBody
    public Object listOne(Integer id) {
        Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage();
        List<Map<String,Object>> list =  storeService.listOne(page,id);
        page.setRecords(list);
        return  super.packForBT(page);
    }
    @RequestMapping(value = "/listTwo")
    @ResponseBody
    public Object listTwo() {
        Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage();
        List<Map<String,Object>> list =  storeService.listTwo(page);
        page.setRecords(list);
        return  super.packForBT(page);
    }
    @RequestMapping(value = "/listTwo1")
    @ResponseBody
    public Object listTwo1(Integer id) {
        Page<TStoreOtherConfigTrue> page = new PageFactory<TStoreOtherConfigTrue>().defaultPage();
        List<TStoreOtherConfigTrue> list = tStoreOtherConfigTrueService.page(page,new LambdaQueryWrapper<TStoreOtherConfigTrue>().eq(TStoreOtherConfigTrue::getPid, id).eq(TStoreOtherConfigTrue::getState,1)).getRecords();
        page.setRecords(list);
        return  super.packForBT(page);
    }
 
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object list(TStore tStore,String time,String userName,String userPhone,String ids,Integer type,Integer yyId,String lat,String lon,String pCode1,String cCode1) {
        try {
            if(yyId==null || type==1){
                yyId=0;
            }
            if(yyId!=0) {
                List<TOperatorCity> list1 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, yyId));
                if(list1.size()>0){
                    if (ToolUtil.isNotEmpty(tStore.getProvinceCode())) {
                        TOperatorCity byId = operatorCityService.getOne(new QueryWrapper<TOperatorCity>().eq("code",tStore.getProvinceCode())
                                .eq("operatorId",yyId));
                        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getCode()));
                        tStore.setProvince(one.getName());
                        tStore.setProvinceCode(one.getCode());
                        List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getPid, byId.getId()).eq(TOperatorCity::getType, 2));
                        if (list.size() > 0) {
                            TOperatorCity byId1 = operatorCityService.getOne(new QueryWrapper<TOperatorCity>().eq("code",tStore.getCityCode())
                                    .eq("operatorId",yyId));
                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
                            tStore.setCity(one1.getName());
                            tStore.setCityCode(one1.getCode());
                        } else {
                            TCity byId1 = cityService.getById(tStore.getCityCode());
                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tStore.getCityCode()));
                            tStore.setCity(one1.getName());
                            tStore.setCityCode(one1.getCode());
                        }
                    }
                }else {
                    TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getProvinceCode()));
                    tStore.setProvince(one.getName());
                    tStore.setProvinceCode(one.getCode());
                    TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getCityCode()));
                    tStore.setCity(one1.getName());
                    tStore.setCityCode(one1.getCode());
                }
 
            }else {
                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, pCode1));
                if (one !=null){
                    tStore.setProvince(one.getName());
                    tStore.setProvinceCode(one.getCode());
                }
                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, cCode1));
                if (one1 !=null){
                    tStore.setCity(one1.getName());
                    tStore.setCityCode(one1.getCode());
                }
            }
            tStore.setStartTime(time.split(" - ")[0]);
            tStore.setEndTime(time.split(" - ")[1]);
            tStore.setIds(ids);
            if (UserExt.getUser().getObjectType()==2){
                tStore.setType(2);
            }else{
                tStore.setType(type);
            }
 
            tStore.setOperatorId(yyId);
            tStore.setState(1);
            tStore.setCreateTime(new Date());
            User user = new User();
            List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getAccount, userPhone));
            if(users.size()>0){
                return "5001";
            }
            user.setAccount(userPhone);
            user.setName(userName);
            user.setRoleid("3");
            user.setPhone(userPhone);
            user.setPassword(SecureUtil.md5("a123456"));
            user.setObjectType(3);
            user.setStatus(1);
            userMapper.insert(user);
            tStore.setStoreStaffId(user.getId());
            tStore.setLon(lon);
            tStore.setLat(lat);
            if (yyId == null || yyId == 0){
                tStore.setOperatorId(0);
            }else{
                tStore.setOperatorId(yyId);
            }
            if (UserExt.getUser().getObjectType()==2){
                tStore.setOperatorId(UserExt.getUser().getObjectId());
            }
 
            // 添加门店
            HashMap<String, String> map1 = new HashMap<>();
            map1.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
            map1.put("name",tStore.getName());
            map1.put("short_name",tStore.getName());
            map1.put("location",tStore.getCity());
            map1.put("address",tStore.getAddress());
            map1.put("telephone",tStore.getPhone());
            map1.put("linkman",userName);
            map1.put("business_time","[{\"start_time\":\""+tStore.getStartTime()+"\",\"close_time\":\""+tStore.getEndTime()+"\"}]");
            map1.put("logo",tStore.getCoverDrawing());
            map1.put("remark",tStore.getIntroduce());
            map1.put("lat",tStore.getLat());
            map1.put("lng",tStore.getLon());
            String result = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addSpace", map1);
            System.out.println(result);
            JSONObject jsonObject = JSONObject.parseObject(result);
            JSONObject data = jsonObject.getJSONObject("data");
            String space_id = data.getString("space_id");
            Integer integer = Integer.valueOf(space_id);
            tStore.setId(integer);
            storeService.save(tStore);
            user.setObjectId(tStore.getId());
            userService.updateById(user);
            ArrayList<StoreConfig> storeConfigs = new ArrayList<>();
            for (int i = 1; i < 9; i++) {
                StoreConfig storeConfig = new StoreConfig();
                storeConfig.setIsOpen(1);
                storeConfig.setSort(i);
                storeConfig.setType(i);
                storeConfig.setStoreId(tStore.getId());
                storeConfigs.add(storeConfig);
            }
            storeConfigService.saveBatch(storeConfigs);
            // 废弃添加门店时 添加闸机
//            HashMap<String, String> mapSite = new HashMap<>();
//            mapSite.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
//            mapSite.put("name",tStore.getName());
//            mapSite.put("space_id",tStore.getId().toString());
//            mapSite.put("area_id",tSite.getId().toString());
//            HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addSpaceArea", mapSite);
//            for (String s : tStore.getIds().split(",")) {
//                HashMap<String, String> map = new HashMap<>();
//                map.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
//                map.put("space_id",tStore.getId()+"");
//                map.put("device_id",s);
//                map.put("region_id",tSite.getId().toString());
//                // 添加门禁
//                String s1 = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addDevice", map);
//                System.out.println(s1);
//            }
            return new SuccessTip<>();
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TStore tStore,String time,String userName,String userPhone,String ids,Integer type,Integer yyId,String lat,String lon,String pCode1,String cCode1) {
        try {
            TStore byIdc = storeService.getById(tStore.getId());
 
            if(yyId==null){
                yyId=0;
            }
            if(tStore.getType()==1){
                yyId=0;
            }
            if(yyId!=0) {
                List<TOperatorCity> list1 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, yyId));
                if(list1.size()>0){
                    if (ToolUtil.isNotEmpty(tStore.getProvinceCode())) {
                        TOperatorCity byId = operatorCityService.getOne(new QueryWrapper<TOperatorCity>().eq("operatorId", yyId)
                                .eq("code", tStore.getProvinceCode()));
                        TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId.getCode()));
                        tStore.setProvince(one.getName());
                        tStore.setProvinceCode(one.getCode());
                        List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>()
                                .eq(TOperatorCity::getPid, byId.getId()).ne(TOperatorCity::getPid, 0));
                        if (list.size() > 0) {
                            TOperatorCity byId1 = operatorCityService.getOne(new QueryWrapper<TOperatorCity>().eq("operatorId", yyId)
                                    .eq("code", tStore.getCityCode()));
                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
                            tStore.setCity(one1.getName());
                            tStore.setCityCode(one1.getCode());
                        } else {
                            TCity byId1 = cityService.getOne(new QueryWrapper<TCity>().eq("code",tStore.getCityCode()));
                            TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, byId1.getCode()));
                            tStore.setCity(one1.getName());
                            tStore.setCityCode(one1.getCode());
                        }
                    }
                }else {
                    TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getProvinceCode()));
                    tStore.setProvince(one.getName());
                    tStore.setProvinceCode(one.getCode());
                    TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getId, tStore.getCityCode()));
                    tStore.setCity(one1.getName());
                    tStore.setCityCode(one1.getCode());
                }
 
            }else {
                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tStore.getProvinceCode()));
                tStore.setProvince(one.getName());
                tStore.setProvinceCode(one.getCode());
                TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, tStore.getCityCode()));
                tStore.setCity(one1.getName());
                tStore.setCityCode(one1.getCode());
            }
            tStore.setStartTime(time.split(" - ")[0]);
            tStore.setEndTime(time.split(" - ")[1]);
            tStore.setIds(ids);
            tStore.setType(type);
            tStore.setOperatorId(yyId);
            if(ToolUtil.isEmpty(tStore.getCoverDrawing())){
                tStore.setCoverDrawing(byIdc.getCoverDrawing());
            }
            User user = userMapper.selectById(byIdc.getStoreStaffId());
            List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getAccount, userPhone).ne(User::getId,tStore.getStoreStaffId()));
            if(users.size()>0){
                return "5001";
            }
            user.setAccount(userPhone);
            user.setName(userName);
            user.setPhone(userPhone);
            userMapper.updateById(user);
            tStore.setLon(lon);
            tStore.setLat(lat);
            // 运营商编辑
            if (UserExt.getUser().getObjectType()==2){
                tStore.setOperatorId(null);
            }
            storeService.updateById(tStore);
 
            return new SuccessTip<>();
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/onChange")
    @ResponseBody
    public Object onChange(Integer oneId) {
        try {
            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, oneId));
            return cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/saveImgAll")
    @ResponseBody
    public Object saveImgAll(Integer id,Integer px1,Integer px2,Integer px3,Integer px4,Integer px5,Integer px6,Integer px7,Integer px8,Integer px10,
                             String c1,String c2,String c3,String c4,String c5,String c6,String c7,String c8,String c10,
                             Integer r1,Integer r2,Integer r3,Integer r4,Integer r5,Integer r6,Integer r7,Integer r8,Integer r10,String str) {
        try {
            ArrayList<StoreConfig> storeConfigs = new ArrayList<>();
            StoreConfig collect1 = collect(id, px1, r1, c1, 1);
            StoreConfig collect2 = collect(id, px2, r2, c2, 2);
            StoreConfig collect3 = collect(id, px3, r3, c3, 3);
            StoreConfig collect4 = collect(id, px4, r4, c4, 4);
            StoreConfig collect5 = collect(id, px5, r5, c5, 5);
            StoreConfig collect6 = collect(id, px6, r6, c6, 6);
            StoreConfig collect7 = collect(id, px7, r7, c7, 7);
            StoreConfig collect8 = collect(id, px8, r8, c8, 8);
            StoreConfig collect10 = collect(id, px10, r10, c10, 10);
            storeConfigs.add(collect1);
            storeConfigs.add(collect2);
            storeConfigs.add(collect3);
            storeConfigs.add(collect4);
            storeConfigs.add(collect5);
            storeConfigs.add(collect6);
            storeConfigs.add(collect7);
            storeConfigs.add(collect8);
            storeConfigs.add(collect10);
            storeConfigService.saveOrUpdateBatch(storeConfigs);
 
            // 修改世界杯
            JSONArray jsonArray = JSONObject.parseArray(str);
            List<WorldCupStore> worldCupStores = new ArrayList<>();
            for (Object o : jsonArray) {
                String s = JSONObject.toJSONString(o);
                JSONObject jsonObject = JSONObject.parseObject(s);
                Integer id1 = jsonObject.getInteger("id");
                String backgroundImage = jsonObject.getString("backgroundImage");
                Integer isOpen = jsonObject.getInteger("isOpen");
                Integer sort = jsonObject.getInteger("sort");
                WorldCupStore worldCupStore = new WorldCupStore();
                worldCupStore.setSort(sort);
                worldCupStore.setId(id1);
                worldCupStore.setBackgroundImage(backgroundImage);
                worldCupStore.setIsOpen(isOpen);
                worldCupStores.add(worldCupStore);
            }
            worldCupStoreClient.updateWorldCupStoreListById(worldCupStores);
 
            return new SuccessTip<>();
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    private StoreConfig collect(Integer id,Integer sort,Integer isOpen,String img,int type){
        StoreConfig one = storeConfigService.getOne(new QueryWrapper<StoreConfig>()
                .eq("storeId", id)
                .eq("type", type));
        if (one!=null){
            one.setSort(sort);
            one.setIsOpen(isOpen);
            if(ToolUtil.isNotEmpty(img)){
                one.setBackgroundImage(img);
            }
        }
        if (one == null){
            StoreConfig storeConfig = new StoreConfig();
            storeConfig.setStoreId(id);
            storeConfig.setType(type);
            storeConfig.setIsOpen(isOpen);
            storeConfig.setSort(sort);
            storeConfig.setBackgroundImage(img);
            storeConfigService.save(storeConfig);
            return storeConfig;
        }
 
        return one;
    }
    @RequestMapping(value = "/oneChangeNext")
    @ResponseBody
    public Object oneChangeNext(String oneId) {
 
        try {
            CityListQuery cityListQuery = new CityListQuery();
            cityListQuery.setCityCode(oneId);
            cityListQuery.setOffset(1);
            cityListQuery.setLimit(100000);
            Page<TCityManager> list = cityClient.list(cityListQuery);
            List<TCityManager> records = list.getRecords();
            for (TCityManager record : records) {
                record.setName(record.getName()+"-"+record.getPhone());
            }
            return records;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @Autowired
    private TOperatorCityService operatorCityService;
 
    @RequestMapping(value = "/onChange1")
    @ResponseBody
    public Object onChange1(Integer oneId) {
        try {
            List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, oneId).eq(TOperatorCity::getType, 1));
            if(list.size()==0){
                List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
                return list1;
            }else {
 
                return list;
            }
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @RequestMapping(value = "/onChange2")
    @ResponseBody
    public Object onChange2(Integer oneId) {
        try {
            List<TOperatorCity> list1 = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getId, oneId).eq(TOperatorCity::getType, 1));
            List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getPid, oneId).eq(TOperatorCity::getType, 2));
 
            // 若是全国 为空 去找这个省下面的市
            if(list1.size()==0){
                TCity byId = cityService.getById(oneId);
                List<TCity> list2 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, byId.getId()));
                return list2;
            }
            if(list.size()==0){
                TOperatorCity tOperatorCity = list1.get(0);
                Integer code = tOperatorCity.getCode();
                TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, code));
                List<TCity> list2 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, one.getId()));
                return list2;
            }else {
                return list;
            }
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
 
    @RequestMapping(value = "/cancel")
    public Object cancel(Integer id) {
        try {
            competitionClient.cancel(id);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @ResponseBody
    @RequestMapping(value = "/deleteOne")
    public Object delete1(Integer id) {
        try {
            storeService.delete1(id);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @ResponseBody
    @RequestMapping(value = "/deleteTwo")
    public Object delete2(Integer id) {
        try {
            tStoreOtherConfigTrueService.removeById(id);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @ResponseBody
    @RequestMapping(value = "/del")
    public Object del(Integer id) {
        try {
            storeOtherService.removeById(id);
            tStoreOtherConfigTrueService.remove(new LambdaQueryWrapper<TStoreOtherConfigTrue>().eq(TStoreOtherConfigTrue::getPid,id));
 
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @RequestMapping(value = "/saveImg")
    @ResponseBody
    public Object saveImg(Integer id,String img) {
        try {
            TStore byId = storeService.getById(id);
            byId.setWelfarePicture(img);
            storeService.updateById(byId);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @RequestMapping(value = "/freeze")
    @ResponseBody
    public Object freeze(Integer id) {
        try {
            // 查询门店 获取门店店长id
            TStore store = storeService.getById(id);
            // 冻结
            store.setState(2);
            storeService.updateById(store);
            Integer storeStaffId = store.getStoreStaffId();
            User user = userService.getById(storeStaffId);
            user.setStatus(2);
            userService.updateById(user);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/unfreeze")
    @ResponseBody
    public Object unfreeze(Integer id) {
        try {
            // 查询门店 获取门店店长id
            TStore store = storeService.getById(id);
            // 解冻
            store.setState(1);
            storeService.updateById(store);
            Integer storeStaffId = store.getStoreStaffId();
            User user = userService.getById(storeStaffId);
            user.setStatus(1);
            userService.updateById(user);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @RequestMapping(value = "/unfreeze1")
    @ResponseBody
    public Object unfreeze1(Integer id,Integer type) {
        try {
            TStoreOther byId = storeOtherService.getById(id);
            byId.setState(type);
            storeOtherService.updateById(byId);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @RequestMapping(value = "/pwd")
    @ResponseBody
    public Object pwd(Integer id) {
        try {
            TStore byId = storeService.getById(id);
            User user = userMapper.selectById(byId.getStoreStaffId());
            user.setPassword(SecureUtil.md5("a123456"));
            userMapper.updateById(user);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/typeChange")
    @ResponseBody
    public Object typeChange(String name) {
        try {
            List<Map<String,Object>> list = storeService.typeChange(name);
            return list;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/typeChangeOne")
    @ResponseBody
    public Object typeChangeOne(Integer id) {
        try {
            List<Map<String,Object>> list = storeService.typeChangeOne(id);
            return list;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    /**
     * ajax.set("url",url);
     *     ajax.set("name",name);
     *     ajax.set("page",page);
     *     ajax.set("type",type);
     *     ajax.set("turnId",turnId);
     *     ajax.set("sort",sort);
     * @return
     */
    @RequestMapping(value = "/addConfigOne")
    @ResponseBody
    public Object addConfigOne(String url,String name,Integer page,Integer type,String  turnId,Integer sort) {
        try {
            storeService.addConfigOne(url,name,page,type,turnId,sort);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/addConfig")
    @ResponseBody
    public Object addConfig(String name,Integer id,Integer sort) {
        try {
            List<TStoreOtherConfig> list = storeOtherConfigService.list();
            if(list.size()>0){
                TStoreOther tStoreOther = new TStoreOther();
                tStoreOther.setName(name);
                tStoreOther.setStoreId(id);
                tStoreOther.setSort(sort);
                storeOtherService.save(tStoreOther);
 
                // 找出temp表数据
 
                ArrayList<TStoreOtherConfigTrue> tStoreOtherConfigTrues = new ArrayList<>();
                for (TStoreOtherConfig tStoreOtherConfig : list) {
                    TStoreOtherConfigTrue tStoreOtherConfigTrue = new TStoreOtherConfigTrue();
                    BeanUtils.copyProperties(tStoreOtherConfig,tStoreOtherConfigTrue);
                    tStoreOtherConfigTrue.setPid(tStoreOther.getId());
                    tStoreOtherConfigTrues.add(tStoreOtherConfigTrue);
                }
                tStoreOtherConfigTrueService.saveBatch(tStoreOtherConfigTrues);
                storeOtherConfigService.remove(new LambdaQueryWrapper<TStoreOtherConfig>().gt(TStoreOtherConfig::getId,0));
            }
 
 
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/addConfig1")
    @ResponseBody
    public Object addConfig1(String name,Integer id,Integer sort) {
        try {
            TStoreOther byId = storeOtherService.getById(id);
            byId.setName(name);
            byId.setSort(sort);
            storeOtherService.updateById(byId);
 
 
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/updateConfigOne")
    @ResponseBody
    public Object addConfigOne(String url,String name,Integer page,Integer type,String  turnId,Integer sort,Integer id) {
        try {
            TStoreOtherConfig byId = storeOtherConfigService.getById(id);
            if(ToolUtil.isNotEmpty(url)){
                byId.setUrl(url);
            }
            byId.setName(name);
            TTurn byId1 = tTurnService.getById(page);
            TTurn byId2 = tTurnService.getById(type);
            byId.setPage(byId1.getName());
            byId.setType(byId2.getName());
            byId.setTurnId(turnId);
            byId.setSort(sort);
            byId.setPageId(page);
            byId.setTypeId(type);
            storeOtherConfigService.updateById(byId);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    @RequestMapping(value = "/updateConfigOne3")
    @ResponseBody
    public Object addConfigOne3(String url,String name,Integer page,Integer type,String  turnId,Integer sort,Integer id) {
        try {
            TStoreOtherConfigTrue byId = tStoreOtherConfigTrueService.getById(id);
            if(ToolUtil.isNotEmpty(url)){
                byId.setUrl(url);
            }
            byId.setName(name);
            if(page!=null){
                TTurn byId1 = tTurnService.getById(page);
                byId.setPage(byId1.getName());
            }
            if(page!=null){
                TTurn byId2 = tTurnService.getById(type);
                byId.setType(byId2.getName());
            }
            byId.setTurnId(turnId);
            byId.setSort(sort);
            byId.setPageId(page);
            byId.setTypeId(type);
            tStoreOtherConfigTrueService.updateById(byId);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
    @RequestMapping(value = "/addConfigOne9")
    @ResponseBody
    public Object addConfigOne9(String url,String name,Integer page,Integer type,String  turnId,Integer sort,Integer id) {
        try {
            TStoreOtherConfigTrue byId = new TStoreOtherConfigTrue();
            byId.setPid(id);
            if(ToolUtil.isNotEmpty(url)){
                byId.setUrl(url);
            }
            byId.setName(name);
            if(page!=null){
                TTurn byId1 = tTurnService.getById(page);
                byId.setPage(byId1.getName());
            }
            if(page!=null){
                TTurn byId2 = tTurnService.getById(type);
                byId.setType(byId2.getName());
            }
            byId.setTurnId(turnId);
            byId.setSort(sort);
            byId.setPageId(page);
            byId.setTypeId(type);
            byId.setState(1);
            tStoreOtherConfigTrueService.save(byId);
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
 
 
}