<?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.trade.service.salesorder.mapper.SalesOrderGoodsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.trade.service.salesorder.domain.SalesOrderGoods">
        <result column="id" property="id" />
        <result column="deleted" property="deleted" />
        <result column="sale_order_id" property="saleOrderId" />
        <result column="sales_commodity_id" property="salesCommodityId" />
        <result column="vendor_entity_no" property="vendorEntityNo" />
        <result column="hs_code" property="hsCode" />
        <result column="name" property="name" />
        <result column="unit" property="unit" />
        <result column="packing_specifications" property="packingSpecifications" />
        <result column="price" property="price" />
        <result column="tax_refund_rate" property="taxRefundRate" />
        <result column="count" property="count" />
        <result column="price_total" property="priceTotal" />
        <result column="model" property="model" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_modified" property="gmtModified" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        deleted,
        sale_order_id, sales_commodity_id, vendor_entity_no, hs_code, name, unit, packing_specifications, price, tax_refund_rate, count, price_total, model, gmt_create, gmt_modified
    </sql>


    <select id="listByOrderId" resultType="com.trade.service.salesorder.vo.SalesOrderGoodsVO">
        SELECT a.*, b.entity_name AS vendor_name
        FROM sales_order_goods a
        left join vendor_entity b on a.vendor_entity_no = b.entity_no
        WHERE a.sale_order_id = #{saleOrderId}
    </select>

    <delete id="physicallyDeleteByOrderId">
        DELETE FROM sales_order_goods
        WHERE sale_order_id = #{saleOrderId}
    </delete>


</mapper>
