package cn.iocoder.yudao.module.order.service.order;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.ecw.dal.dataobject.region.RegionDO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dto.*;
import cn.iocoder.yudao.module.order.vo.approval.OrderApprovalHeadBaseVO;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialApplyVO;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialBatchApplyVO;
import cn.iocoder.yudao.module.order.vo.order.*;
import cn.iocoder.yudao.module.order.vo.orderException.OrderExceptionStatisticsExcelVo;
import cn.iocoder.yudao.module.order.vo.orderException.OrderFeeDetailBackVO;
import cn.iocoder.yudao.module.order.vo.orderItem.OrderItemBackVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseAdjust.OrderWarehouseAdjustBatchApplyBackVO;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.List;

/**
 * 订单 Service 接口
 *
 * @author 系统管理员
 */
public interface OrderQueryService {


    /**
     * 获得订单
     *
     * @param orderId 编号
     * @return 订单
     */
    OrderBackVO getOrder(Long orderId);


    OrderBackVO getParentOrder(Long orderId);


    /**
     * 获得订单修改审批详情
     *
     * @param orderId    编号
     * @param isResubmit 是否重新提交
     * @return 订单修改详情
     */
    OrderBackVO getUpdateOrderApplyInfo(Long orderId, boolean isResubmit);


    /**
     * 获得订单修改审批详情
     *
     * @param orderApprovalId 审批ID
     * @return 订单修改详情
     */
    OrderBackVO getUpdateOrderApplyInfo(Long orderApprovalId);


    /**
     * 获取审核订单的头信息
     *
     * @param orderId 订单ID
     * @return 订单审核头信息
     */
    OrderApprovalHeadBaseVO getOrderApprovalHeadInfo(Long orderId);


    /**
     * 特价申请业务表单详情
     *
     * @param approveId 业务ID
     * @return 特价申请详情
     */
    OrderSpecialApplyVO approvalOrderSpecial(Long approveId);


    /**
     * 特价申请业务表单详情
     *
     * @param approveId 业务ID
     * @return 特价申请详情
     */
    OrderSpecialBatchApplyVO approvalOrderSpecialBatch(Long approveId);

    /**
     * 特价申请业务表单详情
     *
     * @param orderId     订单项Id
     * @param orderItemId 订单项商品Id
     * @param type        特价申请类型详情见order_approval_type
     * @param isResubmit  是否重新提交获取详情
     * @return 特价申请详情
     */
    OrderSpecialApplyVO approvalOrderSpecialByOrderItemId(Long orderId, Long orderItemId, Integer type, boolean isResubmit);

    /**
     * 批量特价申请业务表单详情
     *
     * @param orderId    订单项Id
     * @param type       特价申请类型详情见order_approval_type
     * @param isResubmit 是否重新提交获取详情
     * @return 特价申请详情
     */
    OrderSpecialBatchApplyVO approvalOrderSpecialByOrderId(Long orderId, Integer type, boolean isResubmit);

    /**
     * 获得订单
     *
     * @param orderId 订单ID
     * @return 订单详情
     */
    OrderBackInfoDto info(Long orderId);

    /**
     * 获得订单列表
     *
     * @param ids 编号
     * @return 订单列表
     */
    List<OrderDO> getOrderList(Collection<Long> ids);

    List<OrderDO> getOrderListByOrderNoList(Collection<String> orderNoLIst);

    /**
     * 获得订单分页
     *
     * @param page  分页查询
     * @param query 查询
     * @return 订单分页
     */
    PageResult<OrderDO> getOrderPage(OrderQueryVO query, PageVO page);

    /**
     * 获得订单调仓批量申请列表分页
     *
     * @param page  分页查询
     * @param query 查询
     * @return 订单分页
     */
    PageResult<OrderWarehouseAdjustBatchApplyBackVO> orderWarehouseAdjustBatchApplyPage(OrderQueryVO query, PageVO page);

    /**
     * 获得订单列表, 用于 Excel 导出
     *
     * @param query 查询
     * @return 订单列表
     */
    List<OrderDO> getOrderList(OrderQueryVO query);

    PageResult<OrderBackPageVO> orderPage(OrderQueryVO query, PageVO page);

    PageResult<OrderBackPageVO> myOrderPage(OrderQueryDTO query, PageVO page);

    long orderCount(OrderQueryVO query);


    PageResult<OrderBackPageVO> deptOrderPage(OrderQueryVO query, PageVO page);

    PageResult<OrderBackPageVO> deptOrderPage1(OrderQueryDTO query, PageVO page);

    PageResult<OrderBackPageVO> myIssuedOrderPage(OrderQueryVO query, PageVO page);

    /**
     * 预装订单分页列表
     *
     * @param query
     * @return
     */
    PageResult<OrderPreloadVO> orderPreloadPage(OrderPreloadReq query);

    /**
     * 预装订单列表
     *
     * @param query
     * @return
     */
    List<OrderPreloadVO> orderPreloadList(OrderPreloadReq query);

    List<OrderPreloadVO> orderPreloadListAir(OrderPreloadReq query);


    PageResult<OrderBackPageVO> adminCargoControlOrderPage(OrderQueryVO query, PageVO page);

    PageResult<OrderBackPageVO> adminCargoControlMyOrderPage(OrderQueryDTO query, PageVO page);

    PageResult<OrderBackPageVO> appCargoControlOrderPage(OrderQueryVO query, PageVO page);


    PageResult<OrderBackPageVO> receivedOrderPage(OrderQueryVO query, PageVO page);

    PageResult<OrderBackPageVO> dynamicOrderPage(OrderQueryVO query, PageVO page);

    PageResult<OrderBackPageVO> myAllOrderPage(OrderQueryVO query, PageVO page);

//    PageResult<OrderBackPageVO> getOrderListByIds(List<Long> orderIds, PageVO page, OrderQueryVO orderQueryVO);


    PageResult<OrderBackPageVO> pdaOrderWarehouseInPage(PdaOrderQueryVo query, PageVO page);

    /**
     * pda 调仓-待出仓
     *
     * @param query 查询条件
     * @param page
     * @return
     */
    PageResult<OrderBackPageVO> pdaOrderWarehouseAdjustWaitOut(PdaOrderQueryVo query, PageVO page);

    List<OrderBackPageVO> seasoningCondimentsCargoControlOrderPage(Long orderId, String cargoControlPhone, Integer userType);

    /**
     * 根据订单ID得到所有费用占比
     *
     * @param orderId
     * @return
     */
    OrderFeeDetailBackVO getOrderFeeDetailById(Long orderId);

    /**
     * 订单号分页检索功能
     *
     * @param key
     * @return
     */
    PageResult<SearchBackDto> orderNoSearch(String key, PageParam param);


    /**
     * 提单号分页检索功能
     *
     * @param key
     * @return
     */
    PageResult<SearchBackDto> billNoSearch(String key, PageParam param);


    PageResult<OrderBackVO> getUnGuanlianOrderPage(OrderQueryVO orderQueryVo, PageVO pageVO);

    PageResult<OrderDO> getUnMutualOrderPage(OrderQueryVO orderQueryVo, PageVO pageVO);

    List<OrderExportBackDTO> getExportOrderList(OrderQueryVO query);


    /**
     * 根据线路id与商品id获取未报价的订单商品项列表
     *
     * @param lineId    线路ID
     * @param productId 商品ID
     * @param channelId 出货渠道ID
     * @return 订单项列表
     */
    List<OrderItemDO> getOrderItemByLineIdAndProductId(Long lineId, Long productId, Long channelId);

    /**
     * 获取已退仓的品名数据
     *
     * @param orderId
     * @return
     */
    List<OrderItemBackVO> getOrderItemInfoListWhenWarehouseInDeleted(Long orderId);

    /**
     * 打包页面的订单统计数据。
     * 包含填单的、完成入仓的、打包前的、打包后的  体积重量数量统计数据。
     * @param orderId
     * @return
     */
    OrderPackedPageStatisticsVO orderPackedPageStatistics(Long orderId);

    Integer customDrawee(OrderDO orderDO, Integer feeType);


    /**
     * 获取此订单的所有待审核任务数量
     *
     * @param orderId 订单id
     * @return 数量
     */
    Integer getAllProcessingApprovalCount(Long orderId);


    /**
     * 判断该订单是否有待处理异常或待处理审核
     *
     * @param orderId 订单id
     */
    void throwPendingExceptionOrProcessingApproval(Long orderId);

    /**
     * 判断该订单是否有待处理审核
     *
     * @param orderId 订单id
     */
    void throwProcessingApproval(Long orderId);


    /**
     * 获取最早的装柜时间
     *
     * @param customerId 客户ID
     */
    String getEarliestBoxTime(Long customerId);

    Long getOrderConsigneeMemberInfo(Long orderId);


    List<OrderDO> getOrderChildren(Long parentOrderId);

    List<OrderDO> getOrderChildren(List<Long> orderIds);

    StatisticsOrderVO statisticsOrder(OrderQueryVO query);
    StatisticsOrderVO statisticsMyOrder(OrderQueryDTO query) ;

    void exportOrderExcel(HttpServletResponse response, OrderQueryVO query) throws IOException;

    FileDO makeOrderExcelFile(Long userId, Integer userType, OrderQueryVO query) throws Exception;

    FileDO makeMyOrderExcelFile(Long userId, Integer userType, OrderQueryDTO query) throws Exception;

    List<OrderExceptionStatisticsExcelVo> getOrderExceptionStatisticsExcel(OrderQueryDTO query);

    List<OrderHeavyExcelVo> getHeavyOrderExcelList(OrderQueryDTO query);

    List<OrderReturnOrderExcelVo> getReturnOrderExcelList(OrderQueryDTO query);

    List<OrderSaleRepayExcelVo> getSaleRepayExcelList(OrderQueryDTO query);

    List<OrderCustomsDatasExcelVo> getCustomsDatasExcelList(OrderQueryDTO query);

    List<OrderShipDataExcelVo> getShipDatasExcelList(OrderQueryDTO query);

    List<OrderShipFeeExcelVo> getShipFeeExcelList(OrderQueryDTO query);

    /**
     * 查询订单的身份信息
     *
     * @param key 查询条件
     * @return
     */
    OrderCertificateVO certificateSearch(String key);

    Boolean checkKycStatus(OrderKycReqVO kycReqVO, Long userId);

    OrderKycRespVo getKycStatus(OrderKycReqVO kycReqVO, Long userId);

    List<OrderDO> commissionOrderList();


    OrderDO getOrderById(Long orderId);

    void orderChildren(Long parentOrderId, List<OrderDO> orderChildrenList);


    List<OrderDO> getNoConsigeeCustomerOrderList(Integer day);

    /**
     * 获取同一母订单下的所有相关子订单(包括子订单的再次拆单)
     *
     * @param orderNoLike 订单编号+'-'的子订单编号前置
     * @return
     */
    List<OrderDO> getOrderChildrenLikeByOrderNo(String orderNoLike);


    String getDestCountryByOrderId(Long orderId);

    /**
     * 自编号下订单列表汇总
     *
     * @param destRegion 目的地国家信息
     * @param orderIds 订单ids
     * @return 自编号汇总报表
     */
    ContainerNumberSummaryDto orderSummaryByDestRegionAndOrderIds(RegionDO destRegion, Collection<Long> orderIds);


    /**
     * 订单费用汇总
     *
     * @param orderId 订单id
     * @return 订单汇总报表
     */
    OrderCostSummaryDto orderSummaryByOrderId(Long orderId);

    /**
     * 获取订单费用汇总，参数根据详情信息和列表信息二选一
     *
     * @param orderBackInfoDto 订单详情信息
     * @param orderBackPageVO  订单列表详情信息
     * @return 订单汇总报表
     */
    OrderCostSummaryDto getOrderCostSummaryDto(OrderBackInfoDto orderBackInfoDto, OrderBackPageVO orderBackPageVO);

    /**
     * 订单费用明细汇总
     *
     * @param orderId 订单id
     * @return 订单汇总报表
     */
    OrderDetailSummaryDto orderDetailSummaryByOrderId(Long orderId);

    List<OrderDO> getAirRefreshOrderPrice(List<Integer> transportIdList);


    /**
     * 是否拆单子订单
     *
     * @param orderDO
     * @return true 是拆单子订单   false  否
     */
    boolean isSplitOrderChildren(OrderDO orderDO);
}
