/**
 * @filename:PurchaseOrderService 2024-09-10
 * @project KJT v1.0.0 Copyright(c) 2024 wanglang Co. Ltd. All right reserved.
 */
package com.trade.service.trade.purchaseorder.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.trade.service.thirdparty.xiaotu.dto.InvoiceQueryResponse;
import com.trade.service.trade.purchasecontract.domain.PurchaseContract;
import com.trade.service.trade.purchaseorder.domain.PurchaseOrder;
import com.trade.service.trade.purchaseorder.dto.PurchaseOrderLogisticsDto;
import com.trade.service.trade.purchaseorder.dto.PurchaseSearchDto;
import com.trade.service.trade.purchaseorder.dto.PurchaseOrderDto;
import com.trade.service.trade.purchaseorder.vo.PurchaseOrderDetailsVo;
import com.trade.service.trade.purchaseorder.vo.PurchaseOrderVo;
import com.trade.service.trade.purchaseorder.vo.TradingPlatformInvoiceVo;
import com.trade.service.trade.salesorder.domain.SalesOrder;
import com.trade.service.trade.salesorder.domain.SalesOrderGoods;

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

/**
 * @Description:采购订单信息服务层
 * @version: v1.0.0
 * @author: wanglang
 */
public interface PurchaseOrderService extends IService<PurchaseOrder> {

    /**
     * 保存订单物流信息
     * 
     * @param purchaseOrderLogisticsDto
     * @return true/false
     */
    boolean saveOrderLogistics(PurchaseOrderLogisticsDto purchaseOrderLogisticsDto);

    /**
     * 保存订单
     * 
     * @param purchaseOrderDtos
     * @return true/false
     */
    boolean saveOrder(List<PurchaseOrderDto> purchaseOrderDtos, PurchaseContract purchaseContract);

    /**
     * 根据条件查询采购订单信息
     *
     * @param purchaseSearch
     * @return 采购订单信息
     */
    List<PurchaseOrderVo> selectByCondition(PurchaseSearchDto purchaseSearch);

    /**
     * 根据id查询订单详情
     * 
     * @param id 主键
     * @return 订单详情
     */
    PurchaseOrderDetailsVo getDetailsById(Long id);

    /**
     * 查询所有采购订单的代理公司税号
     * 
     * @param ids
     * @param invoicePullStatus
     * @return
     */
    List<TradingPlatformInvoiceVo> queryAgencyTaxNum(List<Long> ids, String invoicePullStatus);

    /**
     * 查询所有采购订单的代理公司小图账号以及开票公司税号
     *
     * @param ids
     * @param invoicePullStatus
     * @return
     */
    List<TradingPlatformInvoiceVo> queryCustTaxNum(List<Long> ids, String invoicePullStatus);

    /**
     * 查询所有采购订单的非代理公司小图账号以及开票公司税号
     *
     * @param ids
     * @param invoicePullStatus
     * @return
     */
    List<TradingPlatformInvoiceVo> queryClientTaxNum(List<Long> ids, String invoicePullStatus);

    /**
     * 更新采购订单的发票拉取状态
     *
     * @param id
     * @param status
     * @return
     */
    boolean updateInvoicePullStatus(Long id, String status);

    /**
     * 处理订单发票信息
     * 
     * @param invoiceQueryResponses
     * @param orderId
     * @param amountTotal
     * @param source
     */
    void handleOrderInvoice(List<InvoiceQueryResponse> invoiceQueryResponses, Long orderId, BigDecimal amountTotal,
            int source);

    /**
     * 处理订单
     * 
     * @param purchaseContractId 采购合同id
     * @return true/false
     */
    boolean handleOrder(Long purchaseContractId);

    /**
     * 创建采购订单
     * 
     * @param salesOrderGoods
     * @param finalOrderId
     * @param salesOrder
     * @param entityNo
     * @param purchaseOrderDtos
     */
    void createPurchaseOrder(List<SalesOrderGoods> salesOrderGoods, Long finalOrderId, SalesOrder salesOrder,
            String entityNo, List<PurchaseOrderDto> purchaseOrderDtos);

    /**
     * 根据销售订单id查询采购订单列表
     * 
     * @param salesOrderId 销售订单id
     * @return
     */
    List<PurchaseOrder> listBySaleOrderId(Long salesOrderId);
}
