zxl
昨天 d3f5a984360ae152369e6edf743cf8ace4e1d8ec
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?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.lili.modules.lmk.mapper.PrizeRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.PrizeRecordVO">
        <id column="id" property="id"/>
        <result column="user_id" property="userId" />
        <result column="nick_name" property="nickName" />
        <result column="prize_activity_id" property="prizeActivityId" />
        <result column="prize_activity_name" property="prizeActivityName" />
        <result column="prize_activity_cover" property="prizeActivityCover" />
        <result column="prize_status" property="prizeStatus" />
        <result column="prize_content" property="prizeContent" />
        <result column="prize_id" property="prizeId" />
        <result column="prize_img" property="prizeImg" />
        <result column="prize_num_id" property="prizeNumId" />
        <result column="activity_prize_ref_id" property="activityPrizeRefId" />
        <result column="distribute_status" property="distributeStatus" />
        <result column="distribute_status" property="distributeStatus"/>
    </resultMap>
 
 
 
 
 
 
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            LPR.user_id,
            LPR.nick_name,
            LPR.prize_activity_id,
            LPR.prize_activity_name,
            LPR.prize_activity_cover,
            LPR.prize_status,
            LPR.prize_content,
            LPR.prize_id,
            LPR.prize_img,
            LPR.prize_num_id,
            LPR.activity_prize_ref_id,
            LPR.id,
            LPR.distribute_status
        FROM
            lmk_prize_record LPR
        WHERE
            LPR.id = #{id} AND LPR.delete_flag = 0
    </select>
 
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            LPR.user_id,
            LPR.nick_name,
            LPR.prize_activity_id,
            LPR.prize_activity_name,
            LPR.prize_activity_cover,
            LPR.prize_status,
            LPR.prize_content,
            LPR.prize_id,
            LPR.prize_img,
            LPR.prize_num_id,
            LPR.activity_prize_ref_id,
            LPR.distribute_status,
            LPR.create_time,
            LPR.id
        FROM
            lmk_prize_record LPR
        WHERE
            LPR.delete_flag = 0
        <if test="query.nickName != null and query.nickName !=''">
            AND LPR.nick_name like CONCAT('%',#{query.nickName},'%')
        </if>
        <if test="query.activityName != null and query.activityName !=''">
            AND LPR.prize_activity_name like CONCAT('%',#{query.activityName},'%')
        </if>
        <if test="query.prizeStatus != null and query.prizeStatus !=''">
            AND LPR.prize_status  = #{query.prizeStatus}
        </if>
        <if test="query.distributeStatus != null and query.distributeStatus !=''">
            AND LPR.distribute_status  = #{query.distributeStatus}
        </if>
        <if test="query.startTime != null">AND LPR.create_time >= #{query.startTime}</if>
        <if test="query.endTime != null">AND LPR.create_time &lt;= #{query.endTime}</if>
    </select>
    <select id="getByUserIdPage" resultMap="BaseResultMap">
        SELECT
        LPR.user_id,
        LPR.nick_name,
        LPR.prize_activity_id,
        LPR.prize_activity_name,
        LPR.prize_activity_cover,
        LPR.prize_status,
        LPR.prize_content,
        LPR.prize_id,
        LPR.prize_img,
        LPR.prize_num_id,
        LPR.activity_prize_ref_id,
        LPR.distribute_status,
        LPR.id,
        LPR.create_time
        FROM
        lmk_prize_record LPR
        WHERE
        LPR.delete_flag = 0
        AND LPR.user_id = #{userId}
    </select>
    <select id="getExportData" resultMap="BaseResultMap">
        SELECT
        LPR.user_id,
        LPR.nick_name,
        LPR.prize_activity_id,
        LPR.prize_activity_name,
        LPR.prize_activity_cover,
        LPR.prize_status,
        LPR.prize_content,
        LPR.prize_id,
        LPR.prize_img,
        LPR.prize_num_id,
        LPR.activity_prize_ref_id,
        LPR.distribute_status,
        LPR.create_time,
        LPR.id
        FROM
        lmk_prize_record LPR
        WHERE
        LPR.delete_flag = 0
        <if test="query.nickName != null and query.nickName !=''">
            AND LPR.nick_name like CONCAT('%',#{query.nickName},'%')
        </if>
        <if test="query.activityName != null and query.activityName !=''">
            AND LPR.prize_activity_name like CONCAT('%',#{query.activityName},'%')
        </if>
        <if test="query.prizeStatus != null and query.prizeStatus !=''">
            AND LPR.prize_status  = #{query.prizeStatus}
        </if>
        <if test="query.distributeStatus != null and query.distributeStatus !=''">
            AND LPR.distribute_status  = #{query.distributeStatus}
        </if>
        <if test="query.startTime != null">AND LPR.create_time >= #{query.startTime}</if>
        <if test="query.endTime != null">AND LPR.create_time &lt;= #{query.endTime}</if>
    </select>
    <resultMap id="getPrizeRecordListByTimeMap" type="cn.lili.modules.lmk.domain.vo.PrizeRecordTimeVO">
        <result property="activityPrizeRefId" column="activity_prize_ref_id"/>
        <result property="prizeActivityId" column="prize_activity_id"/>
        <result property="total" column="total"/>
    </resultMap>
    <select id="getPrizeRecordListByTime" resultMap="getPrizeRecordListByTimeMap">
        SELECT
            activity_prize_ref_id,
            prize_activity_id,
            count(*) total
        FROM
            lmk_prize_record
        WHERE
            prize_activity_id = #{query.recordActivityId}
          AND delete_flag = 0
          AND create_time BETWEEN #{query.startTime}
            AND #{query.endTime}
        GROUP BY
            activity_prize_ref_id,
            prize_activity_id;
    </select>
</mapper>