<?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.CompanySmsOrderMapper">
    
    <resultMap type="CompanySmsOrder" id="CompanySmsOrderResult">
        <result property="orderId"    column="order_id"    />
        <result property="orderCode"    column="order_code"    />
        <result property="packageId"    column="package_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="smsCount"    column="sms_count"    />
        <result property="price"    column="price"    />
        <result property="payMoney"    column="pay_money"    />
        <result property="createTime"    column="create_time"    />
        <result property="payTime"    column="pay_time"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectCompanySmsOrderVo">
        select order_id, order_code, package_id, company_id, sms_count, price, pay_money, create_time, pay_time, status from company_sms_order
    </sql>


    <select id="selectCompanySmsOrderById" parameterType="Long" resultMap="CompanySmsOrderResult">
        <include refid="selectCompanySmsOrderVo"/>
        where order_id = #{orderId}
    </select>
        
    <insert id="insertCompanySmsOrder" parameterType="CompanySmsOrder" useGeneratedKeys="true" keyProperty="orderId">
        insert into company_sms_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderCode != null">order_code,</if>
            <if test="packageId != null">package_id,</if>
            <if test="companyId != null">company_id,</if>
            <if test="smsCount != null">sms_count,</if>
            <if test="price != null">price,</if>
            <if test="payMoney != null">pay_money,</if>
            <if test="createTime != null">create_time,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderCode != null">#{orderCode},</if>
            <if test="packageId != null">#{packageId},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="smsCount != null">#{smsCount},</if>
            <if test="price != null">#{price},</if>
            <if test="payMoney != null">#{payMoney},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateCompanySmsOrder" parameterType="CompanySmsOrder">
        update company_sms_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderCode != null">order_code = #{orderCode},</if>
            <if test="packageId != null">package_id = #{packageId},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="smsCount != null">sms_count = #{smsCount},</if>
            <if test="price != null">price = #{price},</if>
            <if test="payMoney != null">pay_money = #{payMoney},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where order_id = #{orderId}
    </update>

    <delete id="deleteCompanySmsOrderById" parameterType="Long">
        delete from company_sms_order where order_id = #{orderId}
    </delete>

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