Orders.xml
25.8 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
<?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.diligrp.orders.dao.OrdersDao">
<!-- orders 所有查询列 -->
<sql id="QUERY_COLUMN_LIST">
<![CDATA[a.id,
a.parent_id AS parentId,
a.buyer_id AS buyerId,
a.buyer_name AS buyerName,
a.seller_id AS sellerId,
a.seller_name AS sellerName,
a.market_name AS marketName,
a.market_id AS marketId,
a.delivery_type AS deliveryType,
a.shiping_address AS shipingAddress,
a.order_type AS orderType,
a.order_status AS orderStatus,
a.pay_status AS payStatus,
a.buyer_memo AS buyerMemo,
a.order_status_in_time AS orderStatusInTime,
a.order_status_last_valid_time AS orderStatusLastValidTime,
a.pay_time AS payTime,
a.stocking_in_time AS stockingInTime,
a.stocking_complete_time AS stockingCompleteTime,
a.reservation_stime AS reservationStime,
a.reservation_ftime AS reservationFtime,
a.buyer_confirm_time AS buyerConfirmTime,
a.create_time AS createTime,
a.edit_time AS editTime,
a.invoice_type AS invoiceType,
a.invoice_title AS invoiceTitle,
a.invoice_content AS invoiceContent,
a.pay_type AS payType,
a.price_total AS priceTotal,
a.price_privilege AS pricePrivilege,
a.price_offset AS priceOffset,
a.price_paid AS pricePaid,
a.price_refund AS priceRefund,
a.price_postage AS pricePostage,
a.version_num AS versionNum,
a.is_delete AS isDelete,
a.shop_id AS shopId,
a.trade_no AS tradeNo,
a.shop_name AS shopName,
a.delivery_ver_code AS deliveryVerCode,
a.status_in_reason AS statusInReason,
a.is_commented AS isCommented,
a.price_total_original AS priceTotalOriginal,
a.price_postage_original AS pricePostageOriginal,
a.come_from AS comeFrom,
a.logistics_remarks as logisticsRemarks,
a.buyer_city_id as buyerCityId,
a.goods_weight goodsWeight,
a.seller_source as sellerSource,
a.print_flag AS printFlag,
a.warrant_type as warrantType,
a.market_delivery AS marketDelivery
]]>
</sql>
<!-- orders 查询列来源表-->
<sql id="QUERY_FROM_TABLE"><![CDATA[FROM orders a]]></sql>
<!-- 全部条件(更多功能可以通过queryData扩展实现) -->
<sql id="QUERY_WHERE_CLAUSE">
where 1=1 AND a.is_delete = 0
<!--当id值为0时,此判断条件无法通过判断,不能生成a.id=0的查询条件,导致查询出错
<if test="id != null and id != ''"><![CDATA[AND a.id = #{id}]]></if>
-->
<choose>
<when test="id != null and id != ''">
<![CDATA[AND a.id = #{id}]]>
</when>
<otherwise>
<if test="queryData != null and queryData != ''">
<if test="queryData.orderIdList!=null and queryData.orderIdList.size()>0">
AND a.id in
<foreach collection="queryData.orderIdList" index="index" item="idList" open="(" separator="," close=")">
#{idList}
</foreach>
</if>
</if>
</otherwise>
</choose>
<if test="buyerId != null and buyerId != ''"><![CDATA[AND a.buyer_id = #{buyerId}]]></if>
<if test="sellerId != null and sellerId != ''"><![CDATA[AND a.seller_id = #{sellerId}]]></if>
<if test="buyerName != null and buyerName != ''"><![CDATA[AND a.buyer_name = #{buyerName}]]></if>
<if test="sellerName != null and sellerName != ''"><![CDATA[AND a.seller_name = #{sellerName}]]></if>
<if test="marketName != null and marketName != ''"><![CDATA[AND a.market_name = #{marketName}]]></if>
<if test="sellerSource != null and sellerSource != ''"><![CDATA[AND a.seller_source = #{sellerSource}]]></if>
<if test="printFlag != null "><![CDATA[AND a.print_flag = #{printFlag}]]></if>
<choose>
<when test="deliveryType != null and deliveryType != ''">
<![CDATA[AND a.delivery_type = #{deliveryType}]]>
</when>
<otherwise>
<if test="queryData != null and queryData != ''">
<if test="queryData.deliveryTypeList!=null and queryData.deliveryTypeList.size()>0">
AND a.delivery_type in
<foreach collection="queryData.deliveryTypeList" index="index" item="deliveryType" open="(" separator="," close=")">
#{deliveryType}
</foreach>
</if>
</if>
</otherwise>
</choose>
<if test="shipingAddress != null and shipingAddress != ''"><![CDATA[AND a.shiping_address like CONCAT('%',#{shipingAddress},'%')]]></if>
<if test="orderType != null and orderType != ''"><![CDATA[AND a.order_type = #{orderType}]]></if>
<if test="orderStatus != null and orderStatus != ''"><![CDATA[AND a.order_status = #{orderStatus}]]></if>
<if test="payStatus != null and payStatus != ''"><![CDATA[AND a.pay_status = #{payStatus}]]></if>
<if test="buyerMemo != null and buyerMemo != ''"><![CDATA[AND a.buyer_memo = #{buyerMemo}]]></if>
<if test="orderStatusInTime != null and orderStatusInTime != ''"><![CDATA[AND a.order_status_in_time = #{orderStatusInTime}]]></if>
<if test="orderStatusLastValidTime != null and orderStatusLastValidTime != ''"><![CDATA[AND a.order_status_last_valid_time = #{orderStatusLastValidTime}]]></if>
<if test="payTime != null and payTime != ''"><![CDATA[AND a.pay_time = #{payTime}]]></if>
<if test="stockingInTime != null and stockingInTime != ''"><![CDATA[AND a.stocking_in_time = #{stockingInTime}]]></if>
<if test="stockingCompleteTime != null and stockingCompleteTime != ''"><![CDATA[AND a.stocking_complete_time = #{stockingCompleteTime}]]></if>
<if test="reservationStime != null and reservationStime != '' and (reservationFtime == null or reservationFtime == '')">
<![CDATA[AND a.reservation_stime >= #{reservationStime}]]>
</if>
<if test="reservationFtime != null and reservationFtime != '' and (reservationStime == null or reservationStime == '')">
<![CDATA[AND a.reservation_ftime <= #{reservationFtime}]]>
</if>
<if test="reservationStime != null and reservationStime != '' and (reservationFtime != null and reservationFtime != '')">
<![CDATA[
AND (a.reservation_stime >= #{reservationStime} AND a.reservation_stime<=#{reservationFtime}
OR a.reservation_ftime >= #{reservationStime} AND a.reservation_ftime<=#{reservationFtime}
OR a.reservation_stime <=#{reservationStime} AND a.reservation_ftime>=#{reservationFtime})
]]>
</if>
<if test="marketDelivery != null and marketDelivery !=''"><![CDATA[ AND a.market_delivery = #{marketDelivery} ]]> </if>
<if test="buyerConfirmTime != null and buyerConfirmTime != ''"><![CDATA[AND a.buyer_confirm_time = #{buyerConfirmTime}]]></if>
<if test="createTime != null and createTime != ''"><![CDATA[AND a.create_time = #{createTime}]]></if>
<if test="versionNum != null and versionNum != ''"><![CDATA[AND a.version_num = #{versionNum}]]></if>
<if test="shopId != null and shopId != ''"><![CDATA[AND a.shop_id = #{shopId}]]></if>
<if test="shopName != null and shopName != ''"><![CDATA[AND a.shop_name like CONCAT(#{shopName},'%')]]></if>
<!-- 商品名称like搜索 -->
<if test="productsTitle != null and productsTitle != ''"><![CDATA[AND a.products_title like CONCAT('%',#{productsTitle},'%')]]></if>
<if test="tradeNo != null and tradeNo != ''"><![CDATA[AND a.trade_no = #{tradeNo}]]></if>
<!--当id值为0时,此判断条件无法通过判断,不能生成a.id=0的查询条件,导致查询出错
<if test="isCommented != null and isCommented != ''"><![CDATA[AND a.is_commented = #{isCommented}]]></if>
-->
<if test="isCommented != null"><![CDATA[AND a.is_commented = #{isCommented}]]></if>
<if test="printFlag != null and printFlag != ''"><![CDATA[AND a.print_flag = #{printFlag}]]></if>
<!-- 可以进行出厂的:1.未出厂,2.订单状态(待提货、待发货、交易完成),3.现场交易且(赊账付款或(线下付款且待付款))-->
<choose>
<when test="orderStatus != null and orderStatus != ''">
<![CDATA[AND a.order_status = #{orderStatus}]]>
</when>
<otherwise>
<if test="queryData != null and queryData != ''
and queryData.orderStateSet != null and queryData.orderStateSet.size>0">
<![CDATA[ and a.order_status in ]]>
<foreach item="item" index="index" collection="queryData.orderStateSet" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</otherwise>
</choose>
<if test="queryData != null and queryData != ''">
<if test="queryData.submitBeginTime != null and queryData.submitBeginTime != ''">
<![CDATA[AND a.create_time >= #{queryData.submitBeginTime} ]]>
</if>
<if test="queryData.submitEndTime != null and queryData.submitEndTime != ''">
<![CDATA[AND a.create_time <= #{queryData.submitEndTime} ]]>
</if>
<if test="queryData.payBeginTime != null and queryData.payBeginTime != ''">
<![CDATA[AND a.pay_time >= #{queryData.payBeginTime}]]>
</if>
<if test="queryData.payEndTime != null and queryData.payEndTime != ''">
<![CDATA[AND a.pay_time <= #{queryData.payEndTime}]]>
</if>
<if test="queryData.orderStatusLastValidTimeBegin != null and queryData.orderStatusLastValidTimeBegin != ''">
<![CDATA[AND a.order_status_last_valid_time >= #{queryData.orderStatusLastValidTimeBegin} ]]>
</if>
<if test="queryData.orderStatusLastValidTimeEnd != null and queryData.orderStatusLastValidTimeEnd != ''">
<![CDATA[AND a.order_status_last_valid_time <= #{queryData.orderStatusLastValidTimeEnd} ]]>
</if>
<!-- 根据城市id搜索 -->
<if test="queryData.cityIdList != null and queryData.cityIdList.size() > 0">
AND a.buyer_city_id in
<foreach collection="queryData.cityIdList" index="index" item="cityId" open="(" separator="," close=")">
#{cityId}
</foreach>
</if>
<!-- 根据卖家来源进行查询搜索 -->
<if test="queryData.sellerSourceList != null and queryData.sellerSourceList.size > 0">
AND a.seller_source in
<foreach collection="queryData.sellerSourceList" index="index" item="sellerSource" open="(" separator="," close=")">
#{sellerSource}
</foreach>
</if>
</if>
<choose>
<when test="payType != null and payType != ''">
<![CDATA[AND a.pay_type = #{payType}]]>
</when>
<otherwise>
<if test="queryData != null and queryData != ''">
<if test="queryData.payTypeList!=null and queryData.payTypeList.size()>0">
AND a.pay_type in
<foreach collection="queryData.payTypeList" index="index" item="payType" open="(" separator="," close=")">
#{payType}
</foreach>
</if>
</if>
</otherwise>
</choose>
<choose>
<when test="comeFrom != null and comeFrom != ''">
<![CDATA[AND a.come_from = #{comeFrom}]]>
</when>
<otherwise>
<if test="queryData != null and queryData != ''">
<if test="queryData.comeFromList!=null and queryData.comeFromList.size()>0">
AND a.come_from in
<foreach collection="queryData.comeFromList" index="index" item="comeFrom" open="(" separator="," close=")">
#{comeFrom}
</foreach>
</if>
</if>
</otherwise>
</choose>
</sql>
<!-- 智能排序与分页 -->
<sql id="QUERY_ORDER_LIMIT_CONDTION">
<choose>
<when test="orderField != null and orderField != ''">
<choose>
<when test="orderFieldType != null and orderFieldType != ''">
<![CDATA[ORDER BY a.${orderField} ${orderFieldType}]]>
</when>
<otherwise>
<![CDATA[ORDER BY a.${orderField} desc]]>
</otherwise>
</choose>
</when>
<otherwise>
<![CDATA[ORDER BY a.create_time desc,a.id desc]]>
</otherwise>
</choose>
<if test="startIndex != null and startIndex >= 0 and pageSize != null and pageSize > 0">
<![CDATA[LIMIT #{startIndex},#{pageSize}]]>
</if>
</sql>
<!-- 更新列字段,只要不为NULL则更新,除开主键列 -->
<sql id="UPDATE_COLUMN_SET">
<set>
<if test="buyerId != null"><![CDATA[a.buyer_id = #{buyerId},]]></if>
<if test="sellerId != null"><![CDATA[a.seller_id = #{sellerId},]]></if>
<if test="buyerName != null"><![CDATA[a.buyer_name = #{buyerName},]]></if>
<if test="sellerName != null"><![CDATA[a.seller_name = #{sellerName},]]></if>
<if test="marketName != null"><![CDATA[a.market_name = #{marketName},]]></if>
<if test="marketId != null"><![CDATA[a.market_id = #{marketId},]]></if>
<if test="deliveryType != null"><![CDATA[a.delivery_type = #{deliveryType},]]></if>
<if test="shipingAddress != null"><![CDATA[a.shiping_address = #{shipingAddress},]]></if>
<if test="orderType != null"><![CDATA[a.order_type = #{orderType},]]></if>
<if test="orderStatus != null"><![CDATA[a.order_status = #{orderStatus},]]></if>
<if test="payStatus != null"><![CDATA[a.pay_status = #{payStatus},]]></if>
<if test="buyerMemo != null"><![CDATA[a.buyer_memo = #{buyerMemo},]]></if>
<if test="orderStatusInTime != null"><![CDATA[a.order_status_in_time = #{orderStatusInTime},]]></if>
<if test="logisticsRemarks != null"><![CDATA[a.logistics_remarks = #{logisticsRemarks},]]></if>
<choose>
<when test="queryData != null and queryData.setOrderStatusLastValidTimeToNull=='true'">
<![CDATA[a.order_status_last_valid_time = #{orderStatusLastValidTime},]]>
</when>
<otherwise>
<if test="orderStatusLastValidTime !=null">
<![CDATA[a.order_status_last_valid_time = #{orderStatusLastValidTime},]]>
</if>
</otherwise>
</choose>
<choose>
<when test="queryData != null and queryData.setPayTimeToNull=='true'">
<![CDATA[a.pay_time = NULL ,]]>
</when>
<otherwise>
<if test="payTime != null"><![CDATA[a.pay_time = #{payTime},]]></if>
</otherwise>
</choose>
<if test="stockingInTime != null"><![CDATA[a.stocking_in_time = #{stockingInTime},]]></if>
<if test="stockingCompleteTime != null"><![CDATA[a.stocking_complete_time = #{stockingCompleteTime},]]></if>
<if test="reservationStime != null"><![CDATA[a.reservation_stime = #{reservationStime},]]></if>
<if test="reservationFtime != null"><![CDATA[a.reservation_ftime = #{reservationFtime},]]></if>
<if test="buyerConfirmTime != null"><![CDATA[a.buyer_confirm_time = #{buyerConfirmTime},]]></if>
<if test="payType != null"><![CDATA[a.pay_type = #{payType},]]></if>
<if test="priceTotal != null"><![CDATA[a.price_total = #{priceTotal},]]></if>
<if test="pricePrivilege != null"><![CDATA[a.price_privilege = #{pricePrivilege},]]></if>
<if test="priceOffset != null"><![CDATA[a.price_offset = #{priceOffset},]]></if>
<if test="pricePaid != null"><![CDATA[a.price_paid = #{pricePaid},]]></if>
<if test="priceRefund != null"><![CDATA[a.price_refund = #{priceRefund},]]></if>
<if test="pricePostage != null"><![CDATA[a.price_postage = #{pricePostage},]]></if>
<if test="isDelete != null"><![CDATA[a.is_delete = #{isDelete},]]></if>
<if test="shopId != null"><![CDATA[a.shop_id = #{shopId},]]></if>
<if test="shopName != null"><![CDATA[a.shop_name = #{shopName},]]></if>
<if test="deliveryVerCode != null"><![CDATA[a.delivery_ver_code = #{deliveryVerCode},]]></if>
<if test="tradeNo != null"><![CDATA[a.trade_no = #{tradeNo},]]></if>
<if test="productsTitle != null"><![CDATA[a.products_title = #{productsTitle},]]></if>
<if test="statusInReason != null"><![CDATA[a.status_in_reason = #{statusInReason},]]></if>
<if test="isCommented != null"><![CDATA[a.is_commented = #{isCommented},]]></if>
<if test="comeFrom != null"><![CDATA[a.come_from = #{comeFrom},]]></if>
<if test="printFlag != null"><![CDATA[a.print_flag = #{printFlag},]]></if>
<if test="marketDelivery != null"><![CDATA[ a.market_delivery = #{marketDelivery} ]]> </if>
<choose>
<when test="editTime != null">
<![CDATA[edit_time = #{editTime},]]>
</when>
<otherwise>
<![CDATA[a.edit_time = NOW(),]]>
</otherwise>
</choose>
<![CDATA[a.version_num = a.version_num + 1,]]>
</set>
</sql>
<!-- 插入orders记录 -->
<insert id="insertEntry" parameterType="orders" >
<![CDATA[
INSERT INTO orders (id,parent_id,buyer_id,seller_id,buyer_name,seller_name,market_name,market_id,delivery_type,shiping_address,order_type,order_status,pay_status,buyer_memo,order_status_in_time,order_status_last_valid_time,pay_time,stocking_in_time,stocking_complete_time,reservation_stime,reservation_ftime,buyer_confirm_time,create_time,edit_time,pay_type,price_total,price_privilege,price_offset,price_paid,price_postage,version_num,shop_id,shop_name,delivery_ver_code,trade_no,products_title,status_in_reason,is_commented,price_total_original,price_postage_original,come_from,logistics_remarks,buyer_city_id,seller_source,goods_weight,warrant_type,market_delivery)
VALUES (#{id},#{parentId},#{buyerId},#{sellerId},#{buyerName},#{sellerName},#{marketName},#{marketId},#{deliveryType},#{shipingAddress},#{orderType},#{orderStatus},#{payStatus},#{buyerMemo},#{orderStatusInTime},#{orderStatusLastValidTime},#{payTime},#{stockingInTime},#{stockingCompleteTime},#{reservationStime},#{reservationFtime},#{buyerConfirmTime},#{createTime},#{editTime},#{payType},#{priceTotal},#{pricePrivilege},#{priceOffset},#{pricePaid},#{pricePostage},#{versionNum},#{shopId},#{shopName},#{deliveryVerCode},#{tradeNo},#{productsTitle},#{statusInReason},#{isCommented},#{priceTotalOriginal},#{pricePostageOriginal},#{comeFrom},#{logisticsRemarks},#{buyerCityId},#{sellerSource},#{goodsWeight},#{warrantType},#{marketDelivery})
]]>
</insert>
<!-- 返回插入的编号,在事务开启状态下有效 -->
<select id="lastSequence" resultType="int"><![CDATA[SELECT LAST_INSERT_ID() AS id]]></select>
<!-- 删除记录,主键IN(array) -->
<delete id="deleteByArrayKey" parameterType="java.lang.reflect.Array" >
<![CDATA[DELETE FROM orders a WHERE a.id IN]]>
<foreach collection="array" item="id" open="(" separator="," close=")">
<![CDATA[#{id}]]>
</foreach>
</delete>
<!-- 删除,通过条件 -->
<update id="deleteByCondtion" parameterType="orders" >
<![CDATA[DELETE FROM orders a]]>
<include refid="QUERY_WHERE_CLAUSE"/>
</update>
<!-- 修改记录通过主键 -->
<update id="updateByKey" parameterType="orders" >
<![CDATA[UPDATE orders a]]>
<include refid="UPDATE_COLUMN_SET"/>
<![CDATA[WHERE a.id = #{id} and a.version_num = #{versionNum}]]>
</update>
<!-- 根据符合情况的订单前置状态,更新订单的状态 -->
<update id="updateOrderStatusById" parameterType="java.util.HashMap">
update orders a set a.order_status = #{nextStatus},a.edit_time = #{editTime}
where a.id = #{id} AND a.version_num = #{versionNum} AND a.order_status in
<foreach item="item" index="index" collection="preStatusIds" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<!-- 查询,通过主键IN(array) -->
<select id="selectEntryArray" parameterType="java.lang.reflect.Array" resultType="orders">
<![CDATA[SELECT]]>
<include refid="QUERY_COLUMN_LIST"/>
<include refid="QUERY_FROM_TABLE"/>
<![CDATA[WHERE a.id IN]]>
<foreach collection="array" item="id" open="(" separator="," close=")">
<![CDATA[#{id}]]>
</foreach>
</select>
<!-- 查询,通过条件 -->
<select id="selectEntryList" parameterType="orders" resultType="orders">
<![CDATA[SELECT]]>
<include refid="QUERY_COLUMN_LIST"/>
<include refid="QUERY_FROM_TABLE"/>
<include refid="QUERY_WHERE_CLAUSE"/>
<include refid="QUERY_ORDER_LIMIT_CONDTION"/>
</select>
<!-- 总数查询,通过条件 -->
<select id="selectEntryListCount" parameterType="orders" resultType="int">
<![CDATA[SELECT COUNT(a.id) AS dataCount]]>
<include refid="QUERY_FROM_TABLE"/>
<include refid="QUERY_WHERE_CLAUSE"/>
</select>
<!--统计第三方订单相关数量-->
<sql id="THIRD_QUERY_SUM_COLUMN_LIST">
<![CDATA[ sum(case when a.order_status=#{queryData.dividedOrderStatus} then 1 else 0 end) as dividedOrderCount,
sum(case when a.order_status=#{queryData.takeWaitOrderStatus} then 1 else 0 end) as takeWaitCount,
sum(case when a.order_status=#{queryData.receiveWaitOrderStatus} then 1 else 0 end) as receiveWaitCount,
sum(case when a.order_status=#{queryData.deliveredOrderStatus} then 1 else 0 end) as deliveredOrderCount,
sum(case when a.order_status=#{queryData.refundAppliedOrderStatus} then 1 else 0 end) as refundAppliedCount,
sum(case when a.order_status=#{queryData.refundCompleteOrderStatus} then 1 else 0 end) as refundCompleteCount]]>
</sql>
<!--统计自营代销订单相关数量-->
<sql id="AGENT_QUERY_SUM_COLUMN_LIST">
<![CDATA[ sum(case when a.order_status=#{queryData.divideWaitStatus} then 1 else 0 end) as divideWaitCount,
sum(case when a.order_status=#{queryData.dividedStatus} then 1 else 0 end) as dividedCount,
sum(case when a.order_status=#{queryData.completeStockUpStatus} then 1 else 0 end) as completeStockUpOrderCount,
sum(case when a.order_status=#{queryData.deliveredOutStatus} then 1 else 0 end) as deliveredOutCount,
sum(case when a.order_status=#{queryData.completeStockUpStatus} AND a.reservation_ftime<NOW() then 1 else 0 end) as deliveredOutAlertCount,
sum(case when a.order_status=#{queryData.refundAppliedStatus} then 1 else 0 end) as refundAppliedCount,
sum(case when a.order_status=#{queryData.paymentWaitStatus} then 1 else 0 end) as paymentWaitCount
]]>
</sql>
<select id="selectThirdOrdersSum" parameterType="orders" resultType="ordersSumVO">
<![CDATA[SELECT]]>
<include refid="THIRD_QUERY_SUM_COLUMN_LIST"/>
<include refid="QUERY_FROM_TABLE"/>
<include refid="QUERY_WHERE_CLAUSE"/>
</select>
<select id="selectSelfOrdersSum" parameterType="orders" resultType="ordersSumVO">
<![CDATA[SELECT]]>
<include refid="AGENT_QUERY_SUM_COLUMN_LIST"/>
<include refid="QUERY_FROM_TABLE"/>
<include refid="QUERY_WHERE_CLAUSE"/>
</select>
<select id="getVersionNum" parameterType="long" resultType="long">
<![CDATA[SELECT a.version_num ]]>
<include refid="QUERY_FROM_TABLE"/>
<![CDATA[ WHERE a.id = #{orderId}]]>
</select>
<!-- 统计各状态订单量 -->
<select id="statisticsOrderAmountByStatus" parameterType="orders" resultType="keyValueVO">
<![CDATA[SELECT a.order_status AS code, count(1) AS value from orders a ]]>
<include refid="QUERY_WHERE_CLAUSE"/>
<![CDATA[group by a.order_status]]>
</select>
<!-- 获取订单交易号 -->
<select id="getOrderTradeNo" parameterType="long" resultType="keyValueVO">
<![CDATA[SELECT id as code,trade_no AS value FROM orders]]>
<![CDATA[WHERE id IN]]>
<foreach collection="array" item="id" open="(" separator="," close=")">
<![CDATA[#{id}]]>
</foreach>
</select>
<!-- 获取订单所有商品名称串 -->
<select id="getOrderProductTitle" parameterType="long" resultType="string">
<![CDATA[SELECT products_title AS productsTitle FROM orders WHERE id =#{id}]]>
</select>
<!--获取订单, 只查询指定字段的值-->
<!--
statementType 分为:STATEMENT(非预编译,使用$符号取变量),PREPARED(预编译,使用#变量取变量,且$同时可用)或 CALLABLE(调用存储过程)
-->
<select id="getOrderBySpecFields" parameterType="orders" resultType="orders" statementType="STATEMENT">
<![CDATA[select]]>
<if test="queryData != null and queryData.fieldsMapEntryList != null and queryData.fieldsMapEntryList.size()>0">
<foreach collection="queryData.fieldsMapEntryList" index="index" item="item" separator=",">
<if test="item.dbFieldName!=null and item.dbFieldName!='' and item.domainFieldName!=null and item.domainFieldName!=''">
${item.dbFieldName} AS ${item.domainFieldName}
</if>
</foreach>
</if>
<![CDATA[from orders where id=${id}]]>
<!--因为非预编译原因,为了提高查询效率, 暂时只支持通过id查询 ,后期需要通过其他条件来查询,则使用QUERY_WHERE_CLAUSE_STATEMENT即可-->
<!--<include refid="QUERY_WHERE_CLAUSE_STATEMENT"/>-->
</select>
<!-- 根据店铺id查询,未完结订单数量-->
<select id="getValidOrderNumByShop" parameterType="long" resultType="int">
<![CDATA[
SELECT count(id) FROM orders
WHERE shop_id =#{shopId}
AND order_status IN(10,15,20,30,40,45,80,85)
]]>
</select>
</mapper>