<?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.bonus.canteen.core.supply.purchase.mapper.DrpMaterialLatestPriceMapper">

    <select id="getPriceListByMaterialIdList" resultType="com.bonus.canteen.core.supply.purchase.domain.vo.DrpMaterialLatestPriceVO">
        select
        material_id,
        unit_id,
        latest_price,
        price_type,
        related_id,
        remark
        from drp_material_latest_price
        where material_id in
        <foreach collection="materialIdList" item="materialId" open="(" separator="," close=")">
            #{materialId}
        </foreach>
        <if test="priceType != null ">
            and price_type = #{priceType}
            <if test="priceType == 1 ">
                and now() between start_time and end_time
            </if>
        </if>
        <if test="supplierId != null ">
            and supplier_id = #{supplierId}
        </if>
    </select>
</mapper>
