package com.jwipc.inquiry.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.inquiry.entity.Inquiry;
import com.jwipc.inquiry.entity.PriceInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwipc.inquiry.model.po.CreatePriceInfoPO;
import com.jwipc.inquiry.model.po.HistoryPriceInfoPO;
import com.jwipc.inquiry.model.po.InquiryMaterialPO;
import com.jwipc.inquiry.model.po.PriceInfoPO;
import com.jwipc.inquiry.model.query.PriceInfoQuery;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 价格信息记录主表 Mapper 接口
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-02-28
 */
public interface PriceInfoMapper extends BaseMapper<PriceInfo> {

    List<CreatePriceInfoPO> getByInquiryId(@Param("inquiryId") Long inquiryId);

    List<PriceInfoPO> findPageByQuery(@Param("query") PriceInfoQuery query);

    List<PriceInfoPO> findPageByQuery(Page<Inquiry> dbPage, @Param("query") PriceInfoQuery query);

    List<CreatePriceInfoPO> getByAuditId(@Param("auditId") Long auditId);

    HistoryPriceInfoPO getHistoryLowPrice(@Param("materialCode") String materialCode, @Param("factoryCode") String factoryCode);

    HistoryPriceInfoPO getLastBidPrice(@Param("materialCode") String materialCode, @Param("factoryCode") String factoryCode);

    PriceInfoPO getSupplierLastBidPrice(@Param("supplierCode") String supplierCode, @Param("materialCode") String materialCode, @Param("factoryCode") String factoryCode);

    List<InquiryMaterialPO> makeInquiryMaterial(@Param("priceInfoIdList") List<String> priceInfoIdList);

    PriceInfoPO getLastPrice(@Param("materialCode") String materialCode, @Param("factoryCode") String factoryCode, @Param("supplierCode") String supplierCode);

    List<PriceInfo> getEffectiveMinPrice(@Param("materialCodes")List<String>  materialCodes, @Param("date")Date date);
}
