SysOrderMapper.xml
90.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
<?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.glsx.ordercenter.mapper.SysOrderMapper">
<resultMap id="BaseResultMap" type="com.glsx.ordercenter.pojo.SysOrder">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="order_sn" jdbcType="VARCHAR" property="orderSn"/>
<result column="active_status" jdbcType="TINYINT" property="activeStatus"/>
<result column="canceled" jdbcType="TINYINT" property="canceled"/>
<result column="order_type" jdbcType="TINYINT" property="orderType"/>
<result column="shop_id" jdbcType="INTEGER" property="shopId"/>
<result column="district" jdbcType="INTEGER" property="district"/>
<result column="address" jdbcType="VARCHAR" property="address"/>
<result column="contact" jdbcType="VARCHAR" property="contact"/>
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber"/>
<result column="car_brand" jdbcType="INTEGER" property="carBrand"/>
<result column="car_series" jdbcType="INTEGER" property="carSeries"/>
<result column="car_type" jdbcType="VARCHAR" property="carType"/>
<result column="vin_no" jdbcType="VARCHAR" property="vinNo"/>
<result column="vin_hash" jdbcType="VARCHAR" property="vinHash"/>
<result column="vin_no_decode" jdbcType="VARCHAR" property="vinNoDecode"/>
<result column="car_color" jdbcType="VARCHAR" property="carColor"/>
<result column="expect_install_time" jdbcType="TIMESTAMP" property="expectInstallTime"/>
<result column="service_type" jdbcType="VARCHAR" property="serviceType"/>
<result column="car_owner" jdbcType="VARCHAR" property="carOwner"/>
<result column="car_owner_phone" jdbcType="VARCHAR" property="carOwnerPhone"/>
<result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
<result column="active_status_array" jdbcType="VARCHAR" property="activeStatusArray"/>
<result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
<result column="mechanic_id" jdbcType="INTEGER" property="mechanicId"/>
<result column="repair_reason" jdbcType="VARCHAR" property="repairReason"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="create_by" jdbcType="INTEGER" property="createBy"/>
<result column="update_by" jdbcType="INTEGER" property="updateBy"/>
<result column="device_no" jdbcType="VARCHAR" property="deviceNo"/>
<result column="install_location" jdbcType="VARCHAR" property="installLocation"/>
<result column="overdue_reason" jdbcType="VARCHAR" property="overdueReason"/>
<result column="repair_type" jdbcType="TINYINT" property="repairType"/>
<result column="car_picture" jdbcType="VARCHAR" property="carPicture"/>
<result column="vin_no_picture" jdbcType="VARCHAR" property="vinNoPicture"/>
<result column="install_location_picture" jdbcType="VARCHAR" property="installLocationPicture"/>
<result column="complete_time" jdbcType="TIMESTAMP" property="completeTime"/>
<result column="install_remark" jdbcType="VARCHAR" property="installRemark"/>
<result column="install_device_type" jdbcType="VARCHAR" property="installDeviceType"/>
<result column="after_sale_type" jdbcType="INTEGER" property="afterSaleType"/>
<result column="reserve_install_time" jdbcType="TIMESTAMP" property="reserveInstallTime"/>
<result column="work_order_no" jdbcType="VARCHAR" property="workOrderNo"/>
<result column="work_order_number" jdbcType="VARCHAR" property="workOrderNumber"/>
<result column="channel" jdbcType="VARCHAR" property="channel"/>
<result column="order_source" jdbcType="VARCHAR" property="orderSource"/>
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
<result column="reassign_mechanic_time" jdbcType="TIMESTAMP" property="reassignMechanicTime"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="zone" jdbcType="VARCHAR" property="zone"/>
<result column="installDeviceTypeName" jdbcType="VARCHAR" property="installDeviceTypeName"/>
<result column="orgName" jdbcType="VARCHAR" property="rootOrgName"/>
<result column="orderChannelOrgId" jdbcType="INTEGER" property="orderChannelOrgId"/>
<result column="reserve_install_reason" jdbcType="VARCHAR" property="reserveInstallReason"/>
<result column="connect_location_picture" jdbcType="VARCHAR" property="connectLocationPicture"/>
<result column="surrounding_picture" jdbcType="VARCHAR" property="surroundingPicture"/>
<result column="is_check_in" jdbcType="INTEGER" property="isCheckIn"/>
<result column="check_in_time" jdbcType="TIMESTAMP" property="checkInTime"/>
<result column="reserve_man" jdbcType="VARCHAR" property="reserveMan"/>
<result column="reserve_man_phone" jdbcType="VARCHAR" property="reserveManPhone"/>
<result column="quote_last_time" jdbcType="TIMESTAMP" property="quoteLastTime"/>
<result column="service_code" jdbcType="VARCHAR" property="serviceCode"/>
<result column="oldVinNo" jdbcType="VARCHAR" property="oldVinNo"/>
<result column="mechanic_address" jdbcType="VARCHAR" property="mechanicAddress"/>
<result column="check_in_address" jdbcType="VARCHAR" property="checkInAddress"/>
<result column="longitude" jdbcType="VARCHAR" property="longitude"/>
<result column="latitude" jdbcType="VARCHAR" property="latitude"/>
<result column="install_mode" jdbcType="TINYINT" property="installMode"/>
<result column="receive_time" jdbcType="TIMESTAMP" property="receiveTime"/>
<result column="audit_status" jdbcType="TINYINT" property="auditStatus"/>
<result column="audit_count" jdbcType="TINYINT" property="auditCount"/>
<result column="audit_time" jdbcType="TIMESTAMP" property="auditTime"/>
<result column="volvo_approved_status" jdbcType="INTEGER" property="volvoApprovedStatus"/>
<result column="volvo_approved_time" jdbcType="TIMESTAMP" property="volvoApprovedTime"/>
<result column="install_contacts" jdbcType="VARCHAR" property="installContacts"/>
<result column="install_contact_number" jdbcType="VARCHAR" property="installContactNumber"/>
<result column="trailer_vin" jdbcType="VARCHAR" property="trailerVin"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value}
and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem"
open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, order_sn, active_status, canceled, order_type, shop_id, district,
address ,contact, phone_number, car_brand, car_series, car_type, vin_no, vin_hash, car_color,
expect_install_time, service_type, car_owner, car_owner_phone, cancel_time, active_status_array, merchant_id,
mechanic_id, repair_reason, remark, create_time, update_time, create_by, update_by, device_no,
install_location, overdue_reason, repair_type, car_picture, vin_no_picture, install_location_picture,
complete_time,install_remark,install_device_type,reserve_install_time,check_in_address,
work_order_no, work_order_number, channel, order_source,mechanic_address,
merchant_name,reassign_mechanic_time,reserve_install_reason,connect_location_picture,surrounding_picture,is_check_in,
check_in_time,reserve_man,reserve_man_phone,quote_last_time,service_code,longitude,latitude,
receive_time, audit_status, audit_count, audit_time,install_contacts,install_contact_number,volvo_approved_status,volvo_approved_time,
vin_no_decode,trailer_vin
</sql>
<select id="selectByExample" parameterType="com.glsx.ordercenter.pojo.SysOrderExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'false' as QUERYID,
<include refid="Base_Column_List"/>
from sys_order
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
and order_type != 5
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_order
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAllByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_order
<where>
<if test="orderIds != null and !orderIds.isEmpty()">
and id in
<foreach collection="orderIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_order
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.glsx.ordercenter.pojo.SysOrder">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_order (order_sn, active_status, canceled,
order_type, shop_id, district,
address, contact, phone_number,
car_brand, car_series, car_type,
vin_no, vin_hash, car_color, expect_install_time,
service_type, car_owner, car_owner_phone,
cancel_time, active_status_array, merchant_id,
mechanic_id, repair_reason, remark,
create_time, update_time, create_by,
update_by, device_no, install_location,
overdue_reason, repair_type, car_picture,
vin_no_picture, install_location_picture, complete_time,
install_remark, install_device_type, reserve_install_time,
work_order_no, channel, merchant_name,
service_code, receive_time
)
values (#{orderSn,jdbcType=VARCHAR}, #{activeStatus,jdbcType=TINYINT}, #{canceled,jdbcType=TINYINT},
#{orderType,jdbcType=TINYINT}, #{shopId,jdbcType=INTEGER}, #{district,jdbcType=INTEGER},
#{address,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=VARCHAR},
#{carBrand,jdbcType=INTEGER}, #{carSeries,jdbcType=INTEGER}, #{carType,jdbcType=VARCHAR},
#{vinNo,jdbcType=VARCHAR}, #{vinHash,jdbcType=VARCHAR}, #{carColor,jdbcType=VARCHAR}, #{expectInstallTime,jdbcType=TIMESTAMP},
#{serviceType,jdbcType=VARCHAR}, #{carOwner,jdbcType=VARCHAR}, #{carOwnerPhone,jdbcType=VARCHAR},
#{cancelTime,jdbcType=TIMESTAMP}, #{activeStatusArray,jdbcType=VARCHAR}, #{merchantId,jdbcType=INTEGER},
#{mechanicId,jdbcType=INTEGER}, #{repairReason,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=INTEGER},
#{updateBy,jdbcType=INTEGER}, #{deviceNo,jdbcType=VARCHAR}, #{installLocation,jdbcType=VARCHAR},
#{overdueReason,jdbcType=VARCHAR}, #{repairType,jdbcType=TINYINT}, #{carPicture,jdbcType=VARCHAR},
#{vinNoPicture,jdbcType=VARCHAR}, #{installLocationPicture,jdbcType=VARCHAR},
#{completeTime,jdbcType=TIMESTAMP},
#{installRemark,jdbcType=VARCHAR}, #{installDeviceType,jdbcType=VARCHAR},
#{reserveInstallTime,jdbcType=TIMESTAMP},
#{workOrderNo,jdbcType=VARCHAR}, #{channel,jdbcType=VARCHAR}, #{merchantName,jdbcType=VARCHAR},
#{serviceCode}, #{receiveTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.glsx.ordercenter.pojo.SysOrder" useGeneratedKeys="true"
keyProperty="id">
insert into sys_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderSn != null">
order_sn,
</if>
<if test="activeStatus != null">
active_status,
</if>
<if test="canceled != null">
canceled,
</if>
<if test="orderType != null">
order_type,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="district != null">
district,
</if>
<if test="address != null">
address,
</if>
<if test="contact != null">
contact,
</if>
<if test="phoneNumber != null">
phone_number,
</if>
<if test="carBrand != null">
car_brand,
</if>
<if test="carSeries != null">
car_series,
</if>
<if test="carType != null">
car_type,
</if>
<if test="vinNo != null">
vin_no,
</if>
<if test="vinHash != null">
vin_hash,
</if>
<if test="carColor != null">
car_color,
</if>
<if test="expectInstallTime != null">
expect_install_time,
</if>
<if test="serviceType != null">
service_type,
</if>
<if test="carOwner != null">
car_owner,
</if>
<if test="carOwnerPhone != null">
car_owner_phone,
</if>
<if test="cancelTime != null">
cancel_time,
</if>
<if test="activeStatusArray != null">
active_status_array,
</if>
<if test="merchantId != null">
merchant_id,
</if>
<if test="mechanicId != null">
mechanic_id,
</if>
<if test="repairReason != null">
repair_reason,
</if>
<if test="remark != null">
remark,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="deviceNo != null">
device_no,
</if>
<if test="installLocation != null">
install_location,
</if>
<if test="overdueReason != null">
overdue_reason,
</if>
<if test="repairType != null">
repair_type,
</if>
<if test="carPicture != null">
car_picture,
</if>
<if test="vinNoPicture != null">
vin_no_picture,
</if>
<if test="installLocationPicture != null">
install_location_picture,
</if>
<if test="completeTime != null">
complete_time,
</if>
<if test="installRemark != null">
install_remark,
</if>
<if test="installDeviceType != null">
install_device_type,
</if>
<if test="reserveInstallTime != null">
reserve_install_time,
</if>
<if test="workOrderNo != null">
work_order_no,
</if>
<if test="workOrderNumber != null">
work_order_number,
</if>
<if test="channel != null">
channel,
</if>
<if test="orderSource != null">
order_source,
</if>
<if test="merchantName != null">
merchant_name,
</if>
<if test="longitude != null">
longitude,
</if>
<if test="latitude != null">
latitude,
</if>
<if test="quoteLastTime != null">
quote_last_time,
</if>
<if test="referencePrice != null">
reference_price,
</if>
<if test="serviceCode != null">
service_code,
</if>
<if test="reserveMan != null">
reserve_man,
</if>
<if test="reserveManPhone != null">
reserve_man_phone,
</if>
<if test="installMode != null">
install_mode,
</if>
<if test="receiveTime != null">
receive_time,
</if>
<if test="auditStatus != null">
audit_status,
</if>
<if test="auditCount != null">
audit_count,
</if>
<if test="auditTime != null">
audit_time,
</if>
<if test="installContacts != null">
install_contacts,
</if>
<if test="installContactNumber != null">
install_contact_number,
</if>
<if test="trailerVin != null">
trailer_vin,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderSn != null">
#{orderSn,jdbcType=VARCHAR},
</if>
<if test="activeStatus != null">
#{activeStatus,jdbcType=TINYINT},
</if>
<if test="canceled != null">
#{canceled,jdbcType=TINYINT},
</if>
<if test="orderType != null">
#{orderType,jdbcType=TINYINT},
</if>
<if test="shopId != null">
#{shopId,jdbcType=INTEGER},
</if>
<if test="district != null">
#{district,jdbcType=INTEGER},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="contact != null">
#{contact,jdbcType=VARCHAR},
</if>
<if test="phoneNumber != null">
#{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="carBrand != null">
#{carBrand,jdbcType=INTEGER},
</if>
<if test="carSeries != null">
#{carSeries,jdbcType=INTEGER},
</if>
<if test="carType != null">
#{carType,jdbcType=VARCHAR},
</if>
<if test="vinNo != null">
#{vinNo,jdbcType=VARCHAR},
</if>
<if test="vinHash != null">
#{vinHash,jdbcType=VARCHAR},
</if>
<if test="carColor != null">
#{carColor,jdbcType=VARCHAR},
</if>
<if test="expectInstallTime != null">
#{expectInstallTime,jdbcType=TIMESTAMP},
</if>
<if test="serviceType != null">
#{serviceType,jdbcType=VARCHAR},
</if>
<if test="carOwner != null">
#{carOwner,jdbcType=VARCHAR},
</if>
<if test="carOwnerPhone != null">
#{carOwnerPhone,jdbcType=VARCHAR},
</if>
<if test="cancelTime != null">
#{cancelTime,jdbcType=TIMESTAMP},
</if>
<if test="activeStatusArray != null">
#{activeStatusArray,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
#{merchantId,jdbcType=INTEGER},
</if>
<if test="mechanicId != null">
#{mechanicId,jdbcType=INTEGER},
</if>
<if test="repairReason != null">
#{repairReason,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createBy != null">
#{createBy,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=INTEGER},
</if>
<if test="deviceNo != null">
#{deviceNo,jdbcType=VARCHAR},
</if>
<if test="installLocation != null">
#{installLocation,jdbcType=VARCHAR},
</if>
<if test="overdueReason != null">
#{overdueReason,jdbcType=VARCHAR},
</if>
<if test="repairType != null">
#{repairType,jdbcType=TINYINT},
</if>
<if test="carPicture != null">
#{carPicture,jdbcType=VARCHAR},
</if>
<if test="vinNoPicture != null">
#{vinNoPicture,jdbcType=VARCHAR},
</if>
<if test="installLocationPicture != null">
#{installLocationPicture,jdbcType=VARCHAR},
</if>
<if test="completeTime != null">
#{completeTime,jdbcType=TIMESTAMP},
</if>
<if test="installRemark != null">
#{installRemark,jdbcType=VARCHAR},
</if>
<if test="installDeviceType != null">
#{installDeviceType,jdbcType=VARCHAR},
</if>
<if test="reserveInstallTime != null">
#{reserveInstallTime,jdbcType=TIMESTAMP},
</if>
<if test="workOrderNo != null">
#{workOrderNo,jdbcType=VARCHAR},
</if>
<if test="workOrderNumber != null">
#{workOrderNumber,jdbcType=VARCHAR},
</if>
<if test="channel != null">
#{channel,jdbcType=VARCHAR},
</if>
<if test="orderSource != null">
#{orderSource,jdbcType=VARCHAR},
</if>
<if test="merchantName != null">
#{merchantName,jdbcType=VARCHAR},
</if>
<if test="longitude != null">
#{longitude },
</if>
<if test="latitude != null">
#{latitude },
</if>
<if test="quoteLastTime != null">
#{quoteLastTime},
</if>
<if test="referencePrice != null">
#{referencePrice},
</if>
<if test="serviceCode != null">
#{serviceCode},
</if>
<if test="reserveMan != null">
#{reserveMan},
</if>
<if test="reserveManPhone != null">
#{reserveManPhone},
</if>
<if test="installMode != null">
#{installMode,jdbcType=TINYINT},
</if>
<if test="receiveTime != null">
#{receiveTime,jdbcType=TIMESTAMP},
</if>
<if test="auditStatus != null">
#{auditStatus,jdbcType=TINYINT},
</if>
<if test="auditCount != null">
#{auditCount,jdbcType=TINYINT},
</if>
<if test="auditTime != null">
#{auditTime,jdbcType=TIMESTAMP},
</if>
<if test="installContacts != null">
#{installContacts},
</if>
<if test="installContactNumber != null">
#{installContactNumber},
</if>
<if test="trailerVin != null">
#{trailerVin},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.glsx.ordercenter.pojo.SysOrderExample" resultType="java.lang.Long">
select count(*) from sys_order
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.ordercenter.pojo.SysOrder">
update sys_order
<set>
<if test="orderSn != null">
order_sn = #{orderSn,jdbcType=VARCHAR},
</if>
<if test="activeStatus != null">
active_status = #{activeStatus,jdbcType=TINYINT},
</if>
<if test="canceled != null">
canceled = #{canceled,jdbcType=TINYINT},
</if>
<if test="orderType != null">
order_type = #{orderType,jdbcType=TINYINT},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="district != null">
district = #{district,jdbcType=INTEGER},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="contact != null">
contact = #{contact,jdbcType=VARCHAR},
</if>
<if test="phoneNumber != null">
phone_number = #{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="carBrand != null">
car_brand = #{carBrand,jdbcType=INTEGER},
</if>
<if test="carSeries != null">
car_series = #{carSeries,jdbcType=INTEGER},
</if>
<if test="carType != null">
car_type = #{carType,jdbcType=VARCHAR},
</if>
<if test="vinNo != null">
vin_no = #{vinNo,jdbcType=VARCHAR},
</if>
<if test="vinHash != null">
vin_hash = #{vinHash,jdbcType=VARCHAR},
</if>
<if test="vinNoDecode != null">
vin_no_decode = #{vinNoDecode,jdbcType=VARCHAR},
</if>
<if test="carColor != null">
car_color = #{carColor,jdbcType=VARCHAR},
</if>
<if test="expectInstallTime != null">
expect_install_time = #{expectInstallTime,jdbcType=TIMESTAMP},
</if>
<if test="serviceType != null">
service_type = #{serviceType,jdbcType=VARCHAR},
</if>
<if test="carOwner != null">
car_owner = #{carOwner,jdbcType=VARCHAR},
</if>
<if test="carOwnerPhone != null">
car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
</if>
<if test="cancelTime != null">
cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
</if>
<if test="activeStatusArray != null">
active_status_array = #{activeStatusArray,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=INTEGER},
</if>
<if test="mechanicId != null">
mechanic_id = #{mechanicId,jdbcType=INTEGER},
</if>
<if test="repairReason != null">
repair_reason = #{repairReason,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=INTEGER},
</if>
<if test="deviceNo != null">
device_no = #{deviceNo,jdbcType=VARCHAR},
</if>
<if test="installLocation != null">
install_location = #{installLocation,jdbcType=VARCHAR},
</if>
<if test="overdueReason != null">
overdue_reason = #{overdueReason,jdbcType=VARCHAR},
</if>
<if test="repairType != null">
repair_type = #{repairType,jdbcType=TINYINT},
</if>
<if test="carPicture != null">
car_picture = #{carPicture,jdbcType=VARCHAR},
</if>
<if test="vinNoPicture != null">
vin_no_picture = #{vinNoPicture,jdbcType=VARCHAR},
</if>
<if test="installLocationPicture != null">
install_location_picture = #{installLocationPicture,jdbcType=VARCHAR},
</if>
<if test="completeTime != null">
complete_time = #{completeTime,jdbcType=TIMESTAMP},
</if>
<if test="installRemark != null">
install_remark = #{installRemark,jdbcType=VARCHAR},
</if>
<if test="installDeviceType != null">
install_device_type = #{installDeviceType,jdbcType=VARCHAR},
</if>
<if test="reserveInstallTime != null">
reserve_install_time = #{reserveInstallTime,jdbcType=TIMESTAMP},
</if>
<if test="workOrderNo != null">
work_order_no = #{workOrderNo,jdbcType=VARCHAR},
</if>
<if test="channel != null">
channel = #{channel,jdbcType=VARCHAR},
</if>
<if test="merchantName != null">
merchant_name = #{merchantName,jdbcType=VARCHAR},
</if>
<if test="reassignMechanicTime != null">
reassign_mechanic_time = #{reassignMechanicTime},
</if>
<if test="reserveInstallReason != null">
reserve_install_reason = #{reserveInstallReason},
</if>
<if test="connectLocationPicture != null">
connect_location_picture = #{connectLocationPicture},
</if>
<if test="surroundingPicture != null">
surrounding_picture = #{surroundingPicture},
</if>
<if test="reserveMan != null">
reserve_man = #{reserveMan},
</if>
<if test="reserveManPhone != null">
reserve_man_phone = #{reserveManPhone},
</if>
<if test="isCheckIn != null">
is_check_in = #{isCheckIn},
</if>
<if test="overdueReason != null">
overdue_reason = #{overdueReason},
</if>
<if test="overdueRemark != null">
overdue_remark = #{overdueRemark},
</if>
<if test="mechanicAddress != null">
mechanic_address = #{mechanicAddress},
</if>
<if test="checkInTime != null">
check_in_time = #{checkInTime,jdbcType=TIMESTAMP},
</if>
<if test="checkInAddress != null">
check_in_address = #{checkInAddress},
</if>
<if test="serviceCode != null">
service_code = #{serviceCode},
</if>
<if test="longitude != null">
longitude = #{longitude },
</if>
<if test="latitude != null">
latitude = #{latitude },
</if>
<if test="receiveTime != null">
receive_time = #{receiveTime,jdbcType=TIMESTAMP},
</if>
<if test="auditStatus != null">
audit_status = #{auditStatus,jdbcType=TINYINT},
</if>
<if test="auditCount != null">
audit_count = #{auditCount,jdbcType=TINYINT},
</if>
<if test="auditTime != null">
audit_time = #{auditTime,jdbcType=TIMESTAMP},
</if>
<if test="mortgageTime != null">
mortgage_time = #{mortgageTime,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateAdditionalById" parameterType="com.glsx.ordercenter.pojo.SysOrder">
update sys_order
set car_brand = #{carBrand,jdbcType=INTEGER},
car_series = #{carSeries,jdbcType=INTEGER},
car_type = #{carType,jdbcType=VARCHAR},
vin_no = #{vinNo,jdbcType=VARCHAR},
vin_hash = #{vinHash,jdbcType=VARCHAR},
car_color = #{carColor,jdbcType=VARCHAR},
car_owner = #{carOwner,jdbcType=VARCHAR},
car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.ordercenter.pojo.SysOrder">
update sys_order
set order_sn = #{orderSn,jdbcType=VARCHAR},
active_status = #{activeStatus,jdbcType=TINYINT},
canceled = #{canceled,jdbcType=TINYINT},
order_type = #{orderType,jdbcType=TINYINT},
shop_id = #{shopId,jdbcType=INTEGER},
district = #{district,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR},
contact = #{contact,jdbcType=VARCHAR},
phone_number = #{phoneNumber,jdbcType=VARCHAR},
car_brand = #{carBrand,jdbcType=INTEGER},
car_series = #{carSeries,jdbcType=INTEGER},
car_type = #{carType,jdbcType=VARCHAR},
vin_no = #{vinNo,jdbcType=VARCHAR},
vin_hash = #{vinHash,jdbcType=VARCHAR},
car_color = #{carColor,jdbcType=VARCHAR},
expect_install_time = #{expectInstallTime,jdbcType=TIMESTAMP},
service_type = #{serviceType,jdbcType=VARCHAR},
car_owner = #{carOwner,jdbcType=VARCHAR},
car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
active_status_array = #{activeStatusArray,jdbcType=VARCHAR},
merchant_id = #{merchantId,jdbcType=INTEGER},
mechanic_id = #{mechanicId,jdbcType=INTEGER},
repair_reason = #{repairReason,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_by = #{createBy,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=INTEGER},
device_no = #{deviceNo,jdbcType=VARCHAR},
install_location = #{installLocation,jdbcType=VARCHAR},
overdue_reason = #{overdueReason,jdbcType=VARCHAR},
repair_type = #{repairType,jdbcType=TINYINT},
car_picture = #{carPicture,jdbcType=VARCHAR},
vin_no_picture = #{vinNoPicture,jdbcType=VARCHAR},
install_location_picture = #{installLocationPicture,jdbcType=VARCHAR},
complete_time = #{completeTime,jdbcType=TIMESTAMP},
install_remark = #{installRemark,jdbcType=VARCHAR},
install_device_type = #{installDeviceType,jdbcType=VARCHAR},
reserve_install_time = #{reserveInstallTime,jdbcType=TIMESTAMP},
work_order_no = #{workOrderNo,jdbcType=VARCHAR},
channel = #{channel,jdbcType=VARCHAR},
merchant_name = #{merchantName,jdbcType=VARCHAR},
service_code = #{serviceCode},
receive_time = #{receiveTime,jdbcType=TIMESTAMP},
audit_status = #{auditStatus,jdbcType=TINYINT},
audit_count = #{auditCount,jdbcType=TINYINT},
audit_time = #{auditTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<resultMap id="OrderDetailResultMap" type="com.glsx.ordercenter.dto.QueryOrderResp"
extends="BaseResultMap">
<result column="active_status" jdbcType="TINYINT" property="activeStatus"/>
</resultMap>
<resultMap id="OrderCountResultMap" type="com.glsx.ordercenter.dto.ShopBizAmount">
<result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
<result column="shop_id" jdbcType="INTEGER" property="shopId"/>
<result column="biz_amount" jdbcType="BIGINT" property="bizAmount"/>
</resultMap>
<select id="selectByParams" parameterType="com.glsx.ordercenter.pojo.SysOrderExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from sys_order
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="countByParams" parameterType="java.util.Map" resultMap="OrderCountResultMap">
SELECT
sm.shop_name,so.shop_id,
count(1) AS biz_amount
FROM
sys_order so
LEFT JOIN
sys_merchant sm ON so.shop_id = sm.id
<where>
1=1
<if test="ids != null">
and shop_id in
<foreach item="item" collection="ids" separator="," open="("
close=")" index="">#{item, jdbcType=INTEGER}
</foreach>
</if>
<if test="beginTime != null">
and so.create_time >= #{beginTime}
</if>
<if test="endTime != null">
and so.create_time <= #{endTime}
</if>
<if test="merchantId != null">
and so.merchant_id = #{merchantId}
</if>
</where>
GROUP BY shop_id
ORDER BY biz_amount DESC
LIMIT 10
</select>
<select id="getOrderCount" parameterType="com.glsx.ordercenter.pojo.SysOrder" resultType="Integer">
select
count(1)
from sys_order
<where>
<if test="beginDate != null and beginDate != ''">
and DATE_FORMAT(create_time, '%Y-%m-%d') >= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and DATE_FORMAT(create_time, '%Y-%m-%d') <= #{endDate}
</if>
</where>
</select>
<select id="getServiceItemScale" resultType="com.glsx.ordercenter.dto.ServiceItemInfo">
SELECT
so.service_code installDeviceType,
COUNT(so.service_code) count
<choose>
<when test="userType == 1">
FROM
sys_order so
WHERE so.merchant_id = #{userId}
</when>
<otherwise>
FROM
sys_user_org suo
LEFT JOIN sys_user su ON suo.org_id = su.org_id
LEFT JOIN sys_order so ON su.id = so.shop_id
WHERE suo.user_id = #{userId}
</otherwise>
</choose>
AND so.order_type = 1
AND active_status = 8
<if test="dateStart != null and dateEnd!=null and dateStart !='' and dateEnd !=''">
and so.complete_time between #{dateStart,jdbcType=TIMESTAMP} and #{dateEnd,jdbcType=TIMESTAMP}
</if>
GROUP BY so.service_code
</select>
<select id="getMechanicBusiness" resultType="com.glsx.ordercenter.dto.MechanicBusiness">
SELECT
su.id mechanicId,
su.name,
COUNT(so.mechanic_id) count
FROM
sys_service_mechanic ssm LEFT JOIN sys_user su ON ssm.mechanic_id = su.id
LEFT JOIN sys_order so ON su.id = so.mechanic_id
WHERE
order_type = 1
AND active_status = 8
AND ssm.service_id = #{userId}
AND su.user_type = 3
AND su.user_status NOT IN ('sys_user_status_logout')
<if test="dateStart != null and dateEnd!=null and dateStart !='' and dateEnd !=''">
and so.complete_time between #{dateStart,jdbcType=TIMESTAMP} and #{dateEnd,jdbcType=TIMESTAMP}
</if>
<if test="mechanicId != null ">
and so.mechanic_id = #{mechanicId}
</if>
GROUP BY
so.mechanic_id
ORDER BY count desc
</select>
<select id="getAfterSaleRepairList" parameterType="com.glsx.ordercenter.pojo.SysOrder" resultMap="BaseResultMap">
<if test="queryContent != null and queryContent != ''">
<bind name="queryContent" value="'%' + queryContent + '%'"/>
</if>
select
so.id, so.order_sn, so.active_status, so.canceled, so.order_type,
so.shop_id, so.district, so.address , so.contact, so.phone_number,
so.car_brand, so.car_series, so.car_type, so.vin_no, so.car_color,
so.expect_install_time, so.service_type, so.car_owner, so.car_owner_phone,
so.cancel_time, so.active_status_array, so.merchant_id, so.mechanic_id, so.repair_reason,
so.remark, so.create_time, so.update_time, so.create_by, so.update_by,
so.device_no, so.install_location, so.overdue_reason, so.repair_type, so.car_picture,
so.vin_no_picture, so.install_location_picture, so.complete_time, so.install_remark, so.install_device_type,
so.service_code,
sor.after_sale_type
from
sys_order_repair sor
LEFT JOIN sys_order so on sor.sub_order_id = so.id
<where>
sor.order_id = #{id}
<if test="canceled != null">
and so.canceled = #{canceled}
</if>
<if test="activeStatus != null">
and so.active_status = #{activeStatus}
</if>
<if test="queryContent != null and queryContent != ''">
and (so.order_sn like #{queryContent} or so.vin_no like #{queryContent} or so.car_owner like
#{queryContent})
</if>
</where>
</select>
<select id="getAfterSaleDetail" resultMap="BaseResultMap">
select
so.id, so.order_sn, so.active_status, so.order_type,
so.shop_id, so.district, so.address , so.contact, so.phone_number,
so.car_brand, so.car_series, so.car_type, so.vin_no, so.car_color,
so.expect_install_time, so.car_owner, so.car_owner_phone,so.repair_reason, so.complete_time,
<!-- so.merchant_id, so.merchant_id, so.mechanic_id, so.repair_reason,
so.remark, so.create_time, so.update_time, so.create_by, so.update_by,
so.device_no, so.install_location, so.overdue_reason, so.repair_type, so.car_picture,
so.vin_no_picture, so.install_location_picture, so.complete_time, so.install_remark, -->
so.install_device_type,
sor.after_sale_type,
so2.vin_no as oldVinNo
from
sys_order_repair sor
LEFT JOIN sys_order so on sor.sub_order_id = so.id
LEFT JOIN sys_order so2 on sor.order_id = so2.id
where 1=1
<if test="orderId != null">
and so.canceled = 1
and sor.order_id = #{orderId}
and so.active_status !=8
and so.order_type != 1
</if>
<if test="orderSn != null">
and so.order_sn = #{orderSn}
</if>
</select>
<select id="getOrderOnHand" resultType="com.glsx.ordercenter.pojo.OrderOnHand">
SELECT so.id,so.order_sn AS orderSn,so.order_type AS orderType,so.active_status AS activeStatus,so.merchant_id
AS merchantId,
so.mechanic_id AS mechanicId,so.create_time AS createTime,sdd.data_value AS dataValue
FROM sys_order so
INNER JOIN (SELECT MAX(update_time) AS update_time, order_id FROM sys_order_status GROUP BY order_id)sos ON
so.id=sos.order_id
LEFT JOIN sys_order_wechat_msg sowm ON sos.order_id = sowm.order_id AND sowm.msg_type=3
LEFT JOIN sys_dict_data sdd ON so.install_device_type=sdd.data_key
WHERE sowm.order_id IS NULL
AND so.canceled=1 AND so.active_status=2 AND TIMESTAMPDIFF(MINUTE,sos.update_time,NOW())>=30
</select>
<select id="getDictDataValue" resultType="java.lang.String">
SELECT sdd.data_value FROM sys_order so
LEFT JOIN sys_dict_data sdd ON so.install_device_type=sdd.data_key
where so.id=#{id}
</select>
<select id="getOrderList" parameterType="com.glsx.ordercenter.pojo.SysOrder" resultMap="BaseResultMap">
select so.*,reserve_man as reserveMan,reserve_man_phone as reserveManPhone
from sys_order so
<where>
<if test="workOrderNo != null and workOrderNo != ''">
and so.work_order_no = #{workOrderNo}
</if>
<if test="channel != null and channel != ''">
and so.channel = #{channel}
</if>
<if test="orderSource != null and orderSource != ''">
and so.order_source = #{orderSource}
</if>
<if test="orderType != null">
and so.order_type = #{orderType}
</if>
and so.active_status <> 9
</where>
order by complete_time desc
</select>
<update id="updateChannelOrder" parameterType="com.glsx.ordercenter.pojo.SysOrder">
update sys_order
set
active_status = #{activeStatus,jdbcType=TINYINT},
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
district = #{district,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR},
contact = #{contact,jdbcType=VARCHAR},
phone_number = #{phoneNumber,jdbcType=VARCHAR},
car_type = #{carType,jdbcType=VARCHAR},
vin_no = #{vinNo,jdbcType=VARCHAR},
<if test="vinHash != null and vinHash != ''">
vin_hash = #{vinHash,jdbcType=VARCHAR},
</if>
car_color = #{carColor,jdbcType=VARCHAR},
expect_install_time = #{expectInstallTime,jdbcType=TIMESTAMP},
<if test="serviceType != null and serviceType != ''">
service_type = #{serviceType,jdbcType=VARCHAR},
</if>
car_owner = #{carOwner,jdbcType=VARCHAR},
car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=INTEGER},
</if>
<if test="mechanicId != null">
mechanic_id = #{mechanicId,jdbcType=INTEGER},
</if>
remark = #{remark,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=INTEGER},
<if test="newWorkOrderNo != null and newWorkOrderNo != ''">
work_order_no = #{newWorkOrderNo,jdbcType=VARCHAR},
</if>
<if test="serviceCode != null and serviceCode != ''">
service_code = #{serviceCode,jdbcType=VARCHAR},
</if>
merchant_name = #{merchantName,jdbcType=VARCHAR},
longitude = #{longitude },
latitude = #{latitude },
<if test="installContacts != null and installContacts != ''">
install_contacts = #{installContacts,jdbcType=VARCHAR},
</if>
<if test="installContactNumber != null and installContactNumber != ''">
install_contact_number = #{installContactNumber,jdbcType=VARCHAR},
</if>
receive_time = #{receiveTime,jdbcType=TIMESTAMP}
<where>
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="workOrderNo != null and workOrderNo != ''">
and work_order_no = #{workOrderNo}
</if>
<if test="channel != null and channel != ''">
and channel = #{channel}
</if>
</where>
</update>
<!-- 更新渠道订单 -->
<update id="updateChannelOrderByWorkOrderNo" parameterType="com.glsx.ordercenter.pojo.SysOrder">
update sys_order
<set>
<if test="orderSn != null">
order_sn = #{orderSn,jdbcType=VARCHAR},
</if>
<if test="activeStatus != null">
active_status = #{activeStatus,jdbcType=TINYINT},
</if>
<if test="canceled != null">
canceled = #{canceled,jdbcType=TINYINT},
</if>
<if test="orderType != null">
order_type = #{orderType,jdbcType=TINYINT},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="district != null">
district = #{district,jdbcType=INTEGER},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="contact != null">
contact = #{contact,jdbcType=VARCHAR},
</if>
<if test="phoneNumber != null">
phone_number = #{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="carBrand != null">
car_brand = #{carBrand,jdbcType=INTEGER},
</if>
<if test="carSeries != null">
car_series = #{carSeries,jdbcType=INTEGER},
</if>
<if test="carType != null">
car_type = #{carType,jdbcType=VARCHAR},
</if>
<if test="vinNo != null">
vin_no = #{vinNo,jdbcType=VARCHAR},
</if>
<if test="carColor != null">
car_color = #{carColor,jdbcType=VARCHAR},
</if>
<if test="expectInstallTime != null">
expect_install_time = #{expectInstallTime,jdbcType=TIMESTAMP},
</if>
<if test="serviceType != null">
service_type = #{serviceType,jdbcType=VARCHAR},
</if>
<if test="carOwner != null">
car_owner = #{carOwner,jdbcType=VARCHAR},
</if>
<if test="carOwnerPhone != null">
car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
</if>
<if test="cancelTime != null">
cancel_time = #{cancelTime,jdbcType=TIMESTAMP},
</if>
<if test="activeStatusArray != null">
active_status_array = #{activeStatusArray,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=INTEGER},
</if>
<if test="mechanicId != null">
mechanic_id = #{mechanicId,jdbcType=INTEGER},
</if>
<if test="repairReason != null">
repair_reason = #{repairReason,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=INTEGER},
</if>
<if test="deviceNo != null">
device_no = #{deviceNo,jdbcType=VARCHAR},
</if>
<if test="installLocation != null">
install_location = #{installLocation,jdbcType=VARCHAR},
</if>
<if test="overdueReason != null">
overdue_reason = #{overdueReason,jdbcType=VARCHAR},
</if>
<if test="repairType != null">
repair_type = #{repairType,jdbcType=TINYINT},
</if>
<if test="carPicture != null">
car_picture = #{carPicture,jdbcType=VARCHAR},
</if>
<if test="vinNoPicture != null">
vin_no_picture = #{vinNoPicture,jdbcType=VARCHAR},
</if>
<if test="installLocationPicture != null">
install_location_picture = #{installLocationPicture,jdbcType=VARCHAR},
</if>
<if test="completeTime != null">
complete_time = #{completeTime,jdbcType=TIMESTAMP},
</if>
<if test="installRemark != null">
install_remark = #{installRemark,jdbcType=VARCHAR},
</if>
<if test="installDeviceType != null">
install_device_type = #{installDeviceType,jdbcType=VARCHAR},
</if>
<if test="reserveInstallTime != null">
reserve_install_time = #{reserveInstallTime,jdbcType=TIMESTAMP},
</if>
<if test="workOrderNo != null">
work_order_no = #{workOrderNo,jdbcType=VARCHAR},
</if>
<if test="channel != null">
channel = #{channel,jdbcType=VARCHAR},
</if>
<if test="merchantName != null">
merchant_name = #{merchantName,jdbcType=VARCHAR},
</if>
<if test="receiveTime != null">
receive_time = #{receiveTime,jdbcType=TIMESTAMP},
</if>
<if test="auditStatus != null">
audit_status = #{auditStatus,jdbcType=TINYINT},
</if>
<if test="auditCount != null">
audit_count = #{auditCount,jdbcType=TINYINT},
</if>
<if test="auditTime != null">
audit_time = #{auditTime,jdbcType=TIMESTAMP},
</if>
</set>
where work_order_no = #{workOrderNo}
and channel = #{channel,jdbcType=VARCHAR}
</update>
<select id="getOrderBySubOrderId" resultMap="BaseResultMap">
SELECT
so.*
FROM
sys_order_repair sor
LEFT JOIN sys_order so ON sor.order_id = so.id
WHERE
sor.sub_order_id = #{orderId}
</select>
<select id="getOrderByWorkOrderNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_order
where work_order_no = #{workOrderNo} order by create_time desc
</select>
<update id="updateOrdersBindShop" parameterType="com.glsx.ordercenter.pojo.SysOrder">
UPDATE sys_order so
LEFT JOIN sys_user su ON so.shop_id = su.id
LEFT JOIN sys_channel_org sco ON su.group_id = sco.orgId AND sco.channel = #{channel}
SET so.shop_id = #{shopId},so.service_type=#{serviceType}
WHERE
so.active_status = 1
AND so.canceled = 1
AND so.merchant_name = #{merchantName} AND so.channel=#{channel}
</update>
<!-- 获取未知订单列表 -->
<select id="getUnknownOrderList" parameterType="com.glsx.ordercenter.pojo.SysOrder" resultMap="BaseResultMap">
<if test="orderSn != null and orderSn != ''">
<bind name="orderSn" value="'%' + orderSn + '%'"/>
</if>
<if test="merchantName != null and merchantName != ''">
<bind name="merchantName" value="'%' + merchantName + '%'"/>
</if>
<if test="province != null and province != ''">
<bind name="province" value="'%' + province + '%'"/>
</if>
<if test="city != null and city != ''">
<bind name="city" value="'%' + city + '%'"/>
</if>
<if test="workOrderNo != null and workOrderNo != ''">
<bind name="workOrderNo" value="'%' + workOrderNo + '%'"/>
</if>
<if test="beginDate != null and beginDate != ''">
<bind name="beginDate" value=" beginDate + ' 00:00'"/>
</if>
<if test="endDate != null and endDate != ''">
<bind name="endDate" value="endDate + ' 23:59'"/>
</if>
select
o.id, o.order_sn, o.active_status, o.shop_id, o.district,
o.work_order_no, o.install_device_type, o.address, o.merchant_id, o.merchant_name,
o.create_time,o.car_owner,o.vin_no,
co.orgId as orderChannelOrgId, org.`name` as orgName, m.shop_name, dd.data_value as installDeviceTypeName,
ar1.area_name AS districtName, ar2.area_name as city, ar3.area_name AS province
from sys_order o
LEFT JOIN sys_channel_org co on o.channel = co.channel
LEFT JOIN sys_organization org on co.orgId = org.id
LEFT JOIN sys_merchant m ON o.shop_id = m.user_id
LEFT JOIN sys_dict_data dd on o.install_device_type = dd.data_key
LEFT JOIN sys_area ar1 on o.district = ar1.id
LEFT JOIN sys_area ar2 on ar1.parent_id = ar2.id
LEFT JOIN sys_area ar3 on ar2.parent_id = ar3.id
<where>
o.channel != '' and o.channel is not NULL
and(o.shop_id is NULL or o.merchant_id is null)
and o.canceled = 1
<if test="orderSn != null and orderSn != ''">
and o.order_sn like #{orderSn}
</if>
<if test="installDeviceType != null and installDeviceType != ''">
and o.install_device_type = #{installDeviceType}
</if>
<if test="merchantName != null and merchantName != ''">
and o.merchant_name like #{merchantName}
</if>
<if test="beginDate != null and beginDate != ''">
and o.create_time >= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and o.create_time <= #{endDate}
</if>
<if test="province != null and province != ''">
and ar3.area_name like #{province}
</if>
<if test="city != null and city != ''">
and ar2.area_name like #{city}
</if>
<if test="workOrderNo != null and workOrderNo != ''">
and o.work_order_no like #{workOrderNo}
</if>
<if test="orderChannel != null">
and co.orgId = #{orderChannel}
</if>
</where>
ORDER BY o.create_time DESC, id DESC
</select>
<select id="getOrderListByExample" resultType="com.glsx.ordercenter.pojo.SysOrder">
SELECT DISTINCT so.id id, so.district district, so.order_sn orderSn,
so.active_status as activeStatus, so.canceled as canceled, so.order_type
orderType, so.shop_id as shopId, so.address address, so.create_time createTime,
so.mechanic_id mechanicId, so.install_device_type installDeviceType,
so.service_type serviceType, p.area_name province, c.area_name city, d.area_name zone,
ifnull(so.vin_no, '') as vinNo, so.car_owner carOwner,
so.car_owner_phone carOwnerPhone,
so.car_brand carBrand, so.car_series carSeries, so.car_type carType,
so.check_in_time checkInTime, so.complete_time completeTime,
so.receive_time receiveTime, so.reserve_install_time reserveInstallTime,
ifnull(ssm.shop_name,so.merchant_name) as merchantName,
sd.data_value as reserveInstallReason,ssp.provider_name as serviceName,
ifnull(ssi.service_name, '') as installDeviceTypeName, ifnull(so.work_order_no, '') as workOrderNo, so.channel,
so.audit_status auditStatus, so.audit_count auditCount, so.audit_time auditTime
FROM
<choose>
<!--超级管理员 -->
<when test="userId == 0">
sys_order so
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
<!-- LEFT JOIN sys_user sc ON so.merchant_id = sc.id -->
LEFT JOIN sys_manager ssp ON so.merchant_id = ssp.user_id
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
LEFT JOIN sys_service_item ssi ON so.service_code = ssi.service_code
LEFT JOIN sys_dict_data sd ON so.reserve_install_reason = sd.data_key
LEFT JOIN sys_area d ON d.id = so.district
LEFT JOIN sys_area c ON d.parent_id = c.id
LEFT JOIN sys_area p ON c.parent_id = p.id
LEFT JOIN sys_order_subsidy sos ON so.id = sos.order_id
WHERE so.active_status <> 9
<if test="orderStatus != null ">
<choose>
<when test="orderStatus == 20">
and so.canceled = 0
</when>
<otherwise>
and so.active_status = #{orderStatus}
and so.canceled = 1
</otherwise>
</choose>
</if>
</when>
<!--服务商 -->
<when test="userType == 1">
sys_order so
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_manager ssp ON so.merchant_id = ssp.user_id
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
LEFT JOIN sys_service_item ssi ON so.service_code = ssi.service_code
LEFT JOIN sys_dict_data sd on so.reserve_install_reason = sd.data_key
LEFT JOIN sys_area d ON d.id = so.district
LEFT JOIN sys_area c ON d.parent_id = c.id
LEFT JOIN sys_area p ON c.parent_id = p.id
LEFT JOIN sys_order_subsidy sos ON so.id = sos.order_id
WHERE so.merchant_id = #{userId}
and so.active_status <>9
<choose>
<when test="orderStatus == 0">
and so.active_status in (1,2,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and so.active_status in (4,6,7)
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
<!--运营 -->
<when test="userType == 0">
sys_user_org suo
LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_manager ssp ON so.merchant_id = ssp.user_id
LEFT JOIN sys_service_item ssi ON so.service_code = ssi.service_code
LEFT JOIN sys_dict_data sd on so.reserve_install_reason = sd.data_key
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
LEFT JOIN sys_area d ON d.id = so.district
LEFT JOIN sys_area c ON d.parent_id = c.id
LEFT JOIN sys_area p ON c.parent_id = p.id
LEFT JOIN sys_order_subsidy sos ON so.id = sos.order_id
WHERE
suo.user_id = #{userId}
and so.active_status <> 9
<choose>
<when test="orderStatus == 20">
and so.canceled = 0
</when>
<when test="orderStatus != null">
and so.active_status = #{orderStatus}
and so.canceled = 1
</when>
</choose>
</when>
<!--商户角 -->
<when test="userType == 2">
sys_user_org suo
LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_manager ssp ON so.merchant_id = ssp.user_id
LEFT JOIN sys_service_item ssi ON so.service_code = ssi.service_code
LEFT JOIN sys_dict_data sd on so.reserve_install_reason = sd.data_key
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
LEFT JOIN sys_area d ON d.id = so.district
LEFT JOIN sys_area c ON d.parent_id = c.id
LEFT JOIN sys_area p ON c.parent_id = p.id
LEFT JOIN sys_order_subsidy sos ON so.id = sos.order_id
WHERE
suo.user_id = #{userId}
and so.active_status <> 9
and so.shop_id = #{userId}
<choose>
<when test="orderStatus == 0">
and active_status in (1,2,3,4,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and (active_status in (6,7) )
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
</choose>
<if test="orderSn != null and orderSn!=''">
and so.order_sn like "%"#{orderSn}"%"
</if>
<if test="serviceType != null and serviceType!=''">
and so.install_device_type = #{serviceType,jdbcType=VARCHAR}
</if>
<if test="dateStart != null and dateEnd!=null and dateStart !='' and dateEnd !=''">
and so.create_time between #{dateStart,jdbcType=TIMESTAMP}
and #{dateEnd,jdbcType=TIMESTAMP}
</if>
<if test="reserveInstallTimeStart != null and reserveInstallTimeEnd!=null and reserveInstallTimeStart !='' and reserveInstallTimeEnd !=''">
and (so.reserve_install_time between
#{reserveInstallTimeStart,jdbcType=TIMESTAMP} and
#{reserveInstallTimeEnd,jdbcType=TIMESTAMP})
</if>
<if test="completeTimeStart != null and completeTimeEnd != null">
and (so.complete_time between #{completeTimeStart,jdbcType=TIMESTAMP}
and #{completeTimeEnd,jdbcType=TIMESTAMP})
</if>
<if test="orderChannel != null and orderChannel!=''">
and sp.group_id = #{orderChannel}
</if>
<if test="city != null and city!=''">
and( CONCAT(p.area_name, c.area_name) like "%"#{city}"%")
</if>
<if test="serviceCodeList != null and serviceCodeList.size() != 0">
and so.service_code in
<foreach collection="serviceCodeList" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
<if test="serviceName != null and serviceName!=''">
and ssp.provider_name like "%"#{serviceName}"%"
</if>
<if test="orderType != null and orderType!=''">
and so.order_type = #{orderType}
</if>
<if test="keyWord != null and keyWord!='' and keyWordType != null">
<if test="keyWordType == 1">
and so.vin_no = #{keyWord,jdbcType=VARCHAR}
</if>
<if test="keyWordType == 2">
and so.work_order_no = #{keyWord,jdbcType=VARCHAR}
</if>
<if test="keyWordType == 3">
and so.car_owner like "%"#{keyWord}"%"
</if>
<if test="keyWordType == 4">
and sm.name like "%"#{keyWord}"%"
and sm.user_type = 3
</if>
<if test="keyWordType == 5">
and ssm.shop_name like "%"#{keyWord}"%"
</if>
<!--and(( sm.name like "%"#{keyWord}"%"and sm.user_type = 3)-->
<!-- or ssm.shop_name like "%"#{keyWord}"%"-->
<!-- or so.car_owner like "%"#{keyWord}"%"-->
<!-- or so.vin_no like "%"#{keyWord}"%"-->
<!-- or so.work_order_no like "%"#{keyWord}"%")-->
</if>
<if test="carBrand != null ">
AND so.car_brand = #{carBrand}
</if>
<if test="carSeries != null ">
AND so.car_series = #{carSeries}
</if>
<if test="carOwnerPhone != null and carOwnerPhone != ''">
AND so.car_owner_phone LIKE "%"#{carOwnerPhone}"%"
</if>
<if test="ids != null and !ids.isEmpty()">
and so.id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<choose>
<when test="subsidy == 1">
AND sos.id IS NOT NULL
</when>
<when test="subsidy == 0">
AND sos.id IS NULL
</when>
</choose>
AND so.order_type IN (1,2,3)
GROUP BY so.id
ORDER BY so.create_time DESC
</select>
<select id="orderStatusStatistics" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT so.id) FROM
<choose>
<!--超级管理员 -->
<when test="userId == 0">
sys_order so WHERE so.active_status <> 9
<if test="orderStatus != null ">
<choose>
<when test="orderStatus == 20">
and so.canceled = 0
</when>
<otherwise>
and so.active_status = #{orderStatus}
and so.canceled = 1
</otherwise>
</choose>
</if>
</when>
<!--服务商 -->
<when test="userType == 1">
sys_order so where so.merchant_id = #{userId} and so.active_status <>9
<choose>
<when test="orderStatus == 0">
and so.active_status in (1,2,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and so.active_status in (4,6,7)
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
<!--运营角色 -->
<when test="userType == 0">
sys_user_org suo LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
WHERE suo.user_id = #{userId} AND so.active_status <> 9
<choose>
<when test="orderStatus == 20">
and so.canceled = 0
</when>
<when test="orderStatus != null">
and so.active_status = #{orderStatus}
and so.canceled = 1
</when>
</choose>
</when>
<!--商户角色 -->
<when test="userType == 2">
sys_user_org suo
LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
WHERE suo.user_id = #{userId} AND so.active_status <> 9 AND so.shop_id = #{userId}
<choose>
<when test="orderStatus == 0">
and active_status in (1,2,3,4,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and (active_status in (6,7) )
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
</choose>
AND so.order_type IN (1,2,3)
</select>
<insert id="insertUserOrder">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_user_order (user_id, order_id)
values(#{userId},#{id})
</insert>
<delete id="deleteUserOrder">
delete from sys_user_order
WHERE
user_id = #{userId} AND order_id = #{id}
</delete>
<select id="getByUserIdAndOrderId" resultType="com.glsx.ordercenter.pojo.SysUserOrder">
SELECT
*
FROM
sys_user_order
WHERE
user_id = #{userId} AND order_id = #{id}
</select>
<select id="getConcernOrderList" resultType="com.glsx.ordercenter.pojo.SysOrder">
select
DISTINCT
so.id id,
so.order_sn orderSn,
so.active_status activeStatus,
so.canceled canceled,
so.order_type orderType,
so.address address,
so.create_time createTime,
so.work_order_no workOrderNo,
so.vin_no vinNo,
so.car_owner carOwner,
ssi.service_code as installDeviceType,
so.reserve_install_time reserveInstallTime,
so.complete_time completeTime,
ssi.service_name as installDeviceTypeName,
ssi.img_path as orderIcon,
so.car_brand carBrand,
so.car_series carSeries,
so.car_type carType
FROM
sys_order so
LEFT JOIN sys_user_order suo ON so.id = suo.order_id
LEFT JOIN sys_dict_data dd on so.install_device_type = dd.data_key
LEFT JOIN sys_service_item ssi on so.service_code=ssi.service_code
WHERE so.active_status <> 9
AND so.order_type IN (1,2,3)
<if test="userId != null and userId!=''">
AND suo.user_id = #{userId}
</if>
<if test="orderSn != null and orderSn!=''">
and so.order_sn like "%"#{orderSn}"%"
</if>
<if test="vinNo != null and vinNo!=''">
and so.vin_no like "%"#{vinNo}"%"
</if>
<if test="carOwner != null and carOwner!=''">
and so.car_owner like "%"#{carOwner}"%"
</if>
<if test="workOrderNo != null and workOrderNo!=''">
and so.work_order_no like "%"#{workOrderNo}"%"
</if>
<if test="orderStatus != null">
<choose>
<when test="orderStatus == 0">
and so.active_status in (1,2,3,4,5)
</when>
<when test="orderStatus == 1">
and so.active_status in (8)
</when>
<when test="orderStatus == 2">
and so.active_status in (6,7)
</when>
</choose>
</if>
order by so.create_time desc
</select>
<update id="assignMechanic" parameterType="com.glsx.ordercenter.pojo.SysOrder">
update sys_order
<set>
<if test="activeStatus != null">
active_status = #{activeStatus,jdbcType=TINYINT},
</if>
<if test="mechanicId != null">
mechanic_id = #{mechanicId,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=INTEGER},
</if>
reserve_install_time = #{reserveInstallTime,jdbcType=TIMESTAMP},
<if test="reassignMechanicTime != null">
reassign_mechanic_time = #{reassignMechanicTime},
</if>
<if test="reserveInstallReason != null">
reserve_install_reason = #{reserveInstallReason},
</if>
<if test="reserveMan != null">
reserve_man = #{reserveMan},
</if>
<if test="reserveManPhone != null">
reserve_man_phone = #{reserveManPhone},
</if>
<if test="isCheckIn != null">
is_check_in = #{isCheckIn},
</if>
<if test="overdueReason != null">
overdue_reason = #{overdueReason},
</if>
<if test="overdueRemark != null">
overdue_remark = #{overdueRemark},
</if>
check_in_time = #{checkInTime,jdbcType=TIMESTAMP},
<if test="checkInAddress != null">
check_in_address = #{checkInAddress},
</if>
<if test="merchantId != null">
merchant_id = #{merchantId},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="countByOrderStatusAndUserType" resultType="java.lang.Integer">
select COUNT(1) FROM
<choose>
<when test="userType == 1">
<!-- 服务商 -->
sys_order so
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_user sc ON so.merchant_id = sc.id
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
WHERE so.merchant_id = #{userId}
and so.active_status <> 9
<choose>
<when test="orderStatus == 0">
and so.active_status in (1,2,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and so.active_status in (4,6,7)
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
<when test="userType == 2">
<!-- 商户 -->
sys_user_org suo
LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id
AND u.user_type = 2
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_user sc ON so.merchant_id = sc.id
WHERE suo.user_id = #{userId}
and so.active_status <> 9
and so.shop_id = #{userId}
<choose>
<when test="orderStatus == 0">
and active_status in (1,2,3,4,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and (active_status in (6,7) )
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
<otherwise>
sys_user_org suo
LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id
AND u.user_type = 2
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_user sc ON so.merchant_id = sc.id
WHERE suo.user_id = #{userId}
and so.active_status <> 9
<choose>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
<when test="orderStatus != null and orderStatus!= 20">
and so.active_status = #{orderStatus}
and so.canceled = 1
</when>
</choose>
</otherwise>
</choose>
and so.order_type != 4
</select>
<select id="selectListBySNs" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
sys_order
where
order_sn in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectOrderListForReconciliationDetail" resultType="com.glsx.ordercenter.dto.OrderForReconciliationDto">
SELECT DISTINCT so.id id,so.merchant_id, so.order_sn orderSn,
so.order_type orderType, so.shop_id as shopId, so.create_time createTime,
so.mechanic_id mechanicId, so.install_device_type installDeviceType,
so.service_type serviceType, ifnull(so.vin_no, '') as vinNo, so.car_owner carOwner,
ifnull(ssm.shop_name,so.merchant_name) as merchantName, so.service_code,
ifnull(ssi.service_name, '') as installDeviceTypeName, ifnull(susf.service_fee, 0)+ ifnull(SUM(sos.subsidies),
0.00)-ifnull(soa.amount, 0.00) as actualSettlement,
ifnull(susf.service_fee, 0.00)+ ifnull(SUM(sos.subsidies), 0.00) as quasiSettlementAmount,
ifnull(susf.service_fee, 0.00) as standardAmount,
ifnull(SUM(sos.subsidies), 0.00) as subsidyAmount,ifnull(soa.amount, 0.00) as advanceAmount,(
CASE
WHEN smc.send_type = 2 THEN
sm.name
ELSE
sma.provider_name
END
) AS userName
FROM
sys_order so
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_mechanic smc ON so.mechanic_id = smc.user_id
LEFT JOIN sys_manager sma ON so.merchant_id = sma.user_id
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
LEFT JOIN sys_service_item ssi ON so.service_code = ssi.service_code
LEFT JOIN sys_reconciliation_detail srd ON so.order_sn = srd.order_sn
LEFT JOIN sys_order_subsidy sos ON so.id = sos.order_id
LEFT JOIN sys_operation_advance soa ON so.order_sn = soa.order_sn
<choose>
<when test="userType== 1">
LEFT JOIN sys_user_service_fee susf ON so.merchant_id = susf.user_id AND
so.order_type=susf.fee_type and so.service_code = susf.service_code
WHERE so.merchant_id = #{userId}
</when>
<when test="userType == 3">
LEFT JOIN sys_user_service_fee susf ON so.mechanic_id = susf.user_id and
so.order_type=susf.fee_type AND so.service_code = susf.service_code
WHERE so.mechanic_id = #{userId}
</when>
</choose>
<if test="keyWord != null and keyWord!=''">
and(
so.car_owner like "%"#{keyWord}"%"
or so.vin_no like "%"#{keyWord}"%"
or so.order_sn like "%"#{keyWord}"%")
</if>
<if test="orderType != null ">
and so.order_type = #{orderType}
</if>
<if test="ids != null">
and so.id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
AND so.order_type in (1,2,3)
AND so.active_status <> 9
AND so.canceled = 1
AND so.settlement_status = 0
AND (srd.reconciliation_sn is null )
GROUP BY so.id
order by so.id desc
</select>
<update id="batchUpdateSettlementStatus">
update sys_order
<set>
<if test="settlementStatus != null">
settlement_status = #{settlementStatus},
</if>
</set>
where
<if test="ids != null">
id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
<select id="selectStandardAmountByOrderSn" parameterType="java.lang.String" resultType="java.math.BigDecimal">
SELECT susf.service_fee FROM sys_order so
LEFT JOIN sys_user_service_fee susf ON ((so.mechanic_id = susf.user_id AND
so.service_code=susf.service_code and so.order_type=susf.fee_type)
or (so.merchant_id = susf.user_id AND so.service_code=susf.service_code
and so.order_type=susf.fee_type) )
where so.order_sn =#{orderSn}
</select>
<update id="updateSettlementStatusBySn">
update sys_order
<set>
<if test="settlementStatus != null">
settlement_status = #{settlementStatus},
</if>
</set>
where
order_sn = #{sn}
</update>
<select id="queryOrderByWorkOrderNo" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT id,order_sn,active_status,canceled,vin_no,order_type,create_time
FROM sys_order
WHERE canceled = 1 AND work_order_no = #{workOrderNo} order by id ,create_time desc
</select>
<select id="queryCanceledOrder" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT id,order_sn,active_status,canceled,vin_no,order_type,create_time
FROM sys_order
WHERE work_order_no = #{workOrderNo} order by id ,create_time desc
</select>
<select id="queryOrderByWorkOrderNoAndChannel" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT id,order_sn,active_status,canceled,vin_no,order_type,create_time
FROM sys_order
WHERE canceled = 1
AND work_order_no = #{workOrderNo}
AND channel = #{channel}
AND active_status <> 9
order by id ,create_time desc
</select>
<select id="countByAdmin" resultType="hashmap">
select IFNULL(sum(if(active_status = 1 and canceled = 1, 1, 0)),0) waitAssign,
IFNULL(sum(if(active_status = 2 and canceled = 1, 1, 0)),0) notAssignMechanic,
IFNULL(sum(if(active_status = 4 and canceled = 1, 1, 0)),0) mechanicNotAccept,
IFNULL(sum(if(active_status = 6 and canceled = 1, 1, 0)),0) mechanicWithoutAppointment,
IFNULL(sum(if(active_status = 7 and canceled = 1, 1, 0)),0) notFinish,
IFNULL(sum(if(active_status = 8 and canceled = 1, 1, 0)),0) finished,
IFNULL(sum(if(canceled = 0, 1, 0)),0) canceled
FROM
<choose>
<!--超级管理员 -->
<when test="userId == 0">
sys_order so WHERE so.active_status <> 9
</when>
<!--运营角色 -->
<when test="userType == 0">
sys_user_org suo LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
WHERE suo.user_id = #{userId} AND so.active_status <> 9
</when>
</choose>
AND so.order_type IN (1,2,3)
</select>
<select id="countByMerchant" resultType="hashmap">
select IFNULL(sum(if(active_status in (1, 2, 5) and canceled = 1, 1, 0)),0) waitAssign,
IFNULL(sum(if(active_status in (4, 6, 7) and canceled = 1, 1, 0)),0) finishing,
IFNULL(sum(if(active_status = 8 and canceled = 1, 1, 0)),0) finished,
IFNULL(sum(if(canceled = 0, 1, 0)),0) canceled
FROM
sys_order so where so.merchant_id = #{userId} and so.active_status <>9
AND so.order_type IN (1,2,3)
</select>
<select id="countByShop" resultType="hashmap">
select IFNULL(sum(if(active_status in (1, 2, 3, 4, 5) and canceled = 1, 1, 0)),0) waitAssign,
IFNULL(sum(if(active_status in (6, 7) and canceled = 1, 1, 0)),0) finishing,
IFNULL(sum(if(active_status = 8 and canceled = 1, 1, 0)),0) finished,
IFNULL(sum(if(canceled = 0, 1, 0)),0) canceled
FROM
sys_user_org suo
LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
WHERE suo.user_id = #{userId} AND so.active_status <> 9 AND so.shop_id = #{userId}
AND so.order_type IN (1,2,3)
</select>
<select id="getAfterSaleNumByOrderIdsOrOrdersnList" resultType="com.glsx.ordercenter.dto.OrderRepairDto">
select
sor.order_id orderId,
so.order_sn orderSn,
count(1) num
from
sys_order_repair sor
LEFT JOIN sys_order so on sor.sub_order_id = so.id
LEFT JOIN sys_order so2 on sor.order_id = so2.id
<where>
<if test="orderIds != null and orderIds.size() > 0">
and sor.order_id in
<foreach close=")" collection="orderIds" item="item" open="(" separator=",">
#{item}
</foreach>
and so.canceled = 1
and so.active_status !=8
and so.order_type != 1
</if>
<if test="ordersnList != null and ordersnList.size() > 0">
and so.order_sn in
<foreach close=")" collection="ordersnList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>