<?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.game.business.mapper.AppUsersChargeMapper">
    
    <resultMap type="com.game.business.domain.AppUsersCharge" id="AppUsersChargeResult">
        <result property="id"    column="id"    />
        <result property="addtime"    column="addtime"    />
        <result property="afterCoin"    column="after_coin"    />
        <result property="agentId"    column="agent_id"    />
        <result property="ambient"    column="ambient"    />
        <result property="coin"    column="coin"    />
        <result property="coinType"    column="coin_type"    />
        <result property="coinGive"    column="coin_give"    />
        <result property="isAgent"    column="is_agent"    />
        <result property="isDelete"    column="is_delete"    />
        <result property="isWater"    column="is_water"    />
        <result property="money"    column="money"    />
        <result property="optType"    column="opt_type"    />
        <result property="optUser"    column="opt_user"    />
        <result property="orderno"    column="orderno"    />
        <result property="pid"    column="pid"    />
        <result property="pidLevel1"    column="pid_level1"    />
        <result property="pidLevel2"    column="pid_level2"    />
        <result property="pidLevel3"    column="pid_level3"    />
        <result property="pidLevel4"    column="pid_level4"    />
        <result property="remarks"    column="remarks"    />
        <result property="ruleId"    column="rule_id"    />
        <result property="status"    column="status"    />
        <result property="touid"    column="touid"    />
        <result property="tradeNo"    column="trade_no"    />
        <result property="type"    column="type"    />
        <result property="uid"    column="uid"    />
    </resultMap>

    <sql id="selectAppUsersChargeVo">
        select id, addtime, after_coin, agent_id, ambient, coin, coin_type, coin_give, is_agent, is_delete, is_water, money, opt_type, opt_user, orderno, pid, pid_level1, pid_level2, pid_level3, pid_level4, remarks, rule_id, status, touid, trade_no, type, uid from app_users_charge
    </sql>

    <select id="selectAppUsersChargeList" parameterType="com.game.business.domain.AppUsersCharge" resultMap="AppUsersChargeResult">
        <include refid="selectAppUsersChargeVo"/>
        <where>  
            <if test="addtime != null "> and addtime = #{addtime}</if>
            <if test="afterCoin != null "> and after_coin = #{afterCoin}</if>
            <if test="agentId != null "> and agent_id = #{agentId}</if>
            <if test="ambient != null "> and ambient = #{ambient}</if>
            <if test="coin != null "> and coin = #{coin}</if>
            <if test="coinType != null "> and coin_type = #{coinType}</if>
            <if test="coinGive != null "> and coin_give = #{coinGive}</if>
            <if test="isAgent != null "> and is_agent = #{isAgent}</if>
            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
            <if test="isWater != null "> and is_water = #{isWater}</if>
            <if test="money != null "> and money = #{money}</if>
            <if test="optType != null "> and opt_type = #{optType}</if>
            <if test="optUser != null  and optUser != ''"> and opt_user = #{optUser}</if>
            <if test="orderno != null  and orderno != ''"> and orderno = #{orderno}</if>
            <if test="pid != null "> and pid = #{pid}</if>
            <if test="pidLevel1 != null "> and pid_level1 = #{pidLevel1}</if>
            <if test="pidLevel2 != null "> and pid_level2 = #{pidLevel2}</if>
            <if test="pidLevel3 != null "> and pid_level3 = #{pidLevel3}</if>
            <if test="pidLevel4 != null "> and pid_level4 = #{pidLevel4}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="ruleId != null "> and rule_id = #{ruleId}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="touid != null "> and touid = #{touid}</if>
            <if test="tradeNo != null  and tradeNo != ''"> and trade_no = #{tradeNo}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="uid != null "> and uid = #{uid}</if>
        </where>
    </select>
    
    <select id="selectAppUsersChargeById" parameterType="Long" resultMap="AppUsersChargeResult">
        <include refid="selectAppUsersChargeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAppUsersCharge" parameterType="com.game.business.domain.AppUsersCharge">
        insert into app_users_charge
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="addtime != null">addtime,</if>
            <if test="afterCoin != null">after_coin,</if>
            <if test="agentId != null">agent_id,</if>
            <if test="ambient != null">ambient,</if>
            <if test="coin != null">coin,</if>
            <if test="coinType != null">coin_type,</if>
            <if test="coinGive != null">coin_give,</if>
            <if test="isAgent != null">is_agent,</if>
            <if test="isDelete != null">is_delete,</if>
            <if test="isWater != null">is_water,</if>
            <if test="money != null">money,</if>
            <if test="optType != null">opt_type,</if>
            <if test="optUser != null">opt_user,</if>
            <if test="orderno != null">orderno,</if>
            <if test="pid != null">pid,</if>
            <if test="pidLevel1 != null">pid_level1,</if>
            <if test="pidLevel2 != null">pid_level2,</if>
            <if test="pidLevel3 != null">pid_level3,</if>
            <if test="pidLevel4 != null">pid_level4,</if>
            <if test="remarks != null">remarks,</if>
            <if test="ruleId != null">rule_id,</if>
            <if test="status != null">status,</if>
            <if test="touid != null">touid,</if>
            <if test="tradeNo != null">trade_no,</if>
            <if test="type != null">type,</if>
            <if test="uid != null">uid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="addtime != null">#{addtime},</if>
            <if test="afterCoin != null">#{afterCoin},</if>
            <if test="agentId != null">#{agentId},</if>
            <if test="ambient != null">#{ambient},</if>
            <if test="coin != null">#{coin},</if>
            <if test="coinType != null">#{coinType},</if>
            <if test="coinGive != null">#{coinGive},</if>
            <if test="isAgent != null">#{isAgent},</if>
            <if test="isDelete != null">#{isDelete},</if>
            <if test="isWater != null">#{isWater},</if>
            <if test="money != null">#{money},</if>
            <if test="optType != null">#{optType},</if>
            <if test="optUser != null">#{optUser},</if>
            <if test="orderno != null">#{orderno},</if>
            <if test="pid != null">#{pid},</if>
            <if test="pidLevel1 != null">#{pidLevel1},</if>
            <if test="pidLevel2 != null">#{pidLevel2},</if>
            <if test="pidLevel3 != null">#{pidLevel3},</if>
            <if test="pidLevel4 != null">#{pidLevel4},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="ruleId != null">#{ruleId},</if>
            <if test="status != null">#{status},</if>
            <if test="touid != null">#{touid},</if>
            <if test="tradeNo != null">#{tradeNo},</if>
            <if test="type != null">#{type},</if>
            <if test="uid != null">#{uid},</if>
         </trim>
    </insert>

    <update id="updateAppUsersCharge" parameterType="com.game.business.domain.AppUsersCharge">
        update app_users_charge
        <trim prefix="SET" suffixOverrides=",">
            <if test="addtime != null">addtime = #{addtime},</if>
            <if test="afterCoin != null">after_coin = #{afterCoin},</if>
            <if test="agentId != null">agent_id = #{agentId},</if>
            <if test="ambient != null">ambient = #{ambient},</if>
            <if test="coin != null">coin = #{coin},</if>
            <if test="coinType != null">coin_type = #{coinType},</if>
            <if test="coinGive != null">coin_give = #{coinGive},</if>
            <if test="isAgent != null">is_agent = #{isAgent},</if>
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="isWater != null">is_water = #{isWater},</if>
            <if test="money != null">money = #{money},</if>
            <if test="optType != null">opt_type = #{optType},</if>
            <if test="optUser != null">opt_user = #{optUser},</if>
            <if test="orderno != null">orderno = #{orderno},</if>
            <if test="pid != null">pid = #{pid},</if>
            <if test="pidLevel1 != null">pid_level1 = #{pidLevel1},</if>
            <if test="pidLevel2 != null">pid_level2 = #{pidLevel2},</if>
            <if test="pidLevel3 != null">pid_level3 = #{pidLevel3},</if>
            <if test="pidLevel4 != null">pid_level4 = #{pidLevel4},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="ruleId != null">rule_id = #{ruleId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="touid != null">touid = #{touid},</if>
            <if test="tradeNo != null">trade_no = #{tradeNo},</if>
            <if test="type != null">type = #{type},</if>
            <if test="uid != null">uid = #{uid},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppUsersChargeById" parameterType="Long">
        delete from app_users_charge where id = #{id}
    </delete>

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