point-lottery-mapper.xml
1.89 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
<?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.PointLotteryDao">
<sql id="point_lottery_field">
id,order_no,user_id,goods_id,lottery,lottery_at,lottery_expire,buy,buy_at,buy_expire,remark
</sql>
<sql id="searchCondition">
where 1=1
<if test="goodsId != null and goodsId != ''"> and goods_id=#{goodsId} </if>
<if test="userId != null and userId != ''"> and user_id =#{userId} </if>
<if test="lottery != null and lottery != ''"> and lottery =#{lottery} </if>
<if test="buy != null and buy != ''"> and buy = #{buy} </if>
<if test="startDate != null and startDate != ''"> <![CDATA[ and lottery_at >= #{startDate}]]> </if>
<if test="endDate != null and endDate != ''"> <![CDATA[ and lottery_at <= DATE_ADD(#{endDate}, INTERVAL 1 day)]]> </if>
</sql>
<select id="search" parameterType="map" resultType="PointLotteryInfo">
select <include refid="point_lottery_field" />
from point_lottery
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(*)
from point_lottery
<include refid="searchCondition" />
order by id desc
</select>
<select id="searchLotteryExpire" resultType="PointLotteryInfo">
<![CDATA[ select id from point_lottery where lottery_expire<now()]]>
</select>
<select id="searchBuyExpire" resultType="PointLotteryInfo" >
<![CDATA[ select id
from point_lottery where buy_expire<now()]]>
</select>
<update id="update" parameterType="PointLotteryInfo" >
update point_lottery set
<if test="lottery != null and lottery != ''"> lottery =#{lottery} </if>
<if test="buy != null and buy != ''"> buy =#{buy} </if>
where id=#{id}
</update>
</mapper>