<?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.AppUsersCashrecordMapper">
    
    <resultMap type="com.game.business.domain.AppUsersCashrecord" id="AppUsersCashrecordResult">
        <result property="id"    column="id"    />
        <result property="account"    column="account"    />
        <result property="accountBank"    column="account_bank"    />
        <result property="actualMoney"    column="actual_money"    />
        <result property="addtime"    column="addtime"    />
        <result property="afterAmount"    column="after_amount"    />
        <result property="auditby"    column="auditby"    />
        <result property="beforeAmount"    column="before_amount"    />
        <result property="cashOutBizNo"    column="cash_out_biz_no"    />
        <result property="cashOutOrderId"    column="cash_out_order_id"    />
        <result property="cashOutPayOrderId"    column="cash_out_pay_order_id"    />
        <result property="cashOutRemark"    column="cash_out_remark"    />
        <result property="cashOutStatus"    column="cash_out_status"    />
        <result property="cashType"    column="cash_type"    />
        <result property="guildId"    column="guild_id"    />
        <result property="money"    column="money"    />
        <result property="name"    column="name"    />
        <result property="orderno"    column="orderno"    />
        <result property="platformService"    column="platform_service"    />
        <result property="reason"    column="reason"    />
        <result property="remarks"    column="remarks"    />
        <result property="service"    column="service"    />
        <result property="status"    column="status"    />
        <result property="statusName"    column="status_name"    />
        <result property="tradeNo"    column="trade_no"    />
        <result property="type"    column="type"    />
        <result property="uid"    column="uid"    />
        <result property="unitType"    column="unit_type"    />
        <result property="uptime"    column="uptime"    />
        <result property="votes"    column="votes"    />
        <result property="cashChannelId"    column="cash_channel_id"    />
        <result property="cashAccountId"    column="cash_account_id"    />
    </resultMap>

    <sql id="selectAppUsersCashrecordVo">
        select a.*,b.type as accountType from app_users_cashrecord as a left join app_users_cash_account as b on a.cash_account_id = b.id
    </sql>

    <select id="selectAppUsersCashrecordList" parameterType="com.game.business.domain.AppUsersCashrecord" resultMap="AppUsersCashrecordResult">
        <include refid="selectAppUsersCashrecordVo"/>
        <where>  
            <if test="account != null  and account != ''"> and a.account = #{account}</if>
            <if test="accountBank != null  and accountBank != ''"> and a.account_bank = #{accountBank}</if>
            <if test="actualMoney != null "> and a.actual_money = #{actualMoney}</if>
            <if test="addtime != null "> and a.addtime = #{addtime}</if>
            <if test="afterAmount != null "> and a.after_amount = #{afterAmount}</if>
            <if test="auditby != null  and auditby != ''"> and a.auditby = #{auditby}</if>
            <if test="beforeAmount != null "> and a.before_amount = #{beforeAmount}</if>
            <if test="cashOutBizNo != null  and cashOutBizNo != ''"> and a.cash_out_biz_no = #{cashOutBizNo}</if>
            <if test="cashOutOrderId != null  and cashOutOrderId != ''"> and a.cash_out_order_id = #{cashOutOrderId}</if>
            <if test="cashOutPayOrderId != null  and cashOutPayOrderId != ''"> and a.cash_out_pay_order_id = #{cashOutPayOrderId}</if>
            <if test="cashOutRemark != null  and cashOutRemark != ''"> and a.cash_out_remark = #{cashOutRemark}</if>
            <if test="cashOutStatus != null "> and a.cash_out_status = #{cashOutStatus}</if>
            <if test="cashType != null "> and a.cash_type = #{cashType}</if>
            <if test="cashChannelId != null "> and a.cash_channel_id = #{cashChannelId}</if>
            <if test="cashAccountId != null "> and a.cash_account_id = #{cashAccountId}</if>
            <if test="guildId != null "> and a.guild_id = #{guildId}</if>
            <if test="money != null "> and a.money = #{money}</if>
            <if test="name != null  and name != ''"> and a.name like concat('%', #{name}, '%')</if>
            <if test="orderno != null  and orderno != ''"> and a.orderno = #{orderno}</if>
            <if test="platformService != null "> and a.platform_service = #{platformService}</if>
            <if test="reason != null  and reason != ''"> and a.reason = #{reason}</if>
            <if test="remarks != null  and remarks != ''"> and a.remarks = #{remarks}</if>
            <if test="service != null "> and a.service = #{service}</if>
            <if test="status != null "> and a.status = #{status}</if>
            <if test="statusName != null  and statusName != ''"> and a.status_name like concat('%', #{statusName}, '%')</if>
            <if test="tradeNo != null  and tradeNo != ''"> and a.trade_no = #{tradeNo}</if>
            <if test="type != null "> and a.type = #{type}</if>
            <if test="uid != null "> and a.uid = #{uid}</if>
            <if test="unitType != null "> and a.unit_type = #{unitType}</if>
            <if test="uptime != null "> and a.uptime = #{uptime}</if>
            <if test="votes != null "> and a.votes = #{votes}</if>
            <if test="beginTime != null  and beginTime != ''"> and a.addtime &gt; CONCAT(#{beginTime},' 00:00:00')</if>
            <if test="endTime != null  and endTime != ''"> and a.addtime &lt; CONCAT(#{endTime},' 23:59:59')</if>
        </where>
        order by addtime desc
    </select>
    
    <select id="selectAppUsersCashrecordById" parameterType="Long" resultMap="AppUsersCashrecordResult">
        <include refid="selectAppUsersCashrecordVo"/>
        where a.id = #{id}
    </select>
        
    <insert id="insertAppUsersCashrecord" parameterType="com.game.business.domain.AppUsersCashrecord">
        insert into app_users_cashrecord
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="account != null">account,</if>
            <if test="accountBank != null">account_bank,</if>
            <if test="actualMoney != null">actual_money,</if>
            <if test="addtime != null">addtime,</if>
            <if test="afterAmount != null">after_amount,</if>
            <if test="auditby != null">auditby,</if>
            <if test="beforeAmount != null">before_amount,</if>
            <if test="cashOutBizNo != null">cash_out_biz_no,</if>
            <if test="cashOutOrderId != null">cash_out_order_id,</if>
            <if test="cashOutPayOrderId != null">cash_out_pay_order_id,</if>
            <if test="cashOutRemark != null">cash_out_remark,</if>
            <if test="cashOutStatus != null">cash_out_status,</if>
            <if test="cashType != null">cash_type,</if>
            <if test="cashChannelId != null">cash_channel_id,</if>
            <if test="cashAccountId != null">cash_account_id,</if>
            <if test="guildId != null">guild_id,</if>
            <if test="money != null">money,</if>
            <if test="name != null">name,</if>
            <if test="orderno != null">orderno,</if>
            <if test="platformService != null">platform_service,</if>
            <if test="reason != null">reason,</if>
            <if test="remarks != null">remarks,</if>
            <if test="service != null">service,</if>
            <if test="status != null">status,</if>
            <if test="statusName != null">status_name,</if>
            <if test="tradeNo != null">trade_no,</if>
            <if test="type != null">type,</if>
            <if test="uid != null">uid,</if>
            <if test="unitType != null">unit_type,</if>
            <if test="uptime != null">uptime,</if>
            <if test="votes != null">votes,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="account != null">#{account},</if>
            <if test="accountBank != null">#{accountBank},</if>
            <if test="actualMoney != null">#{actualMoney},</if>
            <if test="addtime != null">#{addtime},</if>
            <if test="afterAmount != null">#{afterAmount},</if>
            <if test="auditby != null">#{auditby},</if>
            <if test="beforeAmount != null">#{beforeAmount},</if>
            <if test="cashOutBizNo != null">#{cashOutBizNo},</if>
            <if test="cashOutOrderId != null">#{cashOutOrderId},</if>
            <if test="cashOutPayOrderId != null">#{cashOutPayOrderId},</if>
            <if test="cashOutRemark != null">#{cashOutRemark},</if>
            <if test="cashOutStatus != null">#{cashOutStatus},</if>
            <if test="cashType != null">#{cashType},</if>
            <if test="cashChannelId != null">#{cashChannelId},</if>
            <if test="cashAccountId != null">#{cashAccountId},</if>
            <if test="guildId != null">#{guildId},</if>
            <if test="money != null">#{money},</if>
            <if test="name != null">#{name},</if>
            <if test="orderno != null">#{orderno},</if>
            <if test="platformService != null">#{platformService},</if>
            <if test="reason != null">#{reason},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="service != null">#{service},</if>
            <if test="status != null">#{status},</if>
            <if test="statusName != null">#{statusName},</if>
            <if test="tradeNo != null">#{tradeNo},</if>
            <if test="type != null">#{type},</if>
            <if test="uid != null">#{uid},</if>
            <if test="unitType != null">#{unitType},</if>
            <if test="uptime != null">#{uptime},</if>
            <if test="votes != null">#{votes},</if>
         </trim>
    </insert>

    <update id="updateAppUsersCashrecord" parameterType="com.game.business.domain.AppUsersCashrecord">
        update app_users_cashrecord
        <trim prefix="SET" suffixOverrides=",">
            <if test="account != null">account = #{account},</if>
            <if test="accountBank != null">account_bank = #{accountBank},</if>
            <if test="actualMoney != null">actual_money = #{actualMoney},</if>
            <if test="addtime != null">addtime = #{addtime},</if>
            <if test="afterAmount != null">after_amount = #{afterAmount},</if>
            <if test="auditby != null">auditby = #{auditby},</if>
            <if test="beforeAmount != null">before_amount = #{beforeAmount},</if>
            <if test="cashOutBizNo != null">cash_out_biz_no = #{cashOutBizNo},</if>
            <if test="cashOutOrderId != null">cash_out_order_id = #{cashOutOrderId},</if>
            <if test="cashOutPayOrderId != null">cash_out_pay_order_id = #{cashOutPayOrderId},</if>
            <if test="cashOutRemark != null">cash_out_remark = #{cashOutRemark},</if>
            <if test="cashOutStatus != null">cash_out_status = #{cashOutStatus},</if>
            <if test="cashType != null">cash_type = #{cashType},</if>
            <if test="cashChannelId != null">cash_channel_id = #{cashChannelId},</if>
            <if test="cashAccountId != null">cash_account_id = #{cashAccountId},</if>
            <if test="guildId != null">guild_id = #{guildId},</if>
            <if test="money != null">money = #{money},</if>
            <if test="name != null">name = #{name},</if>
            <if test="orderno != null">orderno = #{orderno},</if>
            <if test="platformService != null">platform_service = #{platformService},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="service != null">service = #{service},</if>
            <if test="status != null">status = #{status},</if>
            <if test="statusName != null">status_name = #{statusName},</if>
            <if test="tradeNo != null">trade_no = #{tradeNo},</if>
            <if test="type != null">type = #{type},</if>
            <if test="uid != null">uid = #{uid},</if>
            <if test="unitType != null">unit_type = #{unitType},</if>
            <if test="uptime != null">uptime = #{uptime},</if>
            <if test="votes != null">votes = #{votes},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppUsersCashrecordById" parameterType="Long">
        delete from app_users_cashrecord where id = #{id}
    </delete>

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