<?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.platform.dao.ApiOrderShippingMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.platform.entity.OrderShippingVo" id="orderShippingMap">
        <result property="id" column="id"/>
        <result property="orderId" column="order_id"/>
        <result property="brandId" column="brand_id"/>
        <result property="totalPrice" column="total_price"/>
        <result property="freightPrice" column="freight_price"/>
        <result property="couponPrice" column="coupon_Price"/>
        <result property="shippingId" column="shipping_id"/>
        <result property="shippingName" column="shipping_name"/>
        <result property="shippingNo" column="shipping_no"/>
		<result property="shippingStatus" column="shipping_status"/>
    </resultMap>

	<select id="queryObject" resultType="com.platform.entity.OrderShippingVo">
		select * from nideshop_order_shipping where id = #{value}
	</select>

	<select id="queryList" resultType="com.platform.entity.OrderShippingVo">
		select * from nideshop_order_shipping
		WHERE 1=1
		<if test="orderId != null and orderId != ''">
			AND order_id = #{orderId}
		</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 nideshop_order_shipping
		WHERE 1=1
		<if test="orderId != null and orderId != ''">
			AND order_id = #{orderId}
		</if>
	</select>

	<insert id="save" parameterType="com.platform.entity.OrderShippingEntity" useGeneratedKeys="true" keyProperty="id">
		insert into nideshop_order_shipping
		(
		`order_id`,
		`brand_id`,
		`total_price`,
		`freight_price`,
		`coupon_Price`,
		`shipping_id`,
		`shipping_name`,
		`shipping_no`,
		shipping_status
		)
		values
		(
		#{orderId},
		#{brandId},
		#{totalPrice},
		#{freightPrice},
		#{couponPrice},
		#{shippingId},
		#{shippingName},
		#{shippingNo},
		#{shippingStatus}
		)
	</insert>

	<update id="update" parameterType="com.platform.entity.OrderShippingEntity">
		update nideshop_order_shipping
		<set>
			<if test="orderId != null">`order_id` = #{orderId}, </if>
			<if test="brandId != null">`brand_id` = #{brandId}, </if>
			<if test="totalPrice != null">`total_price` = #{totalPrice}, </if>
			<if test="freightPrice != null">`freight_price` = #{freightPrice}, </if>
			<if test="couponPrice != null">`coupon_Price` = #{couponPrice}, </if>
			<if test="shippingId != null">`shipping_id` = #{shippingId}, </if>
			<if test="shippingName != null">`shipping_name` = #{shippingName}, </if>
			<if test="shippingNo != null">`shipping_no` = #{shippingNo}, </if>
			<if test="shippingStatus != null">`shipping_status` = #{shippingStatus}, </if>
		</set>
		where id = #{id}
	</update>
	
	<delete id="delete">
		delete from nideshop_order_shipping where id = #{value}
	</delete>
	
	<delete id="deleteBatch">
		delete from nideshop_order_shipping where id in 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

</mapper>