UnderageLimitMsg.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. /**
  3. * UnderageLimitMsg.php UTF-8
  4. * 未成年限制提示信息
  5. *
  6. * @date : 2019/11/29 9:24
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.5
  11. */
  12. namespace huoIdentify\controller;
  13. use huo\controller\common\Base;
  14. use huolib\constant\IdentifyConst;
  15. class UnderageLimitMsg extends Base {
  16. /**
  17. * 获取提示信息
  18. *
  19. * @param int $type 提示类型
  20. *
  21. * @return array
  22. */
  23. public static function getMsg($type) {
  24. $_identify_conf = (new IdentifyConf())->getConf(true);
  25. $_close_type = IdentifyConst::JS_CLOSE_WEB; // 弹出关闭类型 1 关闭app 2 关闭弹窗
  26. switch ($type) {
  27. case IdentifyConst::UNDERAGE_ONLINE_TIME_LIMIT: //未成年玩家每日在线时长限制
  28. $_limit_minute = $_identify_conf['underage']['day_limit_time'];
  29. $_msg = self::getDayLimitMsg($_limit_minute);
  30. $_close_type = IdentifyConst::JS_CLOSE_APP;
  31. break;
  32. case IdentifyConst::UNDERAGE_HOLIDAY_ONLINE_TIME_LIMIT: //未成年玩家节假日在线时长限制
  33. $_limit_minute = $_identify_conf['underage']['holiday_limit_time'];
  34. $_msg = self::getHolidayLimitMsg($_limit_minute);
  35. $_close_type = IdentifyConst::JS_CLOSE_APP;
  36. break;
  37. case IdentifyConst::UNDERAGE_PERIOD_LIMIT: //未成年玩家节假日在线时长限制
  38. $_limit_today_time = $_identify_conf['underage']['limit_today_time'];
  39. $_limit_next_day_time = $_identify_conf['underage']['limit_next_day_time'];
  40. $_period = $_limit_today_time.':00-'.$_limit_next_day_time.':00';
  41. $_msg = self::getPeriodLimitMsg($_period);
  42. $_close_type = IdentifyConst::JS_CLOSE_APP;
  43. break;
  44. case IdentifyConst::UNDERAGE_AGE_8_CHARGE_LIMIT: //8岁以下不允许支付
  45. $_age = $_identify_conf['underage']['charge_limit'][0]['max_age'];
  46. $_msg = self::getAge8ChargeLimitMsg($_age);
  47. $_close_type = IdentifyConst::JS_CLOSE_WEB;
  48. break;
  49. case IdentifyConst::UNDERAGE_AGE_8_16_CHARGE_LIMIT: //8-16岁限制消费
  50. $_limit = $_identify_conf['underage']['charge_limit'][1];
  51. $_age = $_limit['min_age'].'-'.$_limit['max_age'];
  52. $_week_money = $_limit['week_money'];
  53. $_month_money = $_limit['month_money'];
  54. $_msg = self::getAge816ChargeLimitMsg($_age, $_week_money, $_month_money);
  55. $_close_type = IdentifyConst::JS_CLOSE_WEB;
  56. break;
  57. case IdentifyConst::UNDERAGE_AGE_16_18_CHARGE_LIMIT: //8-16岁限制消费
  58. $_limit = $_identify_conf['underage']['charge_limit'][2];
  59. $_age = $_limit['min_age'].'-'.$_limit['max_age'];
  60. $_week_money = $_limit['week_money'];
  61. $_month_money = $_limit['month_money'];
  62. $_msg = self::getAge816ChargeLimitMsg($_age, $_week_money, $_month_money);
  63. $_close_type = IdentifyConst::JS_CLOSE_WEB;
  64. break;
  65. case IdentifyConst::UNDERAGE_ALLOW_LOGIN_LIMIT: //未成年用户仅限在周五、周六、周日及法定节假日每日20:00-21:00登录游戏
  66. $_allow_start_time = $_identify_conf['underage']['allow_start_time'];
  67. $_allow_start_time_minute = $_identify_conf['underage']['allow_start_time_minute'];
  68. $_allow_start_time = mktime(
  69. $_allow_start_time, $_allow_start_time_minute, 0, date('m'), date('d'), date('Y')
  70. );
  71. $_allow_start_time = date('H:i', $_allow_start_time);
  72. $_allow_end_time = $_identify_conf['underage']['allow_end_time'];
  73. $_allow_end_time_minute = $_identify_conf['underage']['allow_end_time_minute'];
  74. $_allow_end_time = mktime(
  75. $_allow_end_time, $_allow_end_time_minute, 0, date('m'), date('d'), date('Y')
  76. );
  77. $_allow_end_time = date('H:i', $_allow_end_time);
  78. $_period = $_allow_start_time.'-'.$_allow_end_time;
  79. $_msg = self::getPeriodAllowLimitMsg($_period);
  80. $_close_type = IdentifyConst::JS_CLOSE_APP;
  81. break;
  82. default:
  83. $_msg = '';
  84. }
  85. return [
  86. 'msg' => $_msg,
  87. 'close_type' => $_close_type,
  88. ];
  89. }
  90. /**
  91. * 未成年玩家每日在线时长限制
  92. *
  93. * @param int $limit_minute 每日在线时长限制(分钟)
  94. *
  95. * @return string
  96. */
  97. public static function getDayLimitMsg($limit_minute) {
  98. $_msg = sprintf(
  99. '根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏未成年用户平日游戏时长限制为%d分钟,您今天已游玩了%d分钟', $limit_minute, $limit_minute
  100. );
  101. return $_msg;
  102. }
  103. /**
  104. * 未成年玩家节假日在线时长限制
  105. *
  106. * @param int $limit_minute 节假日在线时长限制(分钟)
  107. *
  108. * @return string
  109. */
  110. public static function getHolidayLimitMsg($limit_minute) {
  111. $_msg = sprintf(
  112. '根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏未成年用户节假日游戏时长限制为%d分钟,您今天已游玩了%d分钟', $limit_minute, $limit_minute
  113. );
  114. return $_msg;
  115. }
  116. /**
  117. * 未成年玩家每日游玩时间限制
  118. *
  119. * @param string $period 限制时间段
  120. *
  121. * @return string
  122. */
  123. public static function getPeriodLimitMsg($period) {
  124. $_msg = sprintf('根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,每天的%s,网络游戏未成年用户不允许登录', $period);
  125. return $_msg;
  126. }
  127. /**
  128. * 未成年玩家每日游玩时间限制
  129. *
  130. * @param string $period 限制时间段
  131. *
  132. * @return string
  133. */
  134. public static function getPeriodAllowLimitMsg($period) {
  135. $_msg = sprintf('根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏未成年用户仅限在周五、周六、周日及法定节假日每日%s登录游戏,您现在无法登录游戏', $period);
  136. return $_msg;
  137. }
  138. /**
  139. * 未成年玩家充值限制
  140. *
  141. * @param int $age 限制年龄
  142. *
  143. * @return string
  144. */
  145. public static function getAge8ChargeLimitMsg($age) {
  146. $_msg = sprintf('根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏用户未满%d岁不能充值', $age);
  147. return $_msg;
  148. }
  149. /**
  150. * 未成年玩家充值限制
  151. *
  152. * @param string $age 限制年龄短
  153. * @param float $week_money 每周限制金额
  154. * @param float $month_money 每月限制金额
  155. *
  156. * @return string
  157. */
  158. public static function getAge816ChargeLimitMsg($age, $week_money, $month_money) {
  159. $_msg = sprintf(
  160. '根据国家新闻出版署《关于防止未成年人沉迷网络游戏的通知》的相关要求,网络游戏用户在%s岁的,每周累计充值不能超过%.2f元,每月累计充值不能超过%.2f元', $age, $week_money,
  161. $month_money
  162. );
  163. return $_msg;
  164. }
  165. }