EvalUserPoolDao.xml
5.94 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
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
<?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.fw.morax.dao.eval.EvalUserPoolDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.fw.morax.domain.db.eval.EvalUserPool">
<result column="id" property="id"/>
<result column="eval_group_rank_id" property="evalGroupRankId"/>
<result column="eval_group_rank_stage_id" property="evalGroupRankStageId"/>
<result column="egc" property="egc"/>
<result column="eval_group_id" property="evalGroupId"/>
<result column="user_id" property="userId"/>
<result column="user_name" property="userName"/>
<result column="post_id" property="postId"/>
<result column="post_name" property="postName"/>
<result column="shop_id" property="shopId"/>
<result column="shop_name" property="shopName"/>
<result column="fund_shop_id" property="fundShopId"/>
<result column="fund_shop_name" property="fundShopName"/>
<result column="reward" property="reward"/>
<result column="score" property="score"/>
<result column="score_ratio" property="scoreRatio"/>
<result column="rank" property="rank"/>
<result column="inclusion" property="inclusion"/>
<result column="data_date" property="dataDate"/>
<result column="monthly" property="monthly"/>
<result column="group_id" property="groupId"/>
<result column="yn" property="yn"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="all_columns">
id,eval_group_rank_id,eval_group_rank_stage_id,egc,eval_group_id,user_id,user_name,post_id
,post_name,shop_id,shop_name,fund_shop_id,fund_shop_name
,reward,score,score_ratio,rank,inclusion,data_date
,monthly,group_id,yn,create_time,update_time
</sql>
<select id="getLastPool" resultType="cn.fw.morax.domain.db.eval.EvalUserPool">
SELECT
t1.id
,t1.eval_group_rank_id
,t1.eval_group_rank_stage_id
,t1.egc
,t1.eval_group_id
,t1.user_id
,t1.user_name
,t1.post_id
,t1.post_name
,t1.shop_id
,t1.shop_name
,t1.fund_shop_id
,t1.fund_shop_name
,t1.reward
,t1.score
,t1.score_ratio
,t1.rank
,t1.inclusion
,t1.data_date
,t1.monthly
,t1.group_id
FROM
eval_user_pool t1,
(
SELECT CONVERT
( SUBSTRING_INDEX( group_concat( id ORDER BY `create_time` DESC ), ',', 1 ), SIGNED ) pk
FROM
eval_user_pool
WHERE
DATE_FORMAT( create_time, '%Y-%m' ) >= #{monthly}
AND group_id = #{groupId}
AND yn = 1
GROUP BY
user_id
) t2
WHERE
t1.id = t2.pk
</select>
<select id="queryPagePool" resultType="cn.fw.morax.domain.vo.eval.EvalUserPoolVO">
SELECT
<include refid="all_columns"/>
from eval_user_pool
where yn = 1
and group_id = #{condition.groupId}
<if test="condition.userId !=null">
and user_id = #{condition.userId}
</if>
<if test="condition.userName !=null and condition.userName != ''">
and user_name like concat('%', #{condition.userName}, '%')
</if>
<if test="condition.monthly !=null">
and monthly = #{condition.monthly}
</if>
<if test="condition.postId !=null">
and post_id = #{condition.postId}
</if>
<if test="condition.postName !=null and condition.postName != ''">
and post_name like concat('%', #{condition.postName}, '%')
</if>
<if test="condition.shopId !=null">
and shop_id = #{condition.shopId}
</if>
<if test="condition.shopName !=null and condition.shopName != ''">
and shop_name like concat('%', #{condition.shopName}, '%')
</if>
<if test="condition.managerStaffIds !=null and condition.managerStaffIds.size() > 0">
and user_id in
<foreach collection="condition.managerStaffIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="condition.orderString != null and condition.orderString !='' ">
${condition.orderString}
</if>
limit #{startIndex},#{pageSize};
</select>
<select id="queryPagePoolTotal" resultType="java.lang.Long">
SELECT
IFNULL(count(1),0)
from eval_user_pool
where yn = 1
and group_id = #{groupId}
<if test="userId !=null">
and user_id = #{userId}
</if>
<if test="userName !=null and userName != ''">
and user_name like concat('%', #{userName}, '%')
</if>
<if test="monthly !=null">
and monthly = #{monthly}
</if>
<if test="postId !=null">
and post_id = #{postId}
</if>
<if test="postName !=null and postName != ''">
and post_name like concat('%', #{postName}, '%')
</if>
<if test="shopId !=null">
and shop_id = #{shopId}
</if>
<if test="shopName !=null and shopName != ''">
and shop_name like concat('%', #{shopName}, '%')
</if>
<if test="managerStaffIds !=null and managerStaffIds.size() > 0">
and user_id in
<foreach collection="managerStaffIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</select>
</mapper>