point-user-mapper.xml
2.15 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
<?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 tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.user.point.PointUserDao">
<sql id="point_rule_field">
id, user_id, otc_code,otc_name,point_amount
</sql>
<sql id="searchCondition">
where 1=1
<if test="userId != null and userId != ''"> and user_id=#{userId} </if>
<if test="otcCode != null and otcCode != ''"> and otc_code=#{otcCode} </if>
</sql>
<insert id="insert" parameterType="PointUserInfo" useGeneratedKeys="true" keyProperty="id">
insert into point_user(user_id, point_amount)
values(#{userId}, #{pointAmount})
</insert>
<update id="update" parameterType="PointUserInfo">
update point_user set point_amount = #{pointAmount}
where user_id = #{userId}
</update>
<!-- 增加积分 -->
<update id="addPoint">
update point_user set point_amount = point_amount + #{occurPoint}
where user_id = #{userId}
<if test="otcCode != null and otcCode != ''"> and otc_code=#{otcCode} </if>
</update>
<select id="queryByUserId" parameterType="string" resultType="PointUserInfo">
select <include refid="point_rule_field" /> from point_user
where user_id = #{userId}
</select>
<select id="queryByUserIdAndCode" parameterType="string" resultType="PointUserInfo">
select <include refid="point_rule_field" /> from point_user
where user_id = #{userId} and otc_code=#{otcCode}
</select>
<select id="search" parameterType="map" resultType="PointUserInfo">
select <include refid="point_rule_field" />
from point_user
<include refid="searchCondition" />
<if test="orderBy == 0 ">
order by point_amount asc
</if>
<if test="orderBy == 1 ">
order by point_amount desc
</if>
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(*)
from point_user
<include refid="searchCondition" />
</select>
<select id="searchPointAmount" parameterType="map" resultType="double">
select IFNULL(sum(point_amount),0)
from point_user
<include refid="searchCondition" />
</select>
</mapper>