<?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.pluss.platform.mapper.UserPromotionMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.UserPromotion">
        <id column="id" property="userId" jdbcType="VARCHAR" />
        <result column="user_id" property="userId" />
        <result column="type_code" property="typeCode" />
        <result column="current_fee" property="currentFee" />
        <result column="parent_user_id" property="parentUserId" />
        <result column="create_time" property="createTime" />
        <result column="is_extend" property="isExtend" />
        <result column="update_time" property="updateTime" />
    </resultMap>
    <sql id="Base_Column_List">
        user_id, type_code, current_fee, parent_user_id, is_extend, create_time, update_time
    </sql>
    <update id="updateByPrimaryKey">
        update tb_pluss_user_promotion
        set type_code = #{typeCode,jdbcType=VARCHAR},
            current_fee = #{currentFee,jdbcType=DECIMAL},
            parent_user_id = #{parentUserId,jdbcType=VARCHAR},
            is_extend = #{isExtend,jdbcType=VARCHAR},
            create_time = #{createTime,jdbcType=TIMESTAMP},
            update_time = #{updateTime,jdbcType=TIMESTAMP}
        where user_id = #{userId,jdbcType=INTEGER}
    </update>
    <select id="selectListByUserId" resultType="cn.pluss.platform.entity.UserProfit">
        SELECT * FROM tb_pluss_user_promotion WHERE `user_id` IN
        <foreach open="(" separator="," close=")" collection="userIdList" item="item">
            #{item}
        </foreach>
    </select>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap">
        select *
        from tb_pluss_user_promotion
        where user_id = #{userId}
    </select>
    <select id="selectByUserIdMC" resultType="cn.pluss.platform.entity.UserPromotion">
        select user_id AS userId,type_code AS typeCode,current_fee AS currentFee,parent_user_id AS parentUserId,
               is_extend AS isExtend,create_time AS createTime,update_time AS updateTime
        from tb_pluss_user_promotion
        <where>
            user_id = #{userId}
        AND type_code = 'MC'
        AND is_extend = '1'
        </where>
    </select>


</mapper>
