<?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.system.mapper.OrderLogMapper">
    
    <resultMap type="OrderLog" id="OrderLogResult">
        <result property="id"    column="id"    />
        <result property="oid"    column="oid"    />
        <result property="orderId"    column="order_id"    />
        <result property="logOrderId"    column="log_order_id"    />
        <result property="title"    column="title"    />
        <result property="type"    column="type"    />
        <result property="content"    column="content"    />
        <result property="deposit"    column="deposit"    />
        <result property="depPaid"    column="dep_paid"    />
        <result property="depPayTime"    column="dep_pay_time"    />
        <result property="depLogId"    column="dep_log_id"    />
        <result property="price"    column="price"    />
        <result property="paid"    column="paid"    />
        <result property="payTime"    column="pay_time"    />
        <result property="logId"    column="log_id"    />
        <result property="workerId"    column="worker_id"    />
        <result property="firstWorkerId"    column="first_worker_id"    />
        <result property="giveUp"    column="give_up"    />
        <result property="workerCost"    column="worker_cost"    />
        <result property="reductionPrice"    column="reduction_price"    />
        <result property="isPause"    column="is_pause"    />
        <result property="couponId"    column="coupon_id"    />
        <result property="deduction"    column="deduction"    />
        <result property="workerLogId"    column="worker_log_id"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
        <result property="deletedAt"    column="deleted_at"    />
    </resultMap>

    <sql id="selectOrderLogVo">
        select id, oid, order_id, log_order_id, title, type, content, deposit, dep_paid, dep_pay_time, dep_log_id, price, paid, pay_time, log_id, worker_id, first_worker_id, give_up, worker_cost, reduction_price, is_pause, coupon_id, deduction, worker_log_id, created_at, updated_at, deleted_at from order_log
    </sql>

    <select id="selectOrderLogList" parameterType="OrderLog" resultMap="OrderLogResult">
        <include refid="selectOrderLogVo"/>
        <where>  
            <if test="oid != null "> and oid = #{oid}</if>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="logOrderId != null  and logOrderId != ''"> and log_order_id = #{logOrderId}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="deposit != null "> and deposit = #{deposit}</if>
            <if test="depPaid != null "> and dep_paid = #{depPaid}</if>
            <if test="depPayTime != null "> and dep_pay_time = #{depPayTime}</if>
            <if test="depLogId != null  and depLogId != ''"> and dep_log_id = #{depLogId}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="paid != null "> and paid = #{paid}</if>
            <if test="payTime != null "> and pay_time = #{payTime}</if>
            <if test="logId != null  and logId != ''"> and log_id = #{logId}</if>
            <if test="workerId != null "> and worker_id = #{workerId}</if>
            <if test="firstWorkerId != null "> and first_worker_id = #{firstWorkerId}</if>
            <if test="giveUp != null "> and give_up = #{giveUp}</if>
            <if test="workerCost != null "> and worker_cost = #{workerCost}</if>
            <if test="reductionPrice != null "> and reduction_price = #{reductionPrice}</if>
            <if test="isPause != null "> and is_pause = #{isPause}</if>
            <if test="couponId != null "> and coupon_id = #{couponId}</if>
            <if test="deduction != null "> and deduction = #{deduction}</if>
            <if test="workerLogId != null "> and worker_log_id = #{workerLogId}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
            <if test="deletedAt != null "> and deleted_at = #{deletedAt}</if>
        </where>
    </select>
    
    <select id="selectOrderLogById" parameterType="Long" resultMap="OrderLogResult">
        <include refid="selectOrderLogVo"/>
        where id = #{id}
    </select>

    <select id="selectCountOrderLogByOrderId" parameterType="String" resultType="Integer">
        select count(*) from order_log where order_id = #{orderId}
    </select>

    <select id="selectOrderLogByOrderId" parameterType="String" resultMap="OrderLogResult">
        select * from order_log where order_id = #{orderId}
    </select>

    <insert id="insertOrderLog" parameterType="OrderLog" useGeneratedKeys="true" keyProperty="id">
        insert into order_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="oid != null">oid,</if>
            <if test="orderId != null and orderId != ''">order_id,</if>
            <if test="logOrderId != null">log_order_id,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="type != null">type,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="deposit != null">deposit,</if>
            <if test="depPaid != null">dep_paid,</if>
            <if test="depPayTime != null">dep_pay_time,</if>
            <if test="depLogId != null">dep_log_id,</if>
            <if test="price != null">price,</if>
            <if test="paid != null">paid,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="logId != null">log_id,</if>
            <if test="workerId != null">worker_id,</if>
            <if test="firstWorkerId != null">first_worker_id,</if>
            <if test="giveUp != null">give_up,</if>
            <if test="workerCost != null">worker_cost,</if>
            <if test="reductionPrice != null">reduction_price,</if>
            <if test="isPause != null">is_pause,</if>
            <if test="couponId != null">coupon_id,</if>
            <if test="deduction != null">deduction,</if>
            <if test="workerLogId != null">worker_log_id,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="updatedAt != null">updated_at,</if>
            <if test="deletedAt != null">deleted_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="oid != null">#{oid},</if>
            <if test="orderId != null and orderId != ''">#{orderId},</if>
            <if test="logOrderId != null">#{logOrderId},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="type != null">#{type},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="deposit != null">#{deposit},</if>
            <if test="depPaid != null">#{depPaid},</if>
            <if test="depPayTime != null">#{depPayTime},</if>
            <if test="depLogId != null">#{depLogId},</if>
            <if test="price != null">#{price},</if>
            <if test="paid != null">#{paid},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="logId != null">#{logId},</if>
            <if test="workerId != null">#{workerId},</if>
            <if test="firstWorkerId != null">#{firstWorkerId},</if>
            <if test="giveUp != null">#{giveUp},</if>
            <if test="workerCost != null">#{workerCost},</if>
            <if test="reductionPrice != null">#{reductionPrice},</if>
            <if test="isPause != null">#{isPause},</if>
            <if test="couponId != null">#{couponId},</if>
            <if test="deduction != null">#{deduction},</if>
            <if test="workerLogId != null">#{workerLogId},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="updatedAt != null">#{updatedAt},</if>
            <if test="deletedAt != null">#{deletedAt},</if>
         </trim>
    </insert>

    <update id="updateOrderLog" parameterType="OrderLog">
        update order_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="oid != null">oid = #{oid},</if>
            <if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
            <if test="logOrderId != null">log_order_id = #{logOrderId},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="type != null">type = #{type},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="deposit != null">deposit = #{deposit},</if>
            <if test="depPaid != null">dep_paid = #{depPaid},</if>
            <if test="depPayTime != null">dep_pay_time = #{depPayTime},</if>
            <if test="depLogId != null">dep_log_id = #{depLogId},</if>
            <if test="price != null">price = #{price},</if>
            <if test="paid != null">paid = #{paid},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="logId != null">log_id = #{logId},</if>
            <if test="workerId != null">worker_id = #{workerId},</if>
            <if test="firstWorkerId != null">first_worker_id = #{firstWorkerId},</if>
            <if test="giveUp != null">give_up = #{giveUp},</if>
            <if test="workerCost != null">worker_cost = #{workerCost},</if>
            <if test="reductionPrice != null">reduction_price = #{reductionPrice},</if>
            <if test="isPause != null">is_pause = #{isPause},</if>
            <if test="couponId != null">coupon_id = #{couponId},</if>
            <if test="deduction != null">deduction = #{deduction},</if>
            <if test="workerLogId != null">worker_log_id = #{workerLogId},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
            <if test="updatedAt != null">updated_at = #{updatedAt},</if>
            <if test="deletedAt != null">deleted_at = #{deletedAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderLogById" parameterType="Long">
        delete from order_log where id = #{id}
    </delete>

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