package cn.iocoder.yudao.module.course.mapper;

import cn.iocoder.yudao.module.course.entity.SchoolCourseOrder;
import cn.iocoder.yudao.module.course.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 驾照报名订单 Mapper
 *
 * @author 若依
 */
@Mapper
public interface SchoolCourseOrderMapper extends BaseMapper<SchoolCourseOrder> {

    /**
     * 获得驾照报名订单分页
     *
     * @param entity {@link SchoolCourseOrderVO}
     * @param page      分页参数
     * @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.course.vo.SchoolCommissionVO>
     * @author PQZ
     * @date 10:11 2025/2/25
     **/
    IPage<SchoolCourseOrderVO> queryPage(@Param("entity")SchoolCourseOrderVO entity, Page<SchoolCommissionVO> page);
    IPage<SchoolCourseOrderVO> queryPageNew(@Param("entity")SchoolCourseOrderVO entity, Page<SchoolCommissionVO> page);

    /**
     *
     * @author vinjor-M
     * @date 14:38 2025/2/25
     * @param coachId 教练userId
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return java.util.List<cn.iocoder.yudao.module.course.vo.SchoolCourseOrderVO>
    **/
    Double selectByCoachUserId(@Param("coachId")Long coachId,@Param("startTime")String startTime,@Param("endTime")String endTime);
    Double selectByCoachUserIdIsConfirmed(@Param("coachId")Long coachId,@Param("startTime")String startTime,@Param("endTime")String endTime);


    /** 学员订单信息 */
    SchoolCourseOrderVO getOrderInfo(@Param("userId") Long userId);


    /**创建学员Users表信息*/
    Long createStudentUsers(AdminUserDO adminUserDO);

    /**
     * 根据学员id获取订单提成方案
     */
    String getSchemeByStudentId(@Param("studentId") Long studentId, @Param("courseId") String courseId, @Param("subject") Integer subject);

    /**
     * 查询是否有订单使用该提成方案
     */
    Integer getOrderCountBySchemeId(@Param("schemeId") String schemeId);

    /**
     * 根据教练id获取对应招生
     */
    IPage<SchoolCourseOrderVO> getOrderByCoachId(@Param("entity")SchoolCourseOrderVO entity, Page<SchoolCourseOrderVO> page);

    /**
     * 获取教练的订单总金额
     */
    List<SchoolCourseOrderVO> getCoachMoney(@Param("entity")SchoolCourseOrderVO entity);

    /**
     * 获取教练的订单明细
     */
    IPage<SchoolCourseOrderVO> getOrderMoneyByCoachId(@Param("entity")SchoolCourseOrderVO entity, Page<SchoolCourseOrderVO> page);

    /**
     * 需要导出的数据
     * @param entity
     * @param page
     * @return
     */
    IPage<CourseOrderExportVO> getOrderExportData(@Param("entity")CourseOrderExportVO entity, Page<CourseOrderExportVO> page);

    CourseOrderStatisticsVO getOrderStatistics(@Param("entity")CourseOrderExportVO entity);


    /**
     * 首页财务详细列表
     */
    List<FinanceInfoOnCoachAndStudent> getMoneyInfoOnFinance(@Param("entity")FinanceInfoOnCoachAndStudent entity);
    IPage<FinanceInfoOnCoachAndStudent> getFinanceStudentByCoachId(@Param("entity")FinanceInfoOnCoachAndStudent entity, Page<FinanceInfoOnCoachAndStudent> page);
}
