<?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.kmall.admin.dao.OrderProcessRecordDao">

    <resultMap type="com.kmall.admin.entity.OrderProcessRecordEntity" id="orderProcessRecordMap">
        <result property="id" column="id"/>
        <result property="orderSn" column="order_sn"/>
        <result property="userId" column="user_id"/>
        <result property="orderBizType" column="order_biz_type"/>
        <result property="addOrderStartTime" column="add_order_start_time"/>
        <result property="addOrderSuccTime" column="add_order_succ_time"/>
        <result property="isAddOrderSend" column="is_add_order_send"/>
        <result property="payStartTime" column="pay_start_time"/>
        <result property="paySuccTime" column="pay_succ_time"/>
        <result property="paymentStartTime" column="payment_start_time"/>
        <result property="paymentSuccTime" column="payment_succ_time"/>
        <result property="isPaymentSend" column="is_payment_send"/>
        <result property="eleOrderStartTime" column="ele_order_start_time"/>
        <result property="eleOrderSuccTime" column="ele_order_succ_time"/>
        <result property="isEleOrderSend" column="is_ele_order_send"/>
        <result property="waybillStartTime" column="waybill_start_time"/>
        <result property="waybillSuccTime" column="waybill_succ_time"/>
        <result property="logisticsNo" column="logistics_no"/>
        <result property="customsStartTime" column="customs_start_time"/>
        <result property="customsSuccTime" column="customs_succ_time"/>
        <result property="invtNo" column="invt_no"/>
        <result property="isCustomsSend" column="is_customs_send"/>
        <result property="shipmentStartTime" column="shipment_start_time"/>
        <result property="shipmentSuccTime" column="shipment_succ_time"/>
        <result property="processContent" column="process_content"/>
        <result property="tstm" column="tstm"/>
    </resultMap>

	<select id="queryObject" resultType="com.kmall.admin.entity.OrderProcessRecordEntity">
		select
			`id`,
			`order_sn`,
			`user_id`,
			`order_biz_type`,
			`add_order_start_time`,
			`add_order_succ_time`,
			`is_add_order_send`,
			`pay_start_time`,
			`pay_succ_time`,
			`payment_start_time`,
			`payment_succ_time`,
			`is_payment_send`,
			`ele_order_start_time`,
			`ele_order_succ_time`,
			`is_ele_order_send`,
			`waybill_start_time`,
			`waybill_succ_time`,
			`logistics_no`,
			`customs_start_time`,
			`customs_succ_time`,
			`invt_no`,
			`is_customs_send`,
			`shipment_start_time`,
			`shipment_succ_time`,
			`process_content`,
			`tstm`
		from mall_order_process_record
		where id = #{id}
	</select>

	<select id="queryObjectByOrderSn" resultType="com.kmall.admin.entity.OrderProcessRecordEntity">
		select *
		from mall_order_process_record
		where order_sn = #{orderSn}
	</select>

	<select id="queryList" resultType="com.kmall.admin.entity.OrderProcessRecordEntity">
		select
    		`id`,
    		`order_sn`,
    		`user_id`,
    		`order_biz_type`,
    		`add_order_start_time`,
    		`add_order_succ_time`,
    		`is_add_order_send`,
    		`pay_start_time`,
    		`pay_succ_time`,
    		`payment_start_time`,
    		`payment_succ_time`,
    		`is_payment_send`,
    		`ele_order_start_time`,
    		`ele_order_succ_time`,
    		`is_ele_order_send`,
    		`waybill_start_time`,
    		`waybill_succ_time`,
    		`logistics_no`,
    		`customs_start_time`,
    		`customs_succ_time`,
    		`invt_no`,
    		`is_customs_send`,
    		`shipment_start_time`,
    		`shipment_succ_time`,
    		`process_content`,
    		`tstm`
		from mall_order_process_record
		WHERE 1=1
		<if test="name != null and name.trim() != ''">
			AND name LIKE concat('%',#{name},'%')
		</if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
			<otherwise>
                order by id desc
			</otherwise>
        </choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>
	
 	<select id="queryTotal" resultType="int">
		select count(*) from mall_order_process_record
		WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
	</select>
	 
	<insert id="save" parameterType="com.kmall.admin.entity.OrderProcessRecordEntity" useGeneratedKeys="true" keyProperty="id">
		insert into mall_order_process_record(
			`order_sn`,
			`user_id`,
			`order_biz_type`,
			`add_order_start_time`,
			`add_order_succ_time`,
			`is_add_order_send`,
			`pay_start_time`,
			`pay_succ_time`,
			`payment_start_time`,
			`payment_succ_time`,
			`is_payment_send`,
			`ele_order_start_time`,
			`ele_order_succ_time`,
			`is_ele_order_send`,
			`waybill_start_time`,
			`waybill_succ_time`,
			`logistics_no`,
			`customs_start_time`,
			`customs_succ_time`,
			`invt_no`,
			`is_customs_send`,
			`shipment_start_time`,
			`shipment_succ_time`,
			`process_content`,
			`tstm`)
		values(
			#{orderSn},
			#{userId},
			#{orderBizType},
			#{addOrderStartTime},
			#{addOrderSuccTime},
			#{isAddOrderSend},
			#{payStartTime},
			#{paySuccTime},
			#{paymentStartTime},
			#{paymentSuccTime},
			#{isPaymentSend},
			#{eleOrderStartTime},
			#{eleOrderSuccTime},
			#{isEleOrderSend},
			#{waybillStartTime},
			#{waybillSuccTime},
			#{logisticsNo},
			#{customsStartTime},
			#{customsSuccTime},
			#{invtNo},
			#{isCustomsSend},
			#{shipmentStartTime},
			#{shipmentSuccTime},
			#{processContent},
			#{tstm})
	</insert>
	 
	<update id="update" parameterType="com.kmall.admin.entity.OrderProcessRecordEntity">
		update mall_order_process_record 
		<set>
			<if test="orderSn != null">`order_sn` = #{orderSn}, </if>
			<if test="userId != null">`user_id` = #{userId}, </if>
			<if test="orderBizType != null">`order_biz_type` = #{orderBizType}, </if>
			<if test="addOrderStartTime != null">`add_order_start_time` = #{addOrderStartTime}, </if>
			<if test="addOrderSuccTime != null">`add_order_succ_time` = #{addOrderSuccTime}, </if>
			<if test="isAddOrderSend != null">`is_add_order_send` = #{isAddOrderSend}, </if>
			<if test="payStartTime != null">`pay_start_time` = #{payStartTime}, </if>
			<if test="paySuccTime != null">`pay_succ_time` = #{paySuccTime}, </if>
			<if test="paymentStartTime != null">`payment_start_time` = #{paymentStartTime}, </if>
			<if test="paymentSuccTime != null">`payment_succ_time` = #{paymentSuccTime}, </if>
			<if test="isPaymentSend != null">`is_payment_send` = #{isPaymentSend}, </if>
			<if test="eleOrderStartTime != null">`ele_order_start_time` = #{eleOrderStartTime}, </if>
			<if test="eleOrderSuccTime != null">`ele_order_succ_time` = #{eleOrderSuccTime}, </if>
			<if test="isEleOrderSend != null">`is_ele_order_send` = #{isEleOrderSend}, </if>
			<if test="waybillStartTime != null">`waybill_start_time` = #{waybillStartTime}, </if>
			<if test="waybillSuccTime != null">`waybill_succ_time` = #{waybillSuccTime}, </if>
			<if test="logisticsNo != null">`logistics_no` = #{logisticsNo}, </if>
			<if test="customsStartTime != null">`customs_start_time` = #{customsStartTime}, </if>
			<if test="customsSuccTime != null">`customs_succ_time` = #{customsSuccTime}, </if>
			<if test="invtNo != null">`invt_no` = #{invtNo}, </if>
			<if test="isCustomsSend != null">`is_customs_send` = #{isCustomsSend}, </if>
			<if test="shipmentStartTime != null">`shipment_start_time` = #{shipmentStartTime}, </if>
			<if test="shipmentSuccTime != null">`shipment_succ_time` = #{shipmentSuccTime}, </if>
			<if test="processContent != null">`process_content` = #{processContent}, </if>
			<if test="tstm != null">`tstm` = #{tstm}</if>
		</set>
		where id = #{id}
	</update>
	
	<delete id="delete">
		delete from mall_order_process_record where id = #{value}
	</delete>
	
	<delete id="deleteBatch">
		delete from mall_order_process_record where id in 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

</mapper>