<?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.supply.mapper.supplier.SupplierPriceMapper">
    <select id="getPage" resultType="com.fjhx.supply.entity.supplier.vo.SupplierPriceVo">
        select sp.id,
               sp.supplier_info_id,
               sp.product_info_id,
               sp.price,
               si.name supplierName,
               si.type supplierType,
               sp.company_id
        from supplier_price sp
                 inner join supplier_info si on sp.supplier_info_id = si.id
            ${ew.customSqlSegment}
    </select>
    <select id="getTopPriceList" resultType="com.fjhx.supply.entity.supplier.vo.SupplierPriceVo">
        SELECT
        t1.*,
        si.`name` AS supplierName
        FROM
        (
        SELECT
        sp.supplier_info_id,
        sp.product_info_id,
        sp.price,
        @row_number :=IF( @product_info_id = sp.product_info_id, @row_number + 1, 1 ) AS row_number
        FROM
        supplier_price sp,(SELECT @row_number := 0) b
        ORDER BY
        sp.price ASC
        ) t1
        left join supplier_info si on t1.supplier_info_id = si.id
        where
        t1.row_number &lt;= #{count}
        <foreach collection="productIds" item="productId" open="AND t1.product_info_id IN (" separator="," close=")">
            #{productId}
        </foreach>
    </select>

</mapper>
