<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Util; use ModStart\Core\Dao\ModelUtil; use Module\Vendor\Util\CacheUtil; class MemberGroupUtil { public static function all() { return CacheUtil::rememberForever('MemberGroupList', function () { return ModelUtil::all('member_group', array(), array('*'), array('id', 'asc')); }); } public static function mapIdTitle() { return array_build(self::all(), function ($kEhTf, $y2Ltn) { return array($y2Ltn['id'], $y2Ltn['title']); }); } public static function defaultGroup() { foreach (self::all() as $uOsK7) { if ($uOsK7['isDefault']) { return $uOsK7; } } return null; } public static function defaultGroupId() { $uOsK7 = self::defaultGroup(); return $uOsK7 ? $uOsK7['id'] : 0; } public static function map() { return CacheUtil::rememberForever('MemberGroupMap', function () { return array_build(self::all(), function ($kEhTf, $y2Ltn) { return array($y2Ltn['id'], $y2Ltn); }); }); } public static function get($GlHcc) { goto kSy6d; ACHeJ: return null; goto gg88d; sRrdF: if (empty($GlHcc)) { foreach ($PcqTW as $jIWZA) { if ($jIWZA['isDefault']) { return $jIWZA; } } return null; } goto OsWIC; JPae5: if (null === $PcqTW) { $PcqTW = self::map(); } goto sRrdF; kSy6d: static $PcqTW = null; goto JPae5; OsWIC: if (isset($PcqTW[$GlHcc])) { return $PcqTW[$GlHcc]; } goto ACHeJ; gg88d: } public static function getMemberGroup($g3uu_) { if (empty($g3uu_)) { return null; } return self::get($g3uu_['groupId']); } public static function clearCache() { CacheUtil::forget('MemberGroupList'); CacheUtil::forget('MemberGroupMap'); } }