package com.jwipc.inquiry.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwipc.inquiry.entity.Inquiry;
import com.jwipc.inquiry.entity.PurchaseApplyBill;
import com.jwipc.inquiry.entity.PurchaseApplyBillDetail;
import com.jwipc.inquiry.mapper.PurchaseApplyBillDetailMapper;
import com.jwipc.inquiry.model.po.InquiryMaterialPO;
import com.jwipc.inquiry.model.po.PurchaseApplyBillDetailPO;
import com.jwipc.inquiry.model.query.PurchaseApplyBillDetailQuery;
import com.jwipc.inquiry.service.IPurchaseApplyBillDetailService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 采购申请明细 服务实现类
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-02-29
 */
@Service
public class PurchaseApplyBillDetailServiceImpl extends ServiceImpl<PurchaseApplyBillDetailMapper, PurchaseApplyBillDetail> implements IPurchaseApplyBillDetailService {

    @Override
    public List<PurchaseApplyBillDetailPO> findPageByQuery(Page<Inquiry> dbPage, PurchaseApplyBillDetailQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuery(query);
        }
        return baseMapper.findPageByQuery(dbPage,query);
    }

    @Override
    public List<InquiryMaterialPO> makeInquiryMaterial(List<String> purchaseBillDetailIdList) {
        return baseMapper.makeInquiryMaterial(purchaseBillDetailIdList);
    }

    @Override
    public List<PurchaseApplyBillDetailPO> findPageByQuerySC(Page<Inquiry> dbPage, PurchaseApplyBillDetailQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuerySC(query);
        }
        return baseMapper.findPageByQuerySC(dbPage,query);
    }

    @Override
    public List<PurchaseApplyBillDetailPO> selectPurchaseForContractList(Page<PurchaseApplyBill> dbPage, PurchaseApplyBillDetailQuery query) {
        return baseMapper.selectPurchaseForContractList(dbPage,query);
    }

    @Override
    public BigDecimal getPurchaseNumAmountByBillNoAndCode(String billCode, String itemCode,Long id) {
        return baseMapper.getPurchaseNumAmountByBillNoAndCode(billCode,itemCode,id);
    }

}
