<?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.playlet.system.mapper.PlayletRevenueRecordMapper">

    <resultMap type="PlayletRevenueRecord" id="PlayletRevenueRecordResult">
        <result property="id"    column="id"    />
        <result property="refundMoney"    column="refund_money"    />
        <result property="playletItemId"    column="playlet_item_id"    />
        <result property="userId"    column="user_id"    />
        <result property="sourcePlatform"    column="source_platform"    />
        <result property="earningsType"    column="earnings_type"    />
        <result property="clicksNumber"    column="clicks_number"    />
        <result property="clicksNumberPeople"    column="clicks_number_people"    />
        <result property="rechargeMoney"    column="recharge_money"    />
        <result property="estimateEarnings"    column="estimate_earnings"    />
        <result property="practicalEarnings"    column="practical_earnings"    />
        <result property="pushTime"    column="push_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="itemType" column="item_type" />
    </resultMap>

    <sql id="selectPlayletRevenueRecordVo">
        select id, refund_money, playlet_item_id, user_id, source_platform, earnings_type, clicks_number, clicks_number_people, recharge_money, estimate_earnings, practical_earnings, push_time, create_by, create_time, update_by, update_time, remark, item_type from playlet_revenue_record
    </sql>

    <select id="selectPlayletRevenueRecordList" parameterType="PlayletRevenueRecord" resultMap="PlayletRevenueRecordResult">
        <include refid="selectPlayletRevenueRecordVo"/>
        <where>
            <if test="refundMoney != null "> and refund_money = #{refundMoney}</if>
            <if test="playletItemId != null "> and playlet_item_id = #{playletItemId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="sourcePlatform != null "> and source_platform = #{sourcePlatform}</if>
            <if test="earningsType != null "> and earnings_type = #{earningsType}</if>
            <if test="clicksNumber != null "> and clicks_number = #{clicksNumber}</if>
            <if test="clicksNumberPeople != null "> and clicks_number_people = #{clicksNumberPeople}</if>
            <if test="rechargeMoney != null "> and recharge_money = #{rechargeMoney}</if>
            <if test="estimateEarnings != null "> and estimate_earnings = #{estimateEarnings}</if>
            <if test="practicalEarnings != null "> and practical_earnings = #{practicalEarnings}</if>
            <!--  <if test="pushTime != null "> and push_time = #{pushTime}</if> -->
            <if test="startTime != null and startTime != 0" >
                and push_time <![CDATA[ >= ]]> #{startTime}
            </if>
            <if test="endTime != null and endTime != 0" >
                and push_time <![CDATA[ <= ]]> #{endTime}
            </if>guog
            <if test="itemType != null "> and item_type = #{itemType}</if>
        </where>
    </select>

    <select id="selectPlayletRevenueRecordById" parameterType="Long" resultMap="PlayletRevenueRecordResult">
        <include refid="selectPlayletRevenueRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlayletRevenueRecord" parameterType="PlayletRevenueRecord" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_revenue_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="refundMoney != null">refund_money,</if>
            <if test="playletItemId != null">playlet_item_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="sourcePlatform != null">source_platform,</if>
            <if test="earningsType != null">earnings_type,</if>
            <if test="clicksNumber != null">clicks_number,</if>
            <if test="clicksNumberPeople != null">clicks_number_people,</if>
            <if test="rechargeMoney != null">recharge_money,</if>
            <if test="estimateEarnings != null">estimate_earnings,</if>
            <if test="practicalEarnings != null">practical_earnings,</if>
            <if test="pushTime != null">push_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="itemType != null ">item_type,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="refundMoney != null">#{refundMoney},</if>
            <if test="playletItemId != null">#{playletItemId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="sourcePlatform != null">#{sourcePlatform},</if>
            <if test="earningsType != null">#{earningsType},</if>
            <if test="clicksNumber != null">#{clicksNumber},</if>
            <if test="clicksNumberPeople != null">#{clicksNumberPeople},</if>
            <if test="rechargeMoney != null">#{rechargeMoney},</if>
            <if test="estimateEarnings != null">#{estimateEarnings},</if>
            <if test="practicalEarnings != null">#{practicalEarnings},</if>
            <if test="pushTime != null">#{pushTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="itemType != null ">#{itemType},</if>
        </trim>
    </insert>

    <update id="updatePlayletRevenueRecord" parameterType="PlayletRevenueRecord">
        update playlet_revenue_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="refundMoney != null">refund_money = #{refundMoney},</if>
            <if test="playletItemId != null">playlet_item_id = #{playletItemId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="sourcePlatform != null">source_platform = #{sourcePlatform},</if>
            <if test="earningsType != null">earnings_type = #{earningsType},</if>
            <if test="clicksNumber != null">clicks_number = #{clicksNumber},</if>
            <if test="clicksNumberPeople != null">clicks_number_people = #{clicksNumberPeople},</if>
            <if test="rechargeMoney != null">recharge_money = #{rechargeMoney},</if>
            <if test="estimateEarnings != null">estimate_earnings = #{estimateEarnings},</if>
            <if test="practicalEarnings != null">practical_earnings = #{practicalEarnings},</if>
            <if test="pushTime != null">push_time = #{pushTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="itemType != null ">item_type = #{itemType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlayletRevenueRecordById" parameterType="Long">
        delete from playlet_revenue_record where id = #{id}
    </delete>

    <delete id="deletePlayletRevenueRecordByIds" parameterType="String">
        delete from playlet_revenue_record where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>