package com.ym.mec.biz.service;

import com.ym.mec.biz.dal.entity.SysConfig;
import com.ym.mec.common.exception.BizException;
import com.ym.mec.common.service.BaseService;
import com.ym.mec.util.date.DateUtil;

import java.util.Date;
import java.util.List;

public interface SysConfigService extends BaseService<Long, SysConfig> {
    //乐团基础规则

    //乐团预报名人数达到指定数量，可将乐团状态变更为创建缴费中
    String MUSIC_MIN_STUDENT_NUM = "music_min_student_num";
    //报名缴费阶段乐团若未合并学员，缴费人数达到指定人数时可确认开团(用于校验是否回访)
    String NEW_MUSIC_PAYMENT_STUDENT_NUM = "new_music_payment_student_num";
    //报名缴费阶段乐团若合并学员，缴费人数达到指定人数时可确认开团(用于校验是否回访)
    String OLD_MUSIC_PAYMENT_STUDENT_NUM = "old_music_payment_student_num";
    //乐团问卷调查编号
    String MUSIC_GROUP_TOPIC_ID = "music_group_topic_id";

    //考勤和课酬规则

    //线下课课程开始前指定时间打卡为正常签到
    String OFFLINE_ADVANCE_SIGN_IN_MINUTES = "offline_advance_sign_in_minutes";
    //线下课课程开始后指定时间内签到为迟到
    String OFFLINE_ADVANCE_SIGN_IN_LATE_MINUTES = "offline_advance_sign_in_late_minutes";
    //线下课课程结束前指定时间签退为异常
    String OFFLINE_ADVANCE_SIGN_OUT_MINUTES = "offline_advance_sign_out_minutes";
    //线下课老师异常签到扣减课酬金额
    String OFFLINE_ERROR_SIGN_IN_CUT_SALARY = "offline_error_sign_in_cut_salary";
    //线下课老师异常签到扣减课酬单位（1、元，2、百分比）
    String OFFLINE_ERROR_SIGN_IN_CUT_SALARY_UNIT = "offline_error_sign_in_cut_salary_unit";
    //线下课老师迟到扣减课酬金额
    String OFFLINE_LATE_CUT_SALARY = "offline_late_cut_salary";
    //线下课老师迟到扣减课酬单位（1、元，2、百分比）
    String OFFLINE_LATE_CUT_SALARY_UNIT = "offline_late_cut_salary_unit";
    //线下课老师旷课扣减课酬金额
    String OFFLINE_LEVEL_SIGN_IN_CUT_SALARY = "offline_level_sign_in_cut_salary";
    //线下课老师旷课扣减课酬单位（1、元，2、百分比）
    String OFFLINE_LEVEL_SIGN_IN_CUT_SALARY_UNIT = "offline_level_sign_in_cut_salary_unit";
    //线下课老师旷课扣减课酬金额
    String OFFLINE_NO_SIGN_IN_CUT_SALARY = "offline_no_sign_in_cut_salary";
    //线下课老师旷课扣减课酬单位（1、元，2、百分比）
    String OFFLINE_NO_SIGN_IN_CUT_SALARY_UNIT = "offline_no_sign_in_cut_salary_unit";
    //线下课老师异常签退扣减课酬金额
    String OFFLINE_ERROR_SIGN_OUT_CUT_SALARY = "offline_error_sign_out_cut_salary";
    //线下课老师异常签退扣减课酬单位（1、元，2、百分比）
    String OFFLINE_ERROR_SIGN_OUT_CUT_SALARY_UNIT = "offline_error_sign_out_cut_salary_unit";
    //线下课老师异常签退扣减课酬金额
    String OFFLINE_EARLY_SIGN_OUT_CUT_SALARY = "offline_early_sign_out_cut_salary";
    //线下课老师异常签退扣减课酬单位（1、元，2、百分比）
    String OFFLINE_EARLY_SIGN_OUT_CUT_SALARY_UNIT = "offline_early_sign_out_cut_salary_unit";
    //线下课老师异常签退扣减课酬金额
    String OFFLINE_NO_SIGN_OUT_CUT_SALARY = "offline_no_sign_out_cut_salary";
    //线下课老师异常签退扣减课酬单位（1、元，2、百分比）
    String OFFLINE_NO_SIGN_OUT_CUT_SALARY_UNIT = "offline_no_sign_out_cut_salary_unit";
    //vip课开课前可点名时间段，开课前{}分钟
    String ENABLE_STUDENT_ATTENDANCE_BEFOR_COURSE_START_TIME_RANGE_VIP = "enable_student_attendance_befor_course_start_time_range_vip";
    //vip课程可更新学生签到状态时间限制,课程结束后{}分钟
    String ENABLE_STUDENT_ATTENDANCE_TIME_RANGE_VIP = "enable_student_attendance_time_range_vip";
    //如果没有签退，{}分钟后自动发送推送信息
    String SIGN_OUT_MESSAGE_PUSH_MINUTE = "sign_out_message_push_minute";
    //乐团课老师课程结束后可正常签退时间范围为课程结束后{}分钟内
    String ADVANCE_SIGN_OUT_MINUTES = "advance_sign_out_minutes";

    //线上连堂课间隔时间
    String ONLINE_CONTINUE_COURSE_TIME = "online_continue_course_time";
    //线上课课程开始前指定时间打卡为正常签到
    String ONLINE_ADVANCE_SIGN_IN_MINUTES = "online_advance_sign_in_minutes";
    //线上课课程开始后指定时间内签到为迟到
    String ONLINE_ADVANCE_SIGN_IN_LATE_MINUTES = "online_advance_sign_in_late_minutes";
    //线上课课程结束前指定时间内签退为早退
    String ONLINE_EARLY_SIGN_OUT_MINUTES = "online_early_sign_out_minutes";
    //线上课老师迟到扣减课酬金额
    String ONLINE_LATE_CUT_SALARY = "online_late_cut_salary";
    //线上课老师迟到扣减课酬单位（1、元，2、百分比）
    String ONLINE_LATE_CUT_SALARY_UNIT = "online_late_cut_salary_unit";
    //线上课老师旷课扣减课酬金额
    String ONLINE_LEVEL_SIGN_IN_CUT_SALARY = "online_level_sign_in_cut_salary";
    //线上课老师旷课扣减课酬单位（1、元，2、百分比）
    String ONLINE_LEVEL_SIGN_IN_CUT_SALARY_UNIT = "online_level_sign_in_cut_salary_unit";
    //线上课老师旷课扣减课酬金额
    String ONLINE_NO_SIGN_IN_CUT_SALARY = "online_no_sign_in_cut_salary";
    //线上课老师旷课扣减课酬单位（1、元，2、百分比）
    String ONLINE_NO_SIGN_IN_CUT_SALARY_UNIT = "online_no_sign_in_cut_salary_unit";
    //线上课老师异常签退扣减课酬金额
    String ONLINE_ERROR_SIGN_OUT_CUT_SALARY = "online_error_sign_out_cut_salary";
    //线上课老师异常签退扣减课酬单位（1、元，2、百分比）
    String ONLINE_ERROR_SIGN_OUT_CUT_SALARY_UNIT = "online_error_sign_out_cut_salary_unit";
    //线上课老师早退扣减课酬金额
    String ONLINE_EARLY_SIGN_OUT_CUT_SALARY = "online_early_sign_out_cut_salary";
    //线上课老师早退扣减课酬单位（1、元，2、百分比）
    String ONLINE_EARLY_SIGN_OUT_CUT_SALARY_UNIT = "online_early_sign_out_cut_salary_unit";
    //线上课老师未签退扣减课酬金额
    String ONLINE_NO_SIGN_OUT_CUT_SALARY = "online_no_sign_out_cut_salary";
    //线上课老师未签退扣减课酬单位（1、元，2、百分比）
    String ONLINE_NO_SIGN_OUT_CUT_SALARY_UNIT = "online_no_sign_out_cut_salary_unit";

    //线下课老师可以打卡范围，GPS定位距离教学点距离
    String ATTENDANCE_RANGE = "attendance_range";
    //线下课签到定位异常扣除金额
    String OFFLINE_SIGN_IN_GPS_ERROR_CUT_SALARY = "offline_sign_in_gps_error_cut_salary";
    //线下课签到定位异常扣除金额
    String OFFLINE_SIGN_IN_GPS_ERROR_CUT_SALARY_UNIT = "offline_sign_in_gps_error_cut_salary_unit";
    //线下课签退定位异常扣除金额
    String OFFLINE_SIGN_OUT_GPS_ERROR_CUT_SALARY = "offline_sign_out_gps_error_cut_salary";
    //线下课签退定位异常扣除金额
    String OFFLINE_SIGN_OUT_GPS_ERROR_CUT_SALARY_UNIT = "offline_sign_out_gps_error_cut_salary_unit";
    //vip线下课点名定位异常扣除金额
    String VIP_OFFLINE_GPS_ERROR_CUT_SALARY = "vip_offline_gps_error_cut_salary";
    //vip线下课点名定位异常扣除金额单位
    String VIP_OFFLINE_GPS_ERROR_CUT_SALARY_UNIT = "vip_offline_gps_error_cut_salary_unit";
    //vip线下课未点名扣除金额
    String VIP_OFFLINE_NO_GPS_ERROR_CUT_SALARY = "vip_offline_no_gps_error_cut_salary";
    //vip线下课未点名扣除金额单位
    String VIP_OFFLINE_NO_GPS_ERROR_CUT_SALARY_UNIT = "vip_offline_no_gps_error_cut_salary_unit";

    //试用期老师课酬发放百分比
    String PROBATION_TEACHER_SALARY = "probation_teacher_salary";

    //老师端可申诉考勤时间限制（天）
    String TEACHER_APP_SALARY_COMPLAINTS_TIME = "teacher_app_salary_complaints_time";
    //后台老师考勤申诉时间限制
    String WEB_TEACHER_COMPLAINTS_SALARY = "web_teacher_complaints_salary";

    //线下连堂课间隔时间
    String OFFLINE_CONTINUE_COURSE_MINUTES = "offline_continue_course_minutes";
    //学生允许请假的时间，为开课前{}小时
    String ADVANCE_LEAVE_HOURS = "advance_leave_hours";
    //教师可调整课程默认时间，开课前{}小时
    String ENABLE_TEACHER_COURSE_ADJUST_DEFAULT_HOURS = "enable_teacher_course_adjust_default_hours";
    //退款周期
    String REFUND_PERIOD = "refund_period";

    //服务异常提醒
    //学员当月请假指定次数及以上提醒异常请假
    String STUDENT_ERROR_LEAVE_NUM = "student_error_leave_num";
    //上课时间在指定时间段内提醒时间安排异常
    String COURSE_START_TIME_ERROR = "course_start_time_error";
    //上课时间在指定时间段内提醒时间安排异常
    String COURSE_END_TIME_ERROR = "course_end_time_error";

    //乐保
    //是否开启乐保
    String MUSICAL_REPAIR_OPEN_FLAG = "musical_repair_open_flag";
    //一年期乐保零售价
    String ONE_YEAR_MUSICAL_REPAIR_AMOUNT = "one_year_musical_repair_amount";
    //一年期乐保原价
    String ONE_YEAR_MUSICAL_REPAIR_ORIGINAL_AMOUNT = "one_year_musical_repair_original_amount";


    //特殊规则默认值--》网管&试听课规则
    //试听课默认单节课时长
    String DEMO_GROUP_SINGLE_CLASS_MINUTES_ = "demo_group_single_class_minutes_";
    //陪练课可选老师的分部
    String PRACTICE_TEACHER_ORGAN_RANGE = "practice_teacher_organ_range";
    //陪练课可预约声部列表
    String PRACTICE_SUBJECT_ID_LIST = "practice_subject_id_list";
    //陪练课预约开始时间
//    String PRACTICE_APPLY_START_TIME = "practice_apply_start_time";
    //陪练课预约结束时间
//    String PRACTICE_APPLY_END_TIME = "practice_apply_end_time";

    //特殊规则默认值--》商品规则设置
    //内部库存预警值
    String INNER_REPERTORY_WARN_NUM = "inner_repertory_warn_num";
    //外部库存预警值
    String OUTER_REPERTORY_WARN_NUM = "outer_repertory_warn_num";
    //库存预警手机号
    String REPERTORY_WARN_PHONE = "repertory_warn_phone";

    //课程默认值规则---》乐团规则设置
    //自动确认收货时间
    String AUTO_AFFIRM_RECEIVE_TIME = "auto_affirm_receive_time";
    //提醒老师创建新的缴费项目,距离缴费项有效期前{}天
    String PUSH_CREATE_PAYMENT_CALENDER = "push_create_payment_calender";
    //提醒乐团主管排下学期的课程的时间节点（默认提前14天）
    String REMIND_COURSE_TIME = "remind_course_time";
    //会员结束前15天自动创建乐团续费（默认提前15天）
    String AUTO_CREATE_MEMBER_RENEW = "auto_create_member_renew";
    //会员团每学期赠送课程分钟数
    String MEMBER_GROUP_TERM_GIVE_COURSE_TIME = "member_group_term_give_course_time";
    //各声部不购买会员入团资格限制学员数
    String MEMBER_GROUP_FEE_STUDENT_NUM = "member_group_fee_student_num";


    //乐团所有未开始课程组、商品等服务及产品退费时，退费金额扣减百分比（默认0.005）
    String MUSIC_RETURN_FEE_CHARGES = "5";
    //乐团课退费时若课程组已开始，退费金额扣减百分比(默认0.8)
    String MUSIC_COURSE_START_RETURN_FEE_CHARGES = "80";
    //1v1小班课退费时若课程组已开始，退费金额扣减百分比(默认0.8)
    String VIP_1V1_COURSE_NOT_START_RETURN_FEE_CHARGES = "80";
    //1vn小班课退费时若课程组已开始，退费金额扣减百分比(默认0.7)
    String VIP_1VN_COURSE_NOT_START_RETURN_FEE_CHARGES = "70";


    public static final String BASE_API_URL = "base_api_url";

    /**
     * 缴费状态提前{}天刷新
     */
    public static final String REFRESH_PAYMENT_STATUS_EARLY_DAYS = "refresh_payment_status_early_days";

    /**
     * VIP课结束后，用户可申诉时间，为课程结束后的{}天
     */
    public static final String VIP_APPEAL_DAYS_RANGE = "vip_appeal_days_range";

    /**
     * 线下课最早打卡时间可提前分钟数
     */
    String OFFLINE_SIGN_IN_EARLY_FORWARD_TIME = "offline_sign_in_early_forward_time";

    /**
     * 最早请假提前时间
     */
    String EARLIEST_TIME_FOR_LEAVE="earliest_time_for_leave";


    /**
     * 单技课梯度结算规则设置
     */
    public static final String SIGLE_GRADIENT_SETTLEMENT_RULE = "sigle_gradient_settlement_rule";

    /**
     * 合奏课梯度结算规则设置
     */
    public static final String MAX_GRADIENT_SETTLEMENT_RULE = "max_gradient_settlement_rule";

    /**
     * 小班课梯度结算规则设置
     */
    public static final String HIGH_GRADIENT_SETTLEMENT_RULE = "high_gradient_settlement_rule";

    String STUDENT_APPLY_URL = "student_apply_url";
    String SERVER_PHONE = "server_phone";

    String MUSIC_GROUP_SETTLEMENT_CLASS_MINUTES = "music_group_settlement_class_minutes";

    String MUSIC_GROUP_SETTLEMENT_DAY = "music_group_settlement_day";

    String MUSIC_GROUP_SETTLEMENT_SINGLE_CLASS_MINUTES = "music_group_settlement_single_class_minutes";

    /**
     * 可签退时间限制(自然天)
     */
    String ENABLE_SIGN_OUT_TIME_RANGE = "enable_sign_out_time_range";

    /**
     * 可更新学生签到状态时间限制,课程结束后{}分钟(和前端核实过，乐团的已弃用)
     */
    String ENABLE_STUDENT_ATTENDANCE_TIME_RANGE = "enable_student_attendance_time_range";

    /**
     * @describe 陪练课课酬
     */
    String PRACTICE_COURSE_SALARY = "practice_course_salary";

    /**
     * @describe 陪练课时长
     */
    String PRACTICE_COURSE_MINUTES = "practice_course_minutes";

    /**
     * @describe 陪练课预约时间间隔
     */
    String PRACTICE_APPLY_INTERVAL_TIME = "practice_apply_interval_time";

    /**
     * @describe 教师请假数据
     */
    String TEACHER_LEAVE_DATA = "teacher_leave_data";

    /**
     * 十分钟内最大可发送的短信次数
     */
    String SMS_MAX_TIMES = "sms_max_times";


    /**
     * 连堂课间隔时间
     */
    String AUTO_CLOSE_NETWORK_ROOM = "auto_close_network_room";

    /**
     * @describe 付费陪练课可购买最大月数
     */
    String PRACTICE_PAY_MAX_MONTH = "practice_pay_max_month";

    /**
     * @describe 付费陪练课单月上课数量
     */
    String PRACTICE_PAY_DRILL_TIMES_ON_ONE_WEEK = "practice_pay_drill_times_on_one_week";

    /**
     * @describe 付费陪练课活动截至日期
     */
    String PRACTICE_BUY_ACTIVITY_EXPIRE_DATE = "practice_buy_activity_expire_date";

    /**
     * 陪练老师端入口地址
     */
    String TEACHER_STUDY_REPORT_URL = "teacher_study_report_url";

    /**
     * 陪练课报告地址
     */
    String STUDENT_STUDY_REPORT_URL = "student_study_report_url";

    /**
     * @describe 陪练课续费地址
     */
    String PRACTICE_RENEW_URL = "practice_renew_url";

    /**
     * @describe 老师端baseUrl
     */
    String TEACHER_BASE_URL = "teacher_base_url";

    String PRACTICE_PROMOTION_ACTIVITY_START_DATE = "practice_promotion_activity_start_date";

    String NEW_MSG_PUSH = "您收到一条训练回复，请点击查看";

    /**
     * @describe 教务端baseUrl
     */
    String EDU_TEACHER_BASE_URL = "edu_teacher_base_url";

    String HOLIDAY_SETTING = "holiday_setting";

    String PRACTICE_FREE_APPLY_EXPIRE_DATE = "practice_free_apply_expire_date";
    
    String START_TIME_OF_1111 = "start_time_of_1111";
    
    String END_TIME_OF_1111 = "end_time_of_1111";

    String VIP_SPECIAL_ACTIVITY_IDS = "vip_special_activity_ids";

    //特殊规则默认值--》其他参数设置
    //基本课酬{}元
    String DAYA_BASE_SALARY_AMOUNT = "daya_base_salary_amount";
    //对外课程课后缓冲时间{}分钟
    String COURSE_BEFORE_BUFFER_TIME = "course_before_buffer_time";
    //对外课程课后缓冲时间{}分钟
    String COURSE_AFTER_BUFFER_TIME = "course_after_buffer_time";
    //全职资源公摊金额
    String FULL_JOB_FEE = "full_job_fee";
    //云教练训练时长小于80分钟需要回访
    String STUDENT_CLOUD_TEACHER_TOTAL_PLAY_TIME = "student_cloud_teacher_total_play_time";
    //云教练训练次数小于4次需要回访
    String STUDENT_CLOUD_TEACHER_TRAIN_NUM = "student_cloud_teacher_train_num";
    //考级活动开始时间
    String DEGREE_ACTIVITY_START_TIME = "degree_activity_start_time";
    //考级活动开始时间
    String DEGREE_ACTIVITY_END_TIME = "degree_activity_end_time";
    //支持考级活动报名的分部列表
    String DEGREE_SUPPORT_ORGAN_LIST = "degree_support_organ_list";



    String WARNING_MIN_COURSE_SALARY = "warning_min_course_salary";

    //会员结束前15天提醒学员续费（默认提前15天）
    String PUSH_MEMBER_RENEW = "push_member_renew";

    //试用会员结束前3天提醒学员续费（默认提前3天）
    String EXPERIENCE_PUSH_MEMBER_RENEW = "experience_push_member_renew";

    //云教练活动分部目标JSON
    String CLOUD_TEACHER_ACTIVE_TARGET = "cloud_teacher_active_target";

    //会员结束前15天提醒学员续费（默认提前5天）
    String PUSH_MEMBER_RENEW_AGAIN = "push_member_renew_again";

    //会员结束前5天提醒学员续费(退团提醒)（默认提前5天）
    String PUSH_MEMBER_RENEW_QUIT = "push_member_renew_quit";

    String CHILDREN_DAY_VIP_ACTIVITY_IDS = "children_day_vip_activity_ids";

    //云教练作业开关0关1开
    String HOMEWORK_OPEN_FLAG = "homework_open_flag";

    //云教练免费体验开关0关1开
    String FREE_CLOUD_OPEN_FLAG = "free_cloud_open_flag";

    //云教练试用时间最晚截止时间
    String EXPERIENCE_MEMBERSHIP_END_TIME = "experience_membership_end_time";

    //小课收入是否由平台收款
    String IS_OPEN_SMALL_CLASS_INCOME_TO_PLATFORM = "is_open_small_class_income_to_platform";

    //平台收款账户
    String PLATFORM_PAYEE_ACCOUNT = "platform_payee_account";

    static Date checkActivityDate(String startTimeStr, String endTimeStr) {
        Date now = new Date();
        Date startTime = DateUtil.stringToDate(startTimeStr);
        if (startTime.compareTo(now) > 0) {
            throw new BizException("活动还未开始，谢谢关注");
        }
        Date endTime = DateUtil.stringToDate(endTimeStr);
        if (endTime.compareTo(now) <= 0) {
            throw new BizException("活动已结束，谢谢关注");
        }
        return now;
    }

    /**
     * @return com.ym.mec.biz.dal.entity.SysConfig
     * @params paramName
     * @describe 根据配置名称获取配置信息
     */
    SysConfig findByParamName(String paramName);

    void batchUpdate(List<SysConfig> configList);

    void updateConfig(SysConfig config);
}
