p-honggang.li
5 天以前 cda9decfde8c6b518639c5da506aa293c07f88ff
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
<?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.webmanage.mapper.OrderInfoMapper">
 
    <!-- 基础结果映射 -->
    <resultMap id="BaseResultMap" type="com.webmanage.entity.OrderInfo">
        <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
        <result column="product_id" property="productId" jdbcType="BIGINT"/>
        <result column="user_id" property="userId" jdbcType="BIGINT"/>
        <result column="unit_id" property="unitId" jdbcType="BIGINT"/>
        <result column="product_name" property="productName" jdbcType="VARCHAR"/>
        <result column="provider_name" property="providerName" jdbcType="VARCHAR"/>
        <result column="provider_id" property="providerId" jdbcType="BIGINT"/>
        <result column="apply_time" property="applyTime" jdbcType="TIMESTAMP"/>
        <result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
        <result column="total_amount" property="totalAmount" jdbcType="NUMERIC"/>
        <result column="payment_type" property="paymentType" jdbcType="VARCHAR"/>
        <result column="payment_status" property="paymentStatus" jdbcType="VARCHAR"/>
        <result column="workflow_id" property="workflowId" jdbcType="VARCHAR"/>
        <result column="current_step" property="currentStep" jdbcType="VARCHAR"/>
        <result column="approval_flow" property="approvalFlow" jdbcType="LONGVARCHAR"/>
        <result column="buyer_remarks" property="buyerRemarks" jdbcType="LONGVARCHAR"/>
        <result column="seller_remarks" property="sellerRemarks" jdbcType="LONGVARCHAR"/>
        <result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
        <result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP"/>
        <result column="deleted" property="deleted" jdbcType="INTEGER"/>
        <result column="is_evaluate" property="isEvaluate" jdbcType="VARCHAR"/>
    </resultMap>
 
    <!-- 基础字段列表 -->
    <sql id="Base_Column_List">
        order_id, product_id, user_id, unit_id, product_name, provider_name, provider_id,
        apply_time, order_status, total_amount, payment_type, payment_status, workflow_id,
        current_step, approval_flow, buyer_remarks, seller_remarks, created_at, updated_at, deleted, is_evaluate
    </sql>
 
    <!-- 分页查询买家订单列表 -->
    <select id="selectBuyerOrderPage" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tb_order_info
        WHERE deleted = 0
        <if test="userId != null">
            AND user_id = #{userId}
        </if>
        <if test="unitId != null and unitId != ''">
            AND unit_id = #{unitId}
        </if>
        <if test="orderStatus != null and orderStatus != ''">
            AND order_status = #{orderStatus}
        </if>
        <if test="paymentStatus != null and paymentStatus != ''">
            AND payment_status = #{paymentStatus}
        </if>
        <if test="paymentType != null and paymentType != ''">
            AND payment_type = #{paymentType}
        </if>
        <if test="productName != null and productName != ''">
            AND product_name LIKE CONCAT('%', #{productName}, '%')
        </if>
        <if test="providerName != null and providerName != ''">
            AND provider_name LIKE CONCAT('%', #{providerName}, '%')
        </if>
        <if test="orderId != null and orderId != ''">
            AND order_id LIKE CONCAT('%', #{orderId}, '%')
        </if>
        <if test="applyTimeStart != null and applyTimeStart != ''">
            AND apply_time >= #{applyTimeStart}::timestamp
        </if>
        <if test="applyTimeEnd != null and applyTimeEnd != ''">
            AND apply_time &lt;= #{applyTimeEnd}::timestamp
        </if>
        <if test="createTimeStart != null and createTimeStart != ''">
            AND created_at >= #{createTimeStart}::timestamp
        </if>
        <if test="createTimeEnd != null and createTimeEnd != ''">
            AND created_at &lt;= #{createTimeEnd}::timestamp
        </if>
        ORDER BY
        <choose>
            <when test="orderBy != null and orderBy != ''">
                ${orderBy}
            </when>
            <otherwise>
                created_at
            </otherwise>
        </choose>
        <choose>
            <when test="orderDirection != null and orderDirection == 'asc'">
                ASC
            </when>
            <otherwise>
                DESC
            </otherwise>
        </choose>
    </select>
 
    <!-- 分页查询卖家订单列表 -->
    <select id="selectSellerOrderPage" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tb_order_info
        WHERE deleted = 0
        <if test="providerId != null and providerId != ''">
            AND provider_id = #{providerId}
        </if>
        <if test="orderStatus != null and orderStatus != ''">
            AND order_status = #{orderStatus}
        </if>
        <if test="paymentStatus != null and paymentStatus != ''">
            AND payment_status = #{paymentStatus}
        </if>
        <if test="productName != null and productName != ''">
            AND product_name LIKE CONCAT('%', #{productName}, '%')
        </if>
        <if test="orderId != null and orderId != ''">
            AND order_id LIKE CONCAT('%', #{orderId}, '%')
        </if>
        <if test="applyTimeStart != null and applyTimeStart != ''">
            AND apply_time >= #{applyTimeStart}::timestamp
        </if>
        <if test="applyTimeEnd != null and applyTimeEnd != ''">
            AND apply_time &lt;= #{applyTimeEnd}::timestamp
        </if>
        <if test="createTimeStart != null and createTimeStart != ''">
            AND created_at >= #{createTimeStart}::timestamp
        </if>
        <if test="createTimeEnd != null and createTimeEnd != ''">
            AND created_at &lt;= #{createTimeEnd}::timestamp
        </if>
        ORDER BY
        <choose>
            <when test="orderBy != null and orderBy != ''">
                ${orderBy}
            </when>
            <otherwise>
                created_at
            </otherwise>
        </choose>
        <choose>
            <when test="orderDirection != null and orderDirection == 'asc'">
                ASC
            </when>
            <otherwise>
                DESC
            </otherwise>
        </choose>
    </select>
 
    <!-- 分页查询待审批订单列表 -->
    <select id="selectPendingApprovalOrderPage" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tb_order_info
        WHERE deleted = 0
        AND order_status IN ('待审批授权','待授权', '待交易确认', '已完成', '已取消')
        <if test="orderStatus != null and orderStatus != ''">
            AND order_status = #{orderStatus}
        </if>
        <if test="productName != null and productName != ''">
            AND product_name LIKE CONCAT('%', #{productName}, '%')
        </if>
        <if test="providerName != null and providerName != ''">
            AND provider_name LIKE CONCAT('%', #{providerName}, '%')
        </if>
        <if test="orderId != null and orderId != ''">
            AND order_id LIKE CONCAT('%', #{orderId}, '%')
        </if>
        <if test="applyTimeStart != null and applyTimeStart != ''">
            AND apply_time >= #{applyTimeStart}::timestamp
        </if>
        <if test="applyTimeEnd != null and applyTimeEnd != ''">
            AND apply_time &lt;= #{applyTimeEnd}::timestamp
        </if>
        <if test="workFlowIds != null and workFlowIds.size() > 0">
            AND workflow_id IN
            <foreach collection="workFlowIds" item="workFlowId" open="(" separator="," close=")">
                #{workFlowId}
            </foreach>
        </if>
        ORDER BY
        <choose>
            <when test="orderBy != null and orderBy != ''">
                ${orderBy}
            </when>
            <otherwise>
                created_at
            </otherwise>
        </choose>
        <choose>
            <when test="orderDirection != null and orderDirection == 'asc'">
                ASC
            </when>
            <otherwise>
                DESC
            </otherwise>
        </choose>
    </select>
 
    <!-- 分页查询待审批订单列表(支持产品条件) -->
    <select id="selectPendingApprovalOrderPageWithProductConditions" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tb_order_info
        WHERE deleted = 0
        AND order_status IN ('待授权', '待审批授权', '待交易确认', '已完成', '已取消')
        <if test="orderStatus != null and orderStatus != ''">
            AND order_status = #{orderStatus}
        </if>
        <if test="productName != null and productName != ''">
            AND product_name LIKE CONCAT('%', #{productName}, '%')
        </if>
        <if test="providerName != null and providerName != ''">
            AND provider_name LIKE CONCAT('%', #{providerName}, '%')
        </if>
        <if test="orderId != null and orderId != ''">
            AND order_id LIKE CONCAT('%', #{orderId}, '%')
        </if>
        <if test="applyTimeStart != null and applyTimeStart != ''">
            AND apply_time >= #{applyTimeStart}::timestamp
        </if>
        <if test="applyTimeEnd != null and applyTimeEnd != ''">
            AND apply_time &lt;= #{applyTimeEnd}::timestamp
        </if>
        <if test="productIds != null and productIds.size() > 0">
            AND product_id IN
            <foreach collection="productIds" item="productId" open="(" separator="," close=")">
                #{productId}
            </foreach>
        </if>
        <if test="workFlowIds != null and workFlowIds.size() > 0">
            AND workflow_id IN
            <foreach collection="workFlowIds" item="workFlowId" open="(" separator="," close=")">
                #{workFlowId}
            </foreach>
        </if>
        ORDER BY
        <choose>
            <when test="orderBy != null and orderBy != ''">
                ${orderBy}
            </when>
            <otherwise>
                created_at
            </otherwise>
        </choose>
        <choose>
            <when test="orderDirection != null and orderDirection == 'asc'">
                ASC
            </when>
            <otherwise>
                DESC
            </otherwise>
        </choose>
    </select>
 
    <!-- 分页查询买家订单列表(支持产品条件) -->
    <select id="selectBuyerOrderPageWithProductConditions" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tb_order_info
        WHERE deleted = 0
        <if test="userId != null">
            AND user_id = #{userId}
        </if>
        <if test="unitId != null and unitId != ''">
            AND unit_id = #{unitId}
        </if>
        <if test="orderStatus != null and orderStatus != ''">
            AND order_status = #{orderStatus}
        </if>
        <if test="paymentStatus != null and paymentStatus != ''">
            AND payment_status = #{paymentStatus}
        </if>
        <if test="paymentType != null and paymentType != ''">
            AND payment_type = #{paymentType}
        </if>
        <if test="productName != null and productName != ''">
            AND product_name LIKE CONCAT('%', #{productName}, '%')
        </if>
        <if test="providerName != null and providerName != ''">
            AND provider_name LIKE CONCAT('%', #{providerName}, '%')
        </if>
        <if test="orderId != null and orderId != ''">
            AND order_id LIKE CONCAT('%', #{orderId}, '%')
        </if>
        <if test="applyTimeStart != null and applyTimeStart != ''">
            AND apply_time >= #{applyTimeStart}::timestamp
        </if>
        <if test="applyTimeEnd != null and applyTimeEnd != ''">
            AND apply_time &lt;= #{applyTimeEnd}::timestamp
        </if>
        <if test="createTimeStart != null and createTimeStart != ''">
            AND created_at >= #{createTimeStart}::timestamp
        </if>
        <if test="createTimeEnd != null and createTimeEnd != ''">
            AND created_at &lt;= #{createTimeEnd}::timestamp
        </if>
        <if test="productIds != null and productIds.size() > 0">
            AND product_id IN
            <foreach collection="productIds" item="productId" open="(" separator="," close=")">
                #{productId}
            </foreach>
        </if>
        ORDER BY
        <choose>
            <when test="orderBy != null and orderBy != ''">
                ${orderBy}
            </when>
            <otherwise>
                created_at
            </otherwise>
        </choose>
        <choose>
            <when test="orderDirection != null and orderDirection == 'asc'">
                ASC
            </when>
            <otherwise>
                DESC
            </otherwise>
        </choose>
    </select>
 
    <!-- 分页查询卖家订单列表(支持产品条件) -->
    <select id="selectSellerOrderPageWithProductConditions" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tb_order_info
        WHERE deleted = 0
        <if test="providerId != null and providerId != ''">
            AND provider_id = #{providerId}
        </if>
        <if test="orderStatus != null and orderStatus != ''">
            AND order_status = #{orderStatus}
        </if>
        <if test="paymentStatus != null and paymentStatus != ''">
            AND payment_status = #{paymentStatus}
        </if>
        <if test="productName != null and productName != ''">
            AND product_name LIKE CONCAT('%', #{productName}, '%')
        </if>
        <if test="orderId != null and orderId != ''">
            AND order_id LIKE CONCAT('%', #{orderId}, '%')
        </if>
        <if test="applyTimeStart != null and applyTimeStart != ''">
            AND apply_time >= #{applyTimeStart}::timestamp
        </if>
        <if test="applyTimeEnd != null and applyTimeEnd != ''">
            AND apply_time &lt;= #{applyTimeEnd}::timestamp
        </if>
        <if test="createTimeStart != null and createTimeStart != ''">
            AND created_at >= #{createTimeStart}::timestamp
        </if>
        <if test="createTimeEnd != null and createTimeEnd != ''">
            AND created_at &lt;= #{createTimeEnd}::timestamp
        </if>
        <if test="productIds != null and productIds.size() > 0">
            AND product_id IN
            <foreach collection="productIds" item="productId" open="(" separator="," close=")">
                #{productId}
            </foreach>
        </if>
        ORDER BY
        <choose>
            <when test="orderBy != null and orderBy != ''">
                ${orderBy}
            </when>
            <otherwise>
                created_at
            </otherwise>
        </choose>
        <choose>
            <when test="orderDirection != null and orderDirection == 'asc'">
                ASC
            </when>
            <otherwise>
                DESC
            </otherwise>
        </choose>
    </select>
 
</mapper>