<?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.live.mapper.LiveOrderMapper">

    <resultMap type="LiveOrder" id="LiveOrderResult">
        <result property="orderId"    column="order_id"    />
        <result property="liveId"    column="live_id"    />
        <result property="storeId"    column="store_id"    />
        <result property="orderCode"    column="order_code"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="userPhone"    column="user_phone"    />
        <result property="userAddress"    column="user_address"    />
        <result property="cartId"    column="cart_id"    />
        <result property="totalNum"    column="total_num"    />
        <result property="totalPrice"    column="total_price"    />
        <result property="payPrice"    column="pay_price"    />
        <result property="payMoney"    column="pay_money"    />
        <result property="isPay"    column="is_pay"    />
        <result property="payTime"    column="pay_time"    />
        <result property="payType"    column="pay_type"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
        <result property="refundStatus"    column="refund_status"    />
        <result property="refundImg"    column="refund_img"    />
        <result property="refundExplain"    column="refund_explain"    />
        <result property="refundTime"    column="refund_time"    />
        <result property="refundReason"    column="refund_reason"    />
        <result property="refundMoney"    column="refund_money"    />
        <result property="deliveryCode"    column="delivery_code"    />
        <result property="deliveryName"    column="delivery_name"    />
        <result property="deliverySn"    column="delivery_sn"    />
        <result property="remark"    column="remark"    />
        <result property="isDel"    column="is_del"    />
        <result property="costPrice"    column="cost_price"    />
        <result property="verifyCode"    column="verify_code"    />
        <result property="shippingType"    column="shipping_type"    />
        <result property="isChannel"    column="is_channel"    />
        <result property="finishTime"    column="finish_time"    />
        <result property="deliveryTime"    column="delivery_time"    />
        <result property="tuiMoney"    column="tui_money"    />
        <result property="tuiMoneyStatus"    column="tui_money_status"    />
        <result property="tuiUserId"    column="tui_user_id"    />
        <result property="itemJson"    column="item_json"    />
        <result property="discountMoney"    column="discount_money"    />
        <result property="userCouponId"    column="user_coupon_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyUserId"    column="company_user_id"    />
        <result property="storeHouseCode"    column="store_house_code"    />
        <result property="extendOrderId"    column="extend_order_id"    />
        <result property="payDelivery"    column="pay_delivery"    />
        <result property="payRemain"    column="pay_remain"    />
        <result property="deliveryStatus"    column="delivery_status"    />
        <result property="deliveryPayStatus"    column="delivery_pay_status"    />
        <result property="deliveryPayTime"    column="delivery_pay_time"    />
        <result property="deliveryType"    column="delivery_type"    />
        <result property="deliveryPayMoney"    column="delivery_pay_money"    />
        <result property="deliveryImportTime"    column="delivery_import_time"    />
        <result property="deliverySendTime"    column="delivery_send_time"    />
        <result property="isAfterSales"    column="is_after_sales"    />
        <result property="deptId"    column="dept_id"    />
        <result property="channel"    column="channel"    />
        <result property="source"    column="source"    />
        <result property="billPrice"    column="bill_price"    />
        <result property="totalPostage"    column="total_postage"    />
        <result property="payPostage"    column="pay_postage"    />
        <result property="gainIntegral"    column="gain_integral"    />
        <result property="useIntegral"    column="use_integral"    />
        <result property="payIntegral"    column="pay_integral"    />
        <result property="backIntegral"    column="back_integral"    />
        <result property="isEditMoney"    column="is_edit_money"    />
        <result property="orderName"    column="order_name"    />
        <result property="productIntroduce"    column="product_introduce"    />
        <result property="companyUserName"    column="company_user_name"    />
        <result property="companyName"    column="company_name"    />
        <result property="customerId"    column="customer_id"    />
    </resultMap>

    <sql id="selectLiveOrderVo">
        SELECT
            a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
            a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
            a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
            a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
            a.remark,	a.is_del,	a.cost_price,	a.verify_code,	a.shipping_type,	a.is_channel,	a.finish_time,
            a.delivery_time,	a.tui_money,	a.tui_money_status,	a.tui_user_id,	a.item_json,	a.discount_money,
            a.user_coupon_id,	a.company_id,	a.company_user_id,	a.store_house_code,	a.extend_order_id,	a.pay_delivery,
            a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
            a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
            a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,
            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
        FROM
            live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
    </sql>

    <select id="selectLiveOrderList" parameterType="LiveOrder" resultMap="LiveOrderResult">
        SELECT
        c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
        a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
        a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
        a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
        a.remark,	a.is_del,	a.cost_price,	a.verify_code,	a.shipping_type,	a.is_channel,	a.finish_time,
        a.delivery_time,	a.tui_money,	a.tui_money_status,	a.tui_user_id,	a.item_json,	a.discount_money,
        a.user_coupon_id,	a.company_id,	a.company_user_id,	a.store_house_code,	a.extend_order_id,	a.pay_delivery,
        a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
        a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
        a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,
        a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
        FROM
        live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
        left join company_user cu on a.company_user_id = cu.user_id
        left join company c on a.company_id = c.company_id
        <where>
            <if test="liveId != null "> and live_id = #{liveId}</if>
            <if test="storeId != null "> and store_id = #{storeId}</if>
            <if test="orderCode != null  and orderCode != ''"> and a.order_code = #{orderCode}</if>
            <if test="userId != null  and userId != ''"> and a.user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and a.user_name like concat('%', #{userName}, '%')</if>
            <if test="userPhone != null  and userPhone != ''"> and a.user_phone = #{userPhone}</if>
            <if test="userAddress != null  and userAddress != ''"> and a.user_address = #{userAddress}</if>
            <if test="cartId != null  and cartId != ''"> and cart_id = #{cartId}</if>
            <if test="totalNum != null  and totalNum != ''"> and total_num = #{totalNum}</if>
            <if test="totalPrice != null "> and total_price = #{totalPrice}</if>
            <if test="payPrice != null "> and a.pay_price = #{payPrice}</if>
            <if test="payMoney != null "> and a.pay_money = #{payMoney}</if>
            <if test="isPay != null  and isPay != ''"> and a.is_pay = #{isPay}</if>
            <if test="payTime != null "> and pay_time = #{payTime}</if>
            <if test="payType != null  and payType != ''"> and pay_type = #{payType}</if>
            <if test="status != null "> and a.status = #{status}</if>
            <if test="refundStatus != null  and refundStatus != ''"> and refund_status = #{refundStatus}</if>
            <if test="refundImg != null  and refundImg != ''"> and refund_img = #{refundImg}</if>
            <if test="refundExplain != null  and refundExplain != ''"> and refund_explain = #{refundExplain}</if>
            <if test="refundTime != null "> and refund_time = #{refundTime}</if>
            <if test="refundReason != null  and refundReason != ''"> and refund_reason = #{refundReason}</if>
            <if test="refundMoney != null "> and refund_money = #{refundMoney}</if>
            <if test="deliveryCode != null  and deliveryCode != ''"> and a.delivery_code = #{deliveryCode}</if>
            <if test="deliveryName != null  and deliveryName != ''"> and a.delivery_name like concat('%', #{deliveryName}, '%')</if>
            <if test="deliverySn != null  and deliverySn != ''"> and a.delivery_sn = #{deliverySn}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="costPrice != null "> and cost_price = #{costPrice}</if>
            <if test="verifyCode != null  and verifyCode != ''"> and verify_code = #{verifyCode}</if>
            <if test="shippingType != null "> and shipping_type = #{shippingType}</if>
            <if test="isChannel != null  and isChannel != ''"> and is_channel = #{isChannel}</if>
            <if test="finishTime != null ">and a.finish_time >= #{finishTime} and a.finish_time &lt; date_add(#{finishTime}, interval 1 day)</if>
            <if test="deliveryTime != null  and deliveryTime != ''"> and a.delivery_time = #{deliveryTime}</if>
            <if test="tuiMoney != null "> and tui_money = #{tuiMoney}</if>
            <if test="tuiMoneyStatus != null "> and tui_money_status = #{tuiMoneyStatus}</if>
            <if test="tuiUserId != null "> and tui_user_id = #{tuiUserId}</if>
            <if test="itemJson != null  and itemJson != ''"> and item_json = #{itemJson}</if>
            <if test="discountMoney != null "> and discount_money = #{discountMoney}</if>
            <if test="userCouponId != null "> and user_coupon_id = #{userCouponId}</if>
            <if test="companyId != null "> and a.company_id = #{companyId}</if>
            <if test="companyUserId != null "> and a.company_user_id = #{companyUserId}</if>
            <if test="storeHouseCode != null  and storeHouseCode != ''"> and store_house_code = #{storeHouseCode}</if>
            <if test="extendOrderId != null  and extendOrderId != ''"> and extend_order_id = #{extendOrderId}</if>
            <if test="payDelivery != null "> and pay_delivery = #{payDelivery}</if>
            <if test="payRemain != null "> and pay_remain = #{payRemain}</if>
            <if test="deliveryStatus != null "> and delivery_status = #{deliveryStatus}</if>
            <if test="deliveryPayStatus != null "> and delivery_pay_status = #{deliveryPayStatus}</if>
            <if test="deliveryPayTime != null  and deliveryPayTime != ''"> and delivery_pay_time = #{deliveryPayTime}</if>
            <if test="deliveryType != null  and deliveryType != ''"> and delivery_type = #{deliveryType}</if>
            <if test="deliveryPayMoney != null "> and delivery_pay_money = #{deliveryPayMoney}</if>
            <if test="deliveryImportTime != null "> and delivery_import_time = #{deliveryImportTime}</if>
            <if test="deliverySendTime != null "> and delivery_send_time = #{deliverySendTime}</if>
            <if test="isAfterSales != null "> and is_after_sales = #{isAfterSales}</if>
            <if test="deptId != null "> and cu.dept_id = #{deptId}</if>
            <if test="channel != null  and channel != ''"> and channel = #{channel}</if>
            <if test="source != null "> and source = #{source}</if>
            <if test="billPrice != null "> and bill_price = #{billPrice}</if>
            <if test="totalPostage != null "> and total_postage = #{totalPostage}</if>
            <if test="payPostage != null "> and pay_postage = #{payPostage}</if>
            <if test="gainIntegral != null "> and gain_integral = #{gainIntegral}</if>
            <if test="useIntegral != null "> and use_integral = #{useIntegral}</if>
            <if test="payIntegral != null "> and pay_integral = #{payIntegral}</if>
            <if test="backIntegral != null "> and back_integral = #{backIntegral}</if>
            <if test="isEditMoney != null "> and is_edit_money = #{isEditMoney}</if>
            <if test="orderName != null "> and order_name = #{orderName}</if>
        </where>
        order by a.create_time desc
    </select>

    <select id="selectLiveOrderByOrderId" parameterType="String" resultMap="LiveOrderResult">
        SELECT
            c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
            a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
            a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
            a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
            a.remark,	a.is_del,	a.cost_price,	a.verify_code,	a.shipping_type,	a.is_channel,	a.finish_time,
            a.delivery_time,	a.tui_money,	a.tui_money_status,	a.tui_user_id,	a.item_json,	a.discount_money,
            a.user_coupon_id,	a.company_id,	a.company_user_id,	a.store_house_code,	a.extend_order_id,	a.pay_delivery,
            a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
            a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
            a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,
            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
        FROM
            live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
                         left join company_user cu on a.company_user_id = cu.user_id
                         left join company c on a.company_id = c.company_id
        where a.order_id = #{orderId}
        order by a.create_time desc
    </select>

    <insert id="insertLiveOrder" parameterType="LiveOrder" useGeneratedKeys="true" keyProperty="orderId">
        insert into live_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="liveId != null">live_id,</if>
            <if test="storeId != null">store_id,</if>
            <if test="orderCode != null and orderCode != ''">order_code,</if>
            <if test="userId != null and userId != ''">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="userPhone != null">user_phone,</if>
            <if test="userAddress != null">user_address,</if>
            <if test="cartId != null">cart_id,</if>
            <if test="totalNum != null and totalNum != ''">total_num,</if>
            <if test="totalPrice != null">total_price,</if>
            <if test="payPrice != null">pay_price,</if>
            <if test="payMoney != null">pay_money,</if>
            <if test="isPay != null">is_pay,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="payType != null">pay_type,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="status != null">status,</if>
            <if test="refundStatus != null">refund_status,</if>
            <if test="refundImg != null">refund_img,</if>
            <if test="refundExplain != null">refund_explain,</if>
            <if test="refundTime != null">refund_time,</if>
            <if test="refundReason != null">refund_reason,</if>
            <if test="refundMoney != null">refund_money,</if>
            <if test="deliveryCode != null">delivery_code,</if>
            <if test="deliveryName != null">delivery_name,</if>
            <if test="deliverySn != null">delivery_sn,</if>
            <if test="remark != null">remark,</if>
            <if test="isDel != null">is_del,</if>
            <if test="costPrice != null">cost_price,</if>
            <if test="verifyCode != null">verify_code,</if>
            <if test="shippingType != null">shipping_type,</if>
            <if test="isChannel != null">is_channel,</if>
            <if test="finishTime != null">finish_time,</if>
            <if test="deliveryTime != null">delivery_time,</if>
            <if test="tuiMoney != null">tui_money,</if>
            <if test="tuiMoneyStatus != null">tui_money_status,</if>
            <if test="tuiUserId != null">tui_user_id,</if>
            <if test="itemJson != null">item_json,</if>
            <if test="discountMoney != null">discount_money,</if>
            <if test="userCouponId != null">user_coupon_id,</if>
            <if test="companyId != null">company_id,</if>
            <if test="companyUserId != null">company_user_id,</if>
            <if test="storeHouseCode != null">store_house_code,</if>
            <if test="extendOrderId != null">extend_order_id,</if>
            <if test="payDelivery != null">pay_delivery,</if>
            <if test="payRemain != null">pay_remain,</if>
            <if test="deliveryStatus != null">delivery_status,</if>
            <if test="deliveryPayStatus != null">delivery_pay_status,</if>
            <if test="deliveryPayTime != null">delivery_pay_time,</if>
            <if test="deliveryType != null">delivery_type,</if>
            <if test="deliveryPayMoney != null">delivery_pay_money,</if>
            <if test="deliveryImportTime != null">delivery_import_time,</if>
            <if test="deliverySendTime != null">delivery_send_time,</if>
            <if test="isAfterSales != null">is_after_sales,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="channel != null">channel,</if>
            <if test="source != null">source,</if>
            <if test="billPrice != null">bill_price,</if>
            <if test="totalPostage != null">total_postage,</if>
            <if test="payPostage != null">pay_postage,</if>
            <if test="gainIntegral != null">gain_integral,</if>
            <if test="useIntegral != null">use_integral,</if>
            <if test="payIntegral != null">pay_integral,</if>
            <if test="backIntegral != null">back_integral,</if>
            <if test="isEditMoney != null">is_edit_money,</if>
            <if test="productId != null">product_id,</if>
            <if test="customerId != null">customer_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="liveId != null">#{liveId},</if>
            <if test="storeId != null">#{storeId},</if>
            <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
            <if test="userId != null and userId != ''">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="userPhone != null">#{userPhone},</if>
            <if test="userAddress != null">#{userAddress},</if>
            <if test="cartId != null">#{cartId},</if>
            <if test="totalNum != null and totalNum != ''">#{totalNum},</if>
            <if test="totalPrice != null">#{totalPrice},</if>
            <if test="payPrice != null">#{payPrice},</if>
            <if test="payMoney != null">#{payMoney},</if>
            <if test="isPay != null">#{isPay},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="payType != null">#{payType},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="status != null">#{status},</if>
            <if test="refundStatus != null">#{refundStatus},</if>
            <if test="refundImg != null">#{refundImg},</if>
            <if test="refundExplain != null">#{refundExplain},</if>
            <if test="refundTime != null">#{refundTime},</if>
            <if test="refundReason != null">#{refundReason},</if>
            <if test="refundMoney != null">#{refundMoney},</if>
            <if test="deliveryCode != null">#{deliveryCode},</if>
            <if test="deliveryName != null">#{deliveryName},</if>
            <if test="deliverySn != null">#{deliverySn},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="costPrice != null">#{costPrice},</if>
            <if test="verifyCode != null">#{verifyCode},</if>
            <if test="shippingType != null">#{shippingType},</if>
            <if test="isChannel != null">#{isChannel},</if>
            <if test="finishTime != null">#{finishTime},</if>
            <if test="deliveryTime != null">#{deliveryTime},</if>
            <if test="tuiMoney != null">#{tuiMoney},</if>
            <if test="tuiMoneyStatus != null">#{tuiMoneyStatus},</if>
            <if test="tuiUserId != null">#{tuiUserId},</if>
            <if test="itemJson != null">#{itemJson},</if>
            <if test="discountMoney != null">#{discountMoney},</if>
            <if test="userCouponId != null">#{userCouponId},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="companyUserId != null">#{companyUserId},</if>
            <if test="storeHouseCode != null">#{storeHouseCode},</if>
            <if test="extendOrderId != null">#{extendOrderId},</if>
            <if test="payDelivery != null">#{payDelivery},</if>
            <if test="payRemain != null">#{payRemain},</if>
            <if test="deliveryStatus != null">#{deliveryStatus},</if>
            <if test="deliveryPayStatus != null">#{deliveryPayStatus},</if>
            <if test="deliveryPayTime != null">#{deliveryPayTime},</if>
            <if test="deliveryType != null">#{deliveryType},</if>
            <if test="deliveryPayMoney != null">#{deliveryPayMoney},</if>
            <if test="deliveryImportTime != null">#{deliveryImportTime},</if>
            <if test="deliverySendTime != null">#{deliverySendTime},</if>
            <if test="isAfterSales != null">#{isAfterSales},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="channel != null">#{channel},</if>
            <if test="source != null">#{source},</if>
            <if test="billPrice != null">#{billPrice},</if>
            <if test="totalPostage != null">#{totalPostage},</if>
            <if test="payPostage != null">#{payPostage},</if>
            <if test="gainIntegral != null">#{gainIntegral},</if>
            <if test="useIntegral != null">#{useIntegral},</if>
            <if test="payIntegral != null">#{payIntegral},</if>
            <if test="backIntegral != null">#{backIntegral},</if>
            <if test="isEditMoney != null">#{isEditMoney},</if>
            <if test="productId != null">#{productId},</if>
            <if test="customerId != null">#{customerId},</if>
         </trim>
    </insert>

    <update id="updateLiveOrder" parameterType="LiveOrder">
        update live_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="liveId != null">live_id = #{liveId},</if>
            <if test="storeId != null">store_id = #{storeId},</if>
            <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
            <if test="userId != null and userId != ''">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="userPhone != null">user_phone = #{userPhone},</if>
            <if test="userAddress != null">user_address = #{userAddress},</if>
            <if test="cartId != null">cart_id = #{cartId},</if>
            <if test="totalNum != null and totalNum != ''">total_num = #{totalNum},</if>
            <if test="totalPrice != null">total_price = #{totalPrice},</if>
            <if test="payPrice != null">pay_price = #{payPrice},</if>
            <if test="payMoney != null">pay_money = #{payMoney},</if>
            <if test="isPay != null">is_pay = #{isPay},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="payType != null">pay_type = #{payType},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="refundStatus != null">refund_status = #{refundStatus},</if>
            <if test="refundImg != null">refund_img = #{refundImg},</if>
            <if test="refundExplain != null">refund_explain = #{refundExplain},</if>
            <if test="refundTime != null">refund_time = #{refundTime},</if>
            <if test="refundReason != null">refund_reason = #{refundReason},</if>
            <if test="refundMoney != null">refund_money = #{refundMoney},</if>
            <if test="deliveryCode != null">delivery_code = #{deliveryCode},</if>
            <if test="deliveryName != null">delivery_name = #{deliveryName},</if>
            <if test="deliverySn != null">delivery_sn = #{deliverySn},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="costPrice != null">cost_price = #{costPrice},</if>
            <if test="verifyCode != null">verify_code = #{verifyCode},</if>
            <if test="shippingType != null">shipping_type = #{shippingType},</if>
            <if test="isChannel != null">is_channel = #{isChannel},</if>
            <if test="finishTime != null">finish_time = #{finishTime},</if>
            <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
            <if test="tuiMoney != null">tui_money = #{tuiMoney},</if>
            <if test="tuiMoneyStatus != null">tui_money_status = #{tuiMoneyStatus},</if>
            <if test="tuiUserId != null">tui_user_id = #{tuiUserId},</if>
            <if test="itemJson != null">item_json = #{itemJson},</if>
            <if test="discountMoney != null">discount_money = #{discountMoney},</if>
            <if test="userCouponId != null">user_coupon_id = #{userCouponId},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
            <if test="storeHouseCode != null">store_house_code = #{storeHouseCode},</if>
            <if test="extendOrderId != null">extend_order_id = #{extendOrderId},</if>
            <if test="payDelivery != null">pay_delivery = #{payDelivery},</if>
            <if test="payRemain != null">pay_remain = #{payRemain},</if>
            <if test="deliveryStatus != null">delivery_status = #{deliveryStatus},</if>
            <if test="deliveryPayStatus != null">delivery_pay_status = #{deliveryPayStatus},</if>
            <if test="deliveryPayTime != null">delivery_pay_time = #{deliveryPayTime},</if>
            <if test="deliveryType != null">delivery_type = #{deliveryType},</if>
            <if test="deliveryPayMoney != null">delivery_pay_money = #{deliveryPayMoney},</if>
            <if test="deliveryImportTime != null">delivery_import_time = #{deliveryImportTime},</if>
            <if test="deliverySendTime != null">delivery_send_time = #{deliverySendTime},</if>
            <if test="isAfterSales != null">is_after_sales = #{isAfterSales},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="channel != null">channel = #{channel},</if>
            <if test="source != null">source = #{source},</if>
            <if test="billPrice != null">bill_price = #{billPrice},</if>
            <if test="totalPostage != null">total_postage = #{totalPostage},</if>
            <if test="payPostage != null">pay_postage = #{payPostage},</if>
            <if test="gainIntegral != null">gain_integral = #{gainIntegral},</if>
            <if test="useIntegral != null">use_integral = #{useIntegral},</if>
            <if test="payIntegral != null">pay_integral = #{payIntegral},</if>
            <if test="backIntegral != null">back_integral = #{backIntegral},</if>
            <if test="isEditMoney != null">is_edit_money = #{isEditMoney},</if>
            <if test="customerId != null">customer_id = #{customerId},</if>
        </trim>
        where order_id = #{orderId}
    </update>

    <delete id="deleteLiveOrderByOrderId" parameterType="String">
        delete from live_order where order_id = #{orderId}
    </delete>

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

    <select id="getLiveOrderTimeGranularity" parameterType="com.fs.live.vo.LiveOrderVo" resultMap="LiveOrderResult">
        <include refid="selectLiveOrderVo"/>
        where 1=1
        <if test="timeOptions != 'all'">and a.create_time >= #{createTime}</if>
        <if test="liveId != null">and a.live_id = #{liveId}</if>

        order by a.create_time desc
    </select>
</mapper>
