package com.sckw.order.api.dubbo;

import com.sckw.core.web.response.HttpResult;
import com.sckw.order.api.model.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;

/**
 * @desc: 贸易订单信息相关dubbo
 * @author: yzc
 * @date: 2023-07-18 18:18
 */
public interface TradeOrderInfoService {

    /**
     * @desc: 获取订单详情
     * @author: yzc
     * @date: 2023-07-18 18:25
     * @Param tOrderId:
     * @return: com.sckw.order.api.model.OrderDetailRes
     */
    OrderDetailRes getOrderDetailById(Long tOrderId);


    /**
     * @desc: 获取订单详情
     * @author: yzc
     * @date: 2023-07-18 18:25
     * @Param tOrderId:
     * @return: com.sckw.order.api.model.OrderAddressDetailRes
     */
    OrderAddressDetailRes getOrderDetailByTradeOrderIdAndAddressId(Long tOrderId, Long tAddressId);

    /**
     * @desc: 更新订单状态
     * @author: yzc
     * @date: 2023-07-18 18:31
     * @Param param:
     * @return: void
     */
    void updateOrderStatus(UpdateOrderStatusParam param);

    /**
     * @desc: 生成或撤销物流订单
     * @author: yzc
     * @date: 2023-08-03 10:57
     * @Param param:
     * @return: com.sckw.core.web.response.HttpResult
     */
    HttpResult createOrCancelLogisticsOrder(CreateOrCancelLogisticsOrderParam param);

    /**
     * @desc: 生成或撤销物流订单
     * @author: yzc
     * @date: 2023-08-03 10:57
     * @Param tOrderId: 贸易订单ID
     * @Param unit: 单位
     * @Param entrustAmount: 委托量
     * @Param loading: 辅助单位信息
     * @return: com.sckw.core.web.response.HttpResult
     */
    HttpResult createOrCancelLogisticsOrderV1(Long updateBy, String updateByName, Long tOrderId, List<GoodsLoadingParam> loading);

    /**
     * @desc: 完结物流订单
     * @author: yzc
     * @date: 2023-08-03 11:11
     * @Param param:
     * @return: com.sckw.core.web.response.HttpResult
     */
    HttpResult completeLogisticsOrder(CompleteLogisticsOrderParam param);

    /**
     * @desc: 完结物流订单
     * @author: yzc
     * @date: 2023-08-03 11:11
     * @Param param:
     * @return: com.sckw.core.web.response.HttpResult
     */
    HttpResult completeLogisticsOrderV1(Long updateBy, String updateByName, Long tOrderId, List<GoodsLoadingV1Param> loading);

    /**
     * @desc: 更新订单实际交付量
     * @author: yzc
     * @date: 2023-09-19 15:20
     * @Param param:
     * @return: com.sckw.core.web.response.HttpResult
     */
    HttpResult updateActualAmount(UpdateActualAmountParam param);

    /**
     * @desc: 更新物流订单
     * @author: yzc
     * @date: 2023-09-19 15:20
     * @Param param:
     * @return: com.sckw.core.web.response.HttpResult
     */
    HttpResult updateOrderActualAmount(UpdateActualAmountParam param);


    /**
     * @desc: 合同签约完成
     * @author: yzc
     * @date: 2023-07-20 11:42
     * @Param param:
     * @return: void
     */
    void contractSignCompleted(ContractSignCompletedParam param);

    /**
     * @desc: 更新订单是否关联对账单
     * @author: yzc
     * @date: 2023-08-09 14:24
     * @Param param:
     * @return: void
     */
    void updateAssociateStatement(UpdateAssociateStatementParam param);

    /**
     * @desc: 是否关联企业  true是，false否
     * @author: yzc
     * @date: 2023-08-30 9:08
     * @Param firstEntId:
     * @Param secondEntId:
     * @return: java.lang.Boolean
     */
    Boolean associateEnt(Long firstEntId, Long secondEntId);

    OrderDetailVo queryByTradeOrderId(Long tradeOrderId);

    List<OrderDetailVo> queryByTradeOrderIds(Set<Long> tradeOrderId);

    /**
     * 通交易订单id查询交易订单采购/销售企业信息     * @param tradeOrderId
     *
     * @return
     */
    List<OrderUnitInfoDetailVO> queryOrderUnitInfByTOrderId(Set<Long> tradeOrderId);

    /**
     * 通过企业名称模糊查询
     *
     * @return
     */
    List<OrderUnitInfoDetailVO> queryOrderUnitInfByEntName(String entName);

    /**
     * 通过企业查询贸易订单id
     *
     * @return
     */
    Set<Long> queryOrderIdByEntId(Long entId, String unitType);


    /**
     * 查询近期的贸易订单，计算商品的近期销量
     *
     * @param start
     * @param end
     * @return
     */
    List<OrderSaleVo> queryRecentSale(LocalDateTime start, LocalDateTime end);

    /**
     * 订单结算，更改上游贸易订单累计装货量或累计卸货量
     */
    void orderSettle(TradeOrderSettlePara tradeOrderSettlePara);


    List<TradeOrderContractVo> queryByTradeContactIds(Set<Long> tradeContractIds);

    TradeOrderContractVo queryByContractByTradeOrderId(Long tOrderId);

    List<TradeOrderContractVo>  queryTradeOrderIds(Set<Long> tradeOrderIds);
    Long queryTradeCount();

    Long orderCount();

    List<TradeVo> tradeList();

    SaleDto countSale(CountPara countPara);

    TimeSaleDto timeSale(CountPara countPara);

    RankDto buyRank(CountPara countPara);

    OrderDetailRes auditTradeOrder(TradeOrderAuditPara para);

    BuyDto countBuy(CountPara countPara);

    GoodsDto countGoods(CountPara countPara);

    List<OrderUnitInfoDetailVO> queryOrderUnitByTradeOrderId(Long tradeOrderId);

}
