<?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.czg.service.order.mapper.OrderDetailMapper">

    <insert id="createOrderDetails">
        INSERT INTO tb_order_detail(order_id, shop_id, product_id, product_img, product_name, product_type, sku_id,
        sku_name, price,member_price,discount_sale_amount,unit_price, discount_amount, pack_amount, pay_amount,
        return_amount, num, pack_number, coupon_num,
        return_num, refund_num, refund_no, discount_sale_note, status, place_num, is_temporary, is_print, is_wait_call,
        pro_group_info, remark, refund_remark, create_time, update_time)
        VALUES
        <foreach collection="orderDetails" item="entity" separator=",">
            (#{orderId}, #{entity.shopId}, #{entity.productId}, #{entity.productImg}, #{entity.productName},
            #{entity.productType}, #{entity.skuId}, #{entity.skuName}, #{entity.price},#{entity.memberPrice},
            #{entity.discountSaleAmount}, #{entity.unitPrice}, #{entity.discountAmount},
            #{entity.packAmount}, #{entity.payAmount}, #{entity.returnAmount}, #{entity.num}, #{entity.packNumber},
            #{entity.couponNum}, #{entity.returnNum}, #{entity.refundNum}, #{entity.refundNo},
            #{entity.discountSaleNote}, #{entity.status}, #{entity.placeNum}, #{entity.isTemporary}, #{entity.isPrint},
            #{entity.isWaitCall}, #{entity.proGroupInfo}, #{entity.remark}, #{entity.refundRemark},
            now(), now())
        </foreach>
    </insert>
    <select id="getOrderDetailPrint" resultType="com.czg.order.vo.OrderDetailPrintVo">
        select detail.*, product.category_id as categoryId
        from tb_order_detail detail
                 left join tb_product product on product.id = detail.product_id
        where order_id = #{orderId}
    </select>
</mapper>
