$item) { if ($value >= $item['limit']) $ret = $key; } return $ret; } private static function getPeopleValue() { $gameCode = self::$gameCode; $cacheKey = $gameCode . 'peopleContribution'; $cache = Event::getMemcached(); //正式环境下才会使用memcache缓存值 if (Event::app()->isDebug() == false && $cache->contains($cacheKey)) { return $cache->fetch($cacheKey); } $dql = "select sum(u.peopleContribution) as contribution "; $dql .= " from Vendor\Event\Entities\User u where u.gameCode = '$gameCode'"; $entity = self::$entityManager; /** @var EntityManager $entity */ $rs = $entity->createQuery($dql)->getSingleResult(); $ret = (int)($rs['contribution']); $cache->save($cacheKey, $ret, 60); return $ret; } private static function getPersonalValue() { $user = self::$userData; return ($user instanceof User) ? $user->getPersonalContribution() : 0; } public static function getCoordinate() { $user = self::$userData; $ret = []; foreach (self::$config as $type => $bonusInfo) { /** @var User $user */ $logs = ($user instanceof User) ? self::formatLog($user->getCakeGiftLogs(), $type) : []; $value = self::$status['value'][$type]; foreach ($bonusInfo as $key => $item) { $ret[$type][$key] = 0; $limit = $item['limit']; if ($user instanceof User && $value >= $limit) { $ret[$type][$key] = $logs[$limit] ? -1 : 1; } } } krsort($ret['people']); ksort($ret['personal']); return $ret; } private static function formatLog($cakeGiftLogs, $type) { $array = []; /** @var CakeGiftLog $cakeGiftLog */ foreach ($cakeGiftLogs as $cakeGiftLog) { if ($type == $cakeGiftLog->getType()) { $array[$cakeGiftLog->getLevel()] = $cakeGiftLog; } } return $array; } /*获取横向 纵向进度条的百分比*/ public static function getProcessRate($type) { $lengthConfig = [ 'people' => [0, 106, 194, 283, 372,], 'personal' => [0, 119, 183, 242, 302, 361, 423,], ]; $level = self::$status['level'][$type]; $value = self::$status['value'][$type]; $arr = $lengthConfig[$type]; $max = max($arr); $config = self::$config[$type]; if ($level == 0) { $ret = $value / ($config[1]['limit']) * ($arr[1]) / $max; } else if ($level == count($arr) - 1) { $ret = 1; } else { $ret = $arr[$level]; $value_plus = $config[$level + 1]['limit'] - $config[$level]['limit'];//两级的值的差 $length_plus = $arr[$level + 1] - $arr[$level];//两级的长度的差 $ret += (($value - $config[$level]['limit']) / $value_plus * $length_plus); $ret = $ret / $max; } return $ret * 100; } }
Fatal error: Class 'Vendor\Event\Common\Contribution' not found in /data/project/game-anniversary.oasgames.com/v2.14.1/src/Controllers/IndexController.php on line 47