package com.greenorange.promotion.service.userInfo;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.common.PageRequest;
import com.greenorange.promotion.model.dto.CommonStringRequest;
import com.greenorange.promotion.model.dto.userPerformanceSummary.*;
import com.greenorange.promotion.model.entity.CourseOrder;
import com.greenorange.promotion.model.entity.UserPerformanceSummary;
import com.baomidou.mybatisplus.extension.service.IService;
import com.greenorange.promotion.model.enums.UserRoleEnum;
import com.greenorange.promotion.model.vo.dashboard.WebQueryDashboardVO;
import com.greenorange.promotion.model.vo.userPerformanceSummary.SupervisorPerformanceSummaryVO;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
* @author 35880
* @description 针对表【user_performance_summary(用户绩效汇总表)】的数据库操作Service
* @createDate 2025-07-10 20:38:41
*/
public interface UserPerformanceSummaryService extends IService<UserPerformanceSummary> {

    /**
     * 获取主管查询条件
     */
    QueryWrapper<UserPerformanceSummary> getQueryWrapper(PageRequest pageRequest);


    /**
     * 获取课程订单的查询条件
     */
    QueryWrapper<CourseOrder> getCourseOrderQueryWrapper(UserCourseOrderQueryRequest userCourseOrderQueryRequest);


    /**
     * Web端管理员修改一、二级抽成比例
     */
    void updateRakeRewards(RakeRewardsUpdateRequest rakeRewardsUpdateRequest);


    /**
     * Web端管理员查询一、二级抽成比例
     */
    Map<String, BigDecimal> queryRakeRewardsRate();


    /**
     * Web端管理员根据级别查询抽佣比例
     */
    BigDecimal queryRakeRewardsRateByLevel(RakeRewardsQueryRequest rakeRewardsQueryRequest);


    /**
     * 在内存 List 上模拟 MyBatis-Plus 的分页
     */
    Page<SupervisorPerformanceSummaryVO> queryPage(UserPerformanceSummaryRankQueryRequest req, List<SupervisorPerformanceSummaryVO> allVos);


    /**
     * 查看某个时间段的绩效
     */
    Map<String, Object> getPerformanceSummaryByStartAndEndTime(DateTime beginOfDay, DateTime endOfDay, UserRoleEnum userRoleEnum, Long userId);


    /**
     * 经理查看仪表盘
     */
    WebQueryDashboardVO queryManagerDashboard();


    /**
     * 主管或员工查看仪表盘
     */
    WebQueryDashboardVO querySupervisorOrStaffDashboard(UserRoleEnum userRoleEnum, Long userId);


    /**
     * 对List集合进行排序
     */
    void sortPerformanceRankingList(List<SupervisorPerformanceSummaryVO> supervisorPerformanceSummaryVOS, MiniUserPerformanceSummaryRankQueryRequest request);

}
