<?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.risk.mapper.CuMemberRiskControlMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.bonus.risk.CuMemberRiskControl">

        <id column="PK_ID" property="pkId" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_COUNTRY" property="pkCountry" />
        <result column="PK_CREATOR" property="pkCreator" />
        <result column="CREATION_TIME" property="creationTime" />
        <result column="PK_MODIFIED" property="pkModified" />
        <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="PK_MEMBER" property="pkMember" />
        <result column="START_DATE" property="startDate" />
        <result column="END_DATE" property="endDate" />
        <result column="EXPAND_RATIO" property="expandRatio" />
        <result column="COACH_GENERATION" property="coachGeneration" />
        <result column="ACHIEVE_RATIO" property="achieveRatio" />
    </resultMap>

    <select id="queryByList" resultType="com.hzs.bonus.risk.vo.MemberRiskControlVo">


           select cm.MEMBER_NAME memberName,cm.MEMBER_CODE memberCode ,cmr.PK_ID pkId,
                  cmr.PK_MEMBER pkMember,cmr.START_DATE startDate, cmr.END_DATE endDate ,
                  cmr.EXPAND_RATIO expandRatio,cmr.COACH_GENERATION  coachGeneration,
        cmr.DIRECT_PUSH_RATIO  directPushRatio,cmr.MANAGER_RATIO managerRatio,
        cmr.LEADER_RATIO  leaderRatio, cmr.REPURCHASE_INCOME  repurchaseIncome ,
        cmr.WEIGHTING_INCOME  weightingIncome,cmr.SEE_POINT_AWARD  seePointAward,
        cmr.RANGE_INCOME  rangeIncome,cmr.STORE_REVENUE  storeRevenue,cmr.ACHIEVE_RATIO achieveRatio
        from CU_MEMBER_RISK_CONTROL cmr
           left join cu_member cm on cm.PK_ID = cmr.PK_MEMBER
           where cmr.DEL_FLAG = 0
        <if test="pkCountry != null">
            and cmr.PK_COUNTRY = #{pkCountry}
        </if>
        <if test="memberCode != null and memberCode != ''">
            and cm.MEMBER_CODE like  '%' || #{memberCode} || '%'
        </if>
        <if test="beginStartDate != null">
            and cmr.START_DATE &gt;= #{beginStartDate}
        </if>
        <if test="endStartDate != null">
            and cmr.START_DATE &lt;= #{endStartDate}
        </if>
        <if test="beginEndDate != null">
            and cmr.END_DATE &gt;= #{beginEndDate}
        </if>
        <if test="endEndDate != null">
            and cmr.END_DATE &lt;= #{endEndDate}
        </if>


    </select>

</mapper>
