BuyerOrderMapper.xml
13 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
<?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.yoho.order.dal.BuyerOrderMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.BuyerOrder">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="seller_uid" property="sellerUid" jdbcType="INTEGER" />
<result column="client_type" property="clientType" jdbcType="TINYINT" />
<result column="payment" property="payment" jdbcType="TINYINT" />
<result column="payment_type" property="paymentType" jdbcType="TINYINT" />
<result column="is_cancel" property="isCancel" jdbcType="TINYINT" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<result column="ship_fee" property="shipFee" jdbcType="DECIMAL" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="channel_no" property="channelNo" jdbcType="VARCHAR" />
<result column="attributes" property="attributes" jdbcType="INTEGER" />
<result column="platform_delivery_status" jdbcType="INTEGER" property="platformDeliveryStatus" />
<result column="seller_delivery_status" jdbcType="INTEGER" property="sellerDeliveryStatus" />
<result column="seller_delivery_deal" jdbcType="INTEGER" property="sellerDeliveryDeal" />
<result column="seller_delivery_deal_again" jdbcType="INTEGER" property="sellerDeliveryDealAgain" />
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel,
amount, ship_fee, status, create_time, update_time, channel_no, attributes ,platform_delivery_status,
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again
</sql>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from buyer_order where order_code = #{orderCode}
</select>
<select id="selectById" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from buyer_order where id = #{id}
</select>
<select id="selectCountByStatus" resultType="java.lang.Integer">
select count(1)
from buyer_order where 1=1
<if test="list != null and list.size()>0">
and status in
<foreach collection="list" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
</select>
<select id="selectCountByStatusForAbnormalSellerDelivery" resultType="java.lang.Integer">
select count(1)
from buyer_order where 1=1
and seller_delivery_status = 0
and update_time < #{currentSecondMinus24Hours}
<if test="maxCurrentSecondMinusHours != null">
and update_time >= #{maxCurrentSecondMinusHours}
</if>
<if test="list != null and list.size()>0">
and status in
<foreach collection="list" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
</select>
<select id="selectCountByStatusAndDepotNo" resultType="java.lang.Integer">
select count(1)
from buyer_order a
<if test="depotNo != null">
LEFT JOIN buyer_order_goods b
ON( b.order_code=a.order_code)
LEFT JOIN seller_order_goods c
ON( c.id=b.skup)
</if>
where 1=1
<if test="list != null and list.size()>0">
and a.status in
<foreach collection="list" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
<if test="depotNo != null">
and c.depot_no=#{depotNo}
</if>
<!-- 平台物流是否存在 -->
<if test="platformExpressInfoFlag != null and platformExpressInfoFlag != '' ">
<!--
and
<if test="platformExpressInfoFlag == 'haveNotExpress'">
NOT
</if>
exists (
select tmp.id from express_record tmp where a.order_code = tmp.order_code and tmp.express_type in (2,3,4)
)
-->
<if test="platformExpressInfoFlag == 'haveNotExpress'">
and a.platform_delivery_status = 0
</if>
<if test="platformExpressInfoFlag == 'haveExpress'">
and a.platform_delivery_status in (1,2)
</if>
</if>
</select>
<sql id="Query_Order_Sql" >
<if test="buyerOrderReq.statusList != null and buyerOrderReq.statusList.size() >0">
and a.status in
<foreach collection="buyerOrderReq.statusList" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
<if test="buyerOrderReq.orderCode != null and buyerOrderReq.orderCode != '' ">
and a.order_code = #{buyerOrderReq.orderCode}
</if>
<if test="buyerOrderReq.uid != null and buyerOrderReq.uid != 0 ">
and a.uid = #{buyerOrderReq.uid}
</if>
<if test="buyerOrderReq.sellerUid != null and buyerOrderReq.sellerUid != 0 ">
and a.seller_uid = #{buyerOrderReq.sellerUid}
</if>
<if test="buyerOrderReq.clientType != null and buyerOrderReq.clientType != '' ">
and a.client_type = #{buyerOrderReq.clientType}
</if>
<if test="buyerOrderReq.sellerDeliveryStatus != null ">
and a.seller_delivery_status = #{buyerOrderReq.sellerDeliveryStatus}
</if>
<if test="buyerOrderReq.sellerDeliveryDeal != null ">
and a.seller_delivery_deal = #{buyerOrderReq.sellerDeliveryDeal}
</if>
<if test="buyerOrderReq.sellerDeliveryDealAgain != null ">
and a.seller_delivery_deal_again = #{buyerOrderReq.sellerDeliveryDealAgain}
</if>
<if test="buyerOrderReq.currentSecondMinus24Hours != null ">
and a.update_time < #{buyerOrderReq.currentSecondMinus24Hours}
</if>
<if test="buyerOrderReq.maxCurrentSecondMinusHours != null">
and update_time >= #{buyerOrderReq.maxCurrentSecondMinusHours}
</if>
<if test="buyerOrderReq.status != null ">
and a.status = #{buyerOrderReq.status}
</if>
<if test="buyerOrderReq.buyerStartTime != null ">
and a.create_time > #{buyerOrderReq.buyerStartTime}
</if>
<if test="buyerOrderReq.buyerEndTime != null ">
and a.create_time < #{buyerOrderReq.buyerEndTime}
</if>
<if test="buyerOrderReq.attributesList != null and buyerOrderReq.attributesList.size() >0">
and a.attributes in
<foreach collection="buyerOrderReq.attributesList" item="attributes" open="(" close=")" separator=",">
#{attributes}
</foreach>
</if>
<if test="buyerOrderReq.attributesNotList != null and buyerOrderReq.attributesNotList.size() >0">
and a.attributes not in
<foreach collection="buyerOrderReq.attributesNotList" item="attributes" open="(" close=")" separator=",">
#{attributes}
</foreach>
</if>
<if test="buyerOrderReq.productId != null and buyerOrderReq.productId != 0 ">
and c.product_id = #{buyerOrderReq.productId}
</if>
<if test="buyerOrderReq.skup != null and buyerOrderReq.skup != 0 ">
and c.id = #{buyerOrderReq.skup}
</if>
<if test="buyerOrderReq.storageId != null and buyerOrderReq.storageId != 0 ">
and c.storage_id = #{buyerOrderReq.storageId}
</if>
<if test="buyerOrderReq.depotNo != null">
and c.depot_no = #{buyerOrderReq.depotNo}
</if>
<if test="buyerOrderReq.mobile != null and buyerOrderReq.mobile != '' ">
and (a.uid = #{buyerOrderReq.sellerUid} or a.seller_uid = #{buyerOrderReq.sellerUid})
</if>
<if test="buyerOrderReq.buyerMobile != null and buyerOrderReq.buyerMobile != '' ">
and a.uid = #{buyerOrderReq.uid}
</if>
<if test="buyerOrderReq.sellerMobile != null and buyerOrderReq.sellerMobile != '' ">
and a.seller_uid = #{buyerOrderReq.sellerUid}
</if>
<if test="buyerOrderReq.platformWaybillCode != null and buyerOrderReq.platformWaybillCode != '' ">
and d2.waybill_code = #{buyerOrderReq.platformWaybillCode} and d2.express_type in (2,3,4)
</if>
<if test="buyerOrderReq.sellerWaybillCode != null and buyerOrderReq.sellerWaybillCode != '' ">
and d.waybill_code = #{buyerOrderReq.sellerWaybillCode} and d.express_type=1
</if>
<!-- 平台物流是否存在 -->
<if test="buyerOrderReq.platformExpressInfoFlag != null and buyerOrderReq.platformExpressInfoFlag != '' ">
<!--and
<if test="buyerOrderReq.platformExpressInfoFlag == 'haveNotExpress'">
NOT
</if>
exists (
select tmp.id from express_record tmp where a.order_code = tmp.order_code and tmp.express_type in (2,3,4)
)-->
<if test="buyerOrderReq.platformExpressInfoFlag == 'haveNotExpress'">
and a.platform_delivery_status = 0
</if>
<if test="buyerOrderReq.platformExpressInfoFlag == 'haveExpress'">
and a.platform_delivery_status in (1,2)
</if>
</if>
</sql>
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
select count(a.id)
from buyer_order a
<if test="(buyerOrderReq.depotNo != null) or (buyerOrderReq.productId != null) or (buyerOrderReq.skup != null) or (buyerOrderReq.storageId != null)">
LEFT JOIN buyer_order_goods b
ON( b.order_code=a.order_code)
LEFT JOIN seller_order_goods c
ON( c.id=b.skup)
</if>
<if test="buyerOrderReq.sellerWaybillCode != null and buyerOrderReq.sellerWaybillCode != ''">
LEFT JOIN express_record d
ON(a.order_code=d.order_code)
</if>
<if test="buyerOrderReq.platformWaybillCode != null and buyerOrderReq.platformWaybillCode != ''">
LEFT JOIN express_record d2
ON(a.order_code=d2.order_code)
</if>
where 1=1
<include refid="Query_Order_Sql" />
</select>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.BuyerOrderReq">
select a.*
from buyer_order a
<if test="(buyerOrderReq.depotNo != null) or (buyerOrderReq.productId != null) or (buyerOrderReq.skup != null) or (buyerOrderReq.storageId != null)">
LEFT JOIN buyer_order_goods b
ON( b.order_code=a.order_code)
LEFT JOIN seller_order_goods c
ON( c.id=b.skup)
</if>
<if test="buyerOrderReq.sellerWaybillCode != null and buyerOrderReq.sellerWaybillCode != ''">
LEFT JOIN express_record d
ON(a.order_code=d.order_code)
</if>
<if test="buyerOrderReq.platformWaybillCode != null and buyerOrderReq.platformWaybillCode != ''">
LEFT JOIN express_record d2
ON(a.order_code=d2.order_code)
</if>
where 1=1
<include refid="Query_Order_Sql" />
<choose>
<when test="buyerOrderReq.sortRule!=null and buyerOrderReq.sortRule=='asc'">
order by a.create_time asc
</when>
<otherwise>
order by a.create_time desc
</otherwise>
</choose>
<if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
limit #{buyerOrderReq.start},#{buyerOrderReq.size}
</if>
</select>
<update id="updateStatusById">
update buyer_order set status=#{status} where id=#{id}
</update>
<select id="selectByOrderCodeAndStatus" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from buyer_order
where order_code=#{orderCode} and status=#{status}
</select>
<update id="updateSellerDeliveryDealByOrderCode">
update buyer_order set
seller_delivery_deal = 1
where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
</update>
<update id="updateSellerDeliveryDealAgainByOrderCode">
update buyer_order set
seller_delivery_deal_again = 1
where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
</update>
<select id="selectCountByUidStatus" resultType="java.lang.Integer">
select count(1)
from buyer_order where seller_uid = #{sellerUid, jdbcType=INTEGER}
<if test="statusList != null and statusList.size() > 0">
and status in
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
</select>
</mapper>