<?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 ($KAKiA, $Iim2u) { return array($Iim2u['id'], $Iim2u['title']); }); } public static function defaultGroup() { foreach (self::all() as $qMuVL) { if ($qMuVL['isDefault']) { return $qMuVL; } } return null; } public static function defaultGroupId() { $qMuVL = self::defaultGroup(); return $qMuVL ? $qMuVL['id'] : 0; } public static function map() { return CacheUtil::rememberForever('MemberGroupMap', function () { return array_build(self::all(), function ($KAKiA, $Iim2u) { return array($Iim2u['id'], $Iim2u); }); }); } public static function get($EH9U1) { goto mv2Rv; lIcS8: if (isset($oFNWf[$EH9U1])) { return $oFNWf[$EH9U1]; } goto fsava; mv2Rv: static $oFNWf = null; goto jG1x0; MPY0j: if (empty($EH9U1)) { foreach ($oFNWf as $YaV4m) { if ($YaV4m['isDefault']) { return $YaV4m; } } return null; } goto lIcS8; fsava: return null; goto EQbFe; jG1x0: if (null === $oFNWf) { $oFNWf = self::map(); } goto MPY0j; EQbFe: } public static function getMemberGroup($QqUVI) { if (empty($QqUVI)) { return null; } return self::get($QqUVI['groupId']); } public static function clearCache() { CacheUtil::forget('MemberGroupList'); CacheUtil::forget('MemberGroupMap'); } }