<?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="jnpf.cultivate.mapper.FtbCultivatePromotionNewMapper">
    <!--获取培养推广列表-->
    <select id="getList" resultType="jnpf.model.cultivate.vo.promotion.FtbCultivatePromotionNewVO">
        SELECT
        a.*,
        b.channelIniPoId,
        b.channelIniName,
        c.postChannelLevelNumber
        FROM
        (
        SELECT DISTINCT
        pr.F_Id AS id,
        pr.F_Promotion AS promotion,
        pr.F_PromotionBusinessId AS promotionBusinessId,
        pr.F_LastModifyTime AS lastModifyTime,
        pr.F_CreatorTime AS creatorTime
        FROM
        ftb_cultivate_promotion_new AS pr
        LEFT JOIN ftb_cultivate_promotion_post_new AS po ON pr.F_Id = po.F_PromotionId
        <where>
            pr.F_EnableMark=0
            <if test="dto.postId != null and dto.postId !=''">
                and  po.F_PostId =#{dto.postId}
            </if>
            <if test="dto.keyWord != null and dto.keyWord !=''">
                and  ( pr.F_Promotion like CONCAT('%',#{dto.keyWord},'%')
                or pr.F_PromotionBusinessId like CONCAT('%',#{dto.keyWord},'%')
                )
            </if>
            <if test="dto.promotionId != null and dto.promotionId !=''">
                AND pr.F_Id =#{dto.promotionId}
            </if>
        </where>
        GROUP BY
        pr.F_Id
        ) AS a
        INNER JOIN (
        SELECT
        pr.F_Id,
        po.F_PostId channelIniPoId,
        po.F_PostName channelIniName
        FROM
        ftb_cultivate_promotion_new AS pr
        LEFT JOIN ftb_cultivate_promotion_post_new AS po ON pr.F_Id = po.F_PromotionId
        WHERE
        pr.F_EnableMark = 0
        AND po.F_Level = 1
        ) AS b ON a.id = b.F_Id
        INNER JOIN (
        SELECT DISTINCT
        pr.F_Id AS id,
        COUNT( DISTINCT po.F_Level ) AS postChannelLevelNumber
        FROM
        ftb_cultivate_promotion_new AS pr
        LEFT JOIN ftb_cultivate_promotion_post_new AS po ON pr.F_Id = po.F_PromotionId
        WHERE
        pr.F_EnableMark = 0
        GROUP BY
        pr.F_Id
        ) c ON a.id = c.id
        ORDER BY
        a.creatorTime DESC,
        a.lastModifyTime DESC
    </select>
    <!--查询学习范围-->
    <select id="queryStudyScope" resultType="java.lang.Integer">
        SELECT  count(DISTINCT F_PostId) as count FROM ftb_cultivate_promotion_post_new WHERE F_PromotionId =#{id}
    </select>


    <!--获取培养推广列表-->
    <select id="getThePositionThisPersonHasChosen"
            resultType="jnpf.model.cultivate.vo.promotion.FtbCultivatePromotionMeberPostInfo">
        SELECT DISTINCT
        me.F_UserId userId,
        me.F_UserName userName,
        post.F_PostId postId,
        post.F_PostName postName
        FROM
        `ftb_cultivate_promotion_member_new` AS me
        LEFT JOIN ftb_cultivate_promotion_post_new AS post ON
        me.F_PromotionPostId = post.F_Id
        WHERE
        me.F_PromotionId = #{id} and me.F_DeleteMark=0
    </select>

    <!--查询用户选择的岗位-->
    <select id="queryUserChosesPosts" resultType="java.lang.String">
        SELECT
        DISTINCT post.F_PostName
        FROM
        ftb_cultivate_promotion_member_new AS me
        INNER JOIN ftb_cultivate_promotion_post_new AS post ON me.F_PromotionId = post.F_PromotionId
        AND me.F_PromotionPostId = post.F_Id
        WHERE
        me.F_PromotionId = #{id} and me.F_DeleteMark=0
        AND me.F_UserId = #{userId}
        UNION
        SELECT
        po.F_PostName
        FROM
        ftb_cultivate_promotion_new AS pr
        INNER JOIN ftb_cultivate_promotion_post_new AS po ON pr.F_Id = po.F_PromotionId
        WHERE
        pr.F_EnableMark = 0
        AND po.F_Level = 1
        AND pr.F_Id = #{id}
    </select>
    <!--基于岗位查看学习地图-->
    <select id="viewLearningMapBasedOnPosition"
            resultType="jnpf.model.cultivate.vo.promotion.FtbCultivateLearnMapInfoVO">
        SELECT
        DISTINCT a.*,
        CASE

        WHEN c.F_Id IS NOT NULL THEN
        "1"
        WHEN c.F_Id IS NULL THEN
        "0"
        END selectLogo
        FROM
        (
        SELECT
        intMe.*
        FROM
        ( SELECT post.F_PromotionId FROM ftb_cultivate_promotion_post_new AS post
        WHERE post.F_PostId = #{postId} AND post.F_Level = 1 ) AS intPo
        INNER JOIN (
        SELECT
        post.F_Id as studyMapJobId,
        post.F_PostId postId,
        post.F_PostName postName,
        post.F_PromotionId as promotionId
        FROM
        ftb_cultivate_promotion_post_new AS post
        LEFT JOIN ftb_cultivate_promotion_member_new AS me ON post.F_Id = me.F_PromotionPostId
        WHERE
        (me.F_DeleteMark is null or me.F_DeleteMark = 0) and
        post.F_Level = #{level}
        ) AS intMe ON intPo.F_PromotionId = intMe.promotionId
        ) a
        LEFT JOIN ( SELECT b.* FROM ftb_cultivate_promotion_member_new AS b WHERE b.F_UserId = #{userId} and b.F_DeleteMark=0) c ON a.studyMapJobId = c.F_PromotionPostId

    </select>
    <!--查询用户选择的岗位及其ID-->
    <select id="queryUserChosesPostsWitId" resultType="java.util.Map">
        SELECT
        post.F_PostName as postName,
        post.F_PostId as postId,
        me.F_CurrentLearningStage as currentLearningStage
        FROM
        ftb_cultivate_promotion_member_new AS me
        INNER JOIN ftb_cultivate_promotion_post_new AS post ON me.F_PromotionId = post.F_PromotionId
        AND me.F_PromotionPostId = post.F_Id
        WHERE
        me.F_PromotionId = #{promotionId} and me.F_DeleteMark=0
        AND me.F_UserId = #{userId}
        <if test="level != null">
            AND post.F_Level = #{level}
        </if>
    </select>

    <!--查询用户选择的岗位及其ID-->
    <select id="queryUserChosesPositionIdWidthId" resultType="jnpf.model.cultivate.dto.course.FtbCultivateSelectPositionDto">
        SELECT
        post.F_PostName as postName,
        post.F_PostId as postId,
        me.F_CurrentLearningStage as currentLearningStage
        FROM
        ftb_cultivate_promotion_member_new AS me
        INNER JOIN ftb_cultivate_promotion_post_new AS post ON me.F_PromotionId = post.F_PromotionId
        AND me.F_PromotionPostId = post.F_Id
        WHERE
        me.F_PromotionId = #{promotionId} and me.F_DeleteMark=0
        AND me.F_UserId = #{userId}
    </select>
    <!--查询推广活动的阶段数量-->
    <select id="queryHowManyStages" resultType="java.lang.Integer">
        SELECT
        COUNT( DISTINCT po.F_Level ) AS postChannelLevelNumber
        FROM
        ftb_cultivate_promotion_new AS pr
        LEFT JOIN ftb_cultivate_promotion_post_new AS po ON pr.F_Id = po.F_PromotionId
        WHERE
        pr.F_EnableMark = 0
        AND pr.F_Id =#{promotionId}

    </select>
    <!--在职学习课程查询-->
    <select id="onTheJobLearningCourse" resultType="jnpf.model.cultivate.vo.course.app.FtbGlobalCurriculumAppVO">
        SELECT a.F_CourseId as courseId,b.F_Name as courseName,b.F_Highlights as courseHighlights,c.F_state as learnState,
        a.F_PostRankId as postId
        FROM ftb_cultivate_position_course a JOIN ftb_cultivate_course b ON a.F_CourseId = b.F_Id
        JOIN ftb_cultivate_position_cource_learning c ON a.F_CourseId=c.F_CourceId
        join ftb_cultivate_position d on d.F_Id=a.F_PostLearnId
        WHERE a.F_EnabledMark = 0 AND b.F_EnabledMark = 0 and c.F_EnabledMark = 0
        and b.F_IsGrounding = 1 and d.F_EnabledMark = 0
        and d.F_IsGrounding = 1
        and b.F_Label = 2
        and c.F_UserId = #{userId} and
        <foreach collection="postIds" item="item" open="(" close=")" separator="OR">
            a.F_PostRankId = #{item}
        </foreach>
        <if test="compulsory != null ">
            and a.F_Compulsory = #{compulsory}
        </if>
        GROUP BY a.F_CourseId
        order by c.F_state ASC
    </select>

    <select id="onTheJobLearningCourseNew" resultType="jnpf.model.cultivate.vo.course.app.FtbGlobalCurriculumAppVO">
        SELECT
        DISTINCT a.F_CourseId as courseId,
        b.F_Name as courseName,
        b.F_Highlights as courseHighlights,
        IFNULL(
        (SELECT F_state FROM ftb_cultivate_position_cource_learning AS c
        WHERE a.F_CourseId = c.F_CourceId AND c.F_UserId = #{userId} AND c.F_EnabledMark = 0),
        0
        ) AS learnState,
        a.F_PostRankId as postId
        FROM ftb_cultivate_position_course a
        JOIN ftb_cultivate_course b ON a.F_CourseId = b.F_Id
        JOIN ftb_cultivate_position d ON d.F_Id = a.F_PostLearnId

        WHERE a.F_EnabledMark = 0 AND b.F_EnabledMark = 0
        and b.F_IsGrounding = 1 and d.F_EnabledMark = 0
        and d.F_IsGrounding = 1
        and b.F_Label = 2
        and
        <foreach collection="postIds" item="item" open="(" close=")" separator="OR">
            a.F_PostRankId = #{item}
        </foreach>
        <if test="compulsory != null ">
            and a.F_Compulsory = #{compulsory}
        </if>
        GROUP BY a.F_CourseId order by learnState asc
    </select>
    <!--基于岗位ID查询已选人员-->
    <select id="querySelectedPersonnelBasedOnPositionID" resultType="java.lang.String">
        SELECT DISTINCT
        me.F_UserId
        FROM
        ftb_cultivate_promotion_post_new AS post
        INNER JOIN ftb_cultivate_promotion_member_new AS me ON post.F_PromotionId = me.F_PromotionId
        WHERE
        (me.F_DeleteMark is null or me.F_DeleteMark = 0) and
        post.F_PostId in
        <foreach collection="postIds" item="postId" open="(" close=")" separator=",">
            #{postId}
        </foreach>
    </select>
    <!--查询实践考核学习数量-->
    <select id="queryTheNumberOfPracticalAppraisalStudies" resultType="java.lang.Integer">
        SELECT
        count(0)
        FROM
        ftb_cultivate_position_identify_result AS re
        INNER JOIN ftb_cultivate_identify_apply AS apy ON re.F_IdentifyRecordId = apy.F_Id
        INNER JOIN ftb_cultivate_identify_apply_table_backups AS item ON apy.F_TableId = item.F_Id
        WHERE apy.F_BeIdentifyUserId =#{userId}
        <if test="studyPostIds != null  and studyPostIds.size() > 0">
            AND re.F_PostRankId  in
            <foreach collection="studyPostIds" item="item" open="(" close=")" separator="OR">
                #{item}
            </foreach>
        </if>
        AND	 apy.F_Id in
        <foreach collection="isAPracticalAppraisalIds" item="item" open="(" close=")" separator="OR">
            #{item}
        </foreach>
        <if test="learningMapSetting == 0">
            AND apy.F_Status = 1
        </if>
        <if test="learningMapSetting == 1">
            AND apy.F_Status = 1
            AND apy.F_Result in ( 0,1)
        </if>

        AND apy.F_DeleteMark=0
    </select>
    <!--检查岗位是否有考试-->
    <select id="checkIfThereAreExamsForThisPosition" resultType="java.lang.Integer">
        SELECT
        COUNT(*)
        FROM
        ftb_cultivate_position_exam a
        JOIN ftb_cultivate_position b ON a.F_PostLearnId = b.F_Id
        WHERE
        a.F_EnabledMark = 0
        AND b.F_EnabledMark = 0
        AND a.F_PostRankId = #{postId}
    </select>
    <!--检查岗位是否有实践考核-->
    <select id="checkWhetherThereIsAPracticalAppraisal" resultType="java.lang.String">
        SELECT
        a.F_IdentifyId
        FROM
        ftb_cultivate_position_exam_identify a
        JOIN ftb_cultivate_position b ON a.F_PostLearnId = b.F_Id
        WHERE
        a.F_EnabledMark = 0
        AND b.F_EnabledMark = 0
        AND a.F_PostRankId = #{postId}
    </select>
    <!--查询用户选择的岗位ID-->
    <select id="queryChosePostId" resultType="java.lang.String">
        SELECT DISTINCT
        post.F_PostId,
        post.F_PostName
        FROM
        ftb_cultivate_promotion_member_new AS me
        INNER JOIN ftb_cultivate_promotion_post_new AS post ON me.F_PromotionId = post.F_PromotionId
        AND me.F_PromotionPostId = post.F_Id
        WHERE
        (me.F_DeleteMark is null or me.F_DeleteMark = 0) and
        me.F_PromotionId = #{id}
        AND me.F_UserId =  #{userId}
        UNION
        SELECT
        po.F_PostId,
        po.F_PostName
        FROM
        ftb_cultivate_promotion_new AS pr
        INNER JOIN ftb_cultivate_promotion_post_new AS po ON pr.F_Id = po.F_PromotionId
        WHERE
        pr.F_EnableMark = 0
        AND po.F_Level = 1
        AND pr.F_Id = #{id}
    </select>
    <!--查询用户学习过的岗位信息-->
    <select id="queryTheUserSLearnedPositionInformation"
            resultType="jnpf.model.cultivate.po.promotion.FtbCultivatePromotionMemberNew">
        SELECT DISTINCT
        me.F_UserId userId,
        CONCAT(me.F_OrgName,'_',me.F_PositionName,'_',me.F_GradeName) as organizationInformation,
        CONCAT(me.F_PositionName,'(',me.F_GradeName,')') as postInfo,
        me.F_CurrentLearningStage currentLearningStage,
        me.F_UserName userName
        FROM
        ftb_cultivate_position_cource_learning a
        JOIN ftb_cultivate_position_course b ON a.F_CourceId = b.F_CourseId
        JOIN ftb_cultivate_promotion_member_new AS me ON me.F_UserId = a.F_UserId
        JOIN ftb_cultivate_promotion_post_new AS po ON me.F_PromotionId = po.F_PromotionId
        JOIN ftb_cultivate_course as course ON b.F_CourseId = course.F_Id
        WHERE
        b.F_EnabledMark = 0 and me.F_DeleteMark = 0 and a.F_EnabledMark=0
        AND course.F_EnabledMark = 0
        AND a.F_state IN ( 1, 2 )
        AND me.F_PositionId =#{channelIniId}
        AND po.F_PostId =#{channelIniId}
        AND po.F_Level =1
        AND me.F_PromotionId =#{id}
    </select>
    <!--查询学习过的岗位ID-->
    <select id="doQueryTheLearnedPositionIdFirst" resultType="java.util.Map">
        SELECT a.F_PostRankId as postId,GROUP_CONCAT(a.F_CourseId) as courseIds
        FROM ftb_cultivate_position_course a JOIN ftb_cultivate_course b ON a.F_CourseId = b.F_Id WHERE a.F_EnabledMark = 0
        AND b.F_EnabledMark = 0 and b.F_IsGrounding = 1
        <if test="postId != null and  postId != ''">
            AND a.F_PostRankId =#{postId}
        </if>
        AND b.F_Label = 2
        and a.F_Compulsory = 0
        GROUP BY a.F_PostRankId
    </select>
    <!--查询用户学习进度-->
    <select id="doQueryTheLearnedPositionIdSecond" resultType="java.lang.Integer">
        SELECT COUNT(distinct a.F_CourceId)
        FROM ftb_cultivate_position_cource_learning a join ftb_cultivate_course b on a.F_CourceId = b.F_Id
        <where>
            a.F_UserId = #{userId} and b.F_EnabledMark = 0 and b.F_IsGrounding = 1 and a.F_EnabledMark = 0
            AND a.F_CourceId IN
            <foreach collection="studyPostIds" separator="," open="("  close=")" item="item">
                #{item}
            </foreach>
            <if test="state !=null and state.size() > 0">
                and a.F_state in
                <foreach collection="state" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
    <!--查询推广活动的岗位ID列表-->
    <select id="queryMapPostId" resultType="java.lang.String">
        SELECT DISTINCT
        po.F_PostId
        FROM
        ftb_cultivate_promotion_post_new AS po
        LEFT JOIN ftb_cultivate_promotion_new AS pr ON pr.F_Id = po.F_PromotionId
        WHERE
        pr.F_Id = #{promotionId}
    </select>
    <!--检查岗位是否有课程-->
    <select id="checkIfThePositionHasCourses" resultType="java.lang.Integer">
        SELECT
        count( 0 )
        FROM
        ftb_cultivate_position_course AS po
        INNER JOIN ftb_cultivate_course AS co ON po.F_CourseId = co.F_Id
        WHERE
        co.F_EnabledMark = 0
        AND po.F_EnabledMark = 0
        AND co.F_IsGrounding = 1
        AND po.F_PostRankId = #{postId}
    </select>
    <!--查询用户学习进度-->
    <select id="doQueryTheLearnedPositionIdSecondNew" resultType="jnpf.model.personnels.vo.apply.FtbPersonnelsCourseVO">
        SELECT COUNT(distinct a.F_CourceId) as count,
        a.F_UserId as userId
        FROM ftb_cultivate_position_cource_learning a join ftb_cultivate_course b on a.F_CourceId = b.F_Id
        <where>
           b.F_EnabledMark = 0 and b.F_IsGrounding = 1 and a.F_EnabledMark = 0
            AND a.F_CourceId IN
            <foreach collection="studyPostIds" separator="," open="("  close=")" item="item">
                #{item}
            </foreach>
            <if test="state !=null and state.size() > 0">
                and a.F_state in
                <foreach collection="state" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="userIds !=null and userIds.size() > 0">
                and a.F_UserId IN
                <foreach collection="userIds" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        group by a.F_UserId
    </select>
    <!--检查岗位是否有实践考核-->
    <select id="checkWhetherThereIsAPracticalAppraisalWithNew" resultType="java.lang.String">

        SELECT
        DISTINCT a.F_IdentifyRecordId
        FROM
        ftb_cultivate_position_identify_result a
        JOIN ftb_cultivate_position b ON a.F_PostLearnId = b.F_Id
        WHERE
        a.F_EnabledMark = 0
        AND b.F_EnabledMark = 0
        AND a.F_PostRankId = #{postId}
        AND a.F_UserId = #{userId}
        and a.F_Type=0
        ORDER BY a.F_CreatorTime DESC
        limit 1

    </select>
    <!--检查岗位是否有考试-->
    <select id="checkIfThereAreExamsForThisPositionWithNew" resultType="java.lang.String">
        SELECT
            F_Id
        FROM
            ftb_cultivate_exam_user
        WHERE
            F_RelationPositionId = #{postId}
          AND F_UserId = #{userId}
          AND F_ExamSource = 2
        ORDER BY
            F_CreatorTime DESC
        LIMIT 1
    </select>
    <select id="selectPromoteList" resultType="jnpf.model.cultivate.po.promotion.FtbCultivatePromotionPostNew">
        select F_Id as id,F_PromotionId as promotionId,F_Level as level,F_PostId as postId,F_SelectCourseNumber as selectCourseNumber from ftb_cultivate_promotion_post_new
        where  F_PromotionId = #{pomotionId}
        order by F_Level asc
    </select>
    <select id="selectAllPromoteList"
            resultType="jnpf.model.cultivate.po.promotion.FtbCultivatePromotionPostNew">
        select F_Id as id,F_PromotionId as promotionId,F_Level as level,F_PostId as postId,F_SelectCourseNumber as selectCourseNumber from ftb_cultivate_promotion_post_new
        where  F_PromotionId = #{pomotionId}
        order by F_Level asc
    </select>

    <select id="countByPositionIds" resultType="jnpf.model.cultivate.v2.promotion.vo.PromotionAndPostVo">
        SELECT  distinct  p1.F_Id as promotionId,p1.F_Promotion as promotion, p2.F_PostId as postId
        FROM ftb_cultivate_promotion_new AS p1
        LEFT JOIN ftb_cultivate_promotion_post_new p2 ON p1.F_Id = p2.F_PromotionId
        WHERE p1.F_EnableMark=0
        AND p2.F_DeleteMark=0
        AND p2.F_PostId IN
        <foreach collection="positionIds" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>
    </select>

    <select id="webList" resultType="jnpf.model.cultivate.v2.promotion.vo.WebCultivatePromotionListVo">
        SELECT
        prop.F_Id AS id,
        prop.F_Promotion AS promotion,
        prop.F_PromotionBusinessId AS promotionBusinessId,
        prop.F_IsError AS isError,
        prop.F_LastModifyTime AS lastModifyTime,
        prop.F_CreatorTime AS creatorTime,
        MAX(prop_post.F_Level) AS phaseNumber
        FROM
        ftb_cultivate_promotion_new AS prop
        left join ftb_cultivate_promotion_post_new AS prop_post ON prop.F_Id = prop_post.F_PromotionId
        WHERE
        prop.F_EnableMark = 0
        AND prop_post.F_DeleteMark = 0
        <if test="params.keyWord != null and params.keyWord != ''">
            AND (prop.F_PromotionBusinessId = #{params.keyWord} OR prop.F_Promotion LIKE CONCAT('%', #{params.keyWord},
            '%'))
        </if>
        <if test="params.postId != null and params.postId != ''">
            AND prop_post.F_PostId = #{params.postId}
        </if>
        GROUP BY
        prop.F_Id
        ORDER BY prop.F_CreatorTime DESC
    </select>

    <select id="queryMaxLevel" resultType="jnpf.model.cultivate.dto.learn.BatchCommonCountDto">
        SELECT F_PromotionId as selectKey, max(F_Level) as num
        FROM ftb_cultivate_promotion_post_new
        WHERE F_DeleteMark = 0
        <if test="promotionIds != null and promotionIds.size()>0">
           and  F_PromotionId IN
            <foreach collection="promotionIds" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY F_PromotionId
    </select>

    <select id="personStatisticsV2"
            resultType="jnpf.model.cultivate.v2.promotion.vo.V2CultivatePromotionPersonStatisticVo">
        SELECT a.F_Id                  AS promotionId,
               a.F_Promotion           AS promotionName,
               a.F_PromotionBusinessId AS promotionBusinessId,
               a.F_CreatorTime         AS creationTime,
               b.F_UserId              AS userId
        FROM ftb_cultivate_promotion_new AS a
                 join ftb_cultivate_promotion_user as b on a.F_Id = b.F_PromotionId
        where a.F_EnableMark = 0
          and b.F_EnabledMark = 0
        <if test="params.keyWord != null and params.keyWord != ''">
            and (a.F_PromotionBusinessId = #{params.keyWord} OR a.F_Promotion LIKE CONCAT('%', #{params.keyWord}, '%'))
        </if>

        <if test="userIds != null and userIds.size()>0">
            and b.F_UserId IN
            <foreach collection="userIds" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        <if test="params.startTime != null and params.endTime != null">
            and  a.F_CreatorTime between #{params.startTime} and #{params.endTime}
        </if>
    </select>

    <select id="queryPromotionPosition" resultType="jnpf.model.cultivate.v2.position.vo.CultivateUserPositionVo">
        SELECT
            p.F_PostId as postId,
            u.F_UserId as userId
        FROM ftb_cultivate_promotion_user u
                 INNER JOIN ftb_cultivate_promotion_post_new p ON u.F_PromotionId = p.F_PromotionId
        WHERE u.F_EnabledMark = 0
          AND p.F_DeleteMark = 0

        <if test="userIds != null and userIds.size()>0">
            and u.F_UserId IN
            <foreach collection="userIds" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>

    </select>

    <select id="mapStatisticPageV2"
            resultType="jnpf.model.cultivate.v2.promotion.vo.V2CultivatePromotionOrgStatisticVo">
        SELECT
            a.F_Id AS promotionId,
            a.F_Promotion AS promotionName,
            a.F_PromotionBusinessId AS promotionBusinessId,
            a.F_CreatorTime AS creationTime
        FROM ftb_cultivate_promotion_new AS a
        WHERE a.F_EnableMark = 0
        <if test="params.keyWord != null and params.keyWord != ''">
            and a.F_Promotion LIKE CONCAT('%', #{params.keyWord}, '%')
        </if>
        <if test="params.startTime != null and params.endTime != null">
            and  a.F_CreatorTime between #{params.startTime} and #{params.endTime}
        </if>

    </select>

    <select id="userCountForPromotion" resultType="jnpf.model.cultivate.dto.learn.BatchCommonCountDto">
        SELECT F_PromotionId as selectKey, count(F_UserId) as num, GROUP_CONCAT(F_UserId SEPARATOR ',') as userIds
        FROM ftb_cultivate_promotion_user
        WHERE F_EnabledMark = 0
        <if test="userIds!= null and userIds.size()>0">
           and  F_UserId IN
            <foreach collection="userIds" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY F_PromotionId
    </select>

    <select id="queryPositionNumForMap" resultType="jnpf.model.cultivate.dto.learn.BatchCommonCountDto">
        SELECT F_PromotionId as selectKey, count(F_PostId) as num
        FROM ftb_cultivate_promotion_post_new
        WHERE F_DeleteMark = 0
        <if test="promotionIds != null and promotionIds.size()>0">
           and  F_PromotionId IN
            <foreach collection="promotionIds" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        GROUP BY F_PromotionId
    </select>
</mapper>