package com.jwipc.inquiry.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.inquiry.entity.InquiryMaterialSupplier;
import com.jwipc.inquiry.mapper.InquiryMaterialSupplierMapper;
import com.jwipc.inquiry.model.po.AssistantSupplierPO;
import com.jwipc.inquiry.model.po.InquiryMaterialSupplierPO;
import com.jwipc.inquiry.model.po.InquiryMaterialSupplierQuotaJobPO;
import com.jwipc.inquiry.model.query.InquiryQuoteQuery;
import com.jwipc.inquiry.service.IInquiryMaterialSupplierService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 询价供应商表 服务实现类
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-02-21
 */
@Service
public class InquiryMaterialSupplierServiceImpl extends ServiceImpl<InquiryMaterialSupplierMapper, InquiryMaterialSupplier> implements IInquiryMaterialSupplierService {

    /**
     * 根据询价id查询询价供应商（分组）
     *
     * @param inquiryId 询价id
     */
    @Override
    public List<InquiryMaterialSupplierPO> getGroupListByInquiryId(Long inquiryId,Integer bidFlag) {
        return baseMapper.getGroupListByInquiryId(inquiryId,bidFlag);
    }

    /**
     * 根据询价id和询价物料id查询询价物料供应商
     *
     * @param inquiryId         询价id
     * @param inquiryMaterialId 询价物料id
     * @return 询价物料供应商
     */
    @Override
    public List<InquiryMaterialSupplierPO> getListByInquiryIdAndInquiryMaterialId(Long inquiryId, Long inquiryMaterialId) {
        return baseMapper.getListByInquiryIdAndInquiryMaterialId(inquiryId,inquiryMaterialId);
    }

    /**
     * 获取供应商报价列表
     *
     * @param query  参数
     * @return 供应商报价列表
     */
    @Override
    public List<InquiryMaterialSupplierPO> quoteList(InquiryQuoteQuery query) {
        return baseMapper.quoteList(query);
    }

    @Override
    public List<InquiryMaterialSupplierPO> quoteListPage(Page<InquiryMaterialSupplier> dbPage, InquiryQuoteQuery query) {
        return baseMapper.quoteListPage(dbPage,query);
    }

    /**
     * 获取已经报价的供应商列表
     *
     * @param inquiryId 询价id
     * @return 已经报价的供应商列表
     */
    @Override
    public List<AssistantSupplierPO> getAssistantSupplierByInquiryId(Long inquiryId) {
        return baseMapper.getAssistantSupplierByInquiryId(inquiryId);
    }

    @Override
    public List<AssistantSupplierPO> getAssistantSupplierByInquiryIdAndInquiryMaterialIdAndSupplierCodeList(Long inquiryId, Long inquiryMaterialId,Set<String> supplierCodeList) {
        return baseMapper.getAssistantSupplierByInquiryIdAndInquiryMaterialIdAndSupplierCodeList(inquiryId,inquiryMaterialId,supplierCodeList);
    }

    @Override
    public List<InquiryMaterialSupplierQuotaJobPO> getSupplierQuotaJob(Date startTime, Date endTime) {
        return baseMapper.getSupplierQuotaJob(startTime,endTime);
    }

    @Override
    public List<InquiryMaterialSupplierQuotaJobPO> getQuotationEndNoticeJob() {
        return baseMapper.getQuotationEndNoticeJob();
    }

    @Override
    public List<InquiryMaterialSupplierPO> getBidInquiryListByPurchaseApplyCode(String purchaseApplyCode, String itemNo) {
        return baseMapper.getBidInquiryListByPurchaseApplyCode(purchaseApplyCode, itemNo);
    }
}
