mirror of
				https://gitee.com/zoujingli/ThinkAdmin.git
				synced 2025-10-27 02:12:08 +08:00 
			
		
		
		
	数据商品修改为无限级
This commit is contained in:
		
							parent
							
								
									bca386201c
								
							
						
					
					
						commit
						1baab32868
					
				| @ -2,7 +2,6 @@ | |||||||
| 
 | 
 | ||||||
| namespace app\data\controller\shop; | namespace app\data\controller\shop; | ||||||
| 
 | 
 | ||||||
| use app\data\service\GoodsService; |  | ||||||
| use think\admin\Controller; | use think\admin\Controller; | ||||||
| use think\admin\extend\DataExtend; | use think\admin\extend\DataExtend; | ||||||
| 
 | 
 | ||||||
| @ -19,20 +18,6 @@ class Cate extends Controller | |||||||
|      */ |      */ | ||||||
|     private $table = 'ShopGoodsCate'; |     private $table = 'ShopGoodsCate'; | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * 最大分类等级 |  | ||||||
|      * @var integer |  | ||||||
|      */ |  | ||||||
|     protected $cateLevel; |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 控制器初始化 |  | ||||||
|      */ |  | ||||||
|     protected function initialize() |  | ||||||
|     { |  | ||||||
|         $this->cateLevel = GoodsService::instance()->getCateMax(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |     /** | ||||||
|      * 商品分类管理 |      * 商品分类管理 | ||||||
|      * @auth true |      * @auth true | ||||||
| @ -43,7 +28,7 @@ class Cate extends Controller | |||||||
|      */ |      */ | ||||||
|     public function index() |     public function index() | ||||||
|     { |     { | ||||||
|         $this->title = "商品分类管理(最大{$this->cateLevel}级)"; |         $this->title = "商品分类管理"; | ||||||
|         $query = $this->_query($this->table)->like('name')->dateBetween('create_at'); |         $query = $this->_query($this->table)->like('name')->dateBetween('create_at'); | ||||||
|         $query->equal('status')->where(['deleted' => 0])->order('sort desc,id desc')->page(false); |         $query->equal('status')->where(['deleted' => 0])->order('sort desc,id desc')->page(false); | ||||||
|     } |     } | ||||||
| @ -97,8 +82,8 @@ class Cate extends Controller | |||||||
|             $data['pid'] = intval($data['pid'] ?? input('pid', '0')); |             $data['pid'] = intval($data['pid'] ?? input('pid', '0')); | ||||||
|             $cates = $this->app->db->name($this->table)->where(['deleted' => 0])->order('sort desc,id desc')->select()->toArray(); |             $cates = $this->app->db->name($this->table)->where(['deleted' => 0])->order('sort desc,id desc')->select()->toArray(); | ||||||
|             $this->cates = DataExtend::arr2table(array_merge($cates, [['id' => '0', 'pid' => '-1', 'name' => '顶部分类']])); |             $this->cates = DataExtend::arr2table(array_merge($cates, [['id' => '0', 'pid' => '-1', 'name' => '顶部分类']])); | ||||||
|             if (isset($data['id'])) foreach ($this->cates as $key => $cate) if ($cate['id'] === $data['id']) $data = $cate; |             if (isset($data['id'])) foreach ($this->cates as $cate) if ($cate['id'] === $data['id']) $data = $cate; | ||||||
|             foreach ($this->cates as $key => $cate) if ($cate['spt'] >= $this->cateLevel || (isset($data['spt']) && $data['spt'] <= $cate['spt'])) { |             foreach ($this->cates as $key => $cate) if ((isset($data['spt']) && $data['spt'] <= $cate['spt'])) { | ||||||
|                 unset($this->cates[$key]); |                 unset($this->cates[$key]); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -27,14 +27,6 @@ class Goods extends Controller | |||||||
|      */ |      */ | ||||||
|     protected $cateLevel; |     protected $cateLevel; | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * 控制器初始化 |  | ||||||
|      */ |  | ||||||
|     protected function initialize() |  | ||||||
|     { |  | ||||||
|         $this->cateLevel = GoodsService::instance()->getCateMax(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |     /** | ||||||
|      * 商品数据管理 |      * 商品数据管理 | ||||||
|      * @auth true |      * @auth true | ||||||
|  | |||||||
| @ -59,22 +59,14 @@ class GoodsService extends Service | |||||||
|             } |             } | ||||||
|             $cates[$id]['ids'] = array_reverse($cates[$id]['ids']); |             $cates[$id]['ids'] = array_reverse($cates[$id]['ids']); | ||||||
|             $cates[$id]['names'] = array_reverse($cates[$id]['names']); |             $cates[$id]['names'] = array_reverse($cates[$id]['names']); | ||||||
|             if ($simple && count($cates[$id]['names']) !== $this->getCateMax()) { |             if (isset($pky) && $simple && in_array($cates[$pky]['name'], $cates[$id]['names'])) { | ||||||
|                 unset($cates[$key]); |                 unset($cates[$pky]); | ||||||
|             } |             } | ||||||
|  |             $pky = $key; | ||||||
|         } |         } | ||||||
|         return $cates; |         return $cates; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * 最大分类等级 |  | ||||||
|      * @return integer |  | ||||||
|      */ |  | ||||||
|     public function getCateMax(): int |  | ||||||
|     { |  | ||||||
|         return 3; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |     /** | ||||||
|      * 更新商品库存数据 |      * 更新商品库存数据 | ||||||
|      * @param string $code |      * @param string $code | ||||||
|  | |||||||
| @ -40,13 +40,9 @@ | |||||||
|             <td class='text-center nowrap'>{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{else}<span class="color-green">已激活</span>{/eq}</td> |             <td class='text-center nowrap'>{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{else}<span class="color-green">已激活</span>{/eq}</td> | ||||||
|             <td class='text-center nowrap notselect'> |             <td class='text-center nowrap notselect'> | ||||||
| 
 | 
 | ||||||
|                 {if auth("add")} |                 <!--{if auth("add")}--> | ||||||
|                 <!--{if $vo.spt < $cateLevel-1}--> |  | ||||||
|                 <a class="layui-btn layui-btn-xs layui-btn-primary" data-modal='{:url("add")}?pid={$vo.id}' data-title="添加子分类">添 加</a> |                 <a class="layui-btn layui-btn-xs layui-btn-primary" data-modal='{:url("add")}?pid={$vo.id}' data-title="添加子分类">添 加</a> | ||||||
|                 <!--{else}--> |  | ||||||
|                 <a class="layui-btn layui-btn-xs layui-btn-disabled">添 加</a> |  | ||||||
|                 <!--{/if}--> |                 <!--{/if}--> | ||||||
|                 {/if} |  | ||||||
| 
 | 
 | ||||||
|                 <!--{if auth("edit")}--> |                 <!--{if auth("edit")}--> | ||||||
|                 <a class="layui-btn layui-btn-xs" data-dbclick data-modal='{:url("edit")}?id={$vo.id}' data-title="编辑分类">编 辑</a> |                 <a class="layui-btn layui-btn-xs" data-dbclick data-modal='{:url("edit")}?id={$vo.id}' data-title="编辑分类">编 辑</a> | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								vendor/autoload.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/autoload.php
									
									
									
									
										vendored
									
									
								
							| @ -4,4 +4,4 @@ | |||||||
| 
 | 
 | ||||||
| require_once __DIR__ . '/composer/autoload_real.php'; | require_once __DIR__ . '/composer/autoload_real.php'; | ||||||
| 
 | 
 | ||||||
| return ComposerAutoloaderInit0ec6378467f464339c264d61cf644c03::getLoader(); | return ComposerAutoloaderInitb2f66138aea76ab30d756f683b9213f0::getLoader(); | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								vendor/composer/autoload_real.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								vendor/composer/autoload_real.php
									
									
									
									
										vendored
									
									
								
							| @ -2,7 +2,7 @@ | |||||||
| 
 | 
 | ||||||
| // autoload_real.php @generated by Composer
 | // autoload_real.php @generated by Composer
 | ||||||
| 
 | 
 | ||||||
| class ComposerAutoloaderInit0ec6378467f464339c264d61cf644c03 | class ComposerAutoloaderInitb2f66138aea76ab30d756f683b9213f0 | ||||||
| { | { | ||||||
|     private static $loader; |     private static $loader; | ||||||
| 
 | 
 | ||||||
| @ -22,15 +22,15 @@ class ComposerAutoloaderInit0ec6378467f464339c264d61cf644c03 | |||||||
|             return self::$loader; |             return self::$loader; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         spl_autoload_register(array('ComposerAutoloaderInit0ec6378467f464339c264d61cf644c03', 'loadClassLoader'), true, true); |         spl_autoload_register(array('ComposerAutoloaderInitb2f66138aea76ab30d756f683b9213f0', 'loadClassLoader'), true, true); | ||||||
|         self::$loader = $loader = new \Composer\Autoload\ClassLoader(); |         self::$loader = $loader = new \Composer\Autoload\ClassLoader(); | ||||||
|         spl_autoload_unregister(array('ComposerAutoloaderInit0ec6378467f464339c264d61cf644c03', 'loadClassLoader')); |         spl_autoload_unregister(array('ComposerAutoloaderInitb2f66138aea76ab30d756f683b9213f0', 'loadClassLoader')); | ||||||
| 
 | 
 | ||||||
|         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); | ||||||
|         if ($useStaticLoader) { |         if ($useStaticLoader) { | ||||||
|             require_once __DIR__ . '/autoload_static.php'; |             require_once __DIR__ . '/autoload_static.php'; | ||||||
| 
 | 
 | ||||||
|             call_user_func(\Composer\Autoload\ComposerStaticInit0ec6378467f464339c264d61cf644c03::getInitializer($loader)); |             call_user_func(\Composer\Autoload\ComposerStaticInitb2f66138aea76ab30d756f683b9213f0::getInitializer($loader)); | ||||||
|         } else { |         } else { | ||||||
|             $map = require __DIR__ . '/autoload_namespaces.php'; |             $map = require __DIR__ . '/autoload_namespaces.php'; | ||||||
|             foreach ($map as $namespace => $path) { |             foreach ($map as $namespace => $path) { | ||||||
| @ -51,19 +51,19 @@ class ComposerAutoloaderInit0ec6378467f464339c264d61cf644c03 | |||||||
|         $loader->register(true); |         $loader->register(true); | ||||||
| 
 | 
 | ||||||
|         if ($useStaticLoader) { |         if ($useStaticLoader) { | ||||||
|             $includeFiles = Composer\Autoload\ComposerStaticInit0ec6378467f464339c264d61cf644c03::$files; |             $includeFiles = Composer\Autoload\ComposerStaticInitb2f66138aea76ab30d756f683b9213f0::$files; | ||||||
|         } else { |         } else { | ||||||
|             $includeFiles = require __DIR__ . '/autoload_files.php'; |             $includeFiles = require __DIR__ . '/autoload_files.php'; | ||||||
|         } |         } | ||||||
|         foreach ($includeFiles as $fileIdentifier => $file) { |         foreach ($includeFiles as $fileIdentifier => $file) { | ||||||
|             composerRequire0ec6378467f464339c264d61cf644c03($fileIdentifier, $file); |             composerRequireb2f66138aea76ab30d756f683b9213f0($fileIdentifier, $file); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return $loader; |         return $loader; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function composerRequire0ec6378467f464339c264d61cf644c03($fileIdentifier, $file) | function composerRequireb2f66138aea76ab30d756f683b9213f0($fileIdentifier, $file) | ||||||
| { | { | ||||||
|     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { | ||||||
|         require $file; |         require $file; | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								vendor/composer/autoload_static.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/composer/autoload_static.php
									
									
									
									
										vendored
									
									
								
							| @ -4,7 +4,7 @@ | |||||||
| 
 | 
 | ||||||
| namespace Composer\Autoload; | namespace Composer\Autoload; | ||||||
| 
 | 
 | ||||||
| class ComposerStaticInit0ec6378467f464339c264d61cf644c03 | class ComposerStaticInitb2f66138aea76ab30d756f683b9213f0 | ||||||
| { | { | ||||||
|     public static $files = array ( |     public static $files = array ( | ||||||
|         '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', |         '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', | ||||||
| @ -687,10 +687,10 @@ class ComposerStaticInit0ec6378467f464339c264d61cf644c03 | |||||||
|     public static function getInitializer(ClassLoader $loader) |     public static function getInitializer(ClassLoader $loader) | ||||||
|     { |     { | ||||||
|         return \Closure::bind(function () use ($loader) { |         return \Closure::bind(function () use ($loader) { | ||||||
|             $loader->prefixLengthsPsr4 = ComposerStaticInit0ec6378467f464339c264d61cf644c03::$prefixLengthsPsr4; |             $loader->prefixLengthsPsr4 = ComposerStaticInitb2f66138aea76ab30d756f683b9213f0::$prefixLengthsPsr4; | ||||||
|             $loader->prefixDirsPsr4 = ComposerStaticInit0ec6378467f464339c264d61cf644c03::$prefixDirsPsr4; |             $loader->prefixDirsPsr4 = ComposerStaticInitb2f66138aea76ab30d756f683b9213f0::$prefixDirsPsr4; | ||||||
|             $loader->fallbackDirsPsr0 = ComposerStaticInit0ec6378467f464339c264d61cf644c03::$fallbackDirsPsr0; |             $loader->fallbackDirsPsr0 = ComposerStaticInitb2f66138aea76ab30d756f683b9213f0::$fallbackDirsPsr0; | ||||||
|             $loader->classMap = ComposerStaticInit0ec6378467f464339c264d61cf644c03::$classMap; |             $loader->classMap = ComposerStaticInitb2f66138aea76ab30d756f683b9213f0::$classMap; | ||||||
| 
 | 
 | ||||||
|         }, null, ClassLoader::class); |         }, null, ClassLoader::class); | ||||||
|     } |     } | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								vendor/services.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/services.php
									
									
									
									
										vendored
									
									
								
							| @ -1,5 +1,5 @@ | |||||||
| <?php  | <?php  | ||||||
| // This file is automatically generated at:2021-05-19 19:06:53
 | // This file is automatically generated at:2021-05-20 13:55:29
 | ||||||
| declare (strict_types = 1); | declare (strict_types = 1); | ||||||
| return array ( | return array ( | ||||||
|   0 => 'think\\admin\\Library', |   0 => 'think\\admin\\Library', | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user