EvalUserPoolDao.xml 5.94 KB
<?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>