StorageMapper.xml
5.88 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
<?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.ufo.dal.StorageMapper">
<resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.Storage">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="goods_id" jdbcType="INTEGER" property="goodsId" />
<result column="size_id" jdbcType="INTEGER" property="sizeId" />
<result column="storage_num" jdbcType="INTEGER" property="storageNum" />
<result column="update_time" jdbcType="INTEGER" property="updateTime" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="suggest_low_price" jdbcType="DECIMAL" property="suggestLowPrice" />
<result column="suggest_high_price" jdbcType="DECIMAL" property="suggestHighPrice" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from storage
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.ufo.dal.model.Storage">
insert into storage (id, product_id, goods_id,
size_id, storage_num, update_time,
create_time)
values (#{id,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER},
#{sizeId,jdbcType=INTEGER}, #{storageNum,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER})
</insert>
<update id="updateByPrimaryKey" parameterType="com.yoho.ufo.dal.model.Storage">
update storage
set product_id = #{productId,jdbcType=INTEGER},
goods_id = #{goodsId,jdbcType=INTEGER},
size_id = #{sizeId,jdbcType=INTEGER},
storage_num = #{storageNum,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time
from storage
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time
from storage
</select>
<select id="selectByGoodsId" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time, suggest_low_price, suggest_high_price, status
from storage where goods_id = #{goodsId,jdbcType=INTEGER}
</select>
<select id="selectByGoodsIdList" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time
from storage where goods_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="updateStorageNum">
update storage set storage_num = #{storageNum,jdbcType=INTEGER},
update_time = unix_timestamp()
where id = #{storageId,jdbcType=INTEGER} and storage_num = #{oldStorageNum,jdbcType=INTEGER}
</update>
<select id="selectByIds" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time, suggest_low_price, suggest_high_price
from storage where id in
<foreach item="item" index="index" collection="storageIdList" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="updateSizeId">
update storage set size_id=#{newSizeId} where size_id in
<foreach item="item" index="index" collection="oldSizeIdList" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="updateSuggestPriceById">
update storage set suggest_low_price=#{suggestLowPrice}, suggest_high_price=#{suggestHighPrice} where id=#{id}
</update>
<update id="updateBatchSuggestPrice" parameterType="java.util.List">
update storage
<trim prefix="set" suffixOverrides=",">
<trim prefix="suggest_low_price =case" suffix="end,">
<foreach collection="storageList" item="item" index="index">
<if test="item.suggestLowPrice!=null">
when id=#{item.id,jdbcType=INTEGER} then #{item.suggestLowPrice,jdbcType=DECIMAL}
</if>
</foreach>
</trim>
<trim prefix="suggest_high_price =case" suffix="end,">
<foreach collection="storageList" item="item" index="index">
<if test="item.suggestHighPrice!=null">
when id=#{item.id,jdbcType=INTEGER} then #{item.suggestHighPrice,jdbcType=DECIMAL}
</if>
</foreach>
</trim>
</trim>
where
<foreach collection="storageList" separator="or" item="item" index="index" >
id= #{item.id,jdbcType=INTEGER}
</foreach>
</update>
<select id="selectByCondition" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time, suggest_low_price, suggest_high_price
from storage where ${conditionSql}
</select>
<update id="updateDeleteSuggestPrice" timeout="10">
UPDATE storage s set s.suggest_low_price = null , s.suggest_high_price = null WHERE s.suggest_high_price > 0 AND NOT EXISTS (SELECT * FROM channel_sku_compare c where s.id = c.sku)
</update>
<update id="updateSkuStatus">
UPDATE storage s set s.status = #{status, jdbcType=INTEGER} where s.id = #{storageId, jdbcType=INTEGER}
</update>
<select id="selectBySize" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time, suggest_low_price, suggest_high_price
from storage where product_id=#{productId} and size_id=#{sizeId}
</select>
</mapper>