<?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.ruoyi.oa.mapper.CmcSettleSummaryMapper">
    
    <resultMap type="CmcSettleSummary" id="CmcSettleSummaryResult">
        <result property="summaryId"    column="summary_id"    />
        <result property="settleId"    column="settle_id"    />
        <result property="content"    column="content"    />
        <result property="amount"    column="amount"    />
        <result property="remark"    column="remark"    />
        <result property="tableNumber"    column="table_number"    />
    </resultMap>

    <sql id="selectCmcSettleSummaryVo">
        select summary_id, settle_id, content, amount, table_number, remark from cmc_settle_summary
    </sql>

    <select id="selectCmcSettleSummaryList" parameterType="CmcSettleSummary" resultMap="CmcSettleSummaryResult">
        <include refid="selectCmcSettleSummaryVo"/>
        <where>  
            <if test="settleId != null  and settleId != ''"> and settle_id = #{settleId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="tableNumber != null  and tableNumber != ''"> and table_number = #{tableNumber}</if>
        </where>
        order by settle_id asc
    </select>
    
    <select id="selectCmcSettleSummaryBySettleId" parameterType="String" resultMap="CmcSettleSummaryResult">
        <include refid="selectCmcSettleSummaryVo"/>
        where settle_id = #{settleId}
    </select>
        
    <insert id="insertCmcSettleSummary" parameterType="CmcSettleSummary">
        insert into cmc_settle_summary
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="summaryId != null">summary_id,</if>
            <if test="settleId != null">settle_id,</if>
            <if test="content != null">content,</if>
            <if test="amount != null">amount,</if>
            <if test="tableNumber != null">table_number,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="summaryId != null">#{summaryId},</if>
            <if test="settleId != null">#{settleId},</if>
            <if test="content != null">#{content},</if>
            <if test="amount != null">#{amount},</if>
            <if test="tableNumber != null">#{tableNumber},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCmcSettleSummary" parameterType="CmcSettleSummary">
        update cmc_settle_summary
        <trim prefix="SET" suffixOverrides=",">
            <if test="settleId != null">settle_id = #{settleId},</if>
            <if test="content != null">content = #{content},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="tableNumber != null">table_number = #{tableNumber},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where summary_id = #{summaryId}
    </update>

    <delete id="deleteCmcSettleSummaryBySettleId" parameterType="String">
        delete from cmc_settle_summary where settle_id = #{settleId}
    </delete>

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