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

import cn.iocoder.yudao.module.course.entity.Process;
import cn.iocoder.yudao.module.course.entity.SchoolCourseScheme;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

@Mapper
public interface SchoolCourseSchemeMapper extends BaseMapper<SchoolCourseScheme> {

    @Update("UPDATE drive_school_course_scheme SET is_default = false " +
            "WHERE course_id = #{courseId} AND id != #{excludeId} AND is_default = true")
    int cancelOtherDefault(@Param("courseId") String courseId,
                           @Param("excludeId") String excludeId);

    BigDecimal getCourseDeduct(@Param("courseId") String courseId, @Param("subject") Integer subject);

    BigDecimal getSchemeById(@Param("id") String id, @Param("subject") Integer subject);

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