goods-config-mapper.xml
4.27 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
<?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">
<!-- @author kongmingke -->
<mapper namespace="com.cjs.cms.dao.user.point.GoodsConfigDao">
<sql id="goods_config_field">
id, otc_code, otc_name, otc_account, image, price, point, goods_amount,
goods_remain, goods_status, buy_max, lottery, lottery_probability, lottery_start,
lottery_end, lottery_point, lottery_expire, buy_expire, create_at, create_by
</sql>
<sql id="searchCondition">
where 1=1
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
<if test="otcName != null and otcName != ''">
and otc_name = #{otcName}
</if>
<if test="goodsStatus != null and goodsStatus != ''">
and goods_status = #{goodsStatus}
</if>
<if test="startDate != null and startDate != ''"> <![CDATA[ and create_at >= #{startDate}]]> </if>
<if test="endDate != null and endDate != ''"> <![CDATA[ and create_at <= DATE_ADD(#{endDate}, INTERVAL 1 day)]]> </if>
</sql>
<insert id="insert" parameterType="GoodsConfigInfo">
insert into goods_config(otc_code, otc_name, otc_account, image, price, point, goods_amount,
goods_remain, goods_status, buy_max, lottery, lottery_probability, lottery_start, lottery_end, lottery_point,
lottery_expire, buy_expire, create_at, create_by)
values(#{otcCode}, #{otcName}, #{otcAccount}, #{image}, #{price}, #{point}, #{goodsAmount},
#{goodsAmount}, '0', #{buyMax},#{lottery}, #{lotteryProbability},
<choose>
<when test="lotteryStart != null and lotteryStart != ''">
#{lotteryStart},
</when>
<otherwise>
null,
</otherwise>
</choose>
<choose>
<when test="lotteryEnd != null and lotteryEnd != ''">
#{lotteryEnd},
</when>
<otherwise>
null,
</otherwise>
</choose>
#{lotteryPoint}, #{lotteryExpire}, #{buyExpire}, CURRENT_TIMESTAMP, #{createBy})
</insert>
<update id="updateAll" parameterType="GoodsConfigInfo">
update goods_config set
price =#{price}, point =#{point}, goods_amount =#{goodsAmount}, goods_remain=#{goodsRemain},
buy_max=#{buyMax}, lottery=#{lottery}, lottery_probability=#{lotteryProbability}, lottery_point=#{lotteryPoint}, lottery_expire=#{lotteryExpire}, buy_expire=#{lotteryExpire},
create_by =#{createBy}
<choose>
<when test="lotteryStart != null and lotteryStart != ''">
,lottery_start=#{lotteryStart}
</when>
<otherwise>
,lottery_start = null
</otherwise>
</choose>
<choose>
<when test="lotteryEnd != null and lotteryEnd != ''">
,lottery_end=#{lotteryEnd}
</when>
<otherwise>
,lottery_end = null
</otherwise>
</choose>
<if test="image != null and image != ''">
,image =#{image}
</if>
where id=#{id}
</update>
<!-- 修改藏品状态 -->
<update id="updateStatus" parameterType="GoodsConfigInfo">
update goods_config set goods_status=#{goodsStatus}
where id = #{id}
</update>
<select id="search" parameterType="map" resultType="GoodsConfigInfo">
select <include refid="goods_config_field" />
from goods_config
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(*) from goods_config
<include refid="searchCondition" />
</select>
<select id="queryOne" parameterType="int" resultType="GoodsConfigInfo">
select <include refid="goods_config_field" />
from goods_config
where id=#{id}
</select>
<select id="searchByTime" parameterType="GoodsConfigInfo" resultType="GoodsConfigInfo">
select <include refid="goods_config_field" />
from goods_config
where <![CDATA[ lottery_start<#{lotteryEnd}]]> <![CDATA[and lottery_end>#{lotteryStart}]]>
and lottery=1
and goods_status!=2
and otc_code != #{otcCode}
</select>
<select id="queryByOtcCode" parameterType="String" resultType="GoodsConfigInfo">
select <include refid="goods_config_field" />
from goods_config
where otc_code=#{otcCode} and goods_status !=2
</select>
</mapper>