PromotionRuleMapper.xml
6.1 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
<?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.web.dao.IMPromotionRuleDao">
<resultMap id="rs_PromotionRuleBean" type="com.sibu.orderHelper.integral.model.PromotionRule">
<result property="id" column="id" javaType="java.lang.Long" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="status" column="status" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="prority" column="prority" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="startDate" column="start_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="endDate" column="end_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="isLimit" column="is_limit" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="limitNum" column="limit_num" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="ruleDesc" column="rule_desc" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="isDelete" column="is_delete" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="supplierName" column="supplier_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="supplierId" column="supplier_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="platformType" column="platform_type" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
</resultMap>
<select id="count" resultType="java.lang.Integer" >
SELECT COUNT(id) FROM promotion_rule
<trim prefix="where" prefixOverrides="and | or">
<if test="null != id">
AND id = #{id}
</if>
</trim>
</select>
<select id="list" resultMap="rs_PromotionRuleBean" parameterType="java.util.Map" >
SELECT * FROM promotion_rule where 1=1 and is_delete=0
<if test="name!=null and name!=''">
and name like concat('%',#{name},'%')
</if>
<if test="status !=null">
and status=#{status}
</if>
<if test="type!=null and type!=''">
and type =#{type}
</if>
<if test="startDt != null and startDt != ''">
and start_date >=#{startDt}
</if>
<if test="endDt != null and endDt != ''">
<![CDATA[
and end_date<= #{endDt}
]]>
</if>
<if test="supplierId !='' and supplierId !=null">
and supplier_id=#{supplierId}
</if>
ORDER BY create_date desc
limit ${(pageNow-1)*pageSize}, ${pageSize}
</select>
<select id="get" resultMap="rs_PromotionRuleBean" parameterType="java.lang.Long">
SELECT * FROM promotion_rule
where id = #{id}
</select>
<insert id="save" parameterType="com.sibu.orderHelper.integral.model.PromotionRule">
INSERT INTO promotion_rule (
name,status,prority,start_date,end_date,is_limit,limit_num,rule_desc,type,supplier_id,supplier_name,platform_type
) VALUES (
#{name},#{status},#{prority},#{startDate},#{endDate},#{isLimit},#{limitNum},#{ruleDesc},#{type},#{supplierId},#{supplierName},#{platformType}
)
</insert>
<update id="update" parameterType="java.util.Map">
UPDATE promotion_rule
<trim prefix="SET" suffixOverrides=",">
<if test="null != name">
name=#{name},
</if>
<if test="null != status">
status=#{status},
</if>
<if test="null != prority">
prority=#{prority},
</if>
<if test="null != startDate">
start_date=#{startDate},
</if>
<if test="null != endDate">
end_date=#{endDate},
</if>
<if test="null != isLimit">
is_limit=#{isLimit},
</if>
<if test="null != limitNum">
limit_num=#{limitNum},
</if>
<if test="null != ruleDesc">
rule_desc=#{ruleDesc},
</if>
<if test="null != type">
type=#{type},
</if>
</trim>
WHERE id = #{id}
</update>
<!-- 逻辑删除促销 -->
<delete id="delete" parameterType="java.lang.Long">
update promotion_rule set is_delete = 1 WHERE id = #{id}
</delete>
<delete id="batchDelete" parameterType="java.util.List">
DELETE FROM promotion_rule WHERE id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 查询同一时间内是否有相同的促销规则 -->
<select id="selectTimePromotionNum" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM `promotion_rule` rule WHERE is_delete=0 and rule.type=#{type}
AND (
(start_date <= #{startDt} AND end_date >= #{startDt}) OR
(start_date <= #{endDt} AND end_date >=#{endDt}) OR
(start_date>=#{startDt} AND end_date <= #{endDt})
)
<if test="id !=null">
and id !=#{id}
</if>
</select>
<!-- 获取数据列表(商家) -->
<select id="listSupplier" resultMap="rs_PromotionRuleBean" parameterType="java.util.Map" >
SELECT * FROM promotion_rule where 1=1 and is_delete=0 and supplier_id = #{supplierId}
<if test="name!=null and name!=''">
and name like concat('%',#{name},'%')
</if>
<if test="status !=null">
and status=#{status}
</if>
<if test="type!=null and type!=''">
and type =#{type}
</if>
<if test="startDt != null">
and start_date >=#{startDt}
</if>
<if test="endDt != null">
<![CDATA[
and end_date<= #{endDt}
]]>
</if>
ORDER BY create_date desc
limit ${(pageNow-1)*pageSize}, ${pageSize}
</select>
<!-- 查询同一时间内是否有相同的促销规则 根据平台或商家-->
<select id="selectTimePromotionNumByPlatform" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM `promotion_rule` rule WHERE is_delete=0 and rule.type=#{type} and platform_type = #{platformType}
AND (
(start_date <= #{startDt} AND end_date >= #{startDt}) OR
(start_date <= #{endDt} AND end_date >=#{endDt}) OR
(start_date>=#{startDt} AND end_date <= #{endDt})
)
<if test="id !=null">
and id !=#{id}
</if>
<if test="supplierId !=null and supplierId!=''">
and supplier_id = #{supplierId}
</if>
</select>
</mapper>