package com.crm.activity.service;

import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingDto;
import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingProfitCoverDto;
import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingManualEntity;
import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingMyEntity;
import com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable;

import java.util.List;
import java.util.Map;

/**
 * 排名服务接口
 *
 * @author y
 * @create 2022/7/21
 */
public interface ActivityRaceRankingService {

    /**
     * 列表信息
     * @param entity
     * @return
     * @throws Exception
     */
    BaseResultWithPagerDto<List<ActivityRaceRankingDto>> searchList(ActivityRaceRankingListEntity entity) throws Exception;

    /**
     * 根据ID获取信息
     * @param id
     * @return
     * @throws Exception
     */
    ActivityRaceRankingDto getById(Long id) throws Exception;

    /**
     * 重排序
     * @param ruleId
     */
    void reOrderRanking(Long ruleId) throws Exception;

    /**
     * 手动添加盈利金额
     * @param entity
     */
    void updateManual(ActivityRaceRankingManualEntity entity) throws Exception;

    /**
     * 查询客户排名信息
     * @param entity
     * @return
     */
    ActivityRaceRankingDto searchCustomRankingInfo(ActivityRaceRankingMyEntity entity) throws Exception;

    /**
     * 获取规则内所有排名map信息
     * @param ruleId
     * @return
     * @throws Exception
     */
    Map<Long, ActivityRaceRankingTable> mapAllByRuleId(Long ruleId) throws Exception;

    /**
     * 保存计算结果
     * @param tables
     * @throws Exception
     */
    void updateCalcResult(List<ActivityRaceRankingTable> tables) throws Exception;

    /**
     * 重新排名
     * @param tables
     * @return
     */
    List<ActivityRaceRankingTable> reOrderRanking(List<ActivityRaceRankingTable> tables);

    /**
     *
     * @param entity
     * @return
     * @throws Exception
     */
    BaseResultWithPagerDto<List<ActivityRaceRankingProfitCoverDto>> searchProfitCoverList(ActivityRaceRankingListEntity entity) throws Exception;
}
