package com.retdata.yaoyibi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.retdata.yaoyibi.domain.*;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

public interface WmScorePackageMapper extends BaseMapper<WmScorePackage> {

    Page<WmScorePackageSearchDto> selectByParams(Page<WmScorePackageSearchDto> page,
                                                 @Param("searchParams") WmScorePackageSearchParams searchParams);

    List<WmScorePackageStatusSummary> selectWmScorePackageStatusByPackageIds(@Param("packageIds") Collection<Integer> packageIds);

    List<WmScorePackageSearchDto> selectSubPackagesByPackageIds(@Param("packageIds") Collection<Integer> packageIds);

    List<WmScorePackageChildrenCount> selectWmScorePackageChildrenCount(@Param("packageIds") Collection<Integer> packageIds);

    List<WmScorePackageExportDto> selectExportDto(@Param("searchParams") WmScorePackageSearchParams searchParams);

    List<WmScorePackageExportDto> selectExportDtoByPackageIds(@Param("packageIds") Collection<Integer> packageIds);

    List<WmScorePackageSettleTreeNode> selectSubPackageSettleTreeNodesByPackageIds(@Param("packageIds") Collection<Integer> packageIds);

    List<WmScorePackageSettleTreeNode> selectPackageSettleTreeNodesByPackageIdsForScore(@Param("packageIds") Collection<Integer> packageIds);

    /**
     * 获取下发积分包总值统计
     *
     * @param searchParams
     * @return
     */
    ScoreStat selectScoreStatByParams(@Param("searchParams") WmScorePackageSearchParams searchParams);

    /**
     * 获取按指定时间粒度的下发积分包总值统计
     *
     * @param searchParams
     * @return
     */
    List<ScoreTimeStat> selectScoreTimeStatByParams(@Param("searchParams") WmScorePackageSearchParams searchParams,
                                                    @Param("statUnit") String statUnit);

    /**
     * 获取企业包完成企业任务积分（审批通过以后）
     *
     * @param packageIds
     * @return
     */
    List<ScorePackageEntTaskScoreStat> selectApprovedEntTaskScoreStat(@Param("packageIds") Collection<Integer> packageIds);

    /**
     * 查询源头包ID
     *
     * @param searchParams
     * @return
     */
    List<Integer> selectRootPackageIds(@Param("searchParams") WmScorePackageSearchParams searchParams);

    /**
     * 查询积分包的积分及结算信息
     *
     * @param searchParams
     * @return
     */
    List<WmScorePackageSearchDto> selectByParamsForSettledStat(@Param("searchParams") WmScorePackageSearchParams searchParams);

    /**
     * 检索积分包用户ID
     *
     * @param packageIds
     * @return
     */
    List<Integer> selectUserIdsByPackageIds(@Param("packageIds") Collection<Integer> packageIds);

    List<WmScorePackageStatus> selectPackageStatusByPackageIds(@Param("packageIds") Collection<Integer> packageIds);

    List<String> selectReceiverNames(@Param("keyword") String keyword, @Param("limit") int limit);

    List<DeptGmv> selectCso1GmvByDeptIds(@Param("rootDeptIds") Collection<Integer> rootDeptIds,
                                         @Param("lastYear") Integer lastYear,
                                         @Param("currentYear") Integer currentYear);

    List<DeptGmv> selectCso2GmvByDeptIds(@Param("rootDeptIds") Collection<Integer> rootDeptIds,
                                         @Param("lastYear") Integer lastYear,
                                         @Param("currentYear") Integer currentYear);

}
