ChannelSkuCompareMapper.xml
3.3 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
<?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.ChannelSkuCompareMapper">
<resultMap id="BaseResultMap" type="com.yoho.ufo.model.ChannelSkuCompare">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="product_id" property="productId" jdbcType="INTEGER" />
<result column="sku" property="sku" jdbcType="INTEGER" />
<result column="size_id" property="sizeId" jdbcType="INTEGER" />
<result column="channel_price" property="channelPrice" jdbcType="DECIMAL" />
<result column="low_rate" property="lowRate" jdbcType="DECIMAL" />
<result column="high_rate" property="highRate" jdbcType="DECIMAL" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="channel_url" property="channelUrl" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id, product_id, sku, size_id, channel_price, low_rate, high_rate, update_time, channel_url
</sql>
<sql id="Query_Sql" >
<if test="channelSkuCompareReq.sku != null and channelSkuCompareReq.sku != 0 ">
and a.sku = #{channelSkuCompareReq.sku}
</if>
<if test="channelSkuCompareReq.productId != null and channelSkuCompareReq.productId != 0 ">
and a.product_id = #{channelSkuCompareReq.productId}
</if>
<if test="channelSkuCompareReq.productIdList != null and channelSkuCompareReq.productIdList.size()>0">
and a.product_id in
<foreach collection="channelSkuCompareReq.productIdList" item="productId" open="(" close=")" separator=",">
#{productId}
</foreach>
</if>
<if test="channelSkuCompareReq.sizeIdList != null and channelSkuCompareReq.sizeIdList.size()>0">
and a.size_id in
<foreach collection="channelSkuCompareReq.sizeIdList" item="sizeId" open="(" close=")" separator=",">
#{sizeId}
</foreach>
</if>
<if test="channelSkuCompareReq.status != null and channelSkuCompareReq.status == 0 ">
and b.min_price < a.channel_price
</if>
<if test="channelSkuCompareReq.status != null and channelSkuCompareReq.status == 1 ">
and b.min_price > a.channel_price
</if>
</sql>
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.ufo.model.ChannelSkuCompareReq">
select count(a.id)
from channel_sku_compare a
<if test="channelSkuCompareReq.status != null">
LEFT JOIN product b
ON( b.id=a.product_id)
</if>
where 1=1
<include refid="Query_Sql" />
</select>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.ufo.model.ChannelSkuCompareReq">
select a.*
from channel_sku_compare a
<if test="channelSkuCompareReq.status != null">
LEFT JOIN product b
ON( b.id=a.product_id)
</if>
where 1=1
<include refid="Query_Sql" />
order by a.product_id desc, a.sku asc
<if test="channelSkuCompareReq.start!=null and channelSkuCompareReq.size != null">
limit #{channelSkuCompareReq.start},#{channelSkuCompareReq.size}
</if>
</select>
</mapper>