Pu Zhibing
10 天以前 326f47b6b0c7a02685f514d4088e4070b8858ab4
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
<?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="com.stylefeng.guns.modular.system.dao.UserRedPacketRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.UserRedPacketRecord">
        <id column="id" property="id"/>
        <result column="money" property="money"/>
        <result column="expirationTime" property="expirationTime"/>
        <result column="insertTime" property="insertTime"/>
        <result column="companyId" property="companyId"/>
        <result column="state" property="state"/>
        <result column="endTime" property="endTime"/>
        <result column="orderId" property="orderId"/>
        <result column="orderType" property="orderType"/>
        <result column="userId" property="userId"/>
        <result column="redPacketActivityId" property="redPacketActivityId"/>
    </resultMap>
 
 
 
    <select id="query" resultType="UserRedPacketRecord">
        select
        id as id,
        money as money,
        expirationTime as expirationTime,
        insertTime as insertTime,
        companyId as companyId,
        state as state,
        orderId as orderId,
        orderType as orderType,
        userId as userId,
        redPacketActivityId as redPacketActivityId
        from t_user_red_packet_record where 1=1
        <if test="null != uid">
            and userId = #{uid}
        </if>
        <if test="null != companyId">
            and companyId = #{companyId}
        </if>
        <if test="null != state">
            and state = #{state}
        </if>
        <if test="null != orderType">
            and orderType = #{orderType}
        </if>
        <if test="null != money">
            and money &lt; #{money}
        </if>
        order by money desc limit 0, 1
    </select>
 
 
 
    <select id="query_" resultType="UserRedPacketRecord">
        select
        id as id,
        money as money,
        expirationTime as expirationTime,
        insertTime as insertTime,
        companyId as companyId,
        state as state,
        orderId as orderId,
        orderType as orderType,
        userId as userId,
        redPacketActivityId as redPacketActivityId
        from t_user_red_packet_record where 1=1
        <if test="null != uid">
            and userId = #{uid}
        </if>
        <if test="null != companyId">
            and companyId = #{companyId}
        </if>
        <if test="null != state">
            and state = #{state}
        </if>
        <if test="null != orderType">
            and orderType = #{orderType}
        </if>
        <if test="null != money">
            and money &lt; #{money}
        </if>
        order by insertTime desc limit 0, 1
    </select>
 
 
    <select id="queryMyRedEnvelope" resultType="map">
        select
        a.id as id,
        a.money as money,
        b.name as name
        from t_user_red_packet_record a
        left join t_company b on (a.companyId = b.id)
        where a.state = 1
        <if test="null != uid">
            and a.userId = #{uid}
        </if>
        order by a.insertTime desc
        <if test="null != pageNum and null != size">
            limit #{pageNum}, #{size}
        </if>
    </select>
</mapper>