package com.sckw.payment.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sckw.payment.model.KwpSettlementLogistics;
import com.sckw.payment.model.KwpSettlementRecord;
import com.sckw.payment.model.dto.LedgerUnitDto;
import com.sckw.payment.model.dto.MoneyType;
import com.sckw.payment.model.dto.SettlementLogisticsDto;
import com.sckw.payment.model.vo.SettlementLogistics;
import com.sckw.payment.model.vo.req.SettlementReq;
import com.sckw.payment.model.vo.res.SettlementLogisticsSumVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * @author Aick Spt
 * @date 2023-07-24 14:55
 */
@Mapper
public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLogistics> {

    /**
     * 运费付款-物流订单列表
     *
     * @author Aick Spt
     * @date 2023-07-24 16:23
     */
    List<SettlementLogisticsDto> pageSelect(@Param("settlementReq") SettlementReq settlementReq);

    /**
     * 运营端查询物流结算列表
     *
     * @param settlementReq
     * @return
     */
    List<SettlementLogistics> list(@Param("settlementReq") SettlementReq settlementReq, @Param("authEntIdList") List<Long> authEntIdList);

    /**
     * 运费-物流订单各状态列表总数
     *
     * @author Aick Spt
     * @date 2023-07-24 16:23
     */
    Long getCountList(@Param("settlementReq") SettlementReq settlementReq);

    Map<String, Long> count(@Param("settlementReq") SettlementReq settlementReq, @Param("authEntIdList") List<Long> authEntIdList);

    /**
     * 运费-物流订单列表查询合计
     *
     * @author Aick Spt
     * @date 2023-07-28 09:49
     */
    SettlementLogisticsSumVo selectSum(@Param("settlementReq") SettlementReq settlementReq);

    /**
     * 运营端接口
     *
     * @param settlementReq
     * @return
     */
    SettlementLogisticsSumVo sum(@Param("settlementReq") SettlementReq settlementReq, @Param("authEntIdList") List<Long> authEntIdList);

    /**
     * 运费-物流订单详情
     *
     * @author Aick Spt
     * @date 2023-07-24 16:24
     */
    SettlementLogisticsDto detail(@Param("id") Long id, @Param("unitType") Integer unitType, @Param("unitTypeTwo") Integer unitTypeTwo);

    /**
     * 根据条件查物流结算订单-导出
     *
     * @author Aick Spt
     * @date 2023-07-24 16:24
     */
    List<SettlementLogisticsDto> selectLogisticsList(@Param("settlementReq") SettlementReq settlementReq, @Param("ids") List<Long> ids);

    /**
     * 运营端根据条件导出数据
     *
     * @param settlementReq
     * @param ids
     * @return
     */
    List<SettlementLogistics> exportList(@Param("settlementReq") SettlementReq settlementReq,
                                         @Param("ids") List<Long> ids,
                                         @Param("authEntIdList") List<Long> authEntIdList
    );

    List<LedgerUnitDto> getListById(@Param("id") Long id);

    /**
     * 根据双方企业查询
     *
     * @param entId     托运方
     * @param entTarget 承运方
     * @return
     */
    List<String> selectJoin(@Param("entId") Long entId, @Param("entTarget") Long entTarget);

    /**
     * @param entId    顶级企业id
     * @param cur      当月/周
     * @param pre      上月/周
     * @param unitType 企业类型
     */
    List<MoneyType> sumMoneyType(@Param("entId") Long entId, @Param("cur") List<LocalDateTime> cur, @Param("pre") List<LocalDateTime> pre, @Param("unitType") Integer unitType);

    /**
     * 物流结算定时任务归档数据查询
     *
     * @return
     */
    List<KwpSettlementRecord> queryRecord();

    /**
     * app端详情
     *
     * @param id
     * @param unitType
     * @return
     */
    SettlementLogisticsDto selectDetail(@Param("id") Long id, @Param("unitType") Integer unitType);
}