<?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.fjhx.sale.mapper.pack.PackShipmentMapper">
    <select id="getPage" resultType="com.fjhx.sale.entity.pack.vo.PackShipmentVo">
        select
            ps.id,
            ps.pack_detail_ids,
            ps.contract_id,
            ps.remark,
            ps.update_time,
            ps.update_user,
            ps.create_user,
            ps.create_time
        from pack_shipment ps
            ${ew.customSqlSegment}
    </select>
    <select id="getList" resultType="com.fjhx.sale.entity.pack.vo.PackShipmentVo">
        select
           ps.*,
           c.code contractCode
        from pack_shipment ps
        left join contract c on ps.contract_id = c.id
            ${ew.customSqlSegment}
    </select>
    <select id="productDetailList" resultType="java.util.Map">
        SELECT
            id  as businessId,
            remark,
            null as subDescription,
            null as customsCode,
            quantity,
            null as price,
            10 as type
        FROM
            pack_detail_goods dg
        <where>
            <include refid="productDetail"/>
        </where>
        UNION
        SELECT
            id  as businessId,
            product_name remark,
            null as subDescription,
            null as customsCode,
            quantity,
            null as price,
            20 as type
        FROM
            pack_detail_product dg
        <where>
            <include refid="productDetail"/>
        </where>
    </select>

    <sql id="productDetail">
        <foreach collection="ids" item="id" open="pack_detail_id in(" separator="," close=")">
            #{id}
        </foreach>
    </sql>
</mapper>
