package com.trade.service.trade.salesorder.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.trade.service.trade.salesorder.domain.SalesOrder;
import com.trade.service.trade.salesorder.dto.*;
import com.trade.service.trade.salesorder.vo.SalesOrder4CustomsDeclarationVO;
import com.trade.service.trade.salesorder.vo.SalesOrderDtlVO;
import com.trade.service.trade.salesorder.vo.SalesOrderSearch;
import com.trade.service.trade.salesorder.vo.SalesOrderVO;

import java.util.List;

/**
 * <p>
 * 销售订单表 服务类
 * </p>
 *
 * @author zhangchenm
 * @since 2024-09-06
 */
public interface ISalesOrderService extends IService<SalesOrder> {

    PageInfo<SalesOrderVO> queryListBySearch(SalesOrderSearch search);

    SalesOrderDtlVO getDetail(Long id, boolean is4Update);

    Long saveSalesOrder(SalesOrder salesOrder);

    boolean existSalesOrderByImporterId(Long importerId);

    /**
     * 查询订单号列表，用于拉取报关单
     * 
     * @return 订单号列表
     */
    List<SalesOrder4CustomsDeclarationVO> queryOrderNo4GetCustomsDeclaration();

    /**
     * 根据订单号更新报关单状态为已完成
     */
    void updateCustomsDeclarationStatusFinishedByOrderNo(String orderNo);

    /**
     * 根据订单号查询订单
     * 
     * @param orderNo 订单号
     * @return 订单
     */
    SalesOrder getByOrderNo(String orderNo);

    /**
     * 根据销售合同ID查询订单
     * 
     * @param saleContractId 销售合同ID
     * @return 订单列表
     */
    List<SalesOrder> queryBySaleContractId(Long saleContractId);

    /**
     * 处理商品收款
     * 
     * @param salesOrderReceivePayment
     * @return 勾选商品金额
     */
    Boolean processGoodsReceivePayment(SalesGoodsReceivePaymentDto salesOrderReceivePayment);

    /**
     * 处理订单收款列表
     * 
     * @param receivePaymentExtendDtos
     * @return 勾选订单金额信息
     */
    List<ReceivePaymentExtendDto> processOrderReceivePaymentList(
            List<ReceivePaymentExtendDto> receivePaymentExtendDtos, boolean source);

    /**
     * 根据订单ID查询订单列表信息
     * 
     * @param salesOrderInfo
     * @return 订单列表信息
     */
    List<OrderListInfoDto> queryOrderListInfoByOrderIds(List<SalesOrderReceiveExtendDto> salesOrderInfo);

    /**
     * 提交订单列表信息
     * 
     * @param salesOrderInfo salesOrderInfo
     * @param source
     * @return boolean
     */
    OrderPaymentAmountDto submitOrderListInfo(List<OrderListInfoDto> salesOrderInfo, int source);

    /**
     * 处理商品收款
     *
     * @param receivePaymentSubDto
     * @param source true B端 false C端
     * @return 勾选商品金额
     */
    Boolean processOrderReceivePayment(ReceivePaymentSubDto receivePaymentSubDto, boolean source);

    /**
     * 更新订单与其商品状态
     * 
     * @param salesOrderReceiveExtendDto
     * @param orderStatus
     * @param goodsStatus
     * @return boolean
     */
    boolean updateSalesOrderAndGoodsStatus(SalesOrderReceiveExtendDto salesOrderReceiveExtendDto, int orderStatus,
            int goodsStatus, int flag);
}
