<?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.statis.mapper.CuBonusVertexStatisMapper">

    <!-- 奖金拨比列表-->
    <select id="queryCuBonusStatis" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO">
        SELECT
        cm.MEMBER_CODE,
        cm.MEMBER_NAME,
        cbs.PK_ID,
        cbs.PERIOD,
        cbs.CREATION_TIME,
        cbs.PK_COUNTRY,
        cbs.MAIN_REG_AMOUNT,
        cbs.MAIN_UP_AMOUNT,
        cbs.MAIN_REPUR_AMOUNT,
        cbs.RETAIL_CONSUME_AMOUNT,

        cbs.REAL_INCOME_TOTAL,
        cbs.INTRODUCE_BONUS,
        cbs.STORE_INCOME,
        cbs.GLOBAL_POINTS,
        cbs.RETAIL_RANGE_INCOME,
        cbs.RETAIL_SAME_LEVEL_INCOME,

        cbs.RANGE_INCOME_41,
        cbs.RANGE_INCOME_43,
        cbs.RANGE_INCOME_47,
        cbs.SAME_LEVEL_INCOME_41,
        cbs.SAME_LEVEL_INCOME_43

        FROM CU_BONUS_VERTEX_STATIS cbs
        LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX AND cm.DEL_FLAG = 0
        WHERE 1=1
        <if test="pkCountry != null">
            and cbs.PK_COUNTRY = #{pkCountry}
        </if>
        <if test="pkVertex != null ">
            and cbs.PK_BD_VERTEX = #{pkVertex}
        </if>
        <if test="startDate!=null and startDate!='' ">
            and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cbs.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
        ORDER BY cbs.CREATION_TIME asc
    </select>

    <!-- 奖金拨比列表统计小计（最后一行）-->
    <select id="queryCuBonusSumStatis" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO">
        SELECT
        sum(cbs.MAIN_REG_AMOUNT) MAIN_REG_AMOUNT,
        sum(cbs.MAIN_UP_AMOUNT) MAIN_UP_AMOUNT,
        sum(cbs.MAIN_REPUR_AMOUNT) MAIN_REPUR_AMOUNT,
        sum(cbs.RETAIL_CONSUME_AMOUNT) RETAIL_CONSUME_AMOUNT,

        sum(cbs.REAL_INCOME_TOTAL) REAL_INCOME_TOTAL,
        sum(cbs.INTRODUCE_BONUS) INTRODUCE_BONUS,
        sum(cbs.STORE_INCOME) STORE_INCOME,
        sum(cbs.GLOBAL_POINTS) GLOBAL_POINTS,
        sum(cbs.RETAIL_RANGE_INCOME) RETAIL_RANGE_INCOME,
        sum(cbs.RETAIL_SAME_LEVEL_INCOME) RETAIL_SAME_LEVEL_INCOME,

        sum(cbs.RANGE_INCOME_41) RANGE_INCOME_41,
        sum(cbs.RANGE_INCOME_43) RANGE_INCOME_43,
        sum(cbs.RANGE_INCOME_47) RANGE_INCOME_47,
        sum(cbs.SAME_LEVEL_INCOME_41) SAME_LEVEL_INCOME_41,
        sum(cbs.SAME_LEVEL_INCOME_43) SAME_LEVEL_INCOME_43

        FROM CU_BONUS_VERTEX_STATIS cbs
        LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX
        WHERE 1=1
        <if test="pkCountry != null">
            and cbs.PK_COUNTRY = #{pkCountry}
        </if>

        <if test="pkVertex != null ">
            and cbs.PK_BD_VERTEX = #{pkVertex}
        </if>
        <if test="startDate!=null and startDate!='' ">
            and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cbs.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
    </select>

    <!-- 查询奖金拨比PV列表-->
    <select id="queryCuBonusPvStatis" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisPvVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisPvVO">
        SELECT
        cm.MEMBER_CODE as memberCode,
        cm.MEMBER_NAME as memberName,
        cbs.PK_ID pkId,
        cbs.PERIOD period,
        cbs.CREATION_TIME creationTime,
        cbs.PK_COUNTRY pkCountry,
        #{rate}*nvl(cbs.MAIN_REG_PV,0) mainRegPv,
        #{rate}*nvl(cbs.MAIN_UP_PV,0) mainUpPv,
        #{rate}*nvl(cbs.MAIN_REPUR_PV,0) mainRepurPv,
        #{rate}*nvl(cbs.RETAIL_CONSUME_PV,0) retailConsumePv,
        #{rate}*( nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)) firstPurchaseAll,
        #{rate}*( nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0)) totalAchieve,

        #{rate}*cbs.retail_range_income retailRangeIncome,
        CASE WHEN (nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0))=0 THEN 0 ELSE
        ROUND (100*cbs.retail_range_income /
        (nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0)),4) end as retailRangeIncomeRate,

        #{rate}*cbs.BACK_POINTS backPoints,
        CASE WHEN (nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0))=0 THEN 0 ELSE
        ROUND (100*cbs.BACK_POINTS /
        (nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0)),4) end as backPointsRate,

        (nvl(cbs.retail_range_income,0)+nvl(cbs.BACK_POINTS,0)) totalBonus,

        CASE WHEN (nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0))=0 THEN 0 ELSE
        ROUND(100*(nvl(cbs.retail_range_income,0)+nvl(cbs.BACK_POINTS,0))/
        ( nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0)),4) end as totalBonusRate
        FROM
        CU_BONUS_VERTEX_STATIS cbs
        LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX AND cm.DEL_FLAG = 0
        WHERE 1=1
        <if test="pkCountry != null">
            and cbs.PK_COUNTRY=#{pkCountry}
        </if>
        <if test="pkVertex != null ">
            and cbs.PK_BD_VERTEX =#{pkVertex}
        </if>
        <if test="startDate!=null and startDate!='' ">
            and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cbs.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
        ORDER BY cbs.CREATION_TIME asc
    </select>

    <!-- 奖金拨比列表统计小计(PV)（最后一行）-->
    <select id="queryCuBonusPvSumStatis" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisPvVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisPvVO">
        SELECT
        #{rate}* sum(cbs.MAIN_REG_PV) mainRegPvSum,
        #{rate}* sum(cbs.MAIN_UP_PV) mainUpPvSum,
        #{rate}* sum(cbs.MAIN_REPUR_PV) mainRepurPvSum,
        #{rate}* sum(cbs.RETAIL_CONSUME_PV) retailConsumePvSum,
        #{rate}* sum( nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)) firstPurchaseAllSum,
        #{rate}* sum( nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0)) totalAchieveSum,

        #{rate}* sum(cbs.retail_range_income) retailRangeIncomeSum,
        CASE WHEN (sum(cbs.MAIN_REG_PV+cbs.MAIN_UP_PV+cbs.MAIN_REPUR_PV+cbs.RETAIL_CONSUME_PV))=0 THEN 0 ELSE
        ROUND (100* sum(cbs.retail_range_income) /
        sum(cbs.MAIN_REG_PV+cbs.MAIN_UP_PV+cbs.MAIN_REPUR_PV+cbs.RETAIL_CONSUME_PV),4) end as retailRangeIncomeRateSum,

        #{rate}*sum(cbs.BACK_POINTS) backPointsSum,
        CASE WHEN (sum(nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0)))=0 THEN 0 ELSE
        ROUND (100*sum(cbs.BACK_POINTS) /
        sum(cbs.MAIN_REG_PV+cbs.MAIN_UP_PV+cbs.MAIN_REPUR_PV+cbs.RETAIL_CONSUME_PV),4) end as backPointsRateSum,

        #{rate}* sum(nvl(cbs.retail_range_income,0)+nvl(cbs.BACK_POINTS,0)) totalBonusSum,

        CASE WHEN (sum(nvl(cbs.MAIN_REG_PV,0)+nvl(cbs.MAIN_UP_PV,0)+nvl(cbs.MAIN_REPUR_PV,0)+nvl(cbs.RETAIL_CONSUME_PV,0)))=0 THEN 0 ELSE
        ROUND(100*sum(nvl(cbs.retail_range_income,0)+nvl(cbs.BACK_POINTS,0))/
        sum(cbs.MAIN_REG_PV+cbs.MAIN_UP_PV+cbs.MAIN_REPUR_PV+cbs.RETAIL_CONSUME_PV),4) end as totalBonusRateSum
        FROM
        CU_BONUS_VERTEX_STATIS cbs
        LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX AND cm.DEL_FLAG = 0
        WHERE 1=1
        <if test="pkCountry != null">
            and cbs.PK_COUNTRY=#{pkCountry}
        </if>
        <if test="pkVertex != null ">
            and cbs.PK_BD_VERTEX =#{pkVertex}
        </if>
        <if test="startDate!=null and startDate!='' ">
            and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cbs.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
    </select>

    <!-- 查询顶点奖金拨比汇总-->
    <select id="queryCuBonusStatisTotal" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisTotalVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisTotalVO">
        select * from(
        SELECT
        cbs.PK_BD_VERTEX pkVertex,
        cm.MEMBER_CODE,
        cm.MEMBER_NAME,
        sum (cbs.MAIN_REG_AMOUNT) MAIN_REG_AMOUNT,
        sum (cbs.MAIN_UP_AMOUNT) MAIN_UP_AMOUNT,
        sum (cbs.MAIN_REPUR_AMOUNT) MAIN_REPUR_AMOUNT,
        sum (cbs.RETAIL_CONSUME_AMOUNT) RETAIL_CONSUME_AMOUNT,

        sum (cbs.REAL_INCOME_TOTAL) REAL_INCOME_TOTAL,
        sum (cbs.INTRODUCE_BONUS) INTRODUCE_BONUS,
        sum (cbs.STORE_INCOME) STORE_INCOME,
        sum (cbs.GLOBAL_POINTS) GLOBAL_POINTS,
        sum (cbs.RETAIL_RANGE_INCOME) RETAIL_RANGE_INCOME,
        sum (cbs.RETAIL_SAME_LEVEL_INCOME) RETAIL_SAME_LEVEL_INCOME,

        sum (cbs.RANGE_INCOME_41) RANGE_INCOME_41,
        sum (cbs.RANGE_INCOME_43) RANGE_INCOME_43,
        sum (cbs.RANGE_INCOME_47) RANGE_INCOME_47,
        sum (cbs.SAME_LEVEL_INCOME_41) SAME_LEVEL_INCOME_41,
        sum (cbs.SAME_LEVEL_INCOME_43) SAME_LEVEL_INCOME_43

        FROM CU_BONUS_VERTEX_STATIS cbs
        LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX
        WHERE 1=1
        <if test="pkVertex != null ">
            and cbs.PK_BD_VERTEX = #{pkVertex}
        </if>
        <if test="startDate!=null and startDate!='' ">
            and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cbs.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
        GROUP BY cbs.PK_BD_VERTEX,cm.MEMBER_CODE,cm.MEMBER_NAME
        )
        ORDER BY MEMBER_CODE
    </select>

    <!-- 顶点奖金拨比汇总查询总和-->
    <select id="queryCuBonusStatisSum" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisTotalVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisTotalVO">
        SELECT
        sum (cbs.MAIN_REG_AMOUNT) MAIN_REG_AMOUNT,
        sum (cbs.MAIN_UP_AMOUNT) MAIN_UP_AMOUNT,
        sum (cbs.MAIN_REPUR_AMOUNT) MAIN_REPUR_AMOUNT,
        sum (cbs.RETAIL_CONSUME_AMOUNT) RETAIL_CONSUME_AMOUNT,

        sum (cbs.REAL_INCOME_TOTAL) REAL_INCOME_TOTAL,
        sum (cbs.INTRODUCE_BONUS) INTRODUCE_BONUS,
        sum (cbs.STORE_INCOME) STORE_INCOME,
        sum (cbs.GLOBAL_POINTS) GLOBAL_POINTS,
        sum (cbs.RETAIL_RANGE_INCOME) RETAIL_RANGE_INCOME,
        sum (cbs.RETAIL_SAME_LEVEL_INCOME) RETAIL_SAME_LEVEL_INCOME,

        sum (cbs.RANGE_INCOME_41) RANGE_INCOME_41,
        sum (cbs.RANGE_INCOME_43) RANGE_INCOME_43,
        sum (cbs.RANGE_INCOME_47) RANGE_INCOME_47,
        sum (cbs.SAME_LEVEL_INCOME_41) SAME_LEVEL_INCOME_41,
        sum (cbs.SAME_LEVEL_INCOME_43) SAME_LEVEL_INCOME_43

        FROM CU_BONUS_VERTEX_STATIS cbs
        LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX
        WHERE 1 = 1
        <if test="pkCountry != null">
            and cbs.PK_COUNTRY = #{pkCountry}
        </if>
        <if test="pkVertex != null ">
            and cbs.PK_BD_VERTEX = #{pkVertex}
        </if>
        <if test="startDate!=null and startDate!='' ">
            and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cbs.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
    </select>

    <!-- 查询时间内奖金拨比顶点会员-->
    <select id="queryCuBonusVertex" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisTotalVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisTotalVO">
        select cbs.pk_bd_vertex pkVertex
        from cu_bonus_vertex_statis cbs where 1=1
        <if test="pkCountry != null">
            and cbs.PK_COUNTRY=#{pkCountry}
        </if>
        <if test="pkVertex != null">
            and cbs.PK_BD_VERTEX=#{pkVertex}
        </if>
        <if test="startDate!=null and startDate!='' ">
            and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cbs.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
        GROUP BY cbs.PK_BD_VERTEX
    </select>

    <!-- 7天重算查询订单-->
    <select id="queryAnewSaOrderByLessDay" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO">
        select * from (
        select
        cm.pk_Member pkMember,
        #{pkVertex} pkVertex,
        so.PK_COUNTRY pkCountry,
        so.ORDER_TYPE orderType,
        so.ORDER_AMOUNT orderAmount,
        so.ORDER_ACHIEVE orderAchieve,
        to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
        from (
        SELECT pk_member
        FROM ${settleTableName}
        WHERE category = 0
        start with PK_PARENT = #{pkVertex}
        connect by PK_PARENT = prior pk_member
        ) cm
        INNER JOIN SA_ORDER so on so.pk_member=cm.pk_member
        where so.ORDER_TYPE in (41, 42, 43, 47)
        <if test="pkCountry != null">
            and so.pk_country=#{pkCountry}
        </if>
        <if test="delFlag != null">
            AND so.DEL_FLAG=#{delFlag}
        </if>
        <if test="orderStatus != null">
            AND so.order_status=#{orderStatus}
        </if>
        <if test="startDate != null and startDate!='' ">
            and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate != null and endDate!='' ">
            and so.PAY_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
        <if test="payTimeStr != null and payTimeStr!='' ">
            AND so.PAY_TIME = to_date(#{payTimeStr}, 'YYYY-MM-dd')
        </if>
        )
    </select>

    <!--    删除奖金拨比统计表数据-->
    <delete id="delStatis">
        delete from CU_BONUS_VERTEX_STATIS
        where 1=1
        <if test="pkVertexList!=null and pkVertexList.size> 0 ">
            and PK_BD_VERTEX not in
            <foreach collection="pkVertexList" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="startDate != null and startDate!='' ">
            and CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate != null and endDate!='' ">
            and CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
    </delete>

    <!--      查询生效国外国家-->
    <select id="countrylist" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO">
        select pk_id as pkCountry
        from BD_COUNTRY
        where pk_id!=1 and del_flag = 0 and EFFECTIVE_DATE &lt;= sysdate
    </select>

    <!-- 查询7天重算奖金查询-->
    <select id="queryVertexChinaCountryBonus" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"
            resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO">
        select
        #{pkCountry} pkCountry,
        sum(cmb.DIRECT_INCOME) DIRECT_INCOME,
        sum(cmb.GLOBAL_POINTS) GLOBAL_POINTS,
        sum(cmb.STORE_INCOME) STORE_INCOME,
        sum(cmb.RETAIL_RANGE_INCOME) RETAIL_RANGE_INCOME,
        sum(cmb.RETAIL_SAME_LEVEL_INCOME) RETAIL_SAME_LEVEL_INCOME,
        sum(cmb.REAL_INCOME_TOTAL) REAL_INCOME_TOTAL,
        sum(cmb.RANGE_INCOME_41) RANGE_INCOME_41,
        sum(cmb.RANGE_INCOME_43) RANGE_INCOME_43,
        sum(cmb.RANGE_INCOME_47) RANGE_INCOME_47,
        sum(cmb.SAME_LEVEL_INCOME_41) SAME_LEVEL_INCOME_41,
        sum(cmb.SAME_LEVEL_INCOME_43) SAME_LEVEL_INCOME_43,
        #{pkVertex} pkVertex,
        to_date(to_char(cmsp.settle_date, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
        from CU_MEMBER_BONUS cmb
        INNER join (
        SELECT pk_member
        FROM ${settleTableName}
        WHERE category=0
        start with pk_member = #{pkVertex}
        connect by PK_PARENT = prior pk_member
        ) cm
        on cm.pk_member = cmb.pk_member
        INNER JOIN CU_MEMBER_SETTLE_PERIOD cmsp ON cmsp.pk_id=cmb.period
        where CMB.DEL_FLAG = 0
        AND CMSP.Del_Flag = 0
        <if test="startDate!=null and startDate!='' ">
            and cmsp.settle_date >= to_date(#{startDate}, 'yyyy-mm-dd')
        </if>
        <if test="endDate!=null and endDate!='' ">
            and cmsp.settle_date &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
        GROUP BY
        to_char(cmsp.settle_date, 'yyyy-mm-dd')
    </select>

    <!--   查询当天团队统计数据-->
    <select id="getCuBonusStatis" parameterType="com.hzs.common.domain.member.statis.CuBonusVertexStatis"
            resultType="com.hzs.common.domain.member.statis.CuBonusVertexStatis">
        SELECT *
        FROM CU_BONUS_VERTEX_STATIS a
        WHERE 1=1
        <if test="pkBdVertex != null ">
            AND a.PK_BD_VERTEX = #{pkBdVertex}
        </if>
        <if test="pkCountry != null ">
            AND a.PK_COUNTRY = #{pkCountry}
        </if>
        <if test="creationTime != null ">
            and to_char(a.CREATION_TIME, 'yyyy-mm-dd') = to_char(#{creationTime}, 'yyyy-mm-dd')
        </if>
    </select>

</mapper>
