<?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.FtbCultivatePromotionUserMapper">
    <select id="queryUserForPage" resultType="jnpf.model.cultivate.v2.promotion.vo.V2CultivatePromotionMemberVo">
        SELECT
        F_UserId as userId
        FROM
        ftb_cultivate_promotion_user
        WHERE
        F_PromotionId = #{promotionId}
        AND F_EnabledMark = 0
        <if test="queryUserIds != null and queryUserIds.size() > 0 ">
            and F_UserId in
            <foreach collection="queryUserIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="queryMyAllPromotionList" resultType="jnpf.model.cultivate.v2.promotion.vo.MyCultivatePromotionListVo">
        SELECT
            p.F_Id as id,
            p.F_Promotion as promotion,
            p.F_PromotionBusinessId as promotionBusinessId,
            p.F_LearningMapSetting as learningMapSetting,
            u.F_UserId as userId,
            u.F_CreatorTime as creatorTime,
            u.F_UserSelect as userSelect
        FROM ftb_cultivate_promotion_user u
                 INNER JOIN ftb_cultivate_promotion_new p ON u.F_PromotionId = p.F_Id
        WHERE u.F_UserId = #{userId}
          AND u.F_EnabledMark = 0
          AND p.F_EnableMark = 0
          AND p.F_IsError = 0

    </select>

    <select id="queryMyPromotionById" resultType="jnpf.model.cultivate.v2.promotion.vo.MyCultivatePromotionListVo">
        SELECT
            p.F_Id as id,
            p.F_Promotion as promotion,
            p.F_PromotionBusinessId as promotionBusinessId,
            p.F_LearningMapSetting as learningMapSetting,
            u.F_UserId as userId,
            u.F_CreatorTime as creatorTime,
            u.F_UserSelect as userSelect
        FROM ftb_cultivate_promotion_user u
                 INNER JOIN ftb_cultivate_promotion_new p ON u.F_PromotionId = p.F_Id
        WHERE u.F_UserId = #{userId}
          AND u.F_PromotionId = #{promotionId}
          AND u.F_EnabledMark = 0
          AND p.F_EnableMark = 0
          AND p.F_IsError = 0
        LIMIT 1
    </select>
</mapper>