StorageDepositMapper.xml
11.6 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
<?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.StorageDepositMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.StorageDeposit">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="product_id" property="productId" jdbcType="INTEGER" />
<result column="goods_id" property="goodsId" jdbcType="INTEGER" />
<result column="storage_id" property="storageId" jdbcType="INTEGER" />
<result column="deposit_code" property="depositCode" jdbcType="VARCHAR" />
<result column="shelf_code" property="shelfCode" jdbcType="VARCHAR" />
<result column="owner_uid" property="ownerUid" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="skup" property="skup" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="order_status" property="orderStatus" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="deposit_start_time" property="depositStartTime" jdbcType="INTEGER" />
<result column="deposit_end_time" property="depositEndTime" jdbcType="INTEGER" />
<result column="edit_pid" property="editPid" jdbcType="INTEGER" />
<result column="del_status" property="delStatus" jdbcType="INTEGER" />
<result column="remind_status" property="remindStatus" jdbcType="INTEGER" />
<result column="out_type" property="outType" jdbcType="INTEGER" />
<result column="new_skup" property="newSkup" jdbcType="INTEGER" />
<result column="order_no" property="orderNo" jdbcType="INTEGER" />
<result column="source" property="source" jdbcType="INTEGER" />
<result column="deposit_type" property="depositType" jdbcType="INTEGER" />
<result column="parent_order_code" property="parentOrderCode" jdbcType="BIGINT" />
</resultMap>
<sql id="Base_Column_List">
id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code,
skup, status, order_status, update_time, create_time, deposit_start_time,
deposit_end_time, edit_pid, out_type, del_status, remind_status,new_skup, order_no,
source, deposit_type, parent_order_code
</sql>
<insert id="insert" parameterType="com.yoho.order.model.StorageDeposit">
insert into storage_deposit(id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code,
skup, status, order_status, update_time, create_time, deposit_start_time,
deposit_end_time, edit_pid, out_type, source, deposit_type, parent_order_code)
values (#{id}, #{productId}, #{goodsId}, #{storageId}, #{depositCode}, #{shelfCode}, #{ownerUid}, #{orderCode},
#{skup}, #{status}, #{orderStatus}, #{updateTime}, #{createTime}, #{depositStartTime}, #{depositEndTime}, #{editPid},
#{outType}, #{source}, #{depositType}, #{parentOrderCode})
</insert>
<update id="batchBindShelfCode">
update storage_deposit set shelf_code=#{shelfCode}, order_no=#{orderNo}, deposit_end_time = unix_timestamp(now()) + 3888000
where 1=1
<if test="list != null and list.size()>0">
and deposit_code in
<foreach collection="list" item="depositCode" open="(" close=")" separator=",">
#{depositCode}
</foreach>
</if>
</update>
<select id="selectCountByStatusAndDepotNo" resultType="java.lang.Integer">
select count(1)
from storage_deposit
where del_status=0 AND deposit_type = 0
<if test="status != null">
and status = #{status}
</if>
</select>
<sql id="Query_Order_Sql" >
<if test="storageDepositReq.status != null">
and a.status = #{storageDepositReq.status}
</if>
<if test="storageDepositReq.depositCode != null and storageDepositReq.depositCode != '' ">
and a.deposit_code = #{storageDepositReq.depositCode}
</if>
<if test="storageDepositReq.orderCode != null and storageDepositReq.orderCode != '' ">
and a.order_code = #{storageDepositReq.orderCode}
</if>
<if test="storageDepositReq.shelfCode != null and storageDepositReq.shelfCode != '' ">
and a.shelf_code = #{storageDepositReq.shelfCode}
</if>
</sql>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.StorageDepositReq">
select a.*
from storage_deposit a
<if test="storageDepositReq.status != null and storageDepositReq.status== 0">
LEFT JOIN buyer_order b
ON( b.order_code=a.order_code)
</if>
where a.del_status=0 AND deposit_type = 0
<include refid="Query_Order_Sql" />
<if test="storageDepositReq.status != null and storageDepositReq.status== 0">
order by b.create_time
</if>
<if test="storageDepositReq.status != null and storageDepositReq.status== 3">
order by a.create_time
</if>
<if test="storageDepositReq.status != null and storageDepositReq.status== 4">
order by a.update_time desc
</if>
<if test="storageDepositReq.start!=null and storageDepositReq.size != null">
limit #{storageDepositReq.start},#{storageDepositReq.size}
</if>
</select>
<select id="selectNeddRemindDeposit" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit WHERE del_status = 0 AND deposit_type = 0 and deposit_end_time <= #{curTime} and remind_status in
<foreach collection="remindStatus" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND status = 1 limit 500
</select>
<update id="updateHasRemind">
UPDATE storage_deposit SET remind_status = #{remindStatus} WHERE id = #{id}
</update>
<select id="selectNeddDownDeposit" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit WHERE del_status = 0 AND deposit_type = 0 and deposit_end_time <= #{curTime} AND status = 1 limit 500
</select>
<update id="updateStatus">
UPDATE storage_deposit SET status = #{status}, out_type = #{outType} WHERE id = #{id} AND order_status = #{orderStatus} AND status = #{initStatus}
</update>
<select id="selectShelfCodeCnt" resultType="java.lang.Integer">
select count(distinct shelf_code)
from storage_deposit
where 1=1 and del_status=0 AND deposit_type = 0
<if test="status != null">
and status = #{status}
</if>
</select>
<select id="selectShelfCodeList" resultType="java.lang.String" parameterType="com.yoho.order.model.StorageDepositReq">
select distinct a.shelf_code
from storage_deposit a
where a.del_status=0 AND deposit_type = 0
<include refid="Query_Order_Sql" />
order by a.order_no
<if test="storageDepositReq.start!=null and storageDepositReq.size != null">
limit #{storageDepositReq.start},#{storageDepositReq.size}
</if>
</select>
<select id="selectByShelfCodeList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where del_status=0 AND deposit_type = 0
<if test="list != null and list.size()>0">
and shelf_code in
<foreach collection="list" item="shelfCode" open="(" close=")" separator=",">
#{shelfCode}
</foreach>
</if>
<if test="status != null">
and status = #{status}
</if>
order by update_time
</select>
<select id="selectByDepositCodeList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where del_status=0 AND deposit_type = 0
<if test="list != null and list.size()>0">
and deposit_code in
<foreach collection="list" item="depositCode" open="(" close=")" separator=",">
#{depositCode}
</foreach>
</if>
</select>
<select id="selectHistoryByDepositCodeList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where deposit_type = 0 AND deposit_code in
<foreach collection="list" item="depositCode" open="(" close=")" separator=",">
#{depositCode}
</foreach>
</select>
<update id="batchUpdateStatusByDepositCodeList">
update storage_deposit
set status=#{status}
where deposit_code in
<foreach collection="list" item="depositCode" open="(" close=")" separator=",">
#{depositCode}
</foreach> AND del_status=0 AND status = #{initStatus}
</update>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where order_code=#{orderCode} and del_status=0 AND deposit_type = 0 limit 1
</select>
<select id="selectByNewSkup" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where new_skup=#{newSkup} AND deposit_type = 0 limit 1
</select>
<select id="selectDepositList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where del_status = 0 AND deposit_type = 0
<include refid="deposit_list_where"></include>
order by id desc limit #{start},#{size}
</select>
<select id="selectDepositListCount" resultType="java.lang.Integer">
select count(*)
from storage_deposit
where del_status = 0 AND deposit_type = 0
<include refid="deposit_list_where"></include>
</select>
<sql id="deposit_list_where" >
<if test="status != null">
<if test="status == 1">
and status = 0
</if>
<if test="status == 2">
and status = 1 and order_status = 0
</if>
<if test="status == 3">
and status = 1 and order_status = 1
</if>
<if test="status == 4">
and status in (2,3)
</if>
<if test="status == 5">
and status in(4,5)
</if>
</if>
<if test="depositCode != null and depositCode != ''">
and deposit_code = #{depositCode}
</if>
<if test="orderCode != null and orderCode > 0">
and order_code = #{orderCode}
</if>
<if test="productId != null and productId != ''">
and product_id = #{productId}
</if>
<if test="ownerUid != null and ownerUid > 0">
and owner_uid = #{ownerUid}
</if>
</sql>
<select id="selectByOrderCodeIgnoreDelStatus" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where order_code=#{orderCode} AND deposit_type = 0 limit 1
</select>
<select id="selectDepositedByOrderCode" resultMap="BaseResultMap">
select order_code, deposit_code
from storage_deposit
where order_code in
<foreach collection="orderCodes" item="orderCode" open="(" close=")" separator=",">
#{orderCode}
</foreach>
and status > 0
</select>
</mapper>