<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Shop\Util; use ModStart\Core\Assets\AssetsUtil; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Util\TreeUtil; use Module\Vendor\Util\CacheUtil; class GoodsCategoryUtil { const CACHE_PREFIX = 'shopGoodsCategory:'; public static function clearCache() { goto gBBfa; LxSAn: CacheUtil::forget(self::CACHE_PREFIX . 'all'); goto cz1CC; gBBfa: CacheUtil::forget(self::CACHE_PREFIX . 'tree'); goto JqB_Y; JqB_Y: CacheUtil::forget(self::CACHE_PREFIX . 'treeHome'); goto LxSAn; cz1CC: } public static function treeHome() { return CacheUtil::rememberForever(self::CACHE_PREFIX . 'treeHome', function () { $MCyeh = self::all(); $MCyeh = array_filter($MCyeh, function ($lLaeU) { return $lLaeU['visibleHome']; }); return TreeUtil::nodesToTree($MCyeh); }); } public static function tree() { return CacheUtil::rememberForever(self::CACHE_PREFIX . 'tree', function () { $MCyeh = self::all(); return TreeUtil::nodesToTree($MCyeh); }); } public static function all() { return CacheUtil::rememberForever(self::CACHE_PREFIX . 'all', function () { $MCyeh = ModelUtil::all('goods_category', array(), array('id', 'pid', 'title', 'cover', 'desc', 'sort', 'visibleHome'), array('sort', 'asc')); AssetsUtil::recordsFixFullOrDefault($MCyeh, 'cover'); return $MCyeh; }); } public static function listWithIndent() { $g8_Ju = self::tree(); return TreeUtil::treeToListWithIndent($g8_Ju); } public static function get($gZ39D) { goto x1Zmr; x1Zmr: $g8_Ju = self::tree(); goto nmTHW; JfGY1: return $n9SJ7; goto ztf2l; FISgB: foreach ($g8_Ju as $YaV4m) { goto Jduoe; Jduoe: if ($YaV4m['id'] == $gZ39D) { $n9SJ7 = $YaV4m; break; } goto DTg1t; DTg1t: if (!empty($YaV4m['_child'])) { foreach ($YaV4m['_child'] as $qjga6) { if ($qjga6['id'] == $gZ39D) { $n9SJ7 = $qjga6; break; } } } goto MPQM3; MPQM3: if ($n9SJ7) { break; } goto agd5m; agd5m: } goto JfGY1; nmTHW: $n9SJ7 = null; goto FISgB; ztf2l: } public static function listCategoryChildIds($I0Hpe) { goto gg2Cf; Z6REA: $gRB_N = TreeUtil::nodesChildrenIds($VM7cz, $I0Hpe); goto MuHm2; gg2Cf: $VM7cz = self::all(); goto Z6REA; MuHm2: return array_merge($gRB_N, array($I0Hpe)); goto uSuax; uSuax: } }