123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- /**
- * UnderageLimitMsg.php UTF-8
- * 未成年限制提示信息
- *
- * @date : 2019/11/29 9:24
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @version : HUOSDK 8.5
- */
- namespace huoIdentify\controller;
- use huo\controller\common\Base;
- use huolib\constant\IdentifyConst;
- class UnderageLimitMsg extends Base {
- /**
- * 获取提示信息
- *
- * @param int $type 提示类型
- *
- * @return array
- */
- public static function getMsg($type) {
- $_identify_conf = (new IdentifyConf())->getConf(true);
- $_close_type = IdentifyConst::JS_CLOSE_WEB; // 弹出关闭类型 1 关闭app 2 关闭弹窗
- switch ($type) {
- case IdentifyConst::UNDERAGE_ONLINE_TIME_LIMIT: //未成年玩家每日在线时长限制
- $_limit_minute = $_identify_conf['underage']['day_limit_time'];
- $_msg = self::getDayLimitMsg($_limit_minute);
- $_close_type = IdentifyConst::JS_CLOSE_APP;
- break;
- case IdentifyConst::UNDERAGE_HOLIDAY_ONLINE_TIME_LIMIT: //未成年玩家节假日在线时长限制
- $_limit_minute = $_identify_conf['underage']['holiday_limit_time'];
- $_msg = self::getHolidayLimitMsg($_limit_minute);
- $_close_type = IdentifyConst::JS_CLOSE_APP;
- break;
- case IdentifyConst::UNDERAGE_PERIOD_LIMIT: //未成年玩家节假日在线时长限制
- $_limit_today_time = $_identify_conf['underage']['limit_today_time'];
- $_limit_next_day_time = $_identify_conf['underage']['limit_next_day_time'];
- $_period = $_limit_today_time.':00-'.$_limit_next_day_time.':00';
- $_msg = self::getPeriodLimitMsg($_period);
- $_close_type = IdentifyConst::JS_CLOSE_APP;
- break;
- case IdentifyConst::UNDERAGE_AGE_8_CHARGE_LIMIT: //8岁以下不允许支付
- $_age = $_identify_conf['underage']['charge_limit'][0]['max_age'];
- $_msg = self::getAge8ChargeLimitMsg($_age);
- $_close_type = IdentifyConst::JS_CLOSE_WEB;
- break;
- case IdentifyConst::UNDERAGE_AGE_8_16_CHARGE_LIMIT: //8-16岁限制消费
- $_limit = $_identify_conf['underage']['charge_limit'][1];
- $_age = $_limit['min_age'].'-'.$_limit['max_age'];
- $_week_money = $_limit['week_money'];
- $_month_money = $_limit['month_money'];
- $_msg = self::getAge816ChargeLimitMsg($_age, $_week_money, $_month_money);
- $_close_type = IdentifyConst::JS_CLOSE_WEB;
- break;
- case IdentifyConst::UNDERAGE_AGE_16_18_CHARGE_LIMIT: //8-16岁限制消费
- $_limit = $_identify_conf['underage']['charge_limit'][2];
- $_age = $_limit['min_age'].'-'.$_limit['max_age'];
- $_week_money = $_limit['week_money'];
- $_month_money = $_limit['month_money'];
- $_msg = self::getAge816ChargeLimitMsg($_age, $_week_money, $_month_money);
- $_close_type = IdentifyConst::JS_CLOSE_WEB;
- break;
- case IdentifyConst::UNDERAGE_ALLOW_LOGIN_LIMIT: //未成年用户仅限在周五、周六、周日及法定节假日每日20:00-21:00登录游戏
- $_allow_start_time = $_identify_conf['underage']['allow_start_time'];
- $_allow_start_time_minute = $_identify_conf['underage']['allow_start_time_minute'];
- $_allow_start_time = mktime(
- $_allow_start_time, $_allow_start_time_minute, 0, date('m'), date('d'), date('Y')
- );
- $_allow_start_time = date('H:i', $_allow_start_time);
- $_allow_end_time = $_identify_conf['underage']['allow_end_time'];
- $_allow_end_time_minute = $_identify_conf['underage']['allow_end_time_minute'];
- $_allow_end_time = mktime(
- $_allow_end_time, $_allow_end_time_minute, 0, date('m'), date('d'), date('Y')
- );
- $_allow_end_time = date('H:i', $_allow_end_time);
- $_period = $_allow_start_time.'-'.$_allow_end_time;
- $_msg = self::getPeriodAllowLimitMsg($_period);
- $_close_type = IdentifyConst::JS_CLOSE_APP;
- break;
- default:
- $_msg = '';
- }
- return [
- 'msg' => $_msg,
- 'close_type' => $_close_type,
- ];
- }
- /**
- * 未成年玩家每日在线时长限制
- *
- * @param int $limit_minute 每日在线时长限制(分钟)
- *
- * @return string
- */
- public static function getDayLimitMsg($limit_minute) {
- $_msg = sprintf(
- '根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏未成年用户平日游戏时长限制为%d分钟,您今天已游玩了%d分钟', $limit_minute, $limit_minute
- );
- return $_msg;
- }
- /**
- * 未成年玩家节假日在线时长限制
- *
- * @param int $limit_minute 节假日在线时长限制(分钟)
- *
- * @return string
- */
- public static function getHolidayLimitMsg($limit_minute) {
- $_msg = sprintf(
- '根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏未成年用户节假日游戏时长限制为%d分钟,您今天已游玩了%d分钟', $limit_minute, $limit_minute
- );
- return $_msg;
- }
- /**
- * 未成年玩家每日游玩时间限制
- *
- * @param string $period 限制时间段
- *
- * @return string
- */
- public static function getPeriodLimitMsg($period) {
- $_msg = sprintf('根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,每天的%s,网络游戏未成年用户不允许登录', $period);
- return $_msg;
- }
- /**
- * 未成年玩家每日游玩时间限制
- *
- * @param string $period 限制时间段
- *
- * @return string
- */
- public static function getPeriodAllowLimitMsg($period) {
- $_msg = sprintf('根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏未成年用户仅限在周五、周六、周日及法定节假日每日%s登录游戏,您现在无法登录游戏', $period);
- return $_msg;
- }
- /**
- * 未成年玩家充值限制
- *
- * @param int $age 限制年龄
- *
- * @return string
- */
- public static function getAge8ChargeLimitMsg($age) {
- $_msg = sprintf('根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏用户未满%d岁不能充值', $age);
- return $_msg;
- }
- /**
- * 未成年玩家充值限制
- *
- * @param string $age 限制年龄短
- * @param float $week_money 每周限制金额
- * @param float $month_money 每月限制金额
- *
- * @return string
- */
- public static function getAge816ChargeLimitMsg($age, $week_money, $month_money) {
- $_msg = sprintf(
- '根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏用户在%s岁的,每周累计充值不能超过%.2f元,每月累计充值不能超过%.2f元', $age, $week_money,
- $month_money
- );
- return $_msg;
- }
- }
|