user-rate-mapper.xml
2.6 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
<?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 xiangwei -->
<mapper namespace="com.cjs.cms.dao.user.UserRateDao">
<sql id="user_rate_field">
id, user_id userId, user_name , trade_type , rate_type ,
DATE_FORMAT(rate_time,'%Y-%m-%d')rate_time,
DATE_FORMAT(rate_start,'%Y-%m-%d')rate_start,
DATE_FORMAT(rate_end,'%Y-%m-%d')rate_end,
rate_result ,remark
</sql>
<sql id="searchCondition">
where 1 = 1
<if test="userId != null and userId != ''"> and user_id=#{userId} </if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%') </if>
<if test="tradeType != null and tradeType != ''"> and trade_type = #{tradeType} </if>
<if test="rateType != null and rateType != ''"> and rate_type= #{rateType} </if>
<if test="rateStart != null and rateStart != ''"> <![CDATA[ and rate_start >= #{rateStart}]]>
</if>
<if test="rateEnd != null and rateEnd != ''"> <![CDATA[ and rate_end <= #{rateEnd}]]>
</if>
<if test="rateResult != null and rateResult != ''"> and rate_result=#{rateResult} </if>
<if test="rateTimeStart != null and rateTimeStart != ''"> <![CDATA[ and rate_time >= #{rateTimeStart}]]>
</if>
<if test="rateTimeEnd != null and rateTimeEnd != ''"> <![CDATA[ and rate_time <= #{rateTimeEnd}]]>
</if>
</sql>
<select id="search" parameterType="map" resultType="UserRateInfo">
select
<include refid="user_rate_field" />
from user_rate
<include refid="searchCondition" />
order by rate_time desc, id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(*)
from user_rate
<include refid="searchCondition" />
</select>
<update id="updateRate" parameterType="UserRateInfo">
update user_rate set rate_result=#{rateResult}
<if test="rateEnd != null and rateEnd != ''">
,rate_end=#{rateEnd}
</if>
<if test="rateStart != null and rateStart != ''">
,rate_start=#{rateStart}
</if>
<if test="remark != null and remark != ''">
,remark=#{remark}
</if>
where id=#{id}
</update>
<!-- 查询当天过期的用户 -->
<select id="queryExpire" resultType="UserRateInfo" parameterType="UserRateInfo">
select
<include refid="user_rate_field" />
from user_rate
<![CDATA[ where rate_end<=str_to_date(now(),'%Y-%m-%d')]]>
</select>
<!-- 拿到会员号 -->
<select id="getRateForId" resultType="UserRateInfo"
parameterType="int">
select
<include refid="user_rate_field" />
from user_rate where id=#{id}
</select>
</mapper>