OrderMapper.xml
10.5 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
<?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.b2c.orders.dao.impl.OrderDaoBean">
<resultMap id="OrderRM" type="com.b2c.orders.domain.Order">
<id property="id" column="id" />
<result property="shopBuyerId" column="shop_buyer_id" />
<result property="marketId" column="market_id" />
<result property="deliveryType" column="delivery_type" />
<result property="orderStatus" column="order_status" />
<result property="payStatus" column="pay_status" />
<result property="buyerMemo" column="buyer_memo" />
<result property="payTime" column="pay_time" />
<result property="deliveryTime" column="delivery_time" />
<result property="deliveryAddress" column="delivery_address" />
<result property="receiverName" column="receiver_name" />
<result property="receiverPhoneNumber" column="receiver_phone_number" />
<result property="buyerConfirmTime" column="buyer_confirm_time" />
<result property="sellerConfirmTime" column="seller_confirm_time" />
<result property="reservationTime" column="reservation_time" />
<result property="submitTime" column="submit_time" />
<result property="payType" column="pay_type" />
<result property="totalPrice" column="total_price" />
<result property="realTotalPrice" column="real_total_price" />
<result property="postage" column="postage" />
<result property="versionNum" column="version_num" />
<result property="delete" column="delete_flag" />
<result property="statusInReason" column="status_in_reason" />
<result property="buyerId" column="buyer_id" />
<result property="buyerName" column="buyer_name" />
<result property="buyerPhoneNumber" column="buyer_phone_number" />
<result property="sellerId" column="seller_id" />
<result property="sellerName" column="seller_name" />
<result property="sellerPhoneNumber" column="seller_phone_number" />
<result property="shopId" column="shop_id" />
<result property="shopName" column="shop_name" />
<result property="shopPhoneNumber" column="shop_phone_number" />
<result property="shopAddress" column="shop_address" />
<result property="tradeName" column="trade_name" />
<collection property="orderItems" column="id"
select="com.b2c.orders.dao.impl.OrderItemDaoBean.findByOrderId" />
</resultMap>
<sql id="selectColumn">
t1.id
,t1.buyer_id
,t1.buyer_name
,t1.seller_id
,t1.seller_name
,t1.seller_phone_number
,t1.shop_buyer_id
,t1.market_id
,t1.delivery_type
,t1.order_status
,t1.pay_status
,t1.buyer_memo
,t1.pay_time
,t1.delivery_time
,t1.delivery_address
,t1.receiver_phone_number
,t1.reservation_time
,t1.buyer_confirm_time
,t1.seller_confirm_time
,t1.submit_time
,t1.pay_type
,t1.total_price
,t1.real_total_price
,t1.postage
,t1.version_num
,t1.status_in_reason
,t1.shop_id
,t1.shop_name
,t1.shop_phone_number
,t1.shop_address
,t1.trade_name
</sql>
<sql id="selectCondition">
<if test="param != null">
<if test="param.id != null and param.id != ''">
and t1.id = #{param.id}
</if>
<if test="param.buyerId != null and param.buyerId != ''">
and t1.buyer_id = #{param.buyerId}
</if>
<if test="param.shopBuyerId != null and param.shopBuyerId != ''">
and t1.shop_buyer_id = #{param.shopBuyerId}
</if>
<if test="param.buyerName != null and param.buyerName != ''">
and t1.buyer_name = #{param.buyerName}
</if>
<if test="param.sellerId != null and param.sellerId != ''">
and t1.seller_id = #{param.sellerId}
</if>
<if test="param.sellerName != null and param.sellerName != ''">
and t1.seller_name = #{param.sellerName}
</if>
<if test="param.marketId != null and param.marketId != ''">
and t1.market_id = #{param.marketId}
</if>
<if test="param.deliveryType != null and param.deliveryType != ''">
and t1.delivery_type = #{param.deliveryType}
</if>
<if test="param.orderStatus != null and param.orderStatus != ''">
and t1.order_status = #{param.orderStatus}
</if>
<if test="param.payStatus != null and param.payStatus != ''">
and t1.pay_status = #{param.payStatus}
</if>
<if test="param.buyerMemo != null and param.buyerMemo != ''">
and t1.buyer_memo = #{param.buyerMemo}
</if>
<if
test="param.receiverPhoneNumber != null and param.receiverPhoneNumber != ''">
and t1.receiver_phone_number = #{param.receiverPhoneNumber}
</if>
<if test="param.payBeginTime != null and param.payBeginTime != ''">
<![CDATA[and t1.pay_time >= #{param.payBeginTime}]]>
</if>
<if test="param.payEndTime != null and param.payEndTime != ''">
<![CDATA[and t1.pay_time <= #{param.payEndTime}]]>
</if>
<if
test="param.deliveryBeginTime != null and param.deliveryBeginTime != ''">
<![CDATA[and t1.delivery_time >= #{param.deliveryBeginTime}]]>
</if>
<if test="param.deliveryEndTime != null and param.deliveryEndTime != ''">
<![CDATA[and t1.delivery_time <= #{param.deliveryEndTime}]]>
</if>
<if
test="param.buyerConfirmEndTime != null and param.buyerConfirmBeginTime != ''">
<![CDATA[and t1.buyer_confirm_time >= #{param.buyerConfirmBeginTime}]]>
</if>
<if
test="param.buyerConfirmEndTime != null and param.buyerConfirmEndTime != ''">
<![CDATA[and t1.buyer_confirm_time <= #{param.buyerConfirmEndTime}]]>
</if>
<if
test="param.sellerConfirmBeginTime != null and param.sellerConfirmBeginTime != ''">
<![CDATA[and t1.seller_confirm_time >= #{param.sellerConfirmBeginTime}]]>
</if>
<if
test="param.sellerConfirmEndTime != null and param.sellerConfirmEndTime != ''">
<![CDATA[and t1.seller_confirm_time <= #{param.sellerConfirmEndTime}]]>
</if>
<if
test="param.reservationBeginTime != null and param.reservationBeginTime != ''">
<![CDATA[and t1.reservation_time >= #{param.reservationBeginTime}]]>
</if>
<if
test="param.reservationEndTime != null and param.reservationEndTime != ''">
<![CDATA[and t1.reservation_time <= #{param.reservationEndTime}]]>
</if>
<if test="param.submitBeginTime != null and param.submitBeginTime != ''">
<![CDATA[and t1.submit_time >= #{param.submitBeginTime}]]>
</if>
<if test="param.submitEndTime != null and param.submitEndTime != ''">
<![CDATA[and t1.submit_time <= #{param.submitEndTime}]]>
</if>
<if test="param.buyerMemo != null and param.buyerMemo != ''">
and t1.pay_type = #{param.payType}
</if>
<if test="param.buyerMemo != null and param.buyerMemo != ''">
and t1.total_price = #{param.totalPrice}
</if>
<if test="param.productName != null and param.productName != ''">
<![CDATA[and t1.trade_name like CONCAT('%',#{param.productName},'%')]]>
</if>
<if test="param.buyerDelete != null and param.buyerDelete == false">
and t1.buyer_delete = 0
</if>
<if test="param.sellerDelete != null and param.sellerDelete == false">
and t1.seller_delete = 0
</if>
</if>
</sql>
<sql id="joinOrderItem">
<if test="param.productName != null and param.productName != ''">
RIGHT JOIN t_order_item t2 ON t2.order_id = t1.id
</if>
</sql>
<select id="getById" parameterType="Long" resultMap="OrderRM">
SELECT
<include refid="selectColumn" />
FROM t_order t1
WHERE delete_flag = 0 AND id = #{id}
</select>
<insert id="save" parameterType="com.b2c.orders.domain.Order">
<![CDATA[
INSERT INTO t_order(
id,
buyer_id,
buyer_name,
buyer_phone_number,
seller_id,
seller_name,
seller_phone_number,
shop_id,
shop_name,
shop_address,
shop_phone_number,
shop_buyer_id,
market_id,
delivery_type,
order_status,
pay_status,
buyer_memo,
delivery_time,
delivery_address,
receiver_name,
receiver_phone_number,
pay_type,
total_price,
trade_name
) VALUES(
#{id},
#{buyerId},
#{buyerName},
#{buyerPhoneNumber},
#{sellerId},
#{sellerName},
#{sellerPhoneNumber},
#{shopId},
#{shopName},
#{shopAddress},
#{shopPhoneNumber},
#{shopBuyerId},
#{marketId},
#{deliveryType},
#{orderStatus},
#{payStatus},
#{buyerMemo},
#{deliveryTime},
#{deliveryAddress},
#{receiverName},
#{receiverPhoneNumber},
#{payType},
#{totalPrice},
#{tradeName}
)
]]>
</insert>
<update id="update" parameterType="com.b2c.orders.domain.Order">
<![CDATA[
UPDATE t_order set
order_status=#{orderStatus},
pay_status=#{payStatus},
pay_type=#{payType},
buyer_memo=#{buyerMemo},
pay_time=#{payTime},
delivery_time=#{deliveryTime},
buyer_confirm_time=#{buyerConfirmTime},
seller_confirm_time=#{sellerConfirmTime},
real_total_price=#{realTotalPrice},
postage=#{postage},
status_in_reason=#{statusInReason},
version_num=version_num + 1
where 1=1
and version_num=#{versionNum} and id = #{id}
]]>
</update>
<select id="countByCondition" parameterType="Query" resultType="Integer">
SELECT count(1) FROM t_order t1
<include refid="joinOrderItem" />
where 1=1
<include refid="selectCondition" />
</select>
<select id="listByCondition" parameterType="Query" resultMap="OrderRM">
SELECT
<include refid="selectColumn" />
FROM t_order t1
<include refid="joinOrderItem" />
where 1=1
<include refid="selectCondition" />
order by t1.id desc
<![CDATA[
limit #{startRow},#{pageSize}
]]>
</select>
<update id="buyerRemove" parameterType="Long">
UPDATE t_order SET
buyer_delete = 1 WHERE id = #{orderId}
</update>
<update id="sellerRemove" parameterType="Long">
UPDATE t_order SET
seller_delete = 1 WHERE id = #{orderId}
</update>
<update id="deleteById" parameterType="Long">
<![CDATA[
update t_order set delete_flag = 1,version_num=version_num + 1
where 1 = 1
and id = #{id} and version_num=#{versionNum}
]]>
</update>
</mapper>