OrderParkSmapper.xml 86.7 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 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174
<?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.zteits.order.mapper.smapper.OrderParkSmapper">
    <resultMap id="BaseResultMap" type="com.zteits.order.domain.OrderPark">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="order_id" jdbcType="VARCHAR" property="orderId"/>
        <result column="park_order_type" jdbcType="INTEGER" property="parkOrderType"/>
        <result column="park_detail_type" jdbcType="INTEGER" property="parkDetailType"/>
        <result column="park_state" jdbcType="INTEGER" property="parkState"/>
        <result column="order_state" jdbcType="INTEGER" property="orderState"/>
        <result column="terminal_source" jdbcType="INTEGER" property="terminalSource"/>
        <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
        <result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
        <result column="pl_name" jdbcType="VARCHAR" property="plName"/>
        <result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo"/>
        <result column="berth_range_name" jdbcType="VARCHAR" property="berthRangeName"/>
        <result column="berth_no" jdbcType="VARCHAR" property="berthNo"/>
        <result column="order_dicount_fee" jdbcType="BIGINT" property="orderDicountFee"/>
        <result column="order_act_fee" jdbcType="BIGINT" property="orderActFee"/>
        <result column="order_total_fee" jdbcType="BIGINT" property="orderTotalFee"/>
        <result column="pre_act_fee" jdbcType="BIGINT" property="preActFee"/>
        <result column="pre_total_fee" jdbcType="BIGINT" property="preTotalFee"/>
        <result column="overtime_total_fee" jdbcType="BIGINT" property="overtimeTotalFee"/>
        <result column="overtime_act_fee" jdbcType="BIGINT" property="overtimeActFee"/>
        <result column="back_act_fee" jdbcType="BIGINT" property="backActFee"/>
        <result column="arrearage_fee" jdbcType="BIGINT" property="arrearageFee"/>
        <result column="refund_act_fee" jdbcType="BIGINT" property="refundActFee"/>
        <result column="platform_service_fee" jdbcType="BIGINT" property="platformServiceFee"/>
        <result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
        <result column="car_type" jdbcType="INTEGER" property="carType"/>
        <result column="car_number_color" jdbcType="VARCHAR" property="carNumberColor"/>
        <result column="pre_park_in_time" jdbcType="TIMESTAMP" property="preParkInTime"/>
        <result column="pre_park_out_time" jdbcType="TIMESTAMP" property="preParkOutTime"/>
        <result column="park_in_time" jdbcType="TIMESTAMP" property="parkInTime"/>
        <result column="park_out_time" jdbcType="TIMESTAMP" property="parkOutTime"/>
        <result column="parking_duration" jdbcType="BIGINT" property="parkingDuration"/>
        <result column="record_id" jdbcType="VARCHAR" property="recordId"/>
        <result column="park_in_source_code" jdbcType="VARCHAR" property="parkInSourceCode"/>
        <result column="park_in_source_name" jdbcType="VARCHAR" property="parkInSourceName"/>
        <result column="park_in_device_code" jdbcType="VARCHAR" property="parkInDeviceCode"/>
        <result column="park_in_device_name" jdbcType="VARCHAR" property="parkInDeviceName"/>
        <result column="park_out_source_code" jdbcType="VARCHAR" property="parkOutSourceCode"/>
        <result column="park_out_source_name" jdbcType="VARCHAR" property="parkOutSourceName"/>
        <result column="park_out_device_code" jdbcType="VARCHAR" property="parkOutDeviceCode"/>
        <result column="park_out_device_name" jdbcType="VARCHAR" property="parkOutDeviceName"/>
        <result column="in_free_berths" jdbcType="INTEGER" property="inFreeBerths"/>
        <result column="out_free_berths" jdbcType="INTEGER" property="outFreeBerths"/>
        <result column="cust_type" jdbcType="INTEGER" property="custType"/>
        <result column="cust_id" jdbcType="VARCHAR" property="custId"/>
        <result column="invoice_state" jdbcType="INTEGER" property="invoiceState"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="app_state" jdbcType="INTEGER" property="appState"/>
        <result column="data_state" jdbcType="INTEGER" property="dataState"/>
        <result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId"/>
        <result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName"/>
        <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
        <result column="modfiy_emp_id" jdbcType="VARCHAR" property="modfiyEmpId"/>
        <result column="modfiy_emp_name" jdbcType="VARCHAR" property="modfiyEmpName"/>
        <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate"/>
        <result column="qeual_type" jdbcType="INTEGER" property="qeualType"/>
        <result column="diff_type" jdbcType="INTEGER" property="diffType"/>
        <result column="diff_remark" jdbcType="VARCHAR" property="diffRemark"/>
        <result column="diff_compare_date" jdbcType="TIMESTAMP" property="diffCompareDate"/>
        <result column="trade_service_fee" jdbcType="BIGINT" property="tradeServiceFee"/>
        <result column="org_id" jdbcType="BIGINT" property="orgId"/>
        <result column="org_name" jdbcType="VARCHAR" property="orgName"/>
        <result column="park_in_time_type" jdbcType="INTEGER" property="parkInTimeType"/>
        <result column="is_thirdparty_data" jdbcType="INTEGER" property="isThirdpartyData"/>
        <result column="app_opt_out_time" jdbcType="TIMESTAMP" property="appOptOutTime"/>
        <result column="third_disc_fee" jdbcType="BIGINT" property="thirdDiscFee" />
    </resultMap>
    <sql id="Base_Column_List">
        id, order_id, park_order_type, park_detail_type, park_state, order_state, terminal_source,
        source_type, pl_no, pl_name, berth_range_no, berth_range_name, berth_no, order_dicount_fee,
        order_act_fee, order_total_fee, pre_act_fee, pre_total_fee, overtime_total_fee, overtime_act_fee,
        back_act_fee, arrearage_fee, refund_act_fee, platform_service_fee, car_number, car_type,
        car_number_color, pre_park_in_time, pre_park_out_time, park_in_time, park_out_time,
        parking_duration, record_id, park_in_source_code, park_in_source_name, park_in_device_code,
        park_in_device_name, park_out_source_code, park_out_source_name, park_out_device_code,
        park_out_device_name, in_free_berths, out_free_berths, cust_type, cust_id, invoice_state,
        remark, app_state, data_state, create_emp_id, create_emp_name, create_date, modfiy_emp_id,
        modfiy_emp_name, modfiy_date, qeual_type, diff_type, diff_remark, diff_compare_date,
        trade_service_fee, org_id, org_name, park_in_time_type, is_thirdparty_data, app_opt_out_time,
        third_disc_fee
    </sql>

    <!-- 查询停车订单list对象 -->
    <select id="queryOrderParkForList" resultMap="BaseResultMap"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.OrderParkQueryReq">
        select
        <include refid="Base_Column_List"/>
        from order_park o
        where 1=1

        <if test="berthNos !=null and berthNos.size > 0">
            AND berth_no IN
            <foreach collection="berthNos" separator="," open="(" close=")" item="berthNo">
                #{berthNo}
            </foreach>
        </if>

        <if test="orderId != null and orderId !=''">
            and o.order_id=#{orderId}
        </if>
        <if test="orderIds != null and orderIds.size >0 ">
            AND o.order_id IN
            <foreach collection="orderIds" item="orderId" index="index" open="(" close=")" separator=",">
                #{orderId}
            </foreach>
        </if>

        <if test="parkingDuration != null ">
            and o.parking_duration &lt;= #{parkingDuration}
        </if>
        <if test="parkOrderTypeList != null and parkOrderTypeList.size >0 ">
            AND o.park_order_type IN
            <foreach collection="parkOrderTypeList" item="parkOrderType" index="index" open="(" close=")" separator=",">
                #{parkOrderType}
            </foreach>
        </if>
        <if test="parkStateList != null and parkStateList.size >0 ">
            AND o.park_state IN
            <foreach collection="parkStateList" item="parkState" index="index" open="(" close=")" separator=",">
                #{parkState}
            </foreach>
        </if>
        <if test="parkDetailTypeList != null and parkDetailTypeList.size >0 ">
            AND o.park_detail_type IN
            <foreach collection="parkDetailTypeList" item="parkDetailType" index="index" open="(" close=")"
                     separator=",">
                #{parkDetailType}
            </foreach>
        </if>
        <if test="orderStateList != null and orderStateList.size >0 ">
            AND o.order_state IN
            <foreach collection="orderStateList" item="orderState" index="index" open="(" close=")" separator=",">
                #{orderState}
            </foreach>
        </if>
        <if test="terminalSourceList != null and terminalSourceList.size >0 ">
            AND o.terminal_source IN
            <foreach collection="terminalSourceList" item="terminalSource" index="index" open="(" close=")"
                     separator=",">
                #{terminalSource}
            </foreach>
        </if>
        <if test="sourceTypeList != null and sourceTypeList.size >0 ">
            AND o.source_type IN
            <foreach collection="sourceTypeList" item="sourceType" index="index" open="(" close=")" separator=",">
                #{sourceType}
            </foreach>
        </if>
        <if test="plNoList != null and plNoList.size >0 ">
            AND o.pl_no IN
            <foreach collection="plNoList" item="plNo" index="index" open="(" close=")" separator=",">
                /*停车场编号*/
                #{plNo}
            </foreach>
        </if>
        <if test="plName !=null and plName !=''">
            /*停车场名称模糊搜索*/
            AND o.pl_name like CONCAT('%',#{plName},'%')
        </if>
        <if test="berthRangeNo != null and berthRangeNo !=''">
            and o.berth_range_no=#{berthRangeNo}
        </if>
        <if test="carNumber !=null and carNumber !=''">
            AND o.car_number like CONCAT(#{carNumber},'%')
        </if>

        <if test="carNumberColor != null ">
            and o.car_number_color=#{carNumberColor}
        </if>
        <if test="berthNo != null and berthNo !=''">
            and o.berth_no=#{berthNo}
        </if>
        <if test="parkInTimeBegin !=null">
            /*进场时间*/
            AND o.park_in_time &gt;= #{parkInTimeBegin}
        </if>
        <if test="parkInTimeEnd !=null">
            /*进场时间*/
            AND o.park_in_time &lt;= #{parkInTimeEnd}
        </if>
        <if test="parkOutTimeBegin != null">
            /*出场时间*/
            AND o.park_out_time &gt;= #{parkOutTimeBegin}
        </if>
        <if test="parkOutTimeEnd != null">
            /*出场时间*/
            AND o.park_out_time &lt;= #{parkOutTimeEnd}
        </if>
        <if test="parkInSourceCode != null and parkInSourceCode !=''">
            and o.park_in_source_code=#{parkInSourceCode}
        </if>
        <if test="parkOutSourceCode != null and parkOutSourceCode !=''">
            and o.park_out_source_code=#{parkOutSourceCode}
        </if>

        <if test="chargePerson != null and chargePerson !=''">
            and (o.park_in_source_name like concat( #{chargePerson},'%') or o.park_out_source_name like
            concat(#{chargePerson},'%') )
        </if>
        <if test="custType != null ">
            and o.cust_type=#{custType}
        </if>
        <if test="custId != null and custId !=''">
            and o.cust_id=#{custId}
        </if>
        <if test="appState != null ">
            and o.app_state = #{appState}
        </if>
        <if test="dataState == null ">
            and o.data_state = 1
        </if>
        <if test="dataState != null ">
            and o.data_state=#{dataState}
        </if>
        <if test="entrance !=null">
            /*进口*/
            AND o.park_in_source_code = #{entrance}
        </if>
        <if test="exit != null">
            /*出口*/
            AND o.park_out_source_code = #{exit}
        </if>
        <if test="carNumberList != null and carNumberList.size >0 ">
            AND o.car_number IN
            <foreach collection="carNumberList" item="carNumber" index="index" open="(" close=")" separator=",">
                #{carNumber}
            </foreach>
        </if>
        <if test="queryCarNumber !=null and queryCarNumber !=''">
            AND o.car_number = #{queryCarNumber}
        </if>
        <if test="recordId !=null and recordId !=''">
            AND o.record_id = #{recordId}
        </if>
        <if test="orgId !=null">
            AND o.org_id = #{orgId}
        </if>
        <if test="orgIds != null and orgIds.size >0 ">
            AND o.org_id IN
            <foreach collection="orgIds" item="orgId" index="index" open="(" close=")" separator=",">
                #{orgId}
            </foreach>
        </if>
        order by o.id desc
    </select>

    <!--通过停车订单id更新停车订单表 -->
    <update id="updateOrderParkByOrderId" parameterType="com.zteits.order.domain.OrderPark">
        update order_park
        <set>
            <if test="orderId != null">
                order_id = #{orderId,jdbcType=VARCHAR},
            </if>
            <if test="parkOrderType != null">
                park_order_type = #{parkOrderType,jdbcType=INTEGER},
            </if>
            <if test="parkDetailType != null">
                park_detail_type = #{parkDetailType,jdbcType=INTEGER},
            </if>
            <if test="parkState != null">
                park_state = #{parkState,jdbcType=INTEGER},
            </if>
            <if test="orderState != null">
                order_state = #{orderState,jdbcType=INTEGER},
            </if>
            <if test="terminalSource != null">
                terminal_source = #{terminalSource,jdbcType=INTEGER},
            </if>
            <if test="sourceType != null">
                source_type = #{sourceType,jdbcType=INTEGER},
            </if>
            <if test="plNo != null">
                pl_no = #{plNo,jdbcType=VARCHAR},
            </if>
            <if test="plName != null">
                pl_name = #{plName,jdbcType=VARCHAR},
            </if>
            <if test="berthRangeNo != null">
                berth_range_no = #{berthRangeNo,jdbcType=VARCHAR},
            </if>
            <if test="berthRangeName != null">
                berth_range_name = #{berthRangeName,jdbcType=VARCHAR},
            </if>
            <if test="berthNo != null">
                berth_no = #{berthNo,jdbcType=VARCHAR},
            </if>
            <if test="orderDicountFee != null">
                order_dicount_fee = #{orderDicountFee,jdbcType=BIGINT},
            </if>
            <if test="orderActFee != null">
                order_act_fee = #{orderActFee,jdbcType=BIGINT},
            </if>
            <if test="orderTotalFee != null">
                order_total_fee = #{orderTotalFee,jdbcType=BIGINT},
            </if>
            <if test="preActFee != null">
                pre_act_fee = #{preActFee,jdbcType=BIGINT},
            </if>
            <if test="preTotalFee != null">
                pre_total_fee = #{preTotalFee,jdbcType=BIGINT},
            </if>
            <if test="overtimeActFee != null">
                overtime_act_fee = #{overtimeActFee,jdbcType=BIGINT},
            </if>
            <if test="backActFee != null">
                back_act_fee = #{backActFee,jdbcType=BIGINT},
            </if>
            <if test="arrearageFee != null">
                arrearage_fee = #{arrearageFee,jdbcType=BIGINT},
            </if>
            <if test="refundActFee != null">
                refund_act_fee = #{refundActFee,jdbcType=BIGINT},
            </if>
            <if test="platformServiceFee != null">
                platform_service_fee = #{platformServiceFee,jdbcType=BIGINT},
            </if>
            <if test="carNumber != null">
                car_number = #{carNumber,jdbcType=VARCHAR},
            </if>
            <if test="carType != null">
                car_type = #{carType,jdbcType=INTEGER},
            </if>
            <if test="carNumberColor != null">
                car_number_color = #{carNumberColor,jdbcType=VARCHAR},
            </if>
            <if test="preParkInTime != null">
                pre_park_in_time = #{preParkInTime,jdbcType=TIMESTAMP},
            </if>
            <if test="preParkOutTime != null">
                pre_park_out_time = #{preParkOutTime,jdbcType=TIMESTAMP},
            </if>
            <if test="parkInTime != null">
                park_in_time = #{parkInTime,jdbcType=TIMESTAMP},
            </if>
            <if test="parkOutTime != null">
                park_out_time = #{parkOutTime,jdbcType=TIMESTAMP},
            </if>
            <if test="parkingDuration != null">
                parking_duration = #{parkingDuration,jdbcType=BIGINT},
            </if>
            <if test="recordId != null">
                record_id = #{recordId,jdbcType=VARCHAR},
            </if>
            <if test="parkInSourceCode != null">
                park_in_source_code = #{parkInSourceCode,jdbcType=VARCHAR},
            </if>
            <if test="parkInSourceName != null">
                park_in_source_name = #{parkInSourceName,jdbcType=VARCHAR},
            </if>
            <if test="parkOutSourceCode != null">
                park_out_source_code = #{parkOutSourceCode,jdbcType=VARCHAR},
            </if>
            <if test="parkOutSourceName != null">
                park_out_source_name = #{parkOutSourceName,jdbcType=VARCHAR},
            </if>
            <if test="inFreeBerths != null">
                in_free_berths = #{inFreeBerths,jdbcType=INTEGER},
            </if>
            <if test="outFreeBerths != null">
                out_free_berths = #{outFreeBerths,jdbcType=INTEGER},
            </if>
            <if test="custType != null">
                cust_type = #{custType,jdbcType=INTEGER},
            </if>
            <if test="custId != null">
                cust_id = #{custId,jdbcType=VARCHAR},
            </if>
            <if test="invoiceState != null">
                invoice_state = #{invoiceState,jdbcType=INTEGER},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="dataState != null">
                data_state = #{dataState,jdbcType=INTEGER},
            </if>
            <if test="createEmpId != null">
                create_emp_id = #{createEmpId,jdbcType=VARCHAR},
            </if>
            <if test="createEmpName != null">
                create_emp_name = #{createEmpName,jdbcType=VARCHAR},
            </if>
            <if test="createDate != null">
                create_date = #{createDate,jdbcType=TIMESTAMP},
            </if>
            <if test="modfiyEmpId != null">
                modfiy_emp_id = #{modfiyEmpId,jdbcType=VARCHAR},
            </if>
            <if test="modfiyEmpName != null">
                modfiy_emp_name = #{modfiyEmpName,jdbcType=VARCHAR},
            </if>
            <if test="modfiyDate != null">
                modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP},
            </if>

            <if test="qeualType != null">
                qeual_type = #{qeualType,jdbcType=INTEGER},
            </if>
            <if test="diffType != null">
                diff_type = #{diffType,jdbcType=INTEGER},
            </if>
            <if test="diffCompareDate != null">
                diff_compare_date = #{diffCompareDate,jdbcType=TIMESTAMP},
            </if>
            <if test="tradeServiceFee != null">
                trade_service_fee = #{tradeServiceFee,jdbcType=BIGINT},
            </if>
        </set>
        where order_id = #{orderId,jdbcType=VARCHAR}
    </update>

    <!-- 查询封闭停车场日/月报表 wangfei 2018-02-28 -->
    <select id="querySealedParkingReport"
            parameterType="com.zteits.clouds.api.dto.clouds.param.QuerySealedParkReportRequest"
            resultType="com.zteits.clouds.api.dto.clouds.dto.SealedParkReportDTO">
        SELECT
        <choose>
            <!-- 日报表 -->
            <when test="queryType == 1">
                date(o.park_out_time) paymentTime,
            </when>
            <!-- 月报表 -->
            <when test="queryType == 2">
                DATE_FORMAT(o.park_out_time,'%Y-%m') paymentTime,
            </when>
        </choose>
        o.pl_no parkId,
        o.pl_name parkName,
        sum(o.order_total_fee) orderTotalFee,
        sum(o.order_act_fee) orderPayedFee,
        sum(case o.park_order_type when 100 then 1 else 0 end ) as shortTimeFreeNum,
        sum(case o.park_order_type when 300 then o.order_total_fee else 0 end ) as authorizedFreeFee,
        sum(case o.park_order_type when 300 then 1 else 0 end ) as authorizedFreeNum,
        sum(case o.park_order_type when 400 then o.order_total_fee else 0 end ) as HandFreeFee,
        sum(case o.park_order_type when 400 then 1 else 0 end ) as handFreeNum
        FROM
        order_park o
        WHERE
        o.data_state = 1 and o.order_state in (40,50) AND park_order_type in(100,200,300,400)
        AND o.pl_no IN
        <foreach collection="parkIds" item="plNo" separator="," open="(" close=")" index="index">
            #{plNo}
        </foreach>
        <choose>
            <!-- 日报表 -->
            <when test="queryType == 1">
                AND o.park_out_time BETWEEN #{beginTime} AND #{endTime}
                GROUP BY pl_no,date(o.park_out_time),pl_name
                order by date(o.park_out_time) desc
            </when>
            <!-- 月报表 -->
            <when test="queryType == 2">
                AND o.park_out_time BETWEEN #{beginTime} AND #{endTime}
                GROUP BY pl_no,DATE_FORMAT(o.park_out_time,'%Y-%m'),pl_name
                order by DATE_FORMAT(o.park_out_time,'%Y-%m') desc
            </when>
        </choose>
    </select>
    <!-- 停车场收入统计 -->
    <select id="statisticOrderFeeByDay"
            resultType="com.zteits.clouds.api.dto.clouds.dto.StatisticOrderFeeByDayDTO">
        SELECT
        date(o.park_out_time) paymentTime,
        sum(o.order_act_fee) orderPayedFee
        FROM
        order_park o
        WHERE
        o.data_state = 1 and o.order_state in (40,50) AND park_order_type in(100,200,300,400)
        AND o.pl_no IN
        <foreach collection="parkIds" item="plNo" separator="," open="(" close=")" index="index">
            #{plNo}
        </foreach>
        AND o.park_out_time between #{beginTime} and #{endTime}
        GROUP BY
        date(o.park_out_time)
    </select>


    <!-- 查询停车订单总条数 -->
    <select id="queryOrderParkForPageByConditionCount" resultType="INTEGER"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.OrderParkQueryReq">
        select
        count(1)
        from order_park o
        where 1=1
        <if test="orderId != null and orderId !=''">
            and o.order_id=#{orderId}
        </if>
        <if test="parkOrderTypeList != null and parkOrderTypeList.size >0 ">
            AND o.park_order_type IN
            <foreach collection="parkOrderTypeList" item="parkOrderType" index="index" open="(" close=")" separator=",">
                #{parkOrderType}
            </foreach>
        </if>
        <if test="parkDetailTypeList != null and parkDetailTypeList.size >0 ">
            AND o.park_detail_type IN
            <foreach collection="parkDetailTypeList" item="parkDetailType" index="index" open="(" close=")"
                     separator=",">
                #{parkDetailType}
            </foreach>
        </if>
        <if test="parkStateList != null and parkStateList.size >0 ">
            AND o.park_state IN
            <foreach collection="parkStateList" item="parkState" index="index" open="(" close=")" separator=",">
                #{parkState}
            </foreach>
        </if>
        <if test="orderStateList != null and orderStateList.size >0 ">
            AND o.order_state IN
            <foreach collection="orderStateList" item="orderState" index="index" open="(" close=")" separator=",">
                #{orderState}
            </foreach>
        </if>
        <if test="terminalSourceList != null and terminalSourceList.size >0 ">
            AND o.terminal_source IN
            <foreach collection="terminalSourceList" item="terminalSource" index="index" open="(" close=")"
                     separator=",">
                #{terminalSource}
            </foreach>
        </if>
        <if test="sourceTypeList != null and sourceTypeList.size >0 ">
            AND o.source_type IN
            <foreach collection="sourceTypeList" item="sourceType" index="index" open="(" close=")" separator=",">
                #{sourceType}
            </foreach>
        </if>
        <if test="plNoList != null and plNoList.size >0 ">
            AND o.pl_no IN
            <foreach collection="plNoList" item="plNo" index="index" open="(" close=")" separator=",">
                /*停车场编号*/
                #{plNo}
            </foreach>
        </if>
        <if test="plName !=null and plName !=''">
            /*停车场名称模糊搜索*/
            AND o.pl_name like CONCAT('%',#{plName},'%')
        </if>
        <if test="berthRangeNo != null and berthRangeNo !=''">
            and o.berth_range_no=#{berthRangeNo}
        </if>
        <if test="carNumber !=null and carNumber !=''">
            AND o.car_number like CONCAT(#{carNumber},'%')
        </if>
        <if test="berthNo != null and berthNo !=''">
            and o.berth_no=#{berthNo}
        </if>
        <if test="parkInTimeBegin !=null">
            /*进场时间*/
            AND o.park_in_time &gt;= #{parkInTimeBegin}
        </if>
        <if test="parkInTimeEnd !=null">
            /*进场时间*/
            AND o.park_in_time &lt;= #{parkInTimeEnd}
        </if>
        <if test="parkOutTimeBegin != null">
            /*出场时间*/
            AND o.park_out_time &gt;= #{parkOutTimeBegin}
        </if>
        <if test="parkOutTimeEnd != null">
            /*出场时间*/
            AND o.park_out_time &lt;= #{parkOutTimeEnd}
        </if>
        <if test="parkInSourceCode != null and parkInSourceCode !=''">
            and o.park_in_source_code=#{parkInSourceCode}
        </if>
        <if test="parkOutSourceCode != null and parkOutSourceCode !=''">
            and o.park_out_source_code=#{parkOutSourceCode}
        </if>
        <if test="chargePerson != null and chargePerson !=''">
            and (o.park_in_source_code=#{chargePerson} or o.park_out_source_code=#{chargePerson})
        </if>
        <if test="custType != null ">
            and o.cust_type=#{custType}
        </if>
        <if test="custId != null and custId !=''">
            and o.custId=#{custId}
        </if>
        <if test="dataState == null ">
            and o.data_state = 1
        </if>
        <if test="dataState != null ">
            and o.data_state=#{dataState}
        </if>
        <if test="entrance !=null">
            /*进口*/
            AND o.park_in_source_code = #{entrance}
        </if>
        <if test="exit != null">
            /*出口*/
            AND o.park_out_source_code = #{exit}
        </if>
        order by o.id desc
    </select>

    <!--查询逃逸金额及次数-按天-->
    <select id="queryEscapeFeeAndCountForDay"
            parameterType="com.zteits.clouds.api.dto.clouds.param.CustIncomeParkPayQueryRequset"
            resultType="com.zteits.order.domain.sdo.ParkIncomeDetailforDO">
        SELECT
        a.pl_no parkId,
        ifnull(sum(a.order_total_fee),0) as escapeFee,
        count(1) as escapeCount
        FROM
        order_park a
        WHERE
        a.data_state = 1
        AND a.order_state = 52 /**订单状态[字典表:ORDER_STATE]:10:待核算,20:待支付,30:支付中,40:支付完成,52:欠费逃逸, 53:已补缴 60:退款中 70:退款成功*/
        and a.pl_no in
        <if test="parkIdList != null and parkIdList.size >0">
            <foreach collection="parkIdList" item="plNo" open="(" close=")" separator=",">
                #{plNo}
            </foreach>
        </if>
        <![CDATA[AND a.create_date >= #{beginTime}]]>
        <![CDATA[AND a.create_date <= #{endTime}]]>
        group by a.pl_no
    </select>

    <!--根据parkOut查询停车时长-->
    <select id="queryTdBParkDurationByParkOutTime" resultType="com.zteits.order.domain.TdBParkDurationRep">
        SELECT
        '1' as plType,
        a.order_id as orderId,
        a.park_order_type as orderType,
        a.pl_no as parkId,
        a.pl_name as parkName,
        a.park_in_time as parkInTime,
        a.park_out_time as parkOutTime,
        a.parking_duration as parkingDuration,
        a.park_detail_type as parkType
        FROM
        order_park a
        where 1=1
        and a.data_state=1
        and a.park_state =20 /**停车状态 10:在场 ,20:离场*/
        <![CDATA[and a.park_out_time >=#{beginTime}]]>
        <![CDATA[and a.park_out_time <= #{endTime} ]]>
        AND a.parking_duration  &lt;= (24*60*60*3)
    </select>

    <!-- 收益测算定时任务按次查询 wangfei 2018-03-01  -->
    <select id="queryIncomeForNumJob" resultType="com.zteits.clouds.api.dto.order.parkorder.dto.IncomeForNumJobDTO"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.QueryIncomeForNumJobRequest">
        SELECT
        c.staticDate AS staticDate,
        c.plNo AS plNo,
        c.carType AS carType,
        count(*) AS allNum,
        SUM(
        CASE
        WHEN c.parkingDuration &lt; 15 * 60 THEN
        1
        ELSE
        0
        END
        ) AS freeNum,
        /*停车时长小于15分钟的免费*/
        SUM(
        CASE
        WHEN c.inTimeHour >= 7
        AND c.inTimeHour &lt; 19
        AND c.parkingDuration >= 15 * 60 THEN
        1
        ELSE
        0
        END
        ) AS dayNum,
        /* 停车时长大于15分钟,并且 进场时间大于等于7点,小于19点 白天的数据*/
        SUM(
        CASE
        WHEN (
        c.inTimeHour &lt; 7
        OR c.inTimeHour >= 19
        )
        AND c.parkingDuration >= 15 * 60 THEN
        1
        ELSE
        0
        END
        ) AS nightNum /* 停车时长大于15分钟,并且 进场时间小于7点,大于等于19点 夜间的数据 */
        FROM
        (
        SELECT
        date_format(a.park_out_time, '%Y-%m-%d') AS staticDate,
        a.pl_no AS plNo,
        TIMESTAMPDIFF(
        SECOND,
        a.park_in_time,
        a.park_out_time
        ) AS parkingDuration,
        2 AS carType,
        EXTRACT(HOUR FROM a.park_in_time) AS inTimeHour
        FROM
        order_park a
        WHERE
        a.data_state = 1
        AND a.park_state = 20
        AND a.park_out_time >= #{beginTime}
        AND a.park_out_time &lt;= #{endTime}
        <if test="plNo != null and plNo !=''">
            AND a.pl_no = #{plNo}
        </if>
        ) c
        GROUP BY
        staticDate,plNo,carType
    </select>

    <!-- 收益测算定时任务按次查询 wangfei 2018-03-01  -->
    <select id="queryIncomeForTimeJob" resultType="com.zteits.clouds.api.dto.order.parkorder.dto.IncomeForTimeJobDTO"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.QueryIncomeForNumJobRequest">
        SELECT
        c.staticDate as staticDate,
        c.plNo as plNo,
        c.carType as carType,
        count(*) allNum,
        SUM(CASE WHEN (c.parkingDuration &lt;= 15 * 60)
        THEN 1
        ELSE 0 END) freeNum,
        /*停车时长小于60分钟 免费*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 15 * 60 AND
        c.parkingDuration &lt;= 1 * 60 * 60)
        THEN 1
        ELSE 0 END) day1HourNum,
        /*进场时间位于白天 停车时长大于15分钟,小于等于1小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 1 * 60 * 60 AND
        c.parkingDuration &lt;= 2 * 60 * 60)
        THEN 1
        ELSE 0 END) day2HourNum,
        /*进场时间位于白天 停车时长大于1小时,小于等于2小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 2 * 60 * 60 AND
        c.parkingDuration &lt;= 3 * 60 * 60)
        THEN 1
        ELSE 0 END) day3HourNum,
        /*进场时间位于白天 停车时长大于2小时,小于等于3小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 3 * 60 * 60 AND
        c.parkingDuration &lt;= 4 * 60 * 60)
        THEN 1
        ELSE 0 END) day4HourNum,
        /*进场时间位于白天 停车时长大于3小时,小于等于4小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 4 * 60 * 60 AND
        c.parkingDuration &lt;= 5 * 60 * 60)
        THEN 1
        ELSE 0 END) day5HourNum,
        /*进场时间位于白天 停车时长大于4小时,小于等于5小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 5 * 60 * 60 AND
        c.parkingDuration &lt;= 6 * 60 * 60)
        THEN 1
        ELSE 0 END) day6HourNum,
        /*进场时间位于白天 停车时长大于5小时,小于等于6小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 6 * 60 * 60 AND
        c.parkingDuration &lt;= 7 * 60 * 60)
        THEN 1
        ELSE 0 END) day7HourNum,
        /*进场时间位于白天 停车时长大于6小时,小于等于7小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 7 * 60 * 60 AND
        c.parkingDuration &lt;= 8 * 60 * 60)
        THEN 1
        ELSE 0 END) day8HourNum,
        /*进场时间位于白天 停车时长大于7小时,小于等于8小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 8 * 60 * 60 AND
        c.parkingDuration &lt;= 9 * 60 * 60)
        THEN 1
        ELSE 0 END) day9HourNum,
        /*进场时间位于白天 停车时长大于8小时,小于等于9小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 9 * 60 * 60 AND
        c.parkingDuration &lt;= 10 * 60 * 60)
        THEN 1
        ELSE 0 END) day10HourNum,
        /*进场时间位于白天 停车时长大于9小时,小于等于10小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 10 * 60 * 60 AND
        c.parkingDuration &lt;= 11 * 60 * 60)
        THEN 1
        ELSE 0 END) day11HourNum,
        /*进场时间位于白天 停车时长大于10小时,小于等于11小时*/

        SUM(CASE WHEN (inTimeHour >= 7 AND inTimeHour &lt; 19 AND c.parkingDuration > 11 * 60 * 60 AND
        c.parkingDuration &lt;= 12 * 60 * 60)
        THEN 1
        ELSE 0 END) day12HourNum,
        /*进场时间位于白天 停车时长大于11小时,小于等于12小时*/


        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 15 * 60 AND
        c.parkingDuration &lt;= 1 * 60 * 60)
        THEN 1
        ELSE 0 END) night1HourNum,
        /*进场时间位于夜间 停车时长大于15分钟,小于等于1小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 1 * 60 * 60 AND
        c.parkingDuration &lt;= 2 * 60 * 60)
        THEN 1
        ELSE 0 END) night2HourNum,
        /*进场时间位于夜间 停车时长大于1小时,小于等于2小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 2 * 60 * 60 AND
        c.parkingDuration &lt;= 3 * 60 * 60)
        THEN 1
        ELSE 0 END) night3HourNum,
        /*进场时间位于夜间 停车时长大于2小时,小于等于3小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 3 * 60 * 60 AND
        c.parkingDuration &lt;= 4 * 60 * 60)
        THEN 1
        ELSE 0 END) night4HourNum,
        /*进场时间位于夜间 停车时长大于3小时,小于等于4小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 4 * 60 * 60 AND
        c.parkingDuration &lt;= 5 * 60 * 60)
        THEN 1
        ELSE 0 END) night5HourNum,
        /*进场时间位于夜间 停车时长大于4小时,小于等于5小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 5 * 60 * 60 AND
        c.parkingDuration &lt;= 6 * 60 * 60)
        THEN 1
        ELSE 0 END) night6HourNum,
        /*进场时间位于夜间 停车时长大于5小时,小于等于6小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 6 * 60 * 60 AND
        c.parkingDuration &lt;= 7 * 60 * 60)
        THEN 1
        ELSE 0 END) night7HourNum,
        /*进场时间位于夜间 停车时长大于6小时,小于等于7小时*/


        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 7 * 60 * 60 AND
        c.parkingDuration &lt;= 8 * 60 * 60)
        THEN 1
        ELSE 0 END) night8HourNum,
        /*进场时间位于夜间 停车时长大于7小时,小于等于8小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 8 * 60 * 60 AND
        c.parkingDuration &lt;= 9 * 60 * 60)
        THEN 1
        ELSE 0 END) night9HourNum,
        /*进场时间位于夜间 停车时长大于8小时,小于等于9小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 9 * 60 * 60 AND
        c.parkingDuration &lt;= 10 * 60 * 60)
        THEN 1
        ELSE 0 END) night10HourNum,
        /*进场时间位于夜间 停车时长大于9小时,小于等于10小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 10 * 60 * 60 AND
        c.parkingDuration &lt;= 11 * 60 * 60)
        THEN 1
        ELSE 0 END) night11HourNum,
        /*进场时间位于夜间 停车时长大于10小时,小于等于11小时*/

        SUM(CASE WHEN ((inTimeHour &lt; 7 OR inTimeHour >= 19) AND c.parkingDuration > 11 * 60 * 60 AND
        c.parkingDuration &lt;= 12 * 60 * 60)
        THEN 1
        ELSE 0 END) night12HourNum
        /*进场时间位于夜间 停车时长大于11小时,小于等于12小时*/

        FROM (
        SELECT
        date_format(a.park_out_time, '%Y-%m-%d') AS staticDate,
        a.pl_no AS plNo,
        TIMESTAMPDIFF(
        SECOND,
        a.park_in_time,
        a.park_out_time
        ) AS parkingDuration,
        2 AS carType,
        EXTRACT(HOUR FROM a.park_in_time) AS inTimeHour
        FROM
        order_park a
        WHERE
        a.data_state = 1
        AND a.park_state =20 -- 订单状态:订单状态:10:待核算,20:待支付,30:支付中,40:已支付,51:已出场,52:逃逸
        AND a.park_out_time >= #{beginTime}
        AND a.park_out_time &lt;= #{endTime}
        <if test="plNo != null and plNo !=''">
            AND a.pl_no = #{plNo}
        </if>
        ) c
        GROUP BY staticDate, plNo,carType
    </select>

    <!-- 查询某个账期的具体明细数据  zhaowg 20171127-->
    <select id="querySealedParkingDetailReport"
            parameterType="com.zteits.clouds.api.dto.clouds.param.QuerySealedParkDetailReportRequest"
            resultType="com.zteits.clouds.api.dto.clouds.dto.SealedParkReportDetailDTO">
        SELECT
        <choose>
            <!-- 日报表 -->
            <when test="queryType == 1">
                date(o.park_out_time) paymentTime,
            </when>
            <!-- 月报表 -->
            <when test="queryType == 2">
                DATE_FORMAT(o.park_out_time,'%Y-%m') paymentTime,
            </when>
        </choose>
        o.pl_name parkName,
        o.car_type carType,
        o.car_number carNumber,
        o.park_in_time parkInTime,
        o.park_out_time parkOutTime,
        o.order_total_fee orderTotalFee,
        o.order_act_fee orderPayedFee,
        o.park_order_type orderState
        FROM
        order_park o
        WHERE
        o.data_state = 1 AND o.pl_no = #{parkId}
        <if test="orderState != null">
        </if>
        <choose>
            <!-- 日报表 -->
            <when test="orderState != null">
                AND o.park_order_type = #{orderState}
            </when>
            <!-- 月报表 -->
            <otherwise>
                AND o.park_state =20
            </otherwise>
        </choose>
        <choose>
            <!-- 日报表 -->
            <when test="queryType == 1">
                AND date(o.park_out_time) = #{paymentTime}
            </when>
            <!-- 月报表 -->
            <when test="queryType == 2">
                AND DATE_FORMAT(o.park_out_time,'%Y-%m') = #{paymentTime}
            </when>
        </choose>
        order by o.park_out_time desc
    </select>


    <!-- 查询停车流水 langlw  -->
    <select id="queryParkOrderByCondition" resultMap="BaseResultMap"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.ParkOrderByConditionQueryRequest">
        select
        <include refid="Base_Column_List"/>
        from order_park o
        where 1=1
        <if test="orderId !=null">
            o.order_id = #{orderId}
        </if>


        <if test="plNos != null and plNos.size >0 ">
            AND o.pl_no IN
            <foreach collection="plNos" item="plNo" index="index" open="(" close=")" separator=",">
                /*停车场编号*/
                #{plNo}
            </foreach>
        </if>
        <if test="berthNos != null and berthNos.size >0 ">
            AND o.berth_no IN
            <foreach collection="berthNos" item="berthNo" index="index" open="(" close=")" separator=",">
                /*停车场编号*/
                #{berthNo}
            </foreach>
        </if>
        <if test="parkStatus != null and parkStatus.size >0 ">
            AND o.park_state IN
            <foreach collection="parkStatus" item="parkState" index="index" open="(" close=")" separator=",">
                #{parkState}
            </foreach>
        </if>
        <if test="parkType != null and parkType.size >0 ">
            AND o.park_order_type IN
            <foreach collection="parkType" item="parkOrderType" index="index" open="(" close=")" separator=",">
                #{parkOrderType}
            </foreach>
        </if>
        <if test="beginInTime !=null">
            /*进场时间*/
            AND o.park_in_time &gt;= #{beginInTime}
        </if>
        <if test="endInTime !=null">
            /*进场时间*/
            AND o.park_in_time &lt;= #{endInTime}
        </if>
        <if test="beginOutTime != null">
            /*出场时间*/
            AND o.park_out_time &gt;= #{beginOutTime}
        </if>
        <if test="endOutTime != null">
            /*出场时间*/
            AND o.park_out_time &lt;= #{endOutTime}
        </if>
        <if test="entrance !=null">
            /*进口*/
            AND o.park_in_source_code = #{entrance}
        </if>
        <if test="exit != null">
            /*出口*/
            AND o.park_out_source_code = #{exit}
        </if>
        <if test="carNum !=null and carNum !=''">
            AND o.car_number like CONCAT(#{carNum},'%')
        </if>
        <if test="chargePerson != null and chargePerson !=''">
            and (o.park_in_source_code=#{chargePerson} or o.park_out_source_code=#{chargePerson})
        </if>
        <if test="parkStates != null and parkStates.size >0 ">
            AND o.park_state IN
            <foreach collection="parkStates" item="parkState" index="index" open="(" close=")" separator=",">
                #{parkState}
            </foreach>
        </if>
        <if test="orderStates != null and orderStates.size >0 ">
            AND o.order_state IN
            <foreach collection="orderStates" item="orderState" index="index" open="(" close=")" separator=",">
                #{orderState}
            </foreach>
        </if>
        <if test="carNumbers != null and carNumbers.size >0 ">
            AND o.car_number IN
            <foreach collection="carNumbers" item="carNumber" index="index" open="(" close=")" separator=",">
                #{carNumber}
            </foreach>
        </if>
        <if test="appState != null ">
            and o.app_state = #{appState}
        </if>
        <if test="custId != null and custId !=''">
            and o.cust_id=#{custId}
        </if>
        <if test="terminalSources != null and terminalSources.size >0 ">
            AND o.terminal_source IN
            <foreach collection="terminalSources" item="terminalSource" index="index" open="(" close=")" separator=",">
                /*来源*/
                #{terminalSource}
            </foreach>
        </if>
        <if test="carColorList != null and carColorList.size >0 ">
            and
            <foreach collection="carColorList" item="carColor" index="index" open="(" close=")" separator="">
                <if test="index == 0">
                    ( o.car_number = #{carColor.carNumber}
                    <if test="carColor.carNumberColor != null">
                        and o.car_number_color = #{carColor.carNumberColor}
                    </if>
                    )
                </if>
                <if test="index != 0">
                    or ( o.car_number = #{carColor.carNumber}
                    <if test="carColor.carNumberColor != null">
                        and o.car_number_color = #{carColor.carNumberColor}
                    </if>
                    )
                </if>
            </foreach>
        </if>
        <if test="orgId != null">
            AND o.org_id = #{orgId}
        </if>
        <if test="orgIds != null and orgIds.size >0 ">
            AND o.org_id IN
            <foreach collection="orgIds" item="orgId" index="index" open="(" close=")" separator=",">
                #{orgId}
            </foreach>
        </if>
        and o.data_state = 1
        order by o.id desc
    </select>


    <!-- 收费员今日车辆统计 -->
    <select id="todayCarNumStatistic" resultType="com.zteits.clouds.api.dto.pda.dto.TodayStatisticsDTO">
        select
        sum(case tag when 'carInCount' then num else 0 end) carInCount,/**录入车辆*/
        sum(case tag when 'carSpecialCount' then num else 0 end) carSpecialCount,/**录入车辆中的特殊车辆*/
        sum(case tag when 'carStayCount' then num else 0 end) carStayCount,/**在停车辆*/
        sum(case tag when 'carNoPayCount' then num else 0 end) carNoPayCount/**逃逸车辆*/
        from(
        SELECT
        count(1) num,'carInCount' tag
        FROM
        order_park b
        WHERE
        b.data_state = 1
        AND b.pl_no = #{parkId}
        AND b.terminal_source = 2
        AND b.park_in_source_code = #{chargerCode}
        AND b.park_in_time between #{beginDate} and #{endDate}

        union ALL
        SELECT
        count(1) num,'carSpecialCount' tag
        FROM
        order_park b
        WHERE
        b.data_state = 1
        AND b.park_order_type in (300,500)
        AND b.pl_no = #{parkId}
        AND b.terminal_source = 2
        AND b.park_in_source_code = #{chargerCode}
        AND b.park_in_time between #{beginDate} and #{endDate}


        union ALL
        SELECT
        count(1),'carStayCount'
        FROM
        order_park b
        WHERE
        b.data_state = 1
        AND b.pl_no = #{parkId}
        AND b.terminal_source = 2
        AND b.berth_range_no in
        <foreach collection="berthRangeNos" open="(" close=")" item="berthRangeNo" separator=",">
            #{berthRangeNo}
        </foreach>
        AND b.park_state = 10

        union ALL
        SELECT
        count(1),'carNoPayCount'
        FROM
        order_park b
        WHERE
        b.data_state = 1
        AND b.order_state = 52
        AND b.pl_no = #{parkId}
        AND b.terminal_source = 2
        AND b.park_out_source_code = #{chargerCode}
        AND b.park_out_time between #{beginDate} and #{endDate}
        ) t
    </select>
    <!-- 免费开闸次数=免费停次数+临时停车次数+会员卡停车次数 -->
    <select id="queryFreeCountForPark"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.QueryFreeCountForParkReq"
            resultType="com.zteits.order.domain.sdo.FreeCountForParkDO">
        SELECT
        count(case when a.order_state=52 then
        1
        end) as escapeCount,
        <![CDATA[count(case when a.park_order_type in(100,300,400) and a.order_state <> 52  then ]]>
        1
        end) as freeParkingCount,
        <![CDATA[count(case when a.park_order_type=200 and a.order_state <> 52 then ]]>
        1
        end) as temporaryParkingCount,
        <![CDATA[count(case when a.park_order_type=500 and a.order_state <>52 then ]]>
        1
        end) as dayOrMonthCardParkCount
        FROM
        order_park a
        where 1=1
        and a.park_order_type in(100,200,300,400,500) /**停车大类型:100:短时停车免费,200:临停车,300:授权车免费,400:手动免费开闸 500:白名单车辆免费*/
        and a.data_state =1 /**数据状态:1有效,0无效*/
        and a.park_state=20 /**停车状态 10:在场 ,20:离场*/

        <if test="beginTime != null and endTime != null">
            and a.park_out_time between #{beginTime} and #{endTime}
        </if>
        <if test="parkIdList != null and parkIdList.size >0">
            and a.pl_no in
            <foreach collection="parkIdList" open="(" close=")" item="parkId" separator=",">
                #{parkId}
            </foreach>
        </if>
    </select>
    <!-- 车场概况-查询停车场出车量 -->
    <select id="queryParkOutCount" resultType="com.zteits.order.domain.sdo.ParkOutCountDO"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.ParkOutCountReq">
        SELECT
        a.pl_no as plNo,
        count(1) as outCarNum
        FROM
        order_park a
        WHERE
        1 = 1
        AND a.data_state = 1 /**数据状态:1有效,0无效*/
        AND a.park_out_time BETWEEN #{beginTime} AND #{endTime}
        <if test="plNos != null and plNos.size >0">
            AND a.pl_no IN
            <foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
                #{parkId}
            </foreach>
        </if>
        group by a.pl_no
    </select>

    <!-- 从订单表获取某个时间段进场车辆数 -->
    <select id="queryOrderParkLogInCarNum"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.ParkOutCountReq"
            resultType="com.zteits.order.domain.sdo.ParkLotInOutCarNumDO">
        SELECT
        a.pl_no as plNo,
        count(1) as inCarNum
        FROM
        order_park a
        WHERE
        1 = 1
        AND a.data_state = 1 /**数据状态:1有效,0无效*/
        AND a.park_in_time BETWEEN #{beginTime} AND #{endTime}
        <if test="plNos != null and plNos.size >0">
            AND a.pl_no IN
            <foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
                #{parkId}
            </foreach>
        </if>
        group by a.pl_no
    </select>

    <!-- 车场概况 当前车辆数 -->
    <select id="queryCurrentParkCount" resultType="com.zteits.order.domain.sdo.ParkOutCountDO"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.ParkOutCountReq">
        SELECT
        a.pl_no as plNo,
        count(1) as allCarNum,
        count(case when a.park_order_type in(100,200,400) then
        1
        end) AS tmpCar,
        count(case when a.park_order_type in(300,500) then
        1
        end) AS vipCarNum
        FROM
        order_park a
        WHERE
        1 = 1
        AND a.data_state = 1 /**数据状态:1有效,0无效*/
        and a.order_state in(10,20,30) /**订单状态:10:待核算,20:待支付,30:支付中,40:支付完成,50:已完成,52:欠费逃逸, 53:已补缴 60:退款中 70:退款成功*/
        and a.park_state=10 /**停车状态 10:在场 ,20:离场*/
        AND a.park_in_time BETWEEN #{beginTime} AND #{endTime}
        <if test="plNos != null and plNos.size >0">
            AND a.pl_no IN
            <foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
                #{parkId}
            </foreach>
        </if>
        group by a.pl_no
    </select>


    <select id="queryParkingLotUseStatisticOfParkOrder"
            resultType="com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO">
        SELECT
        t.plNo plNo,
        max(t.plName) plName,
        max(t.inCount) tmp_vehicle_flow,
        max(t.outCount) out_park_count,
        max(t.inCount) fix_vehicle_flow,
        max(t.inFreeBerth) free_ratio,
        max(t.inCount)     turnover_ratio,
        1                  statistic_type
        FROM (SELECT
        pl_no               plNo,
        max(pl_name)        plName,
        count(0)            inCount,
        0                   outCount,
        avg(in_free_berths) inFreeBerth,
        0                   outFreeBerth
        FROM order_park
        WHERE 1 = 1
        AND park_in_time &gt; #{startDate} AND park_in_time &lt;= #{endDate}
        AND data_state = 1
        AND park_state = 10
        AND source_type != 2
        GROUP BY pl_no
        UNION ALL
        SELECT
        pl_no               plNo,
        max(pl_name)        plName,
        0                   inCount,
        count(0)            outCount,
        0                   inFreeBerth,
        avg(in_free_berths) outFreeBerth
        FROM order_park
        WHERE 1 = 1
        AND park_out_time &gt; #{startDate} AND park_out_time &lt;= #{endDate}
        AND data_state = 1
        AND park_state = 20
        AND source_type != 2
        GROUP BY pl_no) t
        GROUP BY t.plNo
    </select>


    <!-- 异常收入定时任务 langlw  2018-04-12 -->
    <select id="queryAbnormalIncomeForTimedTask"
            resultType="com.zteits.order.domain.TdBAbnormalIncome">
        SELECT
        DATE_FORMAT(o.park_out_time,'%Y-%m-%d') abnormalDate,
        o.pl_no plNo,
        o.pl_name plName,
        sum(o.order_total_fee) orderTotalFee,
        sum(o.order_act_fee) orderPayedFee,
        sum(case o.park_order_type when 100 then 1 else 0 end ) as shortTimeFreeNum,
        sum(case o.park_order_type when 300 then o.order_total_fee else 0 end ) as authorizedFreeFee,
        sum(case o.park_order_type when 300 then 1 else 0 end ) as authorizedFreeNum,
        sum(case o.park_order_type when 400 then o.order_total_fee else 0 end ) as handFreeFee,
        sum(case o.park_order_type when 500 then 1 else 0 end ) as whiteListFreeNum,
        sum(case o.park_order_type when 400 then 1 else 0 end ) as handFreeNum
        FROM
        order_park o
        WHERE
        o.data_state = 1 and o.order_state in (40,50) AND o.park_order_type in(100,200,300,400,500)
        AND o.pl_no IN
        <foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
            #{plNo}
        </foreach>
        AND o.park_out_time BETWEEN #{beginTime} AND #{endTime}
        GROUP BY plNo,abnormalDate,plName
    </select>
    <!-- 通过出场时间查询已离场订单数据 -->
    <select id="queryOrderParkByParkOutTime" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_park
        where 1=1
        and data_state = 1
        AND park_state =#{parkState} /**停车状态 10:在场 ,20:离场,30:预订*/
        AND DATE_FORMAT(park_out_time,'%Y-%m-%d') =#{parkOutTime}
        AND park_order_type=200 /**停车大类型:100:短时停车免费,200:临停车,300:授权车免费,400:手动免费开闸 500:白名单车辆免费*/
        <if test="modId != null and modId >=0">
            and id%#{threadNum}=#{modId}
        </if>
    </select>

    <select id="statisticParkReverseIncomeByPlNo" resultType="com.zteits.order.domain.sdo.ParkReverseIncomeDO">
         SELECT
                0              orderNum,
                0 parkShortTimeFreeNum,
                0 parkTempNum,
                0 parkAuthorizationFreeNum,
                0 parkHandOpenNum,
                0 parkWhiteCarNum,
                IFNULL(sum(IFNULL(arrearage_fee, 0)),0) arrearageFee,
                0 refundFee
        FROM order_arrearage
        where data_state=1
        and order_state=52
        and pl_no=#{plNo}
        and park_out_time BETWEEN #{startDate} and #{endDate}
    </select>
    <select id="queryParkIncomeByOrderId" resultType="com.zteits.clouds.api.dto.park.dto.ParkOrderIncomeDTO">

        SELECT
        ifnull(sum(n.order_act_fee), 0) parkIncome,

        ifnull(sum(CASE n.pay_type
        WHEN 1
        THEN n.order_act_fee
        ELSE 0 END), 0)      aliIncome,
        ifnull(sum(CASE n.pay_type
        WHEN 5
        THEN n.order_act_fee
        ELSE 0 END), 0)      balanceIncome,

        ifnull(sum(CASE n.pay_type
        WHEN 6
        THEN n.order_act_fee
        ELSE 0 END), 0)      cashIncome,

        ifnull(sum(CASE
        WHEN n.pay_type IN (2, 4)
        THEN n.order_act_fee
        ELSE 0 END), 0)      wxIncome


        FROM pay_order n
        WHERE n.data_state = 1
        and n.pay_type !=7
        AND pay_order_state = 40
        AND n.rlt_order_id = #{orderId}


    </select>

    <!-- 根据订单统计停车时长 -->
    <select id="statisticParkDurationByPlNo" resultType="com.zteits.order.domain.DurationStatisticParkDay">
         SELECT
		    IFNULL(SUM(o.parking_duration),0) totalDuration,
		    IFNULL(COUNT(1),0) AS totalParkingTimes,
		    IFNULL(COUNT(CASE WHEN (o.parking_duration >= 0 AND o.parking_duration &lt;= 15*60)or(o.parking_duration is null ) THEN o.id END),0) AS min15,
		    IFNULL(COUNT(CASE WHEN o.parking_duration > 15*60 AND o.parking_duration &lt;= 30*60 THEN o.id END),0) AS min30,
		    IFNULL(COUNT(CASE WHEN o.parking_duration > 30*60 AND o.parking_duration &lt;= 60*60 THEN o.id END),0) AS hour1,
		    IFNULL(COUNT(CASE WHEN o.parking_duration > 60*60 AND o.parking_duration &lt;= 6*60*60 THEN o.id END),0) AS hour6,
		    IFNULL(COUNT(CASE WHEN o.parking_duration > 6*60*60 AND o.parking_duration &lt;= 12*60*60 THEN o.id END),0) AS hour12,
		    IFNULL(COUNT(CASE WHEN o.parking_duration > 12*60*60 AND o.parking_duration &lt;= 24*60*60 THEN o.id END),0) AS hour24,
		    IFNULL(COUNT(CASE WHEN o.parking_duration > 24*60*60  THEN o.id END),0) AS day1
		FROM order_park o
	        WHERE o.data_state = 1 AND o.park_state = 20
	        AND o.pl_no = #{plNo}
	        AND o.park_out_time &gt;= #{startDate}
	        AND o.park_out_time &lt; #{endDate}
            AND o.parking_duration  &lt;= (24*60*60*3)
    </select>


    <select id="statisticChargerParkOrderInfo" resultType="com.zteits.order.domain.sdo.ChargerParkOrderDO">

        SELECT
        count(*)   orderNum,
        sum(CASE WHEN park_order_type = 400 OR order_state = 52
        THEN order_total_fee
        ELSE 0 END) errorFee,

        sum(CASE WHEN park_order_type = 400 OR order_state = 52
        THEN 1
        ELSE 0 END) errorOrderNum
        FROM order_park
        WHERE data_state = 1 AND park_out_source_code = #{chargerCode}
        AND park_state = 20
        AND park_out_time &gt;= #{startDate} AND park_out_time &lt;= #{endDate};


    </select>

    <!-- 查询异常停车记录 -->
    <select id="queryAbnormalOrderParkForList" resultMap="BaseResultMap"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.OrderParkQueryReq">
        select
        <include refid="Base_Column_List"/>
        from order_park o
        where 1=1
        and o.data_state = 1

        <if test="plNoList != null and plNoList.size >0 ">
            AND o.pl_no IN
            <foreach collection="plNoList" item="plNo" index="index" open="(" close=")" separator=",">
                /*停车场编号*/
                #{plNo}
            </foreach>
        </if>
        <if test="carNumber !=null and carNumber !=''">
            AND o.car_number like CONCAT(#{carNumber},'%')
        </if>
        <if test="abnormalType !=null and abnormalType ==1">
            AND park_in_time &lt;=#{tempTime} AND park_out_time IS NULL
        </if>
        <if test="abnormalType !=null and abnormalType ==2">
            AND park_in_time IS NULL AND pre_park_in_time IS NULL AND (park_out_time IS NOT NULL or pre_park_out_time IS
            NOT NULL)
        </if>
        <if test="abnormalType !=null and abnormalType ==-1">
            AND ((park_in_time &lt;=#{tempTime} AND park_out_time IS NULL) or
            (park_in_time IS NULL AND pre_park_in_time IS NULL AND (park_out_time IS NOT NULL or pre_park_out_time IS
            NOT NULL)))
        </if>
        <if test="parkInTimeBegin !=null and parkInTimeEnd !=null">
            <if test="abnormalType !=null and abnormalType ==1">
                AND park_in_time between #{parkInTimeBegin} and #{parkInTimeEnd}
            </if>
            <if test="abnormalType !=null and abnormalType ==2">
                AND create_date between #{parkInTimeBegin} and #{parkInTimeEnd}
            </if>
            <if test="abnormalType !=null and abnormalType ==-1">
                AND create_date between #{parkInTimeBegin} and #{parkInTimeEnd}
            </if>
        </if>

        order by o.id desc
    </select>

    <!-- 统计最近24小时收入 -->
    <select id="queryRecentIncome"
            parameterType="com.zteits.clouds.api.dto.order.income.param.IncomeRecentStatisticRequest"
            resultType="com.zteits.clouds.api.dto.order.income.dto.IncomeRecentStatisticDTO">
        SELECT
        DATE_FORMAT(park_out_time,'%Y-%m-%d %H') staticTimeStr,
        SUM(order_act_fee) orderActFee
        FROM
        `order_park`
        WHERE
        data_state = 1
        AND park_state = 20
        AND order_state IN (40,50)
        <if test="beginTime != null and endTime !=null">
            and park_out_time between #{beginTime} and #{endTime}
        </if>
        <if test="plNos != null and plNos.size>0">
            and pl_no in
            <foreach collection="plNos" item="plNo" index="index" open="(" close=")" separator=",">
                #{plNo}
            </foreach>
        </if>
        GROUP BY staticTimeStr
    </select>


    <!-- 统计收费员收入 -->
    <select id="chargerIncomeStatistic" resultType="com.zteits.order.domain.ChargerIncomeStatisticDay">
    		select
		   		   ee.park_in_source_code as chargerCode,
				   ee.park_in_source_name as chargerName,
				   sum(ee.park_in_ount) as parkInOunt,
				   sum(ee.park_out_ount) as parkOutOunt,
				   sum(ee.arrearage_count) as arrearageCount,
				   sum(IFNULL(ee.arrearage_count_on,0)) as arrearageCountOn,
                   sum(IFNULL(ee.arrearage_count_off,0)) as arrearageCountOff,
				   sum(ff.wxnum) as wxCount,
				   sum(ff.aliChargeNum) as aliCount,
				   sum(ff.cashnum) as cashCount,
				   sum(ff.balancenum) as balanceCount,

				   sum(IFNULL(ff.order_act_fee,0) +  IFNULL(ee.arrearage_fee,0))as totalFee,
				   sum(IFNULL(ee.arrearage_fee,0)) as arrearageFee,
				   sum(IFNULL(ee.arrearage_fee_on,0)) as arrearageFeeOn,
                   sum(IFNULL(ee.arrearage_fee_off,0)) as arrearageFeeOff,
				   sum(IFNULL(ff.wxFee,0)) as wxFee,
				   sum(IFNULL(ff.aliFee,0)) as aliFee,
				   sum(IFNULL(ff.cashFee,0)) as cashFee,
				   sum(IFNULL(ff.balanceFee,0)) as balanceFee,
				   sum(IFNULL(ff.order_act_fee,0)) +sum(IFNULL(pp.back_fee,0)) as subTotalFee,
					 sum(IFNULL(pp.back_fee,0)) as backFee,
				   sum(IFNULL(pp.app_back_fee,0)) as appBackFee,
				   sum(IFNULL(pp.pda_back_fee,0)) as pdaBackFee,
					 sum(IFNULL(pp.app_back_num,0)) as appBackCount,
				   sum(IFNULL(pp.pda_back_num,0)) as pdaBackCount,
					 sum(IFNULL(pp.back_num,0)) as backCount,
				   sum(IFNULL(ff.order_dicount_fee,0)) as dicountFee
		 from (
		select
		   c.park_in_source_code,
		   c.park_in_source_name,
		   c.park_in_ount,
		   d.park_out_ount,
		   d.arrearage_count,
		   d.arrearage_count_on,
           d.arrearage_count_off,
		   d.order_total_fee,
		   d.arrearage_fee,
		   d.arrearage_fee_on,
		   d.arrearage_fee_off
		 from (
		SELECT
		    a.park_in_source_code,
		    a.park_in_source_name,
		    count(a.id) as park_in_ount
		FROM
		  order_park a
		WHERE  1=1
		   and a.data_state=1
		   and a.park_state=20
		   and a.terminal_source=2
		   and date(a.park_out_time) between #{startDate} and #{endDate}
			 AND a.park_in_source_code = #{chargerCode}

		    ) c,
		   (SELECT
		    a.park_out_source_code,
		    a.park_out_source_name,
		    count(a.id) as park_out_ount,
		    sum(a.order_total_fee) as order_total_fee,
		    sum(a.arrearage_fee) as arrearage_fee,
		    sum(case when a.order_state in(52,53) then 1 else  0 end) as arrearage_count,
	        sum(case when (a.order_state in(52,53)) AND (DATE_FORMAT(park_out_time,'%H') &lt;18)  then 1 else 0 end) as arrearage_count_on,
	        sum(case when (a.order_state in(52,53)) AND (DATE_FORMAT(park_out_time,'%H') >=18) then 1 else 0 end) as arrearage_count_off,
	        sum(case when (DATE_FORMAT(park_out_time,'%H') &lt;18)  then a.arrearage_fee else 0 end) as arrearage_fee_on,
	        sum(case when (DATE_FORMAT(park_out_time,'%H') >=18)  then a.arrearage_fee else 0 end) as arrearage_fee_off
		FROM
		  order_park a
		WHERE  1=1
		   and a.data_state=1
		   and a.park_state=20
		   and a.terminal_source=2
		   and date(a.park_out_time) between #{startDate} and #{endDate}
			 AND a.park_out_source_code = #{chargerCode}
		) d  where  c.park_in_source_code=d.park_out_source_code) ee
		LEFT JOIN
		  (select
		 a.charger_code,
		 a.charger_name,
		 sum(CASE WHEN a.pay_type = 1 THEN
		      IFNULL(a.order_act_fee, 0)
		    ELSE 0 END) aliFee,
		   sum(CASE WHEN a.pay_type = 1  THEN
		      1 ELSE  0 END) aliChargeNum,
		    sum(CASE WHEN a.pay_type in(2,4) THEN
		      IFNULL(a.order_act_fee, 0)
		    ELSE 0 END) wxFee,
		   sum(CASE WHEN a.pay_type in(2,4)  THEN
		      1 ELSE  0 END) wxnum,
		     sum(CASE WHEN a.pay_type=6 THEN
		      IFNULL(a.order_act_fee, 0)
		    ELSE 0 END) cashFee,
		   sum(CASE WHEN a.pay_type = 6  THEN
		      1 ELSE  0 END) cashnum,
		     sum(CASE WHEN a.pay_type=5 THEN
		      IFNULL(a.order_act_fee, 0)
		    ELSE 0 END) balanceFee,
		   sum(CASE WHEN a.pay_type = 5  THEN
		      1 ELSE  0 END) balancenum,
		     sum(IFNULL(a.order_act_fee, 0)) as order_act_fee,
		 sum(IFNULL(a.order_total_fee, 0)) as order_total_fee,
		     sum(IFNULL(a.order_dicount_fee, 0)) as order_dicount_fee
		 from (
		SELECT
		 p.pay_order_id,
		 p.terminal_source,
		 p.order_total_fee,
		 p.order_dicount_fee,
         p.charger_code AS charger_code,
         p.charger_name AS charger_name,
		 p.pay_type,
		 p.order_act_fee
		FROM
		 pay_order p
		 JOIN order_park o ON p.rlt_order_id = o.order_id
		WHERE
		 p.pay_order_state = 40
		 and p.pay_type !=7
		 AND date( p.pay_finish_time ) between #{startDate} and #{endDate}
		 AND p.pay_order_type IN ( 101, 102 )
		AND p.terminal_source IN ( 1, 2, 3 )) a
		group by a.charger_code,
		a.charger_name) ff
		on ee.park_in_source_code=ff.charger_code
		LEFT JOIN
		(
		   select qq.charger_code,sum(order_act_fee) back_fee,
			sum(pda_back_fee) as pda_back_fee,sum(app_back_fee) as app_back_fee,
			count(back_num) as back_num,
		    count(pda_back_num) as pda_back_num,count(app_back_num) as app_back_num
		   from
		   (SELECT
		    p.pay_order_id,
		    p.terminal_source,
            a.back_emp_id AS charger_code,
		   CASE
		     WHEN p.terminal_source IN ( 1, 3 ) THEN
		     c.park_in_source_name
		     WHEN p.terminal_source = 2 THEN
		     a.back_emp_name
		    END AS charger_name,
		    p.pay_type,
		    p.order_act_fee,
		    case when p.terminal_source IN ( 1, 3 ) then
		       p.order_act_fee
		    end  as app_back_fee,
				count(p.id) as back_num,
				case when p.terminal_source IN ( 1, 3 ) then
		       p.id
		    end  as app_back_num,
		    case when p.terminal_source IN (2) then
		       p.order_act_fee
		    end  as pda_back_fee,
		    case when p.terminal_source IN (2) then
		       p.id
		    end  as pda_back_num
		   from  pay_order p ,order_back_detail a ,order_park c
		   WHERE 1=1
		    and p.rlt_order_id=a.order_id
		    and a.rlt_order_id=c.order_id
		    and p.pay_order_state = 40
		    and p.pay_type !=7
		    AND date(p.pay_finish_time) between #{startDate} and #{endDate}
		    AND p.pay_order_type IN ( 103 )
		   AND p.terminal_source IN ( 1, 2, 3 )
		   group by pay_order_id,pay_type
		   ) qq GROUP BY qq.charger_code

		)pp
		on ee.park_in_source_code=pp.charger_code

    </select>

    <update id="updateOrderParkByCarNumbers"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.UpdateOrderParkByCarNumbersRequest">
        update order_park
        <set>
            app_state = #{appState,jdbcType=BIGINT},
            modfiy_date = #{modfiyDate}
        </set>
        where
        app_state = 1 and order_state != 52
        <if test="carNumbers != null and carNumbers.size>0">
            and car_number in
            <foreach collection="carNumbers" item="carNumber" index="index" open="(" close=")" separator=",">
                #{carNumber}
            </foreach>
        </if>
        <if test="parkState != null">
            and park_state = #{parkState}
        </if>
        <if test="orderId != null">
            and order_id = #{orderId}
        </if>
        <if test="orderIdList != null and orderIdList.size >0">
            and order_id in
            <foreach collection="orderIdList" open="(" close=")" item="orderIdOne" separator=",">
                #{orderIdOne}
            </foreach>
        </if>
    </update>


    <!-- 查询最新完成的停车记录-根据orgIds -->
    <select id="queryLastOrderPark"
            parameterType="com.zteits.clouds.api.dto.park.param.parksource.QueryParkSourceByOrgIdsRequest"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_park
        where order_state in (40,50,53)
        and data_state = 1
        and order_act_fee > 0
        and org_id in
        <foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
            #{orgId}
        </foreach>
        order by modfiy_date desc
        limit 10

    </select>

    <!-- 查询最近一周的进出场数统计-根据orgIds -->
    <select id="queryOrderParkNumForLastWeek"
            parameterType="com.zteits.clouds.api.dto.park.param.parksource.QueryParkSourceByOrgIdsRequest"
            resultType="com.zteits.clouds.api.dto.order.parkorder.dto.QueryOrderParkNumStatisticDTO">
        select A.queryDate queryDate,A.inNum inNum, B.outNum outNum ,A.inNum+B.outNum allNum
        from
        (select
        date(park_in_time) queryDate,
        count(1) inNum
        from order_park
        where park_in_time >= #{beginTime}
        and org_id in
        <foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
            #{orgId}
        </foreach>
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        group by date(park_in_time) desc) A,
        (select
        date(park_out_time) queryDate,
        count(1) outNum
        from order_park
        where park_out_time >= #{beginTime}
        and org_id in
        <foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
            #{orgId}
        </foreach>
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        group by date(park_out_time) desc)B
        where A.queryDate = B.queryDate
    </select>

    <!-- 查询今日车流量-根据orgIds -->
    <select id="queryOrderParkNumForToday"
            parameterType="com.zteits.clouds.api.dto.park.param.parksource.QueryParkSourceByOrgIdsRequest"
            resultType="com.zteits.clouds.api.dto.order.parkorder.dto.QueryOrderParkNumStatisticDTO">
        select A.queryDate queryDate,A.inNum inNum, B.outNum outNum ,A.inNum+B.outNum allNum
        from
        (SELECT
        floor(HOUR (park_in_time)/2) AS queryDate,
        count(1) as inNum
        FROM
        order_park
        where park_in_time >= #{beginTime}
        and org_id in
        <foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
            #{orgId}
        </foreach>
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        GROUP BY floor(HOUR (park_in_time)/2)) A,
        (SELECT
        floor(HOUR (park_out_time)/2) AS queryDate,
        count(1) as outNum
        FROM
        order_park
        where park_out_time >= #{beginTime}
        and org_id in
        <foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
            #{orgId}
        </foreach>
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        GROUP BY floor(HOUR (park_out_time)/2))B
        where A.queryDate = B.queryDate
    </select>

    <!-- 根据停车场编号,删除在停车辆信息不在orderIds中的数据-->
    <update id="deleteInParkInValidData">
        UPDATE order_park
        SET data_state = 0,
        remark = 'CheckInParkBerthsDataJob-删除在停垃圾数据',
        modfiy_date = now( )
        WHERE
        park_state = 10
        AND data_state = 1
        AND berth_no IS NOT NULL
        and pl_no = #{plNo}
        AND order_id NOT IN
        <foreach collection="orderIds" item="orderId" separator="," open="(" close=")" index="index">
            #{orderId}
        </foreach>
    </update>

    <!--通过收费员编码查询收费次数等-->
    <select id="queryChargerIncomeStatisticDayBychargerCode"
            resultType="com.zteits.order.domain.ChargerIncomeStatisticDay">
        select
        aa.pl_no as plNo,
        aa.pl_name as plName,
        aa.org_id as orgId,
        berth_range_no as berthRangeNo,
        aa.berth_range_name as berthRangeName,
        aa.charge_code as chargerCode,
        aa.charge_name as chargerName,
        sum(aa.parkInCount) as parkInOunt,
        sum(aa.parkOutCount) as parkOutOunt,
        sum(aa.arrearageCount) as arrearageCount,
        sum(aa.arrearageCountOn) as arrearageCountOn,
        sum(aa.arrearageCountOff) as arrearageCountOff,
        sum(aa.arrearageFee ) as arrearageFee,
        sum(aa.arrearageFeeOn) as arrearageFeeOn,
        sum(aa.arrearageFeeOff) as arrearageFeeOff
        from (
        SELECT
        a.pl_no ,
        a.pl_name ,
        a.org_id ,
        a.berth_range_no ,
        a.berth_range_name ,
        a.park_in_source_code as charge_code,
        a.park_in_source_name as charge_name,
        count(1) as parkInCount,
        0 as parkOutCount,
        0 as arrearageCount,
        0 as arrearageCountOn,
        0 as arrearageCountOff,
        0 as arrearageFee,
        0 as arrearageFeeOn,
        0 as arrearageFeeOff
        FROM
        order_park a
        WHERE
        1 = 1
        and order_state in (40,50,52,53) /**订单状态-50:已取消,10:待核算,20:待支付,30:支付中,40:支付完成,50:已完成,52:欠费逃逸, 53:已补缴 60:退款中 70:退款成功.*/
        and a.data_state=1
        and a.park_in_source_code=#{chargeCode}
        and a.park_in_time BETWEEN #{beginTime} AND #{endTime}
        <![CDATA[and a.terminal_source<>5 ]]>
        group by a.pl_no ,
        a.pl_name ,
        a.org_id ,
        a.berth_range_no ,
        a.berth_range_name ,
        a.park_in_source_code,
        a.park_in_source_name
        union ALL

        SELECT
        a.pl_no ,
        a.pl_name ,
        a.org_id ,
        a.berth_range_no ,
        a.berth_range_name ,
        a.park_out_source_code as charge_code,
        a.park_out_source_name as charge_name,
        0 as parkInCount,
        count(1) as parkOutCount,
        sum(case when  a.order_state in(52,53) then
        1 else 0
        end) as arrearageCount,
        <![CDATA[ sum(case when HOUR(a.park_out_time) >='8' AND  HOUR(a.park_out_time) <'18' and a.order_state in(52,53) then
        1 else 0
        end) as arrearageCountOn,
        sum(case when (HOUR(a.park_out_time) >='18' or HOUR(a.park_out_time) <'8') and a.order_state in(52,53) then
        1 else 0
        end) as arrearageCountOff,
        sum(case when  a.order_state in(52) then
        a.arrearage_fee else 0
        end) as arrearageFee,
        sum(case when HOUR(a.park_out_time) >='8' AND  HOUR(a.park_out_time) <'18' and a.order_state in(52) then
        a.arrearage_fee else 0
        end) as arrearageFeeOn,
        sum(case when (HOUR(a.park_out_time) >='18' or HOUR(a.park_out_time) <'8')  and a.order_state in(52) then
        a.arrearage_fee else 0
        end) as arrearageFeeOff]]>
        FROM
        order_park a
        WHERE
        1 = 1
        and order_state in (40,50,52,53) /**订单状态-50:已取消,10:待核算,20:待支付,30:支付中,40:支付完成,50:已完成,52:欠费逃逸, 53:已补缴 60:退款中 70:退款成功.*/
        and a.data_state=1
        and a.park_out_time BETWEEN #{beginTime} AND #{endTime}
        <![CDATA[and a.terminal_source<>5]]>
         and a.park_out_source_code=#{chargeCode}
        group by a.pl_no ,
        a.pl_name ,
        a.org_id ,
        a.berth_range_no ,
        a.berth_range_name ,
        a.park_out_source_code,
        a.park_out_source_name) aa
        group by aa.pl_no ,
        aa.pl_name ,
        aa.org_id ,
        berth_range_no,

        aa.charge_code ,
        aa.charge_name
    </select>
    <select id="queryChargerIncomeDiff" resultType="com.zteits.clouds.api.dto.park.dto.ChargerIncomeDiffDTO"
            parameterType="com.zteits.clouds.api.dto.park.param.parksource.ChargerIncomeDiffQueryByOrderReq">

        SELECT
        berth_range_no berthRangeNo,
        max(berth_range_name) berthRangeName,
        count(*) pdaEqpParkNum,
        ifnull(sum(order_total_fee), 0) pdaEqpParkFee
        FROM order_park
        WHERE data_state = 1
        AND berth_no IN
        <foreach collection="berthNos" open="(" close=")" item="berthNo" separator=",">
            #{berthNo}
        </foreach>

        AND park_out_source_code = #{chargerCode}
        AND park_out_time BETWEEN #{startDate} AND #{endDate}
        GROUP BY berth_range_no


    </select>

    <select id="queryArrearageIncomeStatisticDayBychargerCode"
            resultType="com.zteits.order.domain.ChargerIncomeStatisticDay">
        SELECT
        a.park_out_source_code as chargerCode,
        sum(IFNULL(a.arrearage_fee,0) as arrearageFee
        FROM
        order_park a
        WHERE
        1 = 1
        AND order_state IN (52) /**订单状态-50:已取消,10:待核算,20:待支付,30:支付中,40:支付完成,50:已完成,52:欠费逃逸, 53:已补缴 60:退款中 70:退款成功.*/
        AND a.data_state = 1
        <![CDATA[AND a.park_out_time >= #{startTime}
        and a.park_out_time <= #{endTime}]]>
        and a.park_out_source_code=#{chargeCode}
        group by a.park_out_source_code

    </select>

    <resultMap id="carNumberMapResult" type="java.util.HashMap">
        <result property="orderId" column="order_id"/>
        <result property="carNumber" column="car_number"/>
    </resultMap>
    <!-- 根据订单id查询车牌号map -->
    <select id="queryCarNumberMapByOrderIds" resultMap="carNumberMapResult">
        select
        order_id,car_number
        from order_park
        where data_state = 1
        AND order_id IN
        <foreach collection="orderIds" open="(" close=")" item="orderId" separator=",">
            #{orderId}
        </foreach>
    </select>
    <select id="queryLastOrderParkByPlNos" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_park
        where data_state = 1

        <if test="plNos != null and plNos.size>0">
            and pl_no in
            <foreach collection="plNos" separator="," open="(" close=")" item="plNo" index="index">
                #{plNo}
            </foreach>
        </if>

        <if test="orgIds != null and orgIds.size>0">
            and org_id in
            <foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
                #{orgId}
            </foreach>
        </if>
        <if test="queryDate != null ">
            and modfiy_date > #{queryDate}
        </if>
        order by modfiy_date desc
        limit 10


    </select>

    <!-- 对外接口-查询停车记录  -->
    <select id="queryOrderParkForPageByOrgId" resultMap="BaseResultMap"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.QueryParkOrderByOrgIdRequest">
        select
        <include refid="Base_Column_List"/>
        from order_park
        where data_state = 1
        and org_id = #{orgId}
        <if test="beginTime != null and beginTime != ''">
            AND create_date BETWEEN #{beginTime} AND #{endTime}
        </if>
        <if test="outBeginTime != null and outBeginTime != ''">
            AND park_out_time BETWEEN #{outBeginTime} AND #{outEndTime}
        </if>
    </select>

    <!-- 查询车主停车订单总条数 -->
    <select id="queryOwnerOrderParkCount" resultType="com.zteits.clouds.api.dto.owner.dto.OwnerBaseDTO"
            parameterType="com.zteits.clouds.api.dto.owner.param.OwnerRequest">
        select
        count(1) AS totalOrderNum,
        SUM(CASE WHEN (o.park_in_time BETWEEN #{beginTime} AND #{endTime}) THEN 1 ELSE 0 END) monthOrderNum
        from order_park o
        where 1=1
        AND o.car_number in
        <foreach collection="carNumbers" separator="," open="(" close=")" item="carNumber" index="index">
            #{carNumber}
        </foreach>
        and o.data_state = 1
    </select>

    <!-- 修改APP离场时间重新计费 -->
    <update id="updateOrderAppOptOutTimeByOrderId"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.UpdateOrderParkByOrderIdRequest">
        update order_park
        set  app_opt_out_time = NULL
        where order_id = #{orderId,jdbcType=VARCHAR}
    </update>

    <!-- 批量处理订单出场 -->
    <update id="updateGateOrderOutParkByZoro" parameterType="com.zteits.order.domain.OrderPark">
        UPDATE order_park a ,
        (select b.id from order_park b where
        b.data_state = 1
        AND b.source_type not in(2, 14)
        AND b.park_state = 10
        AND b.car_number = #{carNumber}
        AND b.order_id != #{orderId}
        and #{parkInTime} > b.park_in_time
        ) b
        <set>
            <if test="parkOrderType != null">
                a.park_order_type = #{parkOrderType,jdbcType=INTEGER},
            </if>
            <if test="parkState != null">
                a.park_state = #{parkState,jdbcType=INTEGER},
            </if>
            <if test="orderState != null">
                a.order_state = #{orderState,jdbcType=INTEGER},
            </if>
            <if test="parkOutTime != null">
                a.park_out_time = #{parkOutTime,jdbcType=TIMESTAMP},
            </if>
            <if test="parkingDuration != null">
                a.parking_duration = #{parkingDuration,jdbcType=BIGINT},
            </if>
            <if test="parkOutSourceCode != null">
                a.park_out_source_code = #{parkOutSourceCode,jdbcType=VARCHAR},
            </if>
            <if test="parkOutSourceName != null">
                a.park_out_source_name = #{parkOutSourceName,jdbcType=VARCHAR},
            </if>
            <if test="parkOutDeviceCode != null">
                a.park_out_device_code = #{parkOutDeviceCode,jdbcType=VARCHAR},
            </if>
            <if test="parkOutDeviceName != null">
                a.park_out_device_name = #{parkOutDeviceName,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                a.remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="modfiyEmpId != null">
                a.modfiy_emp_id = #{modfiyEmpId,jdbcType=VARCHAR},
            </if>
            <if test="modfiyEmpName != null">
                a.modfiy_emp_name = #{modfiyEmpName,jdbcType=VARCHAR},
            </if>
            <if test="modfiyDate != null">
                a.modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP},
            </if>
        </set>
        WHERE a.id = b.id

    </update>

    <!-- 根据车场编号和车牌号(地锁编号)查询最新的在场记录 -->
    <select id="queryLastInparkOrderByPlNoAndCarNumber" resultMap="BaseResultMap"
            parameterType="com.zteits.clouds.api.dto.order.parkorder.param.ParkOrderByConditionQueryRequest">
        select
        <include refid="Base_Column_List"/>
        from order_park o
        where  o.data_state = 1
        AND o.park_state = 10
        <if test="plNos != null and plNos.size>0">
            and o.pl_no in
            <foreach collection="plNos" separator="," open="(" close=")" item="plNo" index="index">
                #{plNo}
            </foreach>
        </if>
        AND o.car_number = #{carNum}
        <if test="berthNo != null and berthNo != ''">
            AND o.berth_no = #{berthNo}
        </if>
        order by o.id desc limit 1
    </select>
    <select id="statisticOrderInfoForBerthReport"
            resultType="com.zteits.order.domain.sdo.BerthReportOrderInfo">
        select
            count(*)                                                                                    orderNumAll,
            ifnull(sum(IF(parking_duration &lt;= 60 * 15 and order_state=50, 1, 0)), 0)                 orderNumOf15min,
            ifnull(sum(IF(order_state in(40,50,53) and parking_duration &gt;60 * 15, 1, 0)), 0)         orderNumPay,
            ifnull(sum(parking_duration), 0)                                                            parkDurationAll,
            ifnull(sum(IF(parking_duration &lt; 60 * 15, parking_duration, 0)), 0)                      parkDurationOf15min
        from order_park
        where data_state = 1
        and park_state = 20
        and parking_duration &lt;= 60 * 60 * 24 * 3
        and park_out_time between #{startDate} and #{endDate}
        and pl_no = #{plNo}


    </select>

    <!--  根据停车场编号以及车牌号码获取这个车 最新的一个入场记录 -->
    <select id="queryParkOrderByPlNoAndCarnumber" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_park o
        where
        data_state = 1
        and pl_no = #{plNo}
        and car_number = #{carNumber}
        order by park_in_time desc limit 1


    </select>
    <!--  根据停车场编号以及车牌号码获取这个车 最新的一个入场记录 -->
    <select id="queryParkOrderByPlNoAndCarnumberLimit" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_park o
        where
        data_state = 1
        and pl_no = #{plNo}
        and car_number = #{carNumber}
        and car_type = #{carType}
        order by park_in_time desc limit  #{limit}


    </select>

</mapper>