SellerOrderGoodsViewMapper.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
<?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.yohoufo.dal.order.SellerOrderGoodsViewMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SellerOrderGoods">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="product_name" jdbcType="VARCHAR" property="productName" />
<result column="storage_id" jdbcType="INTEGER" property="storageId" />
<result column="depot_no" jdbcType="INTEGER" property="depotNo" />
<result column="size_id" jdbcType="INTEGER" property="sizeId" />
<result column="size_name" jdbcType="VARCHAR" property="sizeName" />
<result column="color_id" jdbcType="SMALLINT" property="colorId" />
<result column="color_name" jdbcType="VARCHAR" property="colorName" />
<result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
<result column="is_del" jdbcType="TINYINT" property="isDel" />
<result column="batch_no" jdbcType="BIGINT" property="batchNo" />
<result column="storage_num" jdbcType="INTEGER" property="storageNum" />
<result column="size_num" jdbcType="INTEGER" property="sizeNum" />
<result column="attributes" jdbcType="INTEGER" property="attributes" />
<result column="region" jdbcType="INTEGER" property="region" />
<result column="bid_Type" jdbcType="INTEGER" property="bidType" />
</resultMap>
<sql id="Base_Column_List">
id, uid, product_id, product_name, storage_id, depot_no, size_id, size_name,
color_id, color_name, goods_price, status, image_url, is_del, batch_no,attributes, region, bid_type
</sql>
<select id="selectEntryCntByUidStatusGBSkc" resultType="java.lang.Integer">
SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
and sog.is_del = 1 AND so.payment = 11
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
GROUP BY sog.uid,product_id) t
</select>
<select id="selectCntByUidStatusGBSkc" resultType="java.lang.Integer">
SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
and sog.is_del = 1
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
GROUP BY sog.uid,product_id) t
</select>
<sql id="Base_Column_List_with_table_name">
sog.id as id, sog.uid as uid, product_id, product_name,storage_id,depot_no,sog.size_id,sog.size_name,
color_id, color_name, goods_price, sog.status as status, image_url, sog.is_del as is_del, batch_no,
sog.attributes as attributes, sog.region as region, sog.bid_type as bid_type
</sql>
<select id="selectEntryListByUidStatusGBSkc" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
and sog.is_del = 1 AND so.payment = 11
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
GROUP BY sog.uid,product_id ORDER BY id DESC
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<select id="selectListByUidStatusGBSkc" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
and sog.is_del = 1
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
GROUP BY sog.uid,product_id ORDER BY id DESC
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<select id="selectByUidStatusGBSkc" resultMap="BaseResultMap">
SELECT `uid`,`product_id`,`product_name`,`color_id`,`color_name`,COUNT(size_id) size_num,SUM(size_storage) storage_num FROM
(
SELECT sog.`uid`,`product_id`,`product_name`,`color_id`,`color_name`,size_id,COUNT(`size_id`) size_storage
FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
and sog.is_del = 1
<if test="isEntry">
AND so.payment = 11
</if>
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
AND product_id = #{productId,jdbcType=INTEGER}
GROUP BY sog.uid,size_id
) t
</select>
<select id="selectNotEntryCntByUidStatus" resultType="java.lang.Integer">
SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
AND (so.payment != 11 or so.payment is null)
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
) t
</select>
<select id="selectNotEntryListByUidStatus" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
AND (so.payment != 11 or so.payment is null)
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
ORDER BY id DESC
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<select id="selectEntryListByUidStatusGBSku" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_with_table_name" />,COUNT(sog.size_id) storage_num
FROM seller_order_goods sog
join seller_order so on sog.id = so.skup
left join product_size ps on sog.size_id = ps.size_id
WHERE sog.uid = #{condition.uid,jdbcType=INTEGER}
<if test="isEntry">
AND so.payment = 11
</if>
<include refid="sql_where_skupTyps_scope" />
AND sog.status = #{condition.status, jdbcType=TINYINT}
AND product_id = #{condition.productId,jdbcType=INTEGER}
GROUP BY sog.attributes,sog.size_id,`goods_price`
order by ps.order_by,sog.size_id,goods_price
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<select id="selectEntryCntByUidStatusGBSku" resultType="java.lang.Integer">
select count(*) FROM
(
SELECT size_id ,goods_price
FROM seller_order_goods sog,seller_order so WHERE sog.id = so.skup
AND sog.uid = #{condition.uid,jdbcType=INTEGER}
<if test="isEntry">
AND so.payment = 11
</if>
<include refid="sql_where_skupTyps_scope" />
AND sog.status = #{condition.status, jdbcType=TINYINT}
AND product_id = #{condition.productId,jdbcType=INTEGER}
GROUP BY sog.attributes,size_id,`goods_price`
) t
</select>
<sql id="sql_where_skupTyps_scope" >
and attributes in
<foreach collection="skupTypes" item="skupType" open="(" close=")" separator=",">
#{skupType,jdbcType=INTEGER}
</foreach>
</sql>
<select id="selectCanSellByStorageId" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM seller_order_goods
WHERE storage_id = #{storageId,jdbcType=INTEGER} and status = 1
</select>
<select id="selectCntByUidTypeStatus" resultType="java.lang.Integer">
SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
) t
</select>
<select id="selectAllByUidTypeStatus" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
ORDER BY id DESC
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<select id="selectAvgPriceOfPrdWithTimeRange" resultMap="BaseResultMap">
select avg(sog.goods_price) goods_price from seller_order_goods sog,buyer_order bo,buyer_order_goods bog
where sog.id = bog.skup
and bo.order_code = bog.order_code
and sog.storage_id = #{storageId,jdbcType=INTEGER}
and bo.status = 5
and bo.update_time between #{startTime} and #{endTime}
</select>
<select id="selectAvgPriceOfPrd" resultMap="BaseResultMap">
select avg(sog.goods_price) goods_price from seller_order_goods sog,buyer_order bo,buyer_order_goods bog
where sog.id = bog.skup
and bo.order_code = bog.order_code
and sog.storage_id = #{storageId,jdbcType=INTEGER}
and bo.status = 5
order by bo.id desc
limit #{limit}
</select>
</mapper>