<?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 ($D5qRP, $qGgGl) { return array($qGgGl['id'], $qGgGl['title']); }); } public static function defaultGroup() { foreach (self::all() as $VDHUR) { if ($VDHUR['isDefault']) { return $VDHUR; } } return null; } public static function defaultGroupId() { $VDHUR = self::defaultGroup(); return $VDHUR ? $VDHUR['id'] : 0; } public static function map() { return CacheUtil::rememberForever('MemberGroupMap', function () { return array_build(self::all(), function ($D5qRP, $qGgGl) { return array($qGgGl['id'], $qGgGl); }); }); } public static function get($z6C2t) { goto r9Tbx; r9Tbx: static $our4j = null; goto OZocK; nXRdN: return null; goto dX3Lq; OZocK: if (null === $our4j) { $our4j = self::map(); } goto pBmz3; pBmz3: if (empty($z6C2t)) { foreach ($our4j as $FSL7c) { if ($FSL7c['isDefault']) { return $FSL7c; } } return null; } goto oBDmA; oBDmA: if (isset($our4j[$z6C2t])) { return $our4j[$z6C2t]; } goto nXRdN; dX3Lq: } public static function getMemberGroup($KAIwS) { if (empty($KAIwS)) { return null; } return self::get($KAIwS['groupId']); } public static function clearCache() { CacheUtil::forget('MemberGroupList'); CacheUtil::forget('MemberGroupMap'); } }