package com.sckw.payment.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sckw.payment.model.KwpSettlementRecord;
import com.sckw.payment.model.KwpSettlementTrade;
import com.sckw.payment.model.dto.LedgerUnitDto;
import com.sckw.payment.model.dto.MoneyType;
import com.sckw.payment.model.dto.SettlementTradeDto;
import com.sckw.payment.model.vo.SettlementTrade;
import com.sckw.payment.model.vo.req.SettlementTradeReq;
import com.sckw.payment.model.vo.res.SettlementSumVo;
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 xucaiqin
 * @date 2023-07-10 16:42:19
 */

@Mapper
public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade> {
    List<SettlementTradeDto> pageSelect(@Param("settlementReq") SettlementTradeReq settlementReq);

    /**
     * 运营端列表查询
     *
     * @param settlementReq
     * @return
     */
    List<SettlementTrade> list(@Param("settlementReq") SettlementTradeReq settlementReq);

    SettlementSumVo sumMoney(@Param("settlementReq") SettlementTradeReq settlementReq);

    /**
     * 运营端统计
     *
     * @param settlementReq
     * @return
     */
    SettlementSumVo sumMoney2(@Param("settlementReq") SettlementTradeReq settlementReq);

    Map<String, Long> countOrder(@Param("settlementReq") SettlementTradeReq settlementReq);

    /**
     * 运营端统计结算单数量
     *
     * @param settlementReq
     * @return
     */
    Map<String, Long> count(@Param("settlementReq") SettlementTradeReq settlementReq);

    List<SettlementTradeDto> selectByIds(@Param("ids") List<Long> ids, @Param("unitType") Integer unitType);

    SettlementTradeDto getById(@Param("id") Long id, @Param("unitType") Integer unitType);

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

    SettlementTradeDto selectDetail(@Param("id") Long id, @Param("unitType") Integer unitType);

    /**
     * 根据双方企业查询
     *
     * @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);

    List<KwpSettlementRecord> queryRecord();

    /**
     * 导出数据查询
     *
     * @param settlementReq
     * @param idList
     * @return
     */
    List<SettlementTradeDto> exportList(@Param("settlementReq") SettlementTradeReq settlementReq, @Param("idList") List<Long> idList);

    /**
     * 运营端导出数据
     *
     * @param settlementReq
     * @param idList
     * @return
     */
    List<SettlementTrade> operateExportList(@Param("settlementReq") SettlementTradeReq settlementReq, @Param("idList") List<Long> idList);
}