<?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.game.business.mapper.ShopBusinessOrderMapper">
    
    <resultMap type="com.game.business.domain.ShopBusinessOrder" id="ShopBusinessOrderResult">
        <result property="id"    column="id"    />
        <result property="addTime"    column="add_time"    />
        <result property="address"    column="address"    />
        <result property="addressId"    column="address_id"    />
        <result property="anchorId"    column="anchor_id"    />
        <result property="auditFailureReason"    column="audit_failure_reason"    />
        <result property="businessId"    column="business_id"    />
        <result property="businessLogo"    column="business_logo"    />
        <result property="businessName"    column="business_name"    />
        <result property="goodsChannelId"    column="goods_channel_id"    />
        <result property="isManualRefund"    column="is_manual_refund"    />
        <result property="logisticsId"    column="logistics_id"    />
        <result property="manualRefundMoney"    column="manual_refund_money"    />
        <result property="manualRefundOperator"    column="manual_refund_operator"    />
        <result property="manualRefundType"    column="manual_refund_type"    />
        <result property="name"    column="name"    />
        <result property="orderAmount"    column="order_amount"    />
        <result property="orderNum"    column="order_num"    />
        <result property="payId"    column="pay_id"    />
        <result property="phoneNum"    column="phone_num"    />
        <result property="platformPayOrder"    column="platform_pay_order"    />
        <result property="quitStatus"    column="quit_status"    />
        <result property="reason"    column="reason"    />
        <result property="refundLogisticsId"    column="refund_logistics_id"    />
        <result property="refundNotes"    column="refund_notes"    />
        <result property="refundNotesImages"    column="refund_notes_images"    />
        <result property="refundOrderNum"    column="refund_order_num"    />
        <result property="refundTime"    column="refund_time"    />
        <result property="refundType"    column="refund_type"    />
        <result property="remake"    column="remake"    />
        <result property="status"    column="status"    />
        <result property="taskId"    column="task_id"    />
        <result property="transactionAmount"    column="transaction_amount"    />
        <result property="transactionTime"    column="transaction_time"    />
        <result property="uid"    column="uid"    />
    </resultMap>

    <sql id="selectShopBusinessOrderVo">
        select id, add_time, address, address_id, anchor_id, audit_failure_reason, business_id, business_logo, business_name, goods_channel_id, is_manual_refund, logistics_id, manual_refund_money, manual_refund_operator, manual_refund_type, name, order_amount, order_num, pay_id, phone_num, platform_pay_order, quit_status, reason, refund_logistics_id, refund_notes, refund_notes_images, refund_order_num, refund_time, refund_type, remake, status, task_id, transaction_amount, transaction_time, uid from shop_business_order
    </sql>

    <select id="selectShopBusinessOrderList" parameterType="com.game.business.domain.ShopBusinessOrder" resultMap="ShopBusinessOrderResult">
        <include refid="selectShopBusinessOrderVo"/>
        <where>  
            <if test="addTime != null "> and add_time = #{addTime}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="addressId != null "> and address_id = #{addressId}</if>
            <if test="anchorId != null "> and anchor_id = #{anchorId}</if>
            <if test="auditFailureReason != null  and auditFailureReason != ''"> and audit_failure_reason = #{auditFailureReason}</if>
            <if test="businessId != null "> and business_id = #{businessId}</if>
            <if test="businessLogo != null  and businessLogo != ''"> and business_logo = #{businessLogo}</if>
            <if test="businessName != null  and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
            <if test="goodsChannelId != null "> and goods_channel_id = #{goodsChannelId}</if>
            <if test="isManualRefund != null "> and is_manual_refund = #{isManualRefund}</if>
            <if test="logisticsId != null "> and logistics_id = #{logisticsId}</if>
            <if test="manualRefundMoney != null "> and manual_refund_money = #{manualRefundMoney}</if>
            <if test="manualRefundOperator != null  and manualRefundOperator != ''"> and manual_refund_operator = #{manualRefundOperator}</if>
            <if test="manualRefundType != null "> and manual_refund_type = #{manualRefundType}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="orderAmount != null "> and order_amount = #{orderAmount}</if>
            <if test="orderNum != null  and orderNum != ''"> and order_num = #{orderNum}</if>
            <if test="payId != null "> and pay_id = #{payId}</if>
            <if test="phoneNum != null  and phoneNum != ''"> and phone_num = #{phoneNum}</if>
            <if test="platformPayOrder != null  and platformPayOrder != ''"> and platform_pay_order = #{platformPayOrder}</if>
            <if test="quitStatus != null "> and quit_status = #{quitStatus}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="refundLogisticsId != null "> and refund_logistics_id = #{refundLogisticsId}</if>
            <if test="refundNotes != null  and refundNotes != ''"> and refund_notes = #{refundNotes}</if>
            <if test="refundNotesImages != null  and refundNotesImages != ''"> and refund_notes_images = #{refundNotesImages}</if>
            <if test="refundOrderNum != null  and refundOrderNum != ''"> and refund_order_num = #{refundOrderNum}</if>
            <if test="refundTime != null "> and refund_time = #{refundTime}</if>
            <if test="refundType != null "> and refund_type = #{refundType}</if>
            <if test="remake != null  and remake != ''"> and remake = #{remake}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="transactionAmount != null "> and transaction_amount = #{transactionAmount}</if>
            <if test="transactionTime != null "> and transaction_time = #{transactionTime}</if>
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="beginTime != null  and beginTime != ''"> and add_time &gt; CONCAT(#{beginTime},' 00:00:00')</if>
            <if test="endTime != null  and endTime != ''"> and add_time &lt; CONCAT(#{endTime},' 23:59:59')</if>
        </where>
    </select>
    
    <select id="selectShopBusinessOrderById" parameterType="Long" resultMap="ShopBusinessOrderResult">
        <include refid="selectShopBusinessOrderVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertShopBusinessOrder" parameterType="com.game.business.domain.ShopBusinessOrder">
        insert into shop_business_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="addTime != null">add_time,</if>
            <if test="address != null">address,</if>
            <if test="addressId != null">address_id,</if>
            <if test="anchorId != null">anchor_id,</if>
            <if test="auditFailureReason != null">audit_failure_reason,</if>
            <if test="businessId != null">business_id,</if>
            <if test="businessLogo != null">business_logo,</if>
            <if test="businessName != null">business_name,</if>
            <if test="goodsChannelId != null">goods_channel_id,</if>
            <if test="isManualRefund != null">is_manual_refund,</if>
            <if test="logisticsId != null">logistics_id,</if>
            <if test="manualRefundMoney != null">manual_refund_money,</if>
            <if test="manualRefundOperator != null">manual_refund_operator,</if>
            <if test="manualRefundType != null">manual_refund_type,</if>
            <if test="name != null">name,</if>
            <if test="orderAmount != null">order_amount,</if>
            <if test="orderNum != null">order_num,</if>
            <if test="payId != null">pay_id,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="platformPayOrder != null">platform_pay_order,</if>
            <if test="quitStatus != null">quit_status,</if>
            <if test="reason != null">reason,</if>
            <if test="refundLogisticsId != null">refund_logistics_id,</if>
            <if test="refundNotes != null">refund_notes,</if>
            <if test="refundNotesImages != null">refund_notes_images,</if>
            <if test="refundOrderNum != null">refund_order_num,</if>
            <if test="refundTime != null">refund_time,</if>
            <if test="refundType != null">refund_type,</if>
            <if test="remake != null">remake,</if>
            <if test="status != null">status,</if>
            <if test="taskId != null">task_id,</if>
            <if test="transactionAmount != null">transaction_amount,</if>
            <if test="transactionTime != null">transaction_time,</if>
            <if test="uid != null">uid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="addTime != null">#{addTime},</if>
            <if test="address != null">#{address},</if>
            <if test="addressId != null">#{addressId},</if>
            <if test="anchorId != null">#{anchorId},</if>
            <if test="auditFailureReason != null">#{auditFailureReason},</if>
            <if test="businessId != null">#{businessId},</if>
            <if test="businessLogo != null">#{businessLogo},</if>
            <if test="businessName != null">#{businessName},</if>
            <if test="goodsChannelId != null">#{goodsChannelId},</if>
            <if test="isManualRefund != null">#{isManualRefund},</if>
            <if test="logisticsId != null">#{logisticsId},</if>
            <if test="manualRefundMoney != null">#{manualRefundMoney},</if>
            <if test="manualRefundOperator != null">#{manualRefundOperator},</if>
            <if test="manualRefundType != null">#{manualRefundType},</if>
            <if test="name != null">#{name},</if>
            <if test="orderAmount != null">#{orderAmount},</if>
            <if test="orderNum != null">#{orderNum},</if>
            <if test="payId != null">#{payId},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="platformPayOrder != null">#{platformPayOrder},</if>
            <if test="quitStatus != null">#{quitStatus},</if>
            <if test="reason != null">#{reason},</if>
            <if test="refundLogisticsId != null">#{refundLogisticsId},</if>
            <if test="refundNotes != null">#{refundNotes},</if>
            <if test="refundNotesImages != null">#{refundNotesImages},</if>
            <if test="refundOrderNum != null">#{refundOrderNum},</if>
            <if test="refundTime != null">#{refundTime},</if>
            <if test="refundType != null">#{refundType},</if>
            <if test="remake != null">#{remake},</if>
            <if test="status != null">#{status},</if>
            <if test="taskId != null">#{taskId},</if>
            <if test="transactionAmount != null">#{transactionAmount},</if>
            <if test="transactionTime != null">#{transactionTime},</if>
            <if test="uid != null">#{uid},</if>
         </trim>
    </insert>

    <update id="updateShopBusinessOrder" parameterType="com.game.business.domain.ShopBusinessOrder">
        update shop_business_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="addTime != null">add_time = #{addTime},</if>
            <if test="address != null">address = #{address},</if>
            <if test="addressId != null">address_id = #{addressId},</if>
            <if test="anchorId != null">anchor_id = #{anchorId},</if>
            <if test="auditFailureReason != null">audit_failure_reason = #{auditFailureReason},</if>
            <if test="businessId != null">business_id = #{businessId},</if>
            <if test="businessLogo != null">business_logo = #{businessLogo},</if>
            <if test="businessName != null">business_name = #{businessName},</if>
            <if test="goodsChannelId != null">goods_channel_id = #{goodsChannelId},</if>
            <if test="isManualRefund != null">is_manual_refund = #{isManualRefund},</if>
            <if test="logisticsId != null">logistics_id = #{logisticsId},</if>
            <if test="manualRefundMoney != null">manual_refund_money = #{manualRefundMoney},</if>
            <if test="manualRefundOperator != null">manual_refund_operator = #{manualRefundOperator},</if>
            <if test="manualRefundType != null">manual_refund_type = #{manualRefundType},</if>
            <if test="name != null">name = #{name},</if>
            <if test="orderAmount != null">order_amount = #{orderAmount},</if>
            <if test="orderNum != null">order_num = #{orderNum},</if>
            <if test="payId != null">pay_id = #{payId},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="platformPayOrder != null">platform_pay_order = #{platformPayOrder},</if>
            <if test="quitStatus != null">quit_status = #{quitStatus},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="refundLogisticsId != null">refund_logistics_id = #{refundLogisticsId},</if>
            <if test="refundNotes != null">refund_notes = #{refundNotes},</if>
            <if test="refundNotesImages != null">refund_notes_images = #{refundNotesImages},</if>
            <if test="refundOrderNum != null">refund_order_num = #{refundOrderNum},</if>
            <if test="refundTime != null">refund_time = #{refundTime},</if>
            <if test="refundType != null">refund_type = #{refundType},</if>
            <if test="remake != null">remake = #{remake},</if>
            <if test="status != null">status = #{status},</if>
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="transactionAmount != null">transaction_amount = #{transactionAmount},</if>
            <if test="transactionTime != null">transaction_time = #{transactionTime},</if>
            <if test="uid != null">uid = #{uid},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteShopBusinessOrderById" parameterType="Long">
        delete from shop_business_order where id = #{id}
    </delete>

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