fix
Helius
2021-08-09 51845e4b8ed9a1f0c828d1e0c6a827867a69f192
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
<?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.xzx.gc.system.mapper.OrderMapper">
    <select id="findStatusNumByPartnerId" resultType="int">
        SELECT count(*) from xzx_order_info a
        inner join xzx_user_other_info b on a.receiver=b.user_id
        WHERE a.order_status in
        <foreach collection="status" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        and b.partner_id=#{partnerId}
    </select>
 
    <select id="queryOrderByCityId"   resultType="com.xzx.gc.model.admin.OrderModel">
        SELECT
        a.*
        FROM
        xzx_order_info a
        where a.order_status in ('4','7') and a.order_type in('1','2')
        <if test="townIds!= null and townIds.size() != 0">
            and a.town_id in
            <foreach collection="townIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
 
    </select>
 
    <select id="queryOrderByTownIdApiList" resultType="com.xzx.gc.model.admin.OrderModel">
        SELECT a.order_id as orderId,a.create_time as createTime,a.reserve_time as reserveTime,a.order_type as
        orderType,
        a.rela_phone as relaPhone,m.receive_time as receiveTime,
        m.complete_time as completeTime,
        m.cancel_reason_name as cancelReasonName,
        a.order_status as orderStatus,
        IFNULL(d.nick_name,c.nick_name) as nickName,
        c.name as name,d.mobile_phone as mobilePhone,a.rela_name as relaName,
        m.orderMoney as orderMoney,m.orderWeight AS orderWeight,
        m.order_fast_flag as orderFastFlag,
        m.mark_code as markCode,
        IFNULL(m.mark_read,0) as markRead,
        d.partner_id as partnerId,
        IFNULL(c.del_flag,0) as delFlag
        FROM xzx_order_info a
        LEFT JOIN ( select SUM(f.money) as orderMoney,SUM(f.weight) AS orderWeight,b.order_id,
        b.complete_time,b.cancel_reason_name,b.receive_time,b.order_fast_flag,b.mark_code,b.mark_read
        from
        xzx_order_detail_info b
        LEFT JOIN xzx_order_item_info f ON f.order_id = b.order_id
        where 1=1 group by b.order_id
        )m ON m.order_id=a.order_id
        LEFT JOIN xzx_user_info d ON a.create_user_id = d.user_id
        LEFT JOIN xzx_user_other_info c ON a.receiver = c.user_id
        WHERE 1=1
 
        <if test="orderStatus != null and orderStatus != ''">
            AND a.order_status=#{orderStatus}
        </if>
 
        <if test="startTime != null and startTime != ''">
            AND a.create_time BETWEEN #{startTime} AND #{endTime}
        </if>
 
        <if test="orderType != null and orderType != ''">
            AND a.order_type = #{orderType}
        </if>
 
        <if test="name != null and name != ''">
            AND c.name like concat('%',#{name} ,'%')
        </if>
 
        <if test="mobilePhone != null and mobilePhone != ''">
            AND (d.mobile_phone like concat('%',#{mobilePhone} ,'%') or d.nick_name = #{nickName} or a.rela_phone like concat('%',#{mobilePhone} ,'%'))
        </if>
 
        <if test="orderId != null and orderId != ''">
            AND a.order_id like concat('%',#{orderId},'%')
        </if>
 
        <if test="createType != null and createType != ''">
            AND a.create_type = #{createType}
        </if>
 
        <if test="townIds != null and townIds.size()>0">
            AND a.town_id in
            <foreach collection="townIds" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY a.order_id
        order by a.create_time desc
    </select>
 
    <select id="queryOrderApiList" resultType="com.xzx.gc.model.admin.OrderModel">
        SELECT a.order_id as orderId,a.create_time as createTime,a.reserve_time as reserveTime,a.order_type as
        orderType,a.rela_phone as relaPhone,b.receive_time as receiveTime,b.complete_time as
        completeTime,b.cancel_reason_name as cancelReasonName,
        a.order_status as orderStatus,IFNULL(d.nick_name,c.nick_name) as nickName,c.name as name,d.mobile_phone as
        mobilePhone,a.rela_name as relaName,SUM(f.money) as orderMoney,SUM(f.weight) AS orderWeight,IFNULL(b.mark_read,0) as markRead,
        b.order_fast_flag as orderFastFlag,b.mark_code as markCode,d.partner_id as partnerId,IFNULL(c.del_flag,0) as delFlag
        FROM xzx_order_info a
        LEFT JOIN xzx_order_detail_info b ON a.order_id = b.order_id
        LEFT JOIN xzx_user_info d ON a.create_user_id = d.user_id
        LEFT JOIN xzx_user_other_info c ON a.receiver = c.user_id
        LEFT JOIN xzx_order_item_info f ON a.order_id = f.order_id
        LEFT JOIN xzx_user_address_info k ON b.address_id=k.address_id
        WHERE 1 = 1
        <if test="orderStatus != null and orderStatus != ''">
            AND a.order_status=#{orderStatus}
        </if>
 
        <if test="startTime != null and startTime != ''">
            AND a.create_time BETWEEN #{startTime} AND #{endTime}
        </if>
 
        <if test="orderType != null and orderType != ''">
            AND a.order_type = #{orderType}
        </if>
 
        <if test="name != null and name != ''">
            AND c.name like concat('%',#{name} ,'%')
        </if>
 
        <if test="mobilePhone != null and mobilePhone != ''">
            AND (d.mobile_phone like concat('%',#{mobilePhone} ,'%') or d.nick_name = #{nickName} or a.rela_phone like concat('%',#{mobilePhone} ,'%'))
        </if>
 
        <if test="orderId != null and orderId != ''">
            AND a.order_id like concat('%',#{orderId} ,'%')
        </if>
 
        <if test="createType != null and createType != ''">
            AND a.create_type = #{createType}
        </if>
 
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND c.partner_id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        <if test="townIds != null">
            AND k.township_id in
            <foreach collection="townIds" index="index" item="tid" separator="," open="(" close=")">
                #{tid}
            </foreach>
        </if>
        GROUP BY a.order_id
        order by a.create_time desc
    </select>
 
    <select id="getSysStorageTypeName" resultType="java.util.Map">
        SELECT sum(c.weight) AS weight, sum(c.money ) as money, d.title FROM xzx_order_info a
        LEFT JOIN xzx_order_detail_info b ON a.order_id=b.order_id
        LEFT JOIN xzx_order_item_info c ON c.order_id=a.order_id
        LEFT JOIN xzx_sys_environmental_info d ON c.item_type = d.item_type
        WHERE a.order_status=5 and b.complete_time is not null
        and a.order_id in
        <foreach collection="orderIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        <if test="startTime != null and startTime != ''">
            AND b.complete_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND b.complete_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test="typeName != null and endTime != ''">
            AND d.title like concat("%",#{typeName},"%")
        </if>
        group by d.title
    </select>
 
    <select id="findPartnerId" resultType="com.xzx.gc.entity.OrderInfo">
        SELECT
            a.order_id "orderId",
            a.create_time "createTime",
            b.partner_id "partnerId",
            c.money
        FROM
            xzx_order_info a
            LEFT JOIN xzx_order_detail_info c on a.order_id=c.order_id
            LEFT JOIN xzx_partner_fence b ON a.town_id = b.fence_id
    </select>
 
    <select id="findPartnerIdByTime" resultType="com.xzx.gc.entity.OrderInfo">
        SELECT
            a.order_id "orderId",
            a.create_time "createTime",
            b.partner_id "partnerId",
            c.money
        FROM
            xzx_order_info a
            LEFT JOIN xzx_order_detail_info c on a.order_id=c.order_id
            LEFT JOIN xzx_partner_fence b ON a.town_id = b.fence_id
                                             AND b.del_flag = 0
        where
            DATE_FORMAT(a.create_time,'%Y-%m-%d')=date_sub(CURRENT_DATE(), interval 1 day)
    </select>
 
 
</mapper>