* @version : HUOSDK 8.5 */ namespace huoIdentify\controller; use huo\controller\common\Base; use huoIdentify\model\IdentifyHolidaySetModel; class HolidaySet extends Base { /** * 判断今日是否为节假日 * * @return bool true 是 false 否 */ public function isHoliday() { $_year = date('Y'); $_holiday_set = (new IdentifyHolidaySetModel())->getInfoByYear($_year); if (empty($_holiday_set)) { if (date('N') == 6 || date('N') == 7) { /* 当天为周六日,判断是否为调班 */ return true; } return false; } $_date = date('Y-m-d'); if (date('N') == 6 || date('N') == 7) { /* 当天为周六日,判断是否为调班 */ if (in_array($_date, $_holiday_set['workday'])) { return false; } return true; } else { /* 非周六日,判断是否为节假日 */ if (in_array($_date, $_holiday_set['holiday'])) { return true; } return false; } } /** * 判断今日是否允许登陆 */ public function isAllowLogin() { if (date('N') == 5 || date('N') == 6 || date('N') == 7) { /* 当天为周五六日,允许登陆 */ return true; } $_year = date('Y'); $_holiday_set = (new IdentifyHolidaySetModel())->getInfoByYear($_year); if (empty($_holiday_set)) { /* 未配置节假日则认为无节假日开放,不允许登陆 */ return false; } $_date = date('Y-m-d'); /* 如果今天是节假日则允许登陆 */ if (in_array($_date, $_holiday_set['holiday'])) { return true; } return false; } }