PayRecordMapper.xml 3.35 KB
Newer Older
licc's avatar
licc committed
1 2 3 4 5 6 7 8
<?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="cn.wisenergy.mapper.PayRecordMapper">
    <resultMap id="advertisingMap" type="cn.wisenergy.model.app.PayRecord">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="type" property="type"/>
licc's avatar
licc committed
9
        <result column="card_id" property="cardId"/>
licc's avatar
licc committed
10 11
        <result column="money" property="money"/>
        <result column="result" property="result"/>
licc's avatar
licc committed
12
        <result column="pay_limit" property="payLimit"/>
licc's avatar
licc committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="table">
        pay_record
    </sql>

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
licc's avatar
licc committed
27
        user_id,type, card_id,money,result,pay_limit, create_time,update_time
licc's avatar
licc committed
28 29 30
    </sql>

    <sql id="vals">
licc's avatar
licc committed
31
        #{userId},#{type},#{cardId},#{money},#{result},#{payLimit},now(),now()
licc's avatar
licc committed
32 33 34 35 36
    </sql>

    <sql id="updateCondition">
        <if test="userId != null">user_id = #{userId},</if>
        <if test="type != null">type =#{type},</if>
licc's avatar
licc committed
37
        <if test="cardId != null">card_id =#{cardId},</if>
licc's avatar
licc committed
38 39
        <if test="money != null">money =#{money},</if>
        <if test="result != null">result =#{result},</if>
licc's avatar
licc committed
40
        <if test="payLimit != null">pay_limit =#{payLimit},</if>
licc's avatar
licc committed
41 42 43 44 45 46 47
        update_time =now()
    </sql>

    <sql id="criteria">
        <if test="id != null">id = #{id}</if>
        <if test="userId != null">and user_id = #{userId}</if>
        <if test="type != null">and type =#{type}</if>
licc's avatar
licc committed
48
        <if test="cardId != null">and card_id =#{cardId}</if>
licc's avatar
licc committed
49 50
        <if test="money != null">and money =#{money}</if>
        <if test="result != null">and result =#{result}</if>
licc's avatar
licc committed
51
        <if test="payLimit != null">and pay_limit =#{payLimit}</if>
licc's avatar
licc committed
52 53 54 55 56 57 58 59 60 61 62 63 64
        <if test="createTime != null">and create_time &gt;= #{createTime}</if>
        <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
    </sql>

    <insert id="add" parameterType="cn.wisenergy.model.app.PayRecord" keyProperty="id" useGeneratedKeys="true">
        insert into
        <include refid="table"/>
        (<include refid="cols_exclude_id"/>)
        value(
        <include refid="vals"/>
        )
    </insert>
    <select id="getList" resultType="cn.wisenergy.model.vo.PayRecordShowVo">
licc's avatar
licc committed
65
        select
66
        id as recordId,type,result,pay_limit as `limit`,create_time as payTime
licc's avatar
licc committed
67 68 69 70 71 72 73
        from
        <include refid="table"/>
        <where>
            <if test="userId != null">
                user_id=#{userId}
            </if>
            order by create_time desc
licc's avatar
licc committed
74
            limit #{startNum},#{endNum}
licc's avatar
licc committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
        </where>
    </select>


    <select id="count" resultType="java.lang.Integer">
        select count(1)
        from
        <include refid="table"/>
        <where>
            <if test="userId != null">
                user_id=#{userId}
            </if>
        </where>

    </select>

91
    <select id="getById" resultMap="advertisingMap">
92 93 94 95
        select
        <include refid="cols_all"/>
        from
        <include refid="table"/>
96 97 98 99 100 101
        <where>
            user_id=#{userId}
            and
            result=0
        </where>
    </select>
licc's avatar
licc committed
102 103

</mapper>