<?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.member.base.mapper.CuMemberRetailDetailMapper">

    <select id="getChildList" resultType="com.hzs.member.structure.controller.vo.ChildCodeVO">
        SELECT
            cud.CHILD_NODE
        FROM
            CU_MEMBER cu LEFT JOIN
            ${ settleTableName } cud ON cu.PK_ID = cud.PK_MEMBER
        WHERE
          cu.MEMBER_CODE = #{ memberCode }
          AND cud.STAGE = #{ stage }
        <if test="stageStatus != null">
            and cud.STAGE_STATUS = #{stageStatus}
        </if>
    </select>

    <select id="getFindCumemberRetailDetail" resultType="java.lang.Integer">
        select 1
        from user_tables
        where table_name = upper(#{settleTableName})
    </select>
    <select id="getCuMemberRetailDetailExt"
            resultType="com.hzs.common.domain.member.achieve.CuMemberRetailDetail">
        SELECT
            cud.*
        FROM
            CU_MEMBER cu
                LEFT JOIN ${ settleTableName } cud ON cu.PK_ID = cud.PK_MEMBER
        WHERE
            cu.MEMBER_CODE = #{ memberCode }
          AND STAGE = #{stage}
          <if test="stageStatus != null">
              and cud.STAGE_STATUS = #{stageStatus}
          </if>
          AND CHILD_NODE = #{childNode}
    </select>
</mapper>
