<?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.com.ctop.kuaishou.modules.report.mapper.EtlKuaiShouAccountMaterialOverviewMapper">

    <insert id="replaceInsert"
            parameterType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaiShouAccountMaterialOverview">
        replace into ctop_etl_kuaishou_account_material_overview
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="newlyCount != null">
                newly_count,
            </if>
            <if test="newlyUseCount != null">
                newly_use_count,
            </if>
            <if test="totalCount != null">
                total_count,
            </if>
            <if test="effectiveCount != null">
                effective_count,
            </if>
            <if test="hotMoneyCount != null">
                hot_money_count,
            </if>
            <if test="stateDate != null">
                state_date
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id},
            </if>
            <if test="accountId != null">
                #{accountId},
            </if>
            <if test="newlyCount != null">
                #{newlyCount},
            </if>
            <if test="newlyUseCount != null">
                #{newlyUseCount},
            </if>
            <if test="totalCount != null">
                #{totalCount},
            </if>
            <if test="effectiveCount != null">
                #{effectiveCount},
            </if>
            <if test="hotMoneyCount != null">
                #{hotMoneyCount},
            </if>
            <if test="stateDate != null">
                #{stateDate}
            </if>
        </trim>
    </insert>
    <select id="getMaterialOverview" resultType="com.alibaba.fastjson.JSONObject">
        select
        newly_count as newlyCount,
        newly_use_count as newlyUseCount,
        total_count as totalCount,
        effective_count as effectiveCount,
        hot_money_count as hotMoneyCount,
        update_time as updateTime
        from  ctop_etl_kuaishou_account_material_overview
        where account_id = #{accountId}
        and state_date = #{statDate}

    </select>
</mapper>