| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | <?php/** * HolidaySet.php  UTF-8 * 节假日配置 * * @date    : 2019/12/4 16:07 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : chenbingling <cbl@huosdk.com> * @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;    }}
 |