<?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="cn.reghao.tnb.file.app.zorder.db.OrderMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into mall_order
        (`order_id`,`product_id`,`delivery_id`,`price`,`amount`,`owner`,`status`)
        values
        (#{orderId},#{productId},#{deliveryId},#{price},#{amount},#{owner},#{status})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into mall_order
        (`order_id`,`product_id`,`delivery_id`,`price`,`amount`,`owner`,`status`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.orderId},#{item.productId},#{item.deliveryId},#{item.price},#{item.amount},#{item.owner},#{item.status})
        </foreach>
    </insert>

    <update id="updateOrderStatus">
        update mall_order
        set `status`=#{status}
        where `order_id`=#{orderId}
    </update>
    
    <select id="findByOwner" resultType="cn.reghao.tnb.file.app.zorder.model.po.Order">
        select *
        from mall_order
        where `owner`=#{owner}
        order by create_time desc
        limit #{pageSize}
    </select>
    <select id="findByOrderId" resultType="cn.reghao.tnb.file.app.zorder.model.po.Order">
        select *
        from mall_order
        where `order_id`=#{orderId}
    </select>
</mapper>
