IMRefundOrderMapper.xml
17.7 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
<?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.sibu.orderHelper.integral.dao.IMRefundOrderDao">
<select id="sumAlreadyRefundQuantityByOrderIdAndOrderItemId" resultType="java.lang.Integer">
select ifnull(sum(quantity),0) from im_refund_order_item where order_id = #{orderId} and order1_id = #{order1Id} and
refund_id in (
select refund_id from im_order_refund where order_id = #{orderId} and refund_status = 7
)
</select>
<select id="countRefundingOrderByOrderId" resultType="java.lang.Integer">
select count(*) from im_order_refund where
order_id = #{orderId} and refund_status != 7 and refund_status != 100 and refund_status != 101
</select>
<resultMap id="BaseResultMap" type="com.sibu.orderHelper.integral.model.IMOrderRefundBean">
<id column="refund_id" jdbcType="VARCHAR" property="refundId"/>
<result column="refund_code" jdbcType="VARCHAR" property="refundCode"/>
<result column="order_id" jdbcType="VARCHAR" property="orderId"/>
<result column="order_code" jdbcType="VARCHAR" property="orderCode"/>
<result column="order_from" jdbcType="TINYINT" property="orderFrom"/>
<result column="member_id" jdbcType="VARCHAR" property="memberId"/>
<result column="refund_type" jdbcType="INTEGER" property="refundType"/>
<result column="refund_goods_status" jdbcType="INTEGER" property="refundGoodsStatus"/>
<result column="refund_reason_id" jdbcType="INTEGER" property="refundReasonId"/>
<result column="refund_reason" jdbcType="VARCHAR" property="refundReason"/>
<result column="refund_money" jdbcType="DECIMAL" property="refundMoney"/>
<result column="order_money" jdbcType="DECIMAL" property="orderMoney"/>
<result column="refund_remark" jdbcType="VARCHAR" property="refundRemark"/>
<result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
<result column="refund_status_last_update_dt" jdbcType="TIMESTAMP" property="refundStatusLastUpdateDt"/>
<result column="apply_date" jdbcType="TIMESTAMP" property="applyDate"/>
<result column="refund_money_success_flag" jdbcType="BIT" property="refundMoneySuccessFlag"/>
<result column="refund_date" jdbcType="TIMESTAMP" property="refundDate"/>
<result column="buyer_username" jdbcType="VARCHAR" property="buyerUsername"/>
<result column="buyer_phone" jdbcType="VARCHAR" property="buyerPhone"/>
<result column="refund_seller_phone" jdbcType="VARCHAR" property="refundSellerPhone"/>
<result column="refund_seller_address" jdbcType="VARCHAR" property="refundSellerAddress"/>
<result column="refund_seller_name" jdbcType="VARCHAR" property="refundSellerName"/>
<result column="finish_date" jdbcType="TIMESTAMP" property="finishDate"/>
<result column="refund_integral" jdbcType="BIGINT" property="refundIntegral"/>
<result column="refund_goods_deliver_id" jdbcType="TINYINT" property="refundGoodsDeliverId"/>
<result column="refund_goods_deliver_name" jdbcType="VARCHAR" property="refundGoodsDeliverName"/>
<result column="refund_goods_waybill" jdbcType="VARCHAR" property="refundGoodsWaybill"/>
<result column="refund_goods_remark" jdbcType="VARCHAR" property="refundGoodsRemark"/>
<result column="refund_tips" jdbcType="VARCHAR" property="refundTips"/>
<result column="receive_goods_flag" jdbcType="BIT" property="receiveGoodsFlag"/>
<result column="receive_goods_dt" jdbcType="TIMESTAMP" property="receiveGoodsDt"/>
<result column="refund_freight" property="refundFreight"/>
<result column="refund_to_account_type" property="refundToAccountType"/>
<result column="refund_alipay_account" property="refundAlipayAccount"/>
<result column="refund_alipay_account_real_name" property="refundAlipayAccountRealName"/>
<result column="refund_bank_account" property="refundBankAccount"/>
<result column="refund_bank_account_real_name" property="refundBankAccountRealName"/>
<result column="refund_bank_branch_full_name" property="refundBankBranchFullName"/>
<result column="change_goods_waybill" property="changeGoodsWaybill"/>
<result column="change_goods_deliver_name" property="changeGoodsDeliverName"/>
<result column="change_goods_finish_flag" property="changeGoodsFinishFlag"/>
</resultMap>
<sql id="Base_Column_List">
refund_id,
refund_code,
order_id,
order_code,
order_from,
member_id,
refund_type,
refund_goods_status,
refund_reason_id,
refund_reason,
refund_money,
order_money,
refund_remark,
refund_status,
refund_status_last_update_dt,
apply_date,
refund_money_success_flag,
refund_date,
buyer_username,
buyer_phone,
refund_seller_phone,
refund_seller_address,
refund_seller_name,
finish_date,
refund_integral,
refund_goods_deliver_id,
refund_goods_deliver_name,
refund_goods_waybill,
refund_goods_remark,
refund_tips,
receive_goods_flag,
receive_goods_dt,
deduction_product_vb,
deduction_product_vb_refund_status,
deduction_product_vb_refund_dt,
profit_refund_status,
profit_refund_dt,
refund_freight,
refund_to_account_type,
refund_alipay_account,
refund_alipay_account_real_name,
refund_bank_account,
refund_bank_account_real_name,
refund_bank_branch_full_name,
change_goods_waybill,
change_goods_deliver_name,
change_goods_finish_flag
</sql>
<select id="list" resultMap="BaseResultMap"
parameterType="com.sibu.orderHelper.integral.request.RefundListPagerRequest">
select
<include refid="Base_Column_List"/>
from im_order_refund
where member_id = #{memberId}
order by apply_date desc
limit ${(pageNow - 1) * pageSize}, ${pageSize}
</select>
<select id="findOneRefundingByOrderIdAndOrder1Id" resultMap="BaseResultMap"
parameterType="com.sibu.orderHelper.integral.request.RefundListPagerRequest">
select
of.*
from im_order_refund of inner join im_refund_order_item oi on of.refund_id = oi.refund_id
and of.order_id = #{orderId} and oi.order1_id = #{order1Id} and of.refund_status != 7 and of.refund_status != 100 and of.refund_status != 101
limit 0,1
</select>
<select id="countList" resultType="java.lang.Integer"
parameterType="com.sibu.orderHelper.integral.request.RefundListPagerRequest">
select count(*) from im_order_refund where member_id = #{memberId}
</select>
<sql id="refund_order_column">
refund_id,refund_code,order_id,order_code,member_id,refund_type,refund_reason,
refund_money,order_money,refund_remark,apply_date,buyer_username,buyer_phone
</sql>
<select id="findOneByRefundIdAndMemberId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from im_order_refund where refund_id = #{refundId} and member_id = #{memberId}
</select>
<insert id="addRefundOrder" parameterType="IMOrderRefundBean">
insert into im_order_refund(<include refid="refund_order_column"/>)
value(
#{refundId},
#{refundCode},
#{orderId},
#{orderCode},
#{memberId},
#{refundType},
#{refundReason},
#{refundMoney},
#{orderMoney},
#{refundRemark},
NOW(),
#{buyerUsername},
${buyerPhone}
)
</insert>
<insert id="insert" parameterType="com.sibu.orderHelper.integral.model.IMOrderRefundBean">
insert into im_order_refund (refund_id, refund_code, order_id,
order_code, order_from, member_id,
refund_type, refund_goods_status, refund_reason_id,
refund_reason, refund_money, order_money,
refund_remark, refund_status, refund_status_last_update_dt,
apply_date, refund_money_success_flag, refund_date,
buyer_username, buyer_phone, refund_seller_phone,
refund_seller_address, refund_seller_name,
finish_date, refund_integral, refund_goods_deliver_id,
refund_goods_deliver_name, refund_goods_waybill,
refund_goods_remark, refund_tips, receive_goods_flag,
receive_goods_dt,deduction_product_vb,supplier_id,supplier_name,platform_type)
values (#{refundId,jdbcType=VARCHAR}, #{refundCode,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR},
#{orderCode,jdbcType=VARCHAR}, #{orderFrom,jdbcType=TINYINT}, #{memberId,jdbcType=VARCHAR},
#{refundType,jdbcType=INTEGER}, #{refundGoodsStatus,jdbcType=INTEGER}, #{refundReasonId,jdbcType=INTEGER},
#{refundReason,jdbcType=VARCHAR}, #{refundMoney,jdbcType=DECIMAL}, #{orderMoney,jdbcType=DECIMAL},
#{refundRemark,jdbcType=VARCHAR}, #{refundStatus,jdbcType=INTEGER}, #{refundStatusLastUpdateDt,jdbcType=TIMESTAMP},
#{applyDate,jdbcType=TIMESTAMP}, #{refundMoneySuccessFlag,jdbcType=BIT}, #{refundDate,jdbcType=TIMESTAMP},
#{buyerUsername,jdbcType=VARCHAR}, #{buyerPhone,jdbcType=VARCHAR}, #{refundSellerPhone,jdbcType=VARCHAR},
#{refundSellerAddress,jdbcType=VARCHAR}, #{refundSellerName,jdbcType=VARCHAR},
#{finishDate,jdbcType=TIMESTAMP}, #{refundIntegral,jdbcType=BIGINT}, #{refundGoodsDeliverId,jdbcType=TINYINT},
#{refundGoodsDeliverName,jdbcType=VARCHAR}, #{refundGoodsWaybill,jdbcType=VARCHAR},
#{refundGoodsRemark,jdbcType=VARCHAR}, #{refundTips,jdbcType=VARCHAR}, #{receiveGoodsFlag,jdbcType=BIT},
#{receiveGoodsDt,jdbcType=TIMESTAMP},#{deductionProductVb},#{supplierId},#{supplierName},#{platformType})
</insert>
<update id="updateDeliveryInfoByRefundIdAndMemberId"
parameterType="com.sibu.orderHelper.integral.request.UpdateDeliveryInfoRequest">
update im_order_refund set
refund_goods_deliver_id=#{deliverId},
refund_goods_deliver_name=#{deliverName},
refund_goods_waybill=#{waybill},
refund_goods_remark=#{remark},
refund_freight=#{refundFreight},
refund_to_account_type=#{refundToAccountType},
refund_alipay_account=#{refundAlipayAccount},
refund_alipay_account_real_name=#{refundAlipayAccountRealName},
refund_bank_account=#{refundBankAccount},
refund_bank_account_real_name=#{refundBankAccountRealName},
refund_bank_branch_full_name=#{refundBankBranchFullName}
where refund_id = #{refundId} and member_id = #{memberId}
</update>
<update id="updateRefundStatusByRefundIdAndMemberId">
update im_order_refund set
refund_status=#{refundStatus}
where refund_id = #{refundId} and member_id = #{memberId}
</update>
<update id="updateByPrimaryKey" parameterType="com.sibu.orderHelper.integral.model.IMOrderRefundBean">
update im_order_refund
<set>
<if test="refundCode != null">
refund_code = #{refundCode,jdbcType=VARCHAR},
</if>
<if test="orderId != null">
order_id = #{orderId,jdbcType=VARCHAR},
</if>
<if test="orderCode != null">
order_code = #{orderCode,jdbcType=VARCHAR},
</if>
<if test="orderFrom != null">
order_from = #{orderFrom,jdbcType=TINYINT},
</if>
<if test="memberId != null">
member_id = #{memberId,jdbcType=VARCHAR},
</if>
<if test="refundType != null">
refund_type = #{refundType,jdbcType=INTEGER},
</if>
<if test="refundGoodsStatus != null">
refund_goods_status = #{refundGoodsStatus,jdbcType=INTEGER},
</if>
<if test="refundReasonId != null">
refund_reason_id = #{refundReasonId,jdbcType=INTEGER},
</if>
<if test="refundReason != null">
refund_reason = #{refundReason,jdbcType=VARCHAR},
</if>
<if test="refundMoney != null">
refund_money = #{refundMoney,jdbcType=DECIMAL},
</if>
<if test="orderMoney != null">
order_money = #{orderMoney,jdbcType=DECIMAL},
</if>
<if test="refundRemark != null">
refund_remark = #{refundRemark,jdbcType=VARCHAR},
</if>
<if test="refundStatus != null">
refund_status = #{refundStatus,jdbcType=INTEGER},
</if>
<if test="refundStatusLastUpdateDt != null">
refund_status_last_update_dt = #{refundStatusLastUpdateDt,jdbcType=TIMESTAMP},
</if>
<if test="applyDate != null">
apply_date = #{applyDate,jdbcType=TIMESTAMP},
</if>
<if test="refundMoneySuccessFlag != null">
refund_money_success_flag = #{refundMoneySuccessFlag,jdbcType=BIT},
</if>
<if test="refundDate != null">
refund_date = #{refundDate,jdbcType=TIMESTAMP},
</if>
<if test="buyerUsername != null">
buyer_username = #{buyerUsername,jdbcType=VARCHAR},
</if>
<if test="buyerPhone != null">
buyer_phone = #{buyerPhone,jdbcType=VARCHAR},
</if>
<if test="refundSellerPhone != null">
refund_seller_phone = #{refundSellerPhone,jdbcType=VARCHAR},
</if>
<if test="refundSellerAddress != null">
refund_seller_address = #{refundSellerAddress,jdbcType=VARCHAR},
</if>
<if test="refundSellerName != null">
refund_seller_name = #{refundSellerName,jdbcType=VARCHAR},
</if>
<if test="finishDate != null">
finish_date = #{finishDate,jdbcType=TIMESTAMP},
</if>
<if test="refundIntegral != null">
refund_integral = #{refundIntegral,jdbcType=BIGINT},
</if>
<if test="refundGoodsDeliverId != null">
refund_goods_deliver_id = #{refundGoodsDeliverId,jdbcType=TINYINT},
</if>
<if test="refundGoodsDeliverName != null">
refund_goods_deliver_name = #{refundGoodsDeliverName,jdbcType=VARCHAR},
</if>
<if test="refundGoodsWaybill != null">
refund_goods_waybill = #{refundGoodsWaybill,jdbcType=VARCHAR},
</if>
<if test="refundGoodsRemark != null">
refund_goods_remark = #{refundGoodsRemark,jdbcType=VARCHAR},
</if>
<if test="refundTips != null">
refund_tips = #{refundTips,jdbcType=VARCHAR},
</if>
<if test="receiveGoodsFlag != null">
receive_goods_flag = #{receiveGoodsFlag,jdbcType=BIT},
</if>
<if test="receiveGoodsDt != null">
receive_goods_dt = #{receiveGoodsDt,jdbcType=TIMESTAMP},
</if>
</set>
where refund_id = #{refundId,jdbcType=VARCHAR}
</update>
<select id="getRefundRecodeResult" parameterType="java.util.Map" resultType="String">
select operator_remark from im_refund_procedure_record where refund_id = #{refundId}
</select>
<select id="getRefundDetail" resultMap="refundResponseResultMap" parameterType="java.util.Map">
select refund_id,refund_code,order_code,refund_type,refund_procedure_status,refund_reason,
refund_money,order_money,refund_remark,refund_status,apply_date,refund_date,refund_seller_phone,refund_seller_address,refund_seller_name
from im_order_refund
where member_id = #{memberId} and order_id = #{orderId}
</select>
<resultMap type="RefundOrderResponse" id="refundResponseResultMap">
<id column="refund_id" property="refundId"/>
<result column="refund_code" property="refundCode"/>
<result column="order_code" property="orderCode"/>
<result column="refund_type" property="refundType"/>
<result column="refund_procedure_status" property="refundProcedureStatus"/>
<result column="refund_reason" property="refundReason"/>
<result column="refund_money" property="refundMoney"/>
<result column="order_money" property="orderMoney"/>
<result column="refund_remark" property="refundRemark"/>
<result column="refund_status" property="refundStatus"/>
<result column="apply_date" property="applyDate"/>
<result column="refund_date" property="refundDate"/>
<result column="refund_seller_address" property="refundSellerAddress"/>
<result column="refund_seller_phone" property="refundSellerPhone"/>
<result column="refund_seller_name" property="refundSellerName"/>
</resultMap>
<select id="statisticsRefundingNum" resultType="java.lang.Integer">
select count(*) from im_order_refund where member_id = #{memberId} and refund_status != 7 and refund_status != 100 and refund_status != 101
</select>
<select id="countOrderItemNotFinishHistory" resultType="java.lang.Integer">
select count(*) from im_order_refund of
inner join im_refund_order_item ofitem
on of.order_id=#{orderId}
and of.refund_status != 7 and of.refund_status != 100 and of.refund_status != 101
and ofitem.order1_id=#{order1Id}
and of.refund_id = ofitem.refund_id
</select>
<select id="searchSuccessRefundOrderList" resultMap="BaseResultMap">
SELECT * FROM im_order_refund WHERE refund_status = 7 GROUP BY order_code
</select>
<select id="countRefundOrderListByOrderCode" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT sum(r1.quantity) FROM im_refund_order_item r1,im_order_refund r WHERE r1.refund_id = r.refund_id
AND r.refund_status = 7 AND r.order_code = #{orderCode}
</select>
</mapper>