<?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="com.hzs.bonus.base.mapper.CuAwardsControlMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.base.CuAwardsControl">
        <id column="PK_ID" property="pkId" />
    <result column="DEL_FLAG" property="delFlag" />
    <result column="PK_COUNTRY" property="pkCountry" />
    <result column="CREATION_TIME" property="creationTime" />
    <result column="MODIFIED_TIME" property="modifiedTime" />
    <result column="PK_CREATOR" property="pkCreator" />
    <result column="PK_MODIFIED" property="pkModified" />
        <result column="REAL_AWARDS" property="realAwards" />
        <result column="MENTORING_AWARD" property="mentoringAward" />
        <result column="DIVIDEND_AWARD" property="dividendAward" />
        <result column="EXTREME_AWARDS" property="extremeAwards" />
        <result column="REPLY_EXAM_AWARD" property="replyExamAward" />
        <result column="DIVVY_EXAM_AWARDS" property="divvyExamAwards" />
        <result column="PK_MEMBER" property="pkMember" />

    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        DEL_FLAG,
        PK_COUNTRY,
        CREATION_TIME,
        MODIFIED_TIME,
        PK_CREATOR,
        PK_MODIFIED,
        PK_ID, REAL_AWARDS, MENTORING_AWARD, DIVIDEND_AWARD, EXTREME_AWARDS, REPURCHASE_ASSESSMENT_AWARD, DIVIDEND_ASSESSMENT_AWARDS
    </sql>

<!--    查询奖衔控制列表-->
    <select id="queryAwardsControlList" parameterType="com.hzs.bonus.base.vo.CuAwardsControlVO"
            resultType="com.hzs.bonus.base.vo.CuAwardsControlVO">
        select
        me.MEMBER_CODE memberCode,
        me.MEMBER_NAME memberName,
        a.PK_ID pkID,
        a.pk_Member pkMember,
        a.REAL_AWARDS realAwards,
        a.MENTORING_AWARD mentoringAward,
        a.DIVIDEND_AWARD dividendAward,
        a.EXTREME_AWARDS extremeAwards,
        a.REPLY_EXAM_AWARD replyExamAward,
        a.DIVVY_EXAM_AWARDS divvyExamAwards,
        b.PK_TRANSACTION realAwardsKey,
        c.PK_TRANSACTION mentoringAwardKey,
        d.PK_TRANSACTION dividendAwardKey,
        e.PK_TRANSACTION extremeAwardsKey,
        f.PK_TRANSACTION replyExamAwardKey,
        g.PK_TRANSACTION divvyExamAwardsKey
        from CU_AWARDS_CONTROL a
        left join CU_MEMBER me on me.PK_ID=PK_MEMBER
        left JOIN BD_AWARDS b on b.PK_ID=a.REAL_AWARDS
        left JOIN BD_AWARDS c on c.PK_ID=a.MENTORING_AWARD
        left JOIN BD_AWARDS d on d.PK_ID=a.DIVIDEND_AWARD
        left JOIN BD_AWARDS e on e.PK_ID=a.EXTREME_AWARDS
        left JOIN BD_AWARDS f on f.PK_ID=a.REPLY_EXAM_AWARD
        left JOIN BD_AWARDS g on g.PK_ID=a.DIVVY_EXAM_AWARDS
        WHERE
        a.DEL_FLAG = 0 and me.DEL_FLAG = 0
        <if test="memberCode != null and memberCode !='' ">
            AND me.MEMBER_CODE like #{memberCode} || '%'
        </if>
        <if test="memberCodeList != null and memberCodeList.size >0">
            and me.MEMBER_CODE in
            <foreach collection="memberCodeList" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="pkMemberList != null and pkMemberList.size >0">
            and a.PK_MEMBER in
            <foreach collection="pkMemberList" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="memberName != null and memberName !='' ">
            AND me.MEMBER_NAME like #{memberName} || '%'
        </if>
        <if test="realAwards != null ">
            AND a.REAL_AWARDS = #{realAwards}
        </if>

        <if test="mentoringAward != null ">
            AND a.MENTORING_AWARD = #{mentoringAward}
        </if>
        <if test="dividendAward != null ">
            AND a.DIVIDEND_AWARD = #{dividendAward}
        </if>
        <if test="extremeAwards != null ">
            AND a.EXTREME_AWARDS = #{extremeAwards}
        </if>

        <if test="replyExamAward != null ">
            AND a.REPLY_EXAM_AWARD = #{replyExamAward}
        </if>
        <if test="divvyExamAwards != null ">
            AND a.DIVVY_EXAM_AWARDS = #{divvyExamAwards}
        </if>
        <if test="pkCountry != null ">
            AND a.pk_Country = #{pkCountry}
        </if>
        order by a.PK_ID desc
    </select>

</mapper>





