huliguo
15 小时以前 c5d38d650d2ac4101b1293a4f17346e7d5420076
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.shop.mapper.shop.ShopMapper">
 
    <resultMap type="com.ruoyi.system.api.domain.poji.shop.Shop" id="ShopResult">
        <result property="shopId"    column="shop_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="shopStatus"    column="shop_status"    />
        <result property="createTime"    column="create_time"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateUserId"    column="update_user_id"    />
        <result property="shopName"    column="shop_name"    />
        <result property="shopNumber"    column="shop_number"    />
        <result property="shopType"    column="shop_type"    />
        <result property="businessStartTime"    column="business_start_time"    />
        <result property="businessEndTime"    column="business_end_time"    />
        <result property="shopownerName"    column="shopowner_name"    />
        <result property="shopownerPhone"    column="shopowner_phone"    />
        <result property="signTime"    column="sign_time"    />
        <result property="signProvinceCode"    column="sign_province_code"    />
        <result property="signCityCode"    column="sign_city_code"    />
        <result property="signAreaCode"    column="sign_area_code"    />
        <result property="signAreaName"    column="sign_area_name"    />
        <result property="shopServicePhone"    column="shop_service_phone"    />
        <result property="belongUserId"    column="belong_user_id"    />
        <result property="belongShopId"    column="belong_shop_id"    />
        <result property="supportingCapacityFlag"    column="supporting_capacity_flag"    />
        <result property="operationPersonFlag"    column="operation_person_flag"    />
        <result property="executiveForceFlag"    column="executive_force_flag"    />
        <result property="patternFlag"    column="pattern_flag"    />
        <result property="connectionFlag"    column="connection_flag"    />
        <result property="economicAbilityFlag"    column="economic_ability_flag"    />
        <result property="relationPartner"    column="relation_partner"    />
        <result property="businessHistory"    column="business_history"    />
        <result property="shopProvinceCode"    column="shop_province_code"    />
        <result property="shopCityCode"    column="shop_city_code"    />
        <result property="shopAreaCode"    column="shop_area_code"    />
        <result property="shopAreaName"    column="shop_area_name"    />
        <result property="shopAddress"    column="shop_address"    />
        <result property="shopLongitude"    column="shop_longitude"    />
        <result property="shopLatitude"    column="shop_latitude"    />
        <result property="shopDetail"    column="shop_detail"    />
        <result property="marketingFunctionFlag"    column="marketing_function_flag"    />
        <result property="platformCouponFlag"    column="platform_coupon_flag"    />
        <result property="platformBirthdayFlag"    column="platform_birthday_flag"    />
        <result property="shopCustomStatus"    column="shop_custom_status"    />
        <result property="recommendPerson"    column="recommend_person"    />
        <result property="cooperationEndTime"    column="cooperation_end_time"    />
        <result property="cooperationStartTime"    column="cooperation_start_time"    />
        <result property="shopTags"    column="shop_tags"    />
        <result property="signUserId"    column="sign_user_id"    />
        <result property="shopSource"    column="shop_source"    />
        <result property="frozenFlag"    column="frozen_flag"    />
        <result property="cooperativeFlag"    column="cooperative_flag"    />
        <result property="modifyPricePermission"    column="modify_price_permission"    />
 
    </resultMap>
 
    <sql id="selectShopVo">
        select shop_id, del_flag, shop_status, create_time, create_user_id, update_time, update_user_id, shop_name, shop_number, shop_type, business_start_time, business_end_time, shopowner_name, shopowner_phone, sign_time, sign_province_code, sign_city_code, sign_area_code, sign_area_name, shop_service_phone, belong_user_id, belong_shop_id, supporting_capacity_flag, operation_person_flag, executive_force_flag, pattern_flag, connection_flag, economic_ability_flag, relation_partner, business_history, shop_province_code, shop_city_code, shop_area_code, shop_area_name, shop_address, shop_longitude, shop_latitude, shop_detail, marketing_function_flag, platform_coupon_flag, platform_birthday_flag, shop_custom_status, recommend_person, cooperation_end_time, cooperation_start_time, shop_tags, sign_user_id, shop_source from t_shop
    </sql>
 
    <select id="selectShopList" parameterType="com.ruoyi.system.api.domain.poji.shop.Shop" resultMap="ShopResult">
        <include refid="selectShopVo"/>
        <where>
            <if test="shopStatus != null "> and shop_status = #{shopStatus}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
            <if test="shopName != null  and shopName != ''"> and shop_name like concat('%', #{shopName}, '%')</if>
            <if test="shopNumber != null  and shopNumber != ''"> and shop_number = #{shopNumber}</if>
            <if test="shopType != null "> and shop_type = #{shopType}</if>
            <if test="businessStartTime != null  and businessStartTime != ''"> and business_start_time = #{businessStartTime}</if>
            <if test="businessEndTime != null  and businessEndTime != ''"> and business_end_time = #{businessEndTime}</if>
            <if test="shopownerName != null  and shopownerName != ''"> and shopowner_name like concat('%', #{shopownerName}, '%')</if>
            <if test="shopownerPhone != null  and shopownerPhone != ''"> and shopowner_phone = #{shopownerPhone}</if>
            <if test="signTime != null "> and sign_time = #{signTime}</if>
            <if test="signProvinceCode != null  and signProvinceCode != ''"> and sign_province_code = #{signProvinceCode}</if>
            <if test="signCityCode != null  and signCityCode != ''"> and sign_city_code = #{signCityCode}</if>
            <if test="signAreaCode != null  and signAreaCode != ''"> and sign_area_code = #{signAreaCode}</if>
            <if test="signAreaName != null  and signAreaName != ''"> and sign_area_name like concat('%', #{signAreaName}, '%')</if>
            <if test="shopServicePhone != null  and shopServicePhone != ''"> and shop_service_phone = #{shopServicePhone}</if>
            <if test="belongUserId != null "> and belong_user_id = #{belongUserId}</if>
            <if test="belongShopId != null "> and belong_shop_id = #{belongShopId}</if>
            <if test="supportingCapacityFlag != null "> and supporting_capacity_flag = #{supportingCapacityFlag}</if>
            <if test="operationPersonFlag != null "> and operation_person_flag = #{operationPersonFlag}</if>
            <if test="executiveForceFlag != null "> and executive_force_flag = #{executiveForceFlag}</if>
            <if test="patternFlag != null "> and pattern_flag = #{patternFlag}</if>
            <if test="connectionFlag != null "> and connection_flag = #{connectionFlag}</if>
            <if test="economicAbilityFlag != null "> and economic_ability_flag = #{economicAbilityFlag}</if>
            <if test="relationPartner != null "> and relation_partner = #{relationPartner}</if>
            <if test="businessHistory != null  and businessHistory != ''"> and business_history = #{businessHistory}</if>
            <if test="shopProvinceCode != null  and shopProvinceCode != ''"> and shop_province_code = #{shopProvinceCode}</if>
            <if test="shopCityCode != null  and shopCityCode != ''"> and shop_city_code = #{shopCityCode}</if>
            <if test="shopAreaCode != null  and shopAreaCode != ''"> and shop_area_code = #{shopAreaCode}</if>
            <if test="shopAreaName != null  and shopAreaName != ''"> and shop_area_name like concat('%', #{shopAreaName}, '%')</if>
            <if test="shopAddress != null  and shopAddress != ''"> and shop_address = #{shopAddress}</if>
            <if test="shopLongitude != null  and shopLongitude != ''"> and shop_longitude = #{shopLongitude}</if>
            <if test="shopLatitude != null  and shopLatitude != ''"> and shop_latitude = #{shopLatitude}</if>
            <if test="shopDetail != null  and shopDetail != ''"> and shop_detail = #{shopDetail}</if>
            <if test="marketingFunctionFlag != null "> and marketing_function_flag = #{marketingFunctionFlag}</if>
            <if test="platformCouponFlag != null "> and platform_coupon_flag = #{platformCouponFlag}</if>
            <if test="platformBirthdayFlag != null "> and platform_birthday_flag = #{platformBirthdayFlag}</if>
            <if test="shopCustomStatus != null  and shopCustomStatus != ''"> and shop_custom_status = #{shopCustomStatus}</if>
            <if test="recommendPerson != null  and recommendPerson != ''"> and recommend_person = #{recommendPerson}</if>
            <if test="cooperationEndTime != null "> and cooperation_end_time = #{cooperationEndTime}</if>
            <if test="cooperationStartTime != null "> and cooperation_start_time = #{cooperationStartTime}</if>
            <if test="shopTags != null  and shopTags != ''"> and shop_tags = #{shopTags}</if>
            <if test="signUserId != null "> and sign_user_id = #{signUserId}</if>
            <if test="shopSource != null  and shopSource != ''"> and shop_source = #{shopSource}</if>
            <if test="frozenFlag != null  and frozenFlag != ''"> and frozen_flag = #{frozenFlag}</if>
            <if test="cooperativeFlag != null  and cooperativeFlag != ''"> and cooperative_flag = #{cooperativeFlag}</if>
            <if test="modifyPricePermission != null and modifyPricePermission != ''">and modify_price_permission = #{modifyPricePermission}</if>
        </where>
    </select>
 
    <select id="selectShopByShopId" parameterType="Long" resultMap="ShopResult">
        <include refid="selectShopVo"/>
        where shop_id = #{shopId}
    </select>
 
    <insert id="insertShop" parameterType="com.ruoyi.system.api.domain.poji.shop.Shop" useGeneratedKeys="true" keyProperty="shopId">
        insert into t_shop
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="shopStatus != null">shop_status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateUserId != null">update_user_id,</if>
            <if test="shopName != null">shop_name,</if>
            <if test="shopNumber != null">shop_number,</if>
            <if test="shopType != null">shop_type,</if>
            <if test="businessStartTime != null">business_start_time,</if>
            <if test="businessEndTime != null">business_end_time,</if>
            <if test="shopownerName != null">shopowner_name,</if>
            <if test="shopownerPhone != null">shopowner_phone,</if>
            <if test="signTime != null">sign_time,</if>
            <if test="signProvinceCode != null">sign_province_code,</if>
            <if test="signCityCode != null">sign_city_code,</if>
            <if test="signAreaCode != null">sign_area_code,</if>
            <if test="signAreaName != null">sign_area_name,</if>
            <if test="shopServicePhone != null">shop_service_phone,</if>
            <if test="belongUserId != null">belong_user_id,</if>
            <if test="belongShopId != null">belong_shop_id,</if>
            <if test="supportingCapacityFlag != null">supporting_capacity_flag,</if>
            <if test="operationPersonFlag != null">operation_person_flag,</if>
            <if test="executiveForceFlag != null">executive_force_flag,</if>
            <if test="patternFlag != null">pattern_flag,</if>
            <if test="connectionFlag != null">connection_flag,</if>
            <if test="economicAbilityFlag != null">economic_ability_flag,</if>
            <if test="relationPartner != null">relation_partner,</if>
            <if test="businessHistory != null">business_history,</if>
            <if test="shopProvinceCode != null">shop_province_code,</if>
            <if test="shopCityCode != null">shop_city_code,</if>
            <if test="shopAreaCode != null">shop_area_code,</if>
            <if test="shopAreaName != null">shop_area_name,</if>
            <if test="shopAddress != null">shop_address,</if>
            <if test="shopLongitude != null">shop_longitude,</if>
            <if test="shopLatitude != null">shop_latitude,</if>
            <if test="shopDetail != null">shop_detail,</if>
            <if test="marketingFunctionFlag != null">marketing_function_flag,</if>
            <if test="platformCouponFlag != null">platform_coupon_flag,</if>
            <if test="platformBirthdayFlag != null">platform_birthday_flag,</if>
            <if test="shopCustomStatus != null">shop_custom_status,</if>
            <if test="recommendPerson != null">recommend_person,</if>
            <if test="cooperationEndTime != null">cooperation_end_time,</if>
            <if test="cooperationStartTime != null">cooperation_start_time,</if>
            <if test="shopTags != null">shop_tags,</if>
            <if test="signUserId != null">sign_user_id,</if>
            <if test="shopSource != null">shop_source,</if>
            <if test="modifyPricePermission != null">modify_price_permission,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="shopStatus != null">#{shopStatus},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="shopName != null">#{shopName},</if>
            <if test="shopNumber != null">#{shopNumber},</if>
            <if test="shopType != null">#{shopType},</if>
            <if test="businessStartTime != null">#{businessStartTime},</if>
            <if test="businessEndTime != null">#{businessEndTime},</if>
            <if test="shopownerName != null">#{shopownerName},</if>
            <if test="shopownerPhone != null">#{shopownerPhone},</if>
            <if test="signTime != null">#{signTime},</if>
            <if test="signProvinceCode != null">#{signProvinceCode},</if>
            <if test="signCityCode != null">#{signCityCode},</if>
            <if test="signAreaCode != null">#{signAreaCode},</if>
            <if test="signAreaName != null">#{signAreaName},</if>
            <if test="shopServicePhone != null">#{shopServicePhone},</if>
            <if test="belongUserId != null">#{belongUserId},</if>
            <if test="belongShopId != null">#{belongShopId},</if>
            <if test="supportingCapacityFlag != null">#{supportingCapacityFlag},</if>
            <if test="operationPersonFlag != null">#{operationPersonFlag},</if>
            <if test="executiveForceFlag != null">#{executiveForceFlag},</if>
            <if test="patternFlag != null">#{patternFlag},</if>
            <if test="connectionFlag != null">#{connectionFlag},</if>
            <if test="economicAbilityFlag != null">#{economicAbilityFlag},</if>
            <if test="relationPartner != null">#{relationPartner},</if>
            <if test="businessHistory != null">#{businessHistory},</if>
            <if test="shopProvinceCode != null">#{shopProvinceCode},</if>
            <if test="shopCityCode != null">#{shopCityCode},</if>
            <if test="shopAreaCode != null">#{shopAreaCode},</if>
            <if test="shopAreaName != null">#{shopAreaName},</if>
            <if test="shopAddress != null">#{shopAddress},</if>
            <if test="shopLongitude != null">#{shopLongitude},</if>
            <if test="shopLatitude != null">#{shopLatitude},</if>
            <if test="shopDetail != null">#{shopDetail},</if>
            <if test="marketingFunctionFlag != null">#{marketingFunctionFlag},</if>
            <if test="platformCouponFlag != null">#{platformCouponFlag},</if>
            <if test="platformBirthdayFlag != null">#{platformBirthdayFlag},</if>
            <if test="shopCustomStatus != null">#{shopCustomStatus},</if>
            <if test="recommendPerson != null">#{recommendPerson},</if>
            <if test="cooperationEndTime != null">#{cooperationEndTime},</if>
            <if test="cooperationStartTime != null">#{cooperationStartTime},</if>
            <if test="shopTags != null">#{shopTags},</if>
            <if test="signUserId != null">#{signUserId},</if>
            <if test="shopSource != null">#{shopSource},</if>
            <if test="modifyPricePermission != null">#{modifyPricePermission},</if>
        </trim>
    </insert>
 
    <update id="updateShop" parameterType="com.ruoyi.system.api.domain.poji.shop.Shop">
        update t_shop
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="shopStatus != null">shop_status = #{shopStatus},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateUserId != null">update_user_id = #{updateUserId},</if>
            <if test="shopName != null">shop_name = #{shopName},</if>
            <if test="shopNumber != null">shop_number = #{shopNumber},</if>
            <if test="shopType != null">shop_type = #{shopType},</if>
            <if test="businessStartTime != null">business_start_time = #{businessStartTime},</if>
            <if test="businessEndTime != null">business_end_time = #{businessEndTime},</if>
            <if test="shopownerName != null">shopowner_name = #{shopownerName},</if>
            <if test="shopownerPhone != null">shopowner_phone = #{shopownerPhone},</if>
            <if test="signTime != null">sign_time = #{signTime},</if>
            <if test="signProvinceCode != null">sign_province_code = #{signProvinceCode},</if>
            <if test="signCityCode != null">sign_city_code = #{signCityCode},</if>
            <if test="signAreaCode != null">sign_area_code = #{signAreaCode},</if>
            <if test="signAreaName != null">sign_area_name = #{signAreaName},</if>
            <if test="shopServicePhone != null">shop_service_phone = #{shopServicePhone},</if>
            <if test="belongUserId != null">belong_user_id = #{belongUserId},</if>
            <if test="belongShopId != null">belong_shop_id = #{belongShopId},</if>
            <if test="supportingCapacityFlag != null">supporting_capacity_flag = #{supportingCapacityFlag},</if>
            <if test="operationPersonFlag != null">operation_person_flag = #{operationPersonFlag},</if>
            <if test="executiveForceFlag != null">executive_force_flag = #{executiveForceFlag},</if>
            <if test="patternFlag != null">pattern_flag = #{patternFlag},</if>
            <if test="connectionFlag != null">connection_flag = #{connectionFlag},</if>
            <if test="economicAbilityFlag != null">economic_ability_flag = #{economicAbilityFlag},</if>
            <if test="relationPartner != null">relation_partner = #{relationPartner},</if>
            <if test="businessHistory != null">business_history = #{businessHistory},</if>
            <if test="shopProvinceCode != null">shop_province_code = #{shopProvinceCode},</if>
            <if test="shopCityCode != null">shop_city_code = #{shopCityCode},</if>
            <if test="shopAreaCode != null">shop_area_code = #{shopAreaCode},</if>
            <if test="shopAreaName != null">shop_area_name = #{shopAreaName},</if>
            <if test="shopAddress != null">shop_address = #{shopAddress},</if>
            <if test="shopLongitude != null">shop_longitude = #{shopLongitude},</if>
            <if test="shopLatitude != null">shop_latitude = #{shopLatitude},</if>
            <if test="shopDetail != null">shop_detail = #{shopDetail},</if>
            <if test="marketingFunctionFlag != null">marketing_function_flag = #{marketingFunctionFlag},</if>
            <if test="platformCouponFlag != null">platform_coupon_flag = #{platformCouponFlag},</if>
            <if test="platformBirthdayFlag != null">platform_birthday_flag = #{platformBirthdayFlag},</if>
            <if test="shopCustomStatus != null">shop_custom_status = #{shopCustomStatus},</if>
            <if test="recommendPerson != null">recommend_person = #{recommendPerson},</if>
            <if test="cooperationEndTime != null">cooperation_end_time = #{cooperationEndTime},</if>
            <if test="cooperationStartTime != null">cooperation_start_time = #{cooperationStartTime},</if>
            <if test="shopTags != null">shop_tags = #{shopTags},</if>
            <if test="signUserId != null">sign_user_id = #{signUserId},</if>
            <if test="shopSource != null">shop_source = #{shopSource},</if>
            <if test="modifyPricePermission != null">modify_price_permission = #{modifyPricePermission},</if>
        </trim>
        where shop_id = #{shopId}
    </update>
 
    <delete id="deleteShopByShopId" parameterType="Long">
        delete from t_shop where shop_id = #{shopId}
    </delete>
 
    <delete id="deleteShopByShopIds" parameterType="String">
        delete from t_shop where shop_id in
        <foreach item="shopId" collection="array" open="(" separator="," close=")">
            #{shopId}
        </foreach>
    </delete>
 
    <select id="pageMgtShop" resultType="com.ruoyi.shop.domain.vo.MgtShopPageVo">
        SELECT
        ts.shop_id shopId,
        ts.sign_time signTime,
        ts.shop_name shopName,
        ts.shop_number shopNumber,
        ts.shop_tags shopTags,
        ts.sign_user_id signUserId,
        null firstWithdraw,
        ts.belong_user_id belongUserId,
        ts.shop_source shopSource,
        ts.sign_area_name signAreaName,
        CONCAT(ts.cooperation_start_time,'-',ts.cooperation_end_time) cooperationTime,
        CONCAT(ts.shop_area_name,ts.shop_address) shopAddress,
        ts.shopowner_name shopownerName,
        ts.shopowner_phone shopownerPhone,
        CASE ts.shop_status
        WHEN 0 THEN "冻结"
        WHEN 1 THEN "正常"
        WHEN 2 THEN "终止合作"
        WHEN 3 THEN "进件中"
        END shopStatus,
        tsm.shop_marketing_total shopActivityCount,
        ts.shop_custom_status shopCustomStatus,
        ts.frozen_flag frozenFlag,
        ts.cooperative_flag cooperativeFlag,
        CASE ts.cooperative_flag WHEN 0 THEN "否" WHEN 1 THEN "是" END deadlineFlag
        FROM t_shop ts
        LEFT JOIN t_shop_marketing tsm ON tsm.shop_id = ts.shop_id
        WHERE ts.del_flag = 0
        <if test="param.shopType!=null and param.shopType!=''">
            AND ts.shop_type = #{param.shopType}
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.signStartTime!=null and param.signStartTime!=''">
            AND Date(ts.sign_time) &gt;= #{param.signStartTime}
        </if>
        <if test="param.signEndTime!=null and param.signEndTime!=''">
            AND Date(ts.sign_time) &lt;= #{param.signEndTime}
        </if>
        <if test="param.signProvinceCode!=null and param.signProvinceCode!=''">
            AND ts.sign_province_code REGEXP CONCAT('(^|;)' , #{param.signProvinceCode} , '(;|$)')   -- 正则表达式 (^|;) 匹配字符串开头或分号,(;|$) 匹配分号或字符串结尾。
        </if>
        <if test="param.signCityCode!=null and param.signCityCode!=''">
            AND ts.sign_city_code = REGEXP CONCAT('(^|;)' ,#{param.signCityCode} , '(;|$)')
        </if>
        <if test="param.signAreaCode!=null and param.signAreaCode!=''">
            AND ts.sign_area_code = REGEXP CONCAT('(^|;)' ,#{param.signAreaCode}, '(;|$)')
        </if>
        <if test="param.shopStatus!=null and param.shopStatus==0">
            AND ts.frozen_flag = 1
        </if>
        <if test="param.shopStatus!=null and param.shopStatus==1">
            AND ts.frozen_flag = 0
        </if>
        <if test="param.recommendPerson!=null and param.recommendPerson!=''">
            AND ts.recommend_person = #{param.recommendPerson}
        </if>
        <if test="param.belongUserId != null">
            AND ts.belong_user_id = #{param.belongUserId}
        </if>
        <if test="param.belongUserIds != null and param.belongUserIds.size() > 0">
            AND ts.belong_user_id in
            <foreach collection="param.belongUserIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.belongShopId!=null and param.belongShopId!=''">
            AND ts.belong_shop_id = #{param.belongShopId}
        </if>
        <if test="param.shopSource!=null and param.shopSource!=''">
            AND ts.shop_source = #{param.shopSource}
        </if>
        <if test="param.shopCustomStatus!=null and param.shopCustomStatus!=''">
            AND FIND_IN_SET(#{param.shopCustomStatus},ts.shop_custom_status) &gt; 0
        </if>
        <if test="param.expireFlag!=null and param.expireFlag!=''">
            AND ts.shop_status = 2
        </if>
        <if test="param.shopTags!=null and param.shopTags!=''">
            AND ts.shop_tags REGEXP #{param.shopTags}
        </if>
        <if test="param.supportingCapacityFlag!=null and param.supportingCapacityFlag!=''">
            AND ts.supporting_capacity_flag = #{param.supportingCapacityFlag}
        </if>
        <if test="param.operationPersonFlag!=null and param.operationPersonFlag!=''">
            AND ts.operation_person_flag = #{param.operationPersonFlag}
        </if>
        <if test="param.executiveForceFlag!=null and param.executiveForceFlag!=''">
            AND ts.executive_force_flag = #{param.executiveForceFlag}
        </if>
        <if test="param.patternFlag!=null and param.patternFlag!=''">
            AND ts.pattern_flag = #{param.patternFlag}
        </if>
        <if test="param.connectionFlag!=null and param.connectionFlag!=''">
            AND ts.connection_flag = #{param.connectionFlag}
        </if>
        <if test="param.economicAbilityFlag!=null and param.economicAbilityFlag!=''">
            AND ts.economic_ability_flag = #{param.economicAbilityFlag}
        </if>
        <if test="param.relationPartner!=null and param.relationPartner!=''">
            AND ts.relation_partner = #{param.relationPartner}
        </if>
        <if test="param.keyword!=null and param.keyword!=''">
            AND (ts.shop_name LIKE CONCAT('%',#{param.keyword},'%') OR ts.shopowner_name LIKE CONCAT('%',#{param.keyword},'%')
            OR ts.shopowner_phone LIKE CONCAT('%',#{param.keyword},'%') OR ts.shop_number LIKE CONCAT('%',#{param.keyword},'%'))
        </if>
        <if test="list !=null and list.size()>0" >
            AND ts.shop_id IN
            <foreach collection="list" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != associatedAccount and associatedAccount.size() > 0">
            and ts.shop_id in (select shop_id from t_shop_rel_user where del_flag = 0 and user_id in
            <foreach collection="associatedAccount" item="iten" index="index" open="(" separator="," close=")">
                #{iten}
            </foreach>
            )
        </if>
        ORDER BY ts.create_time DESC
    </select>
 
 
    <select id="pageMerAgencyVo" resultType="com.ruoyi.shop.domain.vo.MerAgencyPageVo">
        SELECT
        ts.shop_id shopId,
        ts.shop_status shopStatus,
        ts.shop_name shopName,
        CONCAT(ts.shop_area_name,ts.shop_address) shopAddress,
        ts.shopowner_name shopownerName,
        ts.shopowner_phone shopownerPhone,
        ts.cooperation_end_time cooperationEndTime,
        ts.cooperative_flag cooperativeFlag,
        tsf.file_url shopPicture
        FROM t_shop ts
        LEFT JOIN t_shop_file tsf ON tsf.shop_id = ts.shop_id AND tsf.del_flag = 0 AND tsf.file_type = 1
        WHERE ts.del_flag = 0 AND ts.belong_shop_id = #{param.shopId}
        <if test="param.shopStatus!=null and param.shopStatus==1">
            AND ts.shop_status = 1
        </if>
        <if test="param.shopStatus!=null and param.shopStatus==0">
            AND ts.frozen_flag = 1
        </if>
        <if test="param.shopStatus!=null and param.shopStatus==2">
            AND ts.cooperation_end_time IS NOT NULL AND (CURRENT_DATE &lt; Date(ts.cooperation_start_time) OR CURRENT_DATE &gt; Date(ts.cooperation_end_time))
        </if>
        <if test="param.keyword!=null and param.keyword!=''">
            AND (ts.shop_name LIKE CONCAT('%',#{param.keyword},'%') OR ts.shopowner_name LIKE CONCAT('%',#{param.keyword},'%')
            OR ts.shopowner_phone LIKE CONCAT('%',#{param.keyword},'%'))
        </if>
        <if test="param.startCooperDate!=null and param.startCooperDate!=''">
            AND Date(ts.cooperation_start_time) &gt;= #{param.startCooperDate}
        </if>
        <if test="param.endCooperDate!=null and param.endCooperDate!=''">
            AND Date(ts.cooperation_end_time) &lt;= #{param.endCooperDate}
        </if>
        ORDER BY ts.create_time
    </select>
 
    <select id="getNearbyShop"  resultType="com.ruoyi.shop.domain.vo.AppNearShopVo">
        SELECT ts.shop_id shopId,
               6378.138 * 2 * ASIN(SQRT(POW(SIN((#{param.latitude} * PI() / 180 - ts.shop_latitude * PI() / 180) / 2), 2)
                + COS(#{param.latitude} * PI() / 180) * COS(ts.shop_latitude * PI() / 180) * POW(
               SIN((#{param.longitude} * PI() / 180 - ts.shop_longitude * PI() / 180) / 2), 2
               ))) AS distance
        FROM t_shop ts
        WHERE del_flag = 0 AND shop_status = 1
        ORDER BY distance ASC LIMIT 1
    </select>
 
 
    <select id="getNearbyShops"  resultType="com.ruoyi.shop.domain.vo.AppNearShopVo">
        SELECT
        ts.shop_id shopId,
        6378.138 * 2 * ASIN(SQRT(POW(SIN((#{param.latitude} * PI() / 180 - ts.shop_latitude * PI() / 180) / 2), 2)
                + COS(#{param.latitude} * PI() / 180) * COS(ts.shop_latitude * PI() / 180) * POW(
               SIN((#{param.longitude} * PI() / 180 - ts.shop_longitude * PI() / 180) / 2), 2
               ))) AS distance,
        shop_longitude as longitude,
        shop_latitude as latitude
        FROM t_shop ts
        WHERE del_flag = 0 AND shop_status = 1
        ORDER BY distance ASC LIMIT 0, 5
    </select>
 
 
    <select id="pageMgtShopProportion" resultType="com.ruoyi.shop.domain.vo.MgtShopProportionPageVo">
        SELECT
        tsp.proportion_id proportionId,
        ts.shop_id shopId,
        ts.shop_name shopName,
        ts.shop_address shopAddress,
        ts.shopowner_name shopownerName,
        tsp.proportion_percent proportionPercent
        FROM t_shop ts
        INNER JOIN t_shop_proportion tsp ON ts.shop_id = tsp.shop_id AND tsp.del_flag = 0
        WHERE ts.del_flag = 0 AND ts.shop_type = #{param.shopType}
        <if test="param.shopName!=null and param.shopName!=''">
            AND ts.shop_name LIKE CONCAT('%',#{param.shopName},'%')
        </if>
    </select>
 
    <update id="deleteShopTag">
        UPDATE t_shop SET shop_tags = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', shop_tags, ','), CONCAT(',',#{shopTag},','), ','))
        WHERE FIND_IN_SET(#{shopTag}, shop_tags) &gt; 0
    </update>
 
    <select id="getShopIdByCode" resultType="java.lang.Long">
        SELECT
        ts.shop_id
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="param.shopName!=null and param.shopName!=''">
            AND ts.shop_name LIKE CONCAT('%',#{param.shopName},'%')
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.belongUserId!=null and param.belongUserId!=''">
            AND ts.belong_user_id = #{param.belongUserId}
        </if>
    </select>
 
    <select id="listMgtShopSimpleVo" resultType="com.ruoyi.shop.domain.vo.MgtShopListSimpleVo">
        SELECT
            shop_id,
            shop_name,
            shopowner_name shopUser
        FROM t_shop
        WHERE del_flag = 0
        <if test="param.shopType!=null and param.shopType!=''">
            AND shop_type = #{param.shopType}
        </if>
        <if test="param.keyword!=null and param.keyword!=''">
            AND shop_name LIKE CONCAT('%',#{param.keyword},'%')
        </if>
        <if test="list !=null and list.size()>0" >
            AND shop_id IN
            <foreach collection="list" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
 
    <select id="listShopSimpleVoByIds" resultType="com.ruoyi.system.api.domain.vo.MgtSimpleShopVo">
        SELECT
            shop_id,
            shop_name,
            shop_service_phone
        FROM t_shop
        WHERE del_flag = 0
        <if test="null != shopIds and '' != shopIds">
            AND FIND_IN_SET(shop_id,#{shopIds}) &gt; 0
        </if>
    </select>
    
    <select id="pageMgtShopByCityCode" resultType="com.ruoyi.system.api.domain.vo.MgtSimpleShopVo">
        SELECT
        shop_id,
        shop_name
        FROM t_shop
        WHERE del_flag = 0 AND shop_status = 1
          <if test="param.cityCodeList !=null and param.cityCodeList.size()>0" >
              AND shop_city_code IN
              <foreach collection="param.cityCodeList" item="item" open="(" separator="," close=")">
                  #{item}
              </foreach>
          </if>
    </select>
 
    <select id="pageMgtShopAuth" resultType="com.ruoyi.shop.domain.vo.MgtShopAuthPageVo">
        SELECT
        tsa.auth_id authId,
        ts.shop_id shopId,
        ts.shop_name shopName,
        ts.shopowner_name shopownerName,
        ts.shopowner_phone shopownerPhone,
        CASE tsa.main_type
            WHEN 1 THEN '个人'
            WHEN 2 THEN '企业'
            END mainType,
        tsa.audit_status auditStatus,
        tsa.sign_state signState,
        tsa.sign_url signUrl,
        CASE tsa.audit_status
            WHEN 0 THEN '待审核'
            WHEN 1 THEN '审核中'
            WHEN 2 THEN '审核中'
            WHEN 3 THEN '审核中'
            WHEN 4 THEN '已拒绝'
            WHEN 5 THEN '审核中'
            WHEN 6 THEN '已通过'
            WHEN 7 THEN '已拒绝'
            WHEN 8 THEN '已拒绝'
        END auditStatusDesc,
        ts.account_flag accountFlag,
        CASE tsa.audit_status
            WHEN 4 THEN 1
            WHEN 5 THEN 1
        END auditStatusSort
        FROM t_shop ts
        INNER JOIN t_shop_authentication tsa ON ts.shop_id = tsa.shop_id AND tsa.del_flag = 0
        WHERE ts.del_flag = 0
        <if test="param.shopName!=null and param.shopName!=''">
            AND ts.shop_name LIKE CONCAT('%',#{param.shopName},'%')
        </if>
        <if test="param.shopownerName!=null and param.shopownerName!=''">
            AND ts.shopowner_name LIKE CONCAT('%',#{param.shopownerName},'%')
        </if>
        <if test="param.shopownerPhone!=null and param.shopownerPhone!=''">
            AND ts.shopowner_phone LIKE CONCAT('%',#{param.shopownerPhone},'%')
        </if>
        <if test="param.mainType!=null and param.mainType!=''">
            AND tsa.main_type = #{param.mainType}
        </if>
        <if test="param.auditStatus!=null">
            AND tsa.audit_status = #{param.auditStatus}
        </if>
        <if test="param.shopStatus!=null and param.shopStatus!=''">
            AND ts.shop_status = #{param.shopStatus}
        </if>
        <if test="list!=null and list.size()>0">
            AND ts.shop_id IN
            <foreach collection="list" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        ORDER BY auditStatusSort ASC,ts.create_time DESC
    </select>
 
 
 
    <select id="pageMgtShopHFTXAuth" resultType="com.ruoyi.shop.domain.vo.MgtShopHFTXAuthPageVo">
        select
        a.shop_id as shopId,
        a.shop_name as shopName,
        a.shopowner_name as shopownerName,
        a.shopowner_phone as shopownerPhone,
        CASE b.type WHEN 1 THEN '个人' WHEN 2 THEN '企业' END mainType,
        CASE b.audit_status WHEN 'U' THEN '审核中' WHEN 'Y' THEN '审核通过' WHEN 'N' THEN '审核拒绝' WHEN 'F' THEN '失败' END auditStatus,
        b.audit_desc as auditDesc,
        b.share_ratio as shareRatio,
        if(b.id is null, 1, 2) as status
        from t_shop a
        left join t_shop_authentication_hftx b on (a.shop_id = b.shop_id)
        where a.del_flag = 0
        <if test="param.shopName!=null and param.shopName!=''">
            AND a.shop_name LIKE CONCAT('%',#{param.shopName},'%')
        </if>
        <if test="param.shopownerName!=null and param.shopownerName!=''">
            AND a.shopowner_name LIKE CONCAT('%',#{param.shopownerName},'%')
        </if>
        <if test="param.shopownerPhone!=null and param.shopownerPhone!=''">
            AND a.shopowner_phone LIKE CONCAT('%',#{param.shopownerPhone},'%')
        </if>
        <if test="param.mainType!=null and param.mainType!=''">
            AND b.type = #{param.mainType}
        </if>
        <if test="param.auditStatus != null and '' != param.auditStatus">
            AND b.audit_status = #{param.auditStatus}
        </if>
        <if test="param.shopStatus!=null and param.shopStatus!=''">
            AND a.shop_status = #{param.shopStatus}
        </if>
        <if test="list!=null and list.size()>0">
            AND a.shop_id IN
            <foreach collection="list" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        ORDER BY a.create_time DESC
    </select>
 
 
 
    <select id="shopTotal" resultType="com.ruoyi.system.api.domain.vo.MgtBulletinBoardVo">
        SELECT
            COUNT(shop_id) AS shopTotal,
            SUM(CASE WHEN shop_type = 1 THEN 1 ELSE 0 END) AS dealerTotal,
            SUM(CASE WHEN shop_type = 2 THEN 1 ELSE 0 END) AS agencyTotal
        FROM t_shop
        WHERE del_flag = 0
        <if test="null != userIds and userIds.size() > 0">
            and belong_user_id in
            <foreach collection="userIds" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
 
    <select id="getPlTotalShopTotal" resultType="com.ruoyi.shop.domain.vo.MgtPlTotalShopTotalVo">
        SELECT
            COUNT(shop_id) AS shopTotal,
            SUM(CASE WHEN shop_type = 1 THEN 1 ELSE 0 END) AS dealerTotal,
            SUM(CASE WHEN shop_type = 2 THEN 1 ELSE 0 END) AS agencyTotal,
            SUM(CASE WHEN cooperative_flag = 0 THEN 1 ELSE 0 END) AS terminateTotal
        FROM t_shop
        WHERE del_flag = 0
        <if test="null != userIds and userIds.size() > 0">
            and belong_user_id in
            <foreach collection="userIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
 
    <select id="listShopIdByTotal" resultType="java.lang.Long">
        SELECT
        ts.shop_id
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(ts.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(ts.create_time) &lt;= #{param.endDate}
        </if>
    </select>
 
    <select id="listShopIdByPlTotal" resultType="java.lang.Long">
        SELECT
        ts.shop_id
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="param.userId!=null and param.userId!=''">
            AND ts.belong_user_id = #{param.userId}
        </if>
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
    </select>
 
 
    <select id="listShopTypeTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
        SELECT
        ts.shop_type mapKey,
        COUNT(ts.shop_id) mapValue
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(ts.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(ts.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY ts.shop_type
    </select>
 
    <select id="listShopStatusTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
        SELECT
        ts.shop_custom_status mapKey,
        COUNT(ts.shop_id) mapValue
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(ts.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(ts.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY ts.shop_custom_status
    </select>
 
    <select id="listShopAreaRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
        SELECT
        SUBSTRING_INDEX(SUBSTRING_INDEX(ts.shop_area_name, ',', 2), ',', -1) mapKey,
        COUNT(ts.shop_id) mapValue
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(ts.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(ts.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY mapKey
        ORDER BY COUNT(ts.shop_id) DESC LIMIT 15
    </select>
 
    <select id="listShopSalesRank" resultType="java.lang.Long">
        SELECT
        ts.shop_name mapKey,
        tst.total_order_money mapValue
        FROM t_shop ts
        INNER JOIN t_shop_total tst ON ts.shop_id = tst.shop_id
        WHERE ts.del_flag = 0
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(ts.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(ts.create_time) &lt;= #{param.endDate}
        </if>
        ORDER BY tst.total_order_money DESC LIMIT 15
    </select>
 
    <select id="listShopRecommendRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
        SELECT
        ts.recommend_person mapKey,
        COUNT(ts.shop_id) mapValue
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.startDate!=null and param.startDate!=''">
            AND Date(ts.create_time) &gt;= #{param.startDate}
        </if>
        <if test="param.endDate!=null and param.endDate!=''">
            AND Date(ts.create_time) &lt;= #{param.endDate}
        </if>
        GROUP BY ts.recommend_person
        ORDER BY COUNT(ts.shop_id) DESC
    </select>
 
    <select id="pageStaffShop" resultType="com.ruoyi.shop.domain.vo.StaffShopPageVo">
        SELECT
        ts.shop_id shopId,
        ts.sign_time signTime,
        ts.shop_name shopName,
        ts.shop_tags shopTags,
        ts.cooperation_end_time cooperationTime,
        CONCAT(ts.shop_area_name,ts.shop_address) shopAddress,
        ts.shopowner_name shopownerName,
        ts.shopowner_phone shopownerPhone,
        ts.shop_status shopStatus,
        tsf.file_url shopPicture,
        tbs.shop_name belongShopName,
        ts.frozen_flag frozenFlag
        FROM t_shop ts
        LEFT JOIN t_shop_file tsf ON tsf.shop_id = ts.shop_id AND tsf.del_flag = 0 AND file_type = 1
        LEFT JOIN t_shop tbs ON tbs.shop_id = ts.belong_shop_id AND tbs.del_flag = 0
        WHERE ts.del_flag = 0
        <if test="param.shopType!=null and param.shopType!=''">
            AND ts.shop_type = #{param.shopType}
        </if>
        <if test="param.signStartTime!=null and param.signStartTime!=''">
            AND Date(ts.sign_time) &gt;= #{param.signStartTime}
        </if>
        <if test="param.signEndTime!=null and param.signEndTime!=''">
            AND Date(ts.sign_time) &lt;= #{param.signEndTime}
        </if>
        <if test="param.signProvinceCode!=null and param.signProvinceCode!=''">
            AND ts.sign_province_code = REGEXP CONCAT('(^|;)' ,#{param.signProvinceCode}, '(;|$)')
        </if>
        <if test="param.signCityCode!=null and param.signCityCode!=''">
            AND ts.sign_city_code = REGEXP CONCAT('(^|;)' ,#{param.signCityCode}, '(;|$)')
        </if>
        <if test="param.signAreaCode!=null and param.signAreaCode!=''">
            AND ts.sign_area_code = REGEXP CONCAT('(^|;)' ,#{param.signAreaCode}, '(;|$)')
        </if>
        <if test="param.recommendPerson!=null and param.recommendPerson!=''">
            AND ts.recommend_person = #{param.recommendPerson}
        </if>
        <if test="param.belongUserId!=null and param.belongUserId!=''">
            AND ts.belong_user_id = #{param.belongUserId}
        </if>
        <if test="param.userIdList!=null and param.userIdList.size()>0">
            AND ts.belong_user_id IN
            <foreach item="id" collection="param.userIdList" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="param.shopCustomStatus!=null and param.shopCustomStatus!=''">
            AND FIND_IN_SET(#{param.shopCustomStatus},ts.shop_custom_status) &gt; 0
        </if>
        <if test="param.supportingCapacityFlag!=null and param.supportingCapacityFlag!=''">
            AND ts.supporting_capacity_flag = #{param.supportingCapacityFlag}
        </if>
        <if test="param.operationPersonFlag!=null and param.operationPersonFlag!=''">
            AND ts.operation_person_flag = #{param.operationPersonFlag}
        </if>
        <if test="param.executiveForceFlag!=null and param.executiveForceFlag!=''">
            AND ts.executive_force_flag = #{param.executiveForceFlag}
        </if>
        <if test="param.patternFlag!=null and param.patternFlag!=''">
            AND ts.pattern_flag = #{param.patternFlag}
        </if>
        <if test="param.connectionFlag!=null and param.connectionFlag!=''">
            AND ts.connection_flag = #{param.connectionFlag}
        </if>
        <if test="param.economicAbilityFlag!=null and param.economicAbilityFlag!=''">
            AND ts.economic_ability_flag = #{param.economicAbilityFlag}
        </if>
        <if test="param.relationPartner!=null and param.relationPartner!=''">
            AND ts.relation_partner = #{param.relationPartner}
        </if>
        <if test="param.keyword!=null and param.keyword!=''">
            AND (ts.shop_name LIKE CONCAT('%',#{param.keyword},'%') OR ts.shopowner_name LIKE CONCAT('%',#{param.keyword},'%')
            OR ts.shopowner_phone LIKE CONCAT('%',#{param.keyword},'%') OR ts.shop_number LIKE CONCAT('%',#{param.keyword},'%')
            OR tbs.shop_name LIKE CONCAT('%',#{param.keyword},'%'))
        </if>
        ORDER BY ts.create_time DESC
    </select>
 
    <select id="getStaffSimpleTotal" resultType="com.ruoyi.shop.domain.vo.StaffShopSimpleTotalVo">
        SELECT
        COUNT(shop_id) shopTotal,
        SUM(CASE shop_status WHEN 0 THEN 1 WHEN 2 THEN 1 WHEN 3 THEN 1 ELSE 0 END) closeShopTotal,
        SUM(CASE shop_status WHEN 1 THEN 1 ELSE 0 END) openShopTotal
        FROM t_shop ts
        WHERE ts.del_flag = 0 AND ts.shop_type = #{shopType}
        <if test="null != userIdList">
            AND ts.belong_user_id IN
            <foreach item="id" collection="userIdList" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <select id="getStaffHomeTotal" resultType="com.ruoyi.shop.domain.vo.StaffHomeShopTotalVo">
        SELECT
        COUNT(shop_id) shopTotal,
        SUM(CASE shop_type WHEN 1 THEN 1 ELSE 0 END) dealerTotal,
        SUM(CASE shop_type WHEN 2 THEN 1 ELSE 0 END) agencyTotal
        FROM t_shop ts
        WHERE ts.del_flag = 0
        <if test="null != userIdList">
            AND ts.belong_user_id IN
            <foreach item="id" collection="userIdList" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <update id="updateExtendContacts">
        update t_shop SET
        <if test="extendContacts!=null and extendContacts != ''">
            extend_contacts = #{extendContacts},
        </if>
        <if test="extendContacts ==null or extendContacts == ''">
            extend_contacts = null,
        </if>
        <if test="updateTime != null">update_time = #{updateTime},</if>
        <if test="updateUserId != null">update_user_id = #{updateUserId}</if>
        WHERE shop_id = #{shopId}
    </update>
 
    <update id="setBelongShopIdNull">
        UPDATE t_shop
        SET belong_shop_id = NULL
        WHERE belong_shop_id = #{shopId} and del_flag = 0  and shopstatus!=-1 and shop_type = 2
    </update>
    <update id="updateShopByOneClinkSyncing">
        UPDATE t_shop
        SET
            shop_detail = #{param.shopDetail},
            platform_coupon_flag = #{param.platformCouponFlag},
            platform_birthday_flag = #{param.platformBirthdayFlag},
            update_user_id = #{param.userId},
            update_time = NOW()
        WHERE
            shop_id IN
        <foreach item="id" collection="param.shopIdList" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
 
    <select id="listShopIdByCityCode" resultType="java.lang.Long">
        SELECT shop_id
        FROM t_shop
        WHERE del_flag = 0
        AND shop_city_code IN
        <foreach item="id" collection="cityCodes" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
 
 
    <select id="listShopByCityCode" resultMap="ShopResult">
        <include refid="selectShopVo"/>
        WHERE del_flag = 0 and shop_status = 1
        AND shop_city_code  IN
        <foreach item="id" collection="cityCodes" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
 
    <select id="getTaskMsgList" resultType="com.ruoyi.system.api.domain.vo.MgtUserTaskMsgVo">
        SELECT
            ts.belong_user_id userId,
            CONCAT('[', GROUP_CONCAT(tst.task_title SEPARATOR '],['), ']') taskTitle
        FROM t_shop_task tst
        INNER JOIN t_shop ts ON tst.shop_id = ts.shop_id AND ts.del_flag = 0
        WHERE tst.del_flag = 0 AND tst.task_status = 1 AND tst.task_date = CURRENT_DATE
        GROUP BY userId
        UNION ALL
        SELECT
            tsru.user_id userId,
            CONCAT('[', GROUP_CONCAT(tst.task_content SEPARATOR '],['), ']') taskTitle
        FROM t_agency_task tst
                 INNER JOIN t_shop_rel_user tsru ON tsru.shop_id = tst.shop_id AND tsru.del_flag = 0
        WHERE tst.del_flag = 0 AND tst.task_status = 1 AND tst.task_date = CURRENT_DATE
        GROUP BY userId
    </select>
 
    <select id="getFranchiseeIdsBYDealerId" resultType="com.ruoyi.system.api.domain.poji.shop.Shop">
        select
            *
        from t_shop
        where
            del_flag=0
          and
            belong_shop_id = #{shopId}
    </select>
    <select id="getMgtShopPageVoByShopIds" resultType="com.ruoyi.system.api.domain.vo.MgtOneClinkSyncingShopPageVo">
        SELECT
            ts.shop_id shopId,
            ts.shop_number shopNumber,
            ts.shop_name shopName,
            ts.shop_tags shopTags,
            ts.shop_source shopSource,
            belong.shop_name belongShopName,
            ts.sign_area_name signAreaName,
            CONCAT(ts.cooperation_start_time,'-',ts.cooperation_end_time) cooperationTime,
            CONCAT(ts.shop_area_name,ts.shop_address) shopAddress,
            ts.shopowner_name shopownerName,
            ts.shopowner_phone shopownerPhone,
            tsm.shop_marketing_total shopActivityCount,
            ts.shop_custom_status shopCustomStatus,
            ts.frozen_flag frozenFlag
        FROM t_shop ts
                 LEFT JOIN t_shop_marketing tsm ON tsm.shop_id = ts.shop_id
                left join t_shop belong on ts.belong_shop_id = belong.shop_id
        WHERE ts.del_flag = 0
        <if test="list !=null and list.size()>0" >
            AND ts.shop_id IN
            <foreach collection="list" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
 
    </select>
 
</mapper>