<?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.fs.company.mapper.CompanyRechargeMapper">
    
    <resultMap type="CompanyRecharge" id="CompanyRechargeResult">
        <result property="rechargeId"    column="recharge_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="rechargeNo"    column="recharge_no"    />
        <result property="money"    column="money"    />
        <result property="createTime"    column="create_time"    />
        <result property="payTime"    column="pay_time"    />
        <result property="status"    column="status"    />
        <result property="payType"    column="pay_type"    />
        <result property="tradeNo"    column="trade_no"    />
        <result property="balance"    column="balance"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="isAudit"    column="is_audit"    />
        <result property="auditUserId"    column="audit_user_id"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCompanyRechargeVo">
        select recharge_id, company_id, recharge_no, money, create_time, pay_time, status, pay_type, trade_no, balance, create_user_id, is_audit, audit_user_id, audit_time,remark from company_recharge
    </sql>

    <select id="selectCompanyRechargeList" parameterType="CompanyRecharge" resultMap="CompanyRechargeResult">
        <include refid="selectCompanyRechargeVo"/>
        <where>  
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="rechargeNo != null  and rechargeNo != ''"> and recharge_no = #{rechargeNo}</if>
            <if test="money != null "> and money = #{money}</if>
            <if test="payTime != null "> and pay_time = #{payTime}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="payType != null "> and pay_type = #{payType}</if>
            <if test="tradeNo != null  and tradeNo != ''"> and trade_no = #{tradeNo}</if>
            <if test="balance != null "> and balance = #{balance}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="isAudit != null "> and is_audit = #{isAudit}</if>
            <if test="auditUserId != null "> and audit_user_id = #{auditUserId}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
        </where>
    </select>
    
    <select id="selectCompanyRechargeById" parameterType="Long" resultMap="CompanyRechargeResult">
        <include refid="selectCompanyRechargeVo"/>
        where recharge_id = #{rechargeId}
    </select>
        
    <insert id="insertCompanyRecharge" parameterType="CompanyRecharge" useGeneratedKeys="true" keyProperty="rechargeId">
        insert into company_recharge
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyId != null">company_id,</if>
            <if test="rechargeNo != null">recharge_no,</if>
            <if test="money != null">money,</if>
            <if test="createTime != null">create_time,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="status != null">status,</if>
            <if test="payType != null">pay_type,</if>
            <if test="tradeNo != null">trade_no,</if>
            <if test="balance != null">balance,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="isAudit != null">is_audit,</if>
            <if test="auditUserId != null">audit_user_id,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyId != null">#{companyId},</if>
            <if test="rechargeNo != null">#{rechargeNo},</if>
            <if test="money != null">#{money},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="status != null">#{status},</if>
            <if test="payType != null">#{payType},</if>
            <if test="tradeNo != null">#{tradeNo},</if>
            <if test="balance != null">#{balance},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="isAudit != null">#{isAudit},</if>
            <if test="auditUserId != null">#{auditUserId},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCompanyRecharge" parameterType="CompanyRecharge">
        update company_recharge
        <trim prefix="SET" suffixOverrides=",">
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="rechargeNo != null">recharge_no = #{rechargeNo},</if>
            <if test="money != null">money = #{money},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="payType != null">pay_type = #{payType},</if>
            <if test="tradeNo != null">trade_no = #{tradeNo},</if>
            <if test="balance != null">balance = #{balance},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="isAudit != null">is_audit = #{isAudit},</if>
            <if test="auditUserId != null">audit_user_id = #{auditUserId},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where recharge_id = #{rechargeId}
    </update>

    <delete id="deleteCompanyRechargeById" parameterType="Long">
        delete from company_recharge where recharge_id = #{rechargeId}
    </delete>

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