123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * Created by PhpStorm.
- * User: guanxl
- * Date: 2018/4/4
- * Time: 0:08
- */
-
- namespace App\Services;
-
- use App\Traits\Singleton;
- use Illuminate\Support\Facades\Redis;
-
-
- class GameTimeService
- {
- use Singleton;
-
- /**
- * @param $activityId
- * @return bool
- */
- public function isReachStartTime($activityId)
- {
-
- $brainstorming = BrainstormingService::getInstance()->get($activityId);
-
- if ($brainstorming["start_time"] <= time()) {
- return 1;
- } else {
- return 0;
- }
- }
-
- /**
- * @param $activityId
- * @return bool
- */
- public function isReachEndTime($activityId)
- {
- $brainstorming = BrainstormingService::getInstance()->get($activityId);
- $endTime = $brainstorming["end_time"];
- $now = time();
- if ($endTime > 0 && $now > $endTime) {
- return true;
- }
- return false;
- }
-
- /**
- * @param $activityId
- * @return bool
- */
- public function isCanGame($activityId,$userId)
- {
- $brainstorming = BrainstormingService::getInstance()->get($activityId);
- $user = UserService::getInstance()->getUser($userId);
- $startTime = $brainstorming["start_time"];
- $endTime = $brainstorming["end_time"];
- $now = time();
- if ($startTime > 0 && $now < $startTime && $user["is_white_list"]==0) {
- return false;
- }
- if ($endTime > 0 && $now > $endTime) {
- return false;
- }
- return true;
- }
- }
|