rabin 2 years ago
commit
0611e2415a
9 changed files with 1742 additions and 0 deletions
  1. 267 0
      database/category.php
  2. 487 0
      database/category_attr.php
  3. 346 0
      database/info.php
  4. 65 0
      database/info_category.php
  5. 63 0
      database/info_extend.php
  6. 261 0
      database/info_sku.php
  7. 10 0
      index.php
  8. 32 0
      lib/Manage.php
  9. 211 0
      src/Category.php

+ 267 - 0
database/category.php

@@ -0,0 +1,267 @@
+<?php
+
+$status = array
+(
+	1 => '启用',
+	2 => '不启用',
+);
+
+return array
+(
+	# 表名
+	'name' => 'category',
+	# 显示给用户看的名称
+	'lang' => '商品分类',
+	# 是否显示在后台菜单
+	'order' => 10,
+
+	'end' => array
+	(
+		'insert' => 'product/lib/manage.updateCategory',
+		'update' => 'product/lib/manage.updateCategory',
+	),
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'asc',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '分类名称',
+			'default' 	=> '',
+			'desc' 		=> '分类名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'category'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '上级分类',
+			'default' 	=> Dever::input('option_category', -1),
+			'desc' 		=> '请选择上级分类',
+			'match' 	=> 'is_string',
+			'update'	=> 'linkage',
+			'linkage' 	=> 'id=' . Dever::input('where_id'),
+			'option'	=> Dever::url('category.get', 'product'),
+			//'list'		=> 'Dever::load("product/api.string", "{category}")',
+		),
+
+		'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '上级分类',
+			'default' 	=> -1,
+			'desc' 		=> '请选择上级分类',
+			'match' 	=> 'is_numeric',
+			'value'		=> Dever::input('option_category_id', -1),
+			'list'		=> '{category_id} > 0 ? Dever::load("product/category-one#name", {category_id}) : "父级分类"',
+		),
+
+		'top_category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '顶级分类',
+			'default' 	=> -1,
+			'desc' 		=> '请选择顶级分类',
+			'match' 	=> 'is_numeric',
+		),
+
+		'level'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类级别-1为顶级分类、2为2级分类,-1为最后一级分类',
+			'default' 	=> 1,
+			'desc' 		=> '分类级别',
+			'match' 	=> 'is_numeric',
+		),
+
+		'icon'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '图标',
+			'default' 	=> '',
+			'desc' 		=> '图标',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key'		=> 1,
+			'tab'		=> 1,
+		),
+
+		'size'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '字体大小-字体px值,为空则使用系统默认字体大小',
+			'default' 	=> '',
+			'desc' 		=> '字体大小',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'tab'		=> 1,
+		),
+
+		'color'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '字体颜色-请填写颜色代码',
+			'default' 	=> '',
+			'desc' 		=> '字体颜色',
+			'match' 	=> 'option',
+			'update'	=> 'color',
+			'tab'		=> 1,
+		),
+
+		'bgcolor'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '背景颜色-请填写颜色代码',
+			'default' 	=> '',
+			'desc' 		=> '背景颜色',
+			'match' 	=> 'option',
+			'update'	=> 'color',
+			'tab'		=> 1,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否启用',
+			'default' 	=> '1',
+			'desc' 		=> '是否启用',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'lang' => 'name',
+		//'tab' => array('基础设置', '前端样式'),
+		# 列表页的类型
+		'list_type' => 'tree',
+		'list_button' => array
+		(
+			'add' => array('新增子分类', '"{category}" == -1 ? "category&option_category={id}" : "category&option_category={category},{id}"'),
+		),
+	),
+
+	'request' => array
+	(
+		# 获取顶级分类
+		'getTop' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'category_id' => -1,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => '*|id',
+		),
+
+		'getChild' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'category_id' => 'yes',
+				'top_category_id' => 'yes',
+				'level' => 'yes',
+				'category_id_in' => array('yes-category_id', 'in'),
+				'id' => array('yes', '!='),
+				'category' => array('yes', 'like'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => '*|category_id|',
+		),
+
+		'getList' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'category_id' => 'yes',
+				'top_category_id' => 'yes',
+				'level' => 'yes',
+				'category_id_in' => array('yes-category_id', 'in'),
+				'id' => array('yes', '!='),
+				'category' => array('yes', 'like'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => '*',
+		),
+
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'category_id' => 'yes',
+				'id' => array('yes', '!='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => 'id as value, name',
+		),
+	)
+);

+ 487 - 0
database/category_attr.php

@@ -0,0 +1,487 @@
+<?php
+
+$col = 'id,name,is_must,is_sell,sell_type,sell_compute,sell_value,`type`,data_type,`match`,`unit`,ename,icon,color,bgcolor,list_reorder,search_reorder,view_reorder,cate_id,state';
+$type = array
+(
+	1 => '数字输入框',
+	2 => '单行输入框',
+	3 => '多行输入框',
+	//4 => '图文编辑器',
+	5 => '单图片上传',
+	6 => '多图片上传',
+	7 => '地区选择器',
+	//8 => '多级分类',
+	9 => '区间输入框',
+
+	10 => '单选框',
+	11 => '多选框',
+	12 => '单项选择框',
+);
+
+$is_must = array
+(
+	1 => '必填项',
+	2 => '选填项',
+);
+
+$is_sell = array
+(
+	1 => '普通属性',
+	2 => '销售属性',
+);
+
+$sell_type = array
+(
+	1 => '组合',
+	2 => '单选',
+	3 => '输入',
+);
+
+$sell_compute = array
+(
+	1 => '相乘',
+	2 => '相加',
+	3 => '相减',
+);
+
+$data_type = array
+(
+	1 => '数字',
+	2 => '字符',
+	3 => '正则匹配',
+);
+
+
+/*
+使用该组件,这么用
+$attr = function()
+{
+	$auth = Dever::load('attr/api.get', false);
+	return $auth;
+};
+
+'attr'		=> array
+(
+	'type' 		=> 'varchar-800',
+	'name' 		=> '属性设置',
+	'default' 	=> '',
+	'desc' 		=> '属性设置',
+	'match' 	=> 'option',
+	'update'	=> 'checkbox',
+	'option'	=> $attr,
+	'update_input' => '',
+	'update_input_default' => '',
+	'update_parent' => 'checkbox',
+),
+
+'attr_input'		=> array
+(
+	'type' 		=> 'text-255',
+	'name' 		=> '属性值设置',
+	'default' 	=> '',
+	'desc' 		=> '属性值设置',
+	'match' 	=> 'option',
+),
+*/
+
+return array
+(
+	# 表名
+	'name' => 'category_attr',
+	# 显示给用户看的名称
+	'lang' => '属性设置',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu'	=> false,
+	'sell_type' => $sell_type,
+	'sell_compute' => $sell_compute,
+	'end' => array
+    (
+        'insert' => 'product/lib/manage.attrUpdate',
+        'update' => 'product/lib/manage.attrUpdate',
+    ),
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'asc',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '名称',
+			'default' 	=> '',
+			'desc' 		=> '名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+			'tab'		=> 0,
+		),
+
+		'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类',
+			'default' 	=> '-1',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			//'list'		=> '{category_id} > 0 ? Dever::load("product/category-one#name", {category_id}) : "未选择"',
+			'tab'		=> 0,
+		),
+
+		'is_must'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否必填',
+			'default' 	=> '1',
+			'desc' 		=> '是否必填',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $is_must,
+			'search'	=> 'select',
+			'list'		=> true,
+			'tab'		=> 0,
+		),
+
+		'is_sell'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否销售属性-销售属性将可以配置价格',
+			'default' 	=> '1',
+			'desc' 		=> '属性类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $is_sell,
+			'search'	=> 'select',
+			'list'		=> true,
+			//'edit'		=> true,
+			'control'	=> 'is_sell',
+		),
+
+		'sell_type'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '销售属性类型-组合类型将会生成不同的SKU组合价格,根据不同的SKU组合生成总价和库存;单选类型将生成单独的属性价格,将影响总价,可单独设置库存;输入类型一般为输入尺寸,需要单独设置影响总价的方式;具体价格都需要在商品中设置',
+			'default' 	=> '1',
+			'desc' 		=> '销售属性类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $sell_type,
+			//'search'	=> 'select',
+			'show'		=> 'is_sell=2',
+			'control'	=> 'sell_type',
+		),
+
+		'sell_compute'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '计算方式-如输入类型设置了宽度和高度,总价需要平米来计算,这里选择相乘即可',
+			'default' 	=> '1',
+			'desc' 		=> '销售属性类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $sell_compute,
+			//'search'	=> 'select',
+			'show'		=> 'sell_type=3',
+		),
+
+		'sell_value' => array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> '价格起始值-同样是平米为例,这里输入10的话,就是大于10平米时开始加价,具体加价多少需要在商品中设置',
+			'default' 	=> '0',
+			'desc' 		=> '价格起始值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'sell_type=3',
+		),
+
+		'type'	  => array
+		(
+			'type' 		=> 'tinyint-11',
+			'name' 		=> '后台录入类型-配置录入类型后可以在后台商品管理中的属性设置进行设置',
+			'default' 	=> '1',
+			'desc' 		=> '后台录入类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+			//'search'	=> 'select',
+			//'list'		=> true,
+			'show'		=> 'is_sell=1',
+			'control'	=> 'type',
+		),
+
+        'data_type'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '数据验证类型-选择类型之后会自动验证数据有效性',
+			'default' 	=> '1',
+			'desc' 		=> '数据验证类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $data_type,
+			'search'	=> 'select',
+			//'list'		=> true,
+			'control' 	=> 'data_type',
+			'show'      => 'type=2',
+		),
+
+		'match'		=> array
+		(
+			'type' 		=> 'varchar-600',
+			'name' 		=> '正则匹配规则-直接输入正则表达式即可',
+			'default' 	=> '',
+			'desc' 		=> '正则匹配规则',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+			'show'		=> array('data_type' => 3),
+		),
+
+		'hr2'		=> array
+		(
+			'name' 		=> '排序规则',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
+		'list_reorder'	  => array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '列表页排序-设置该属性在前台列表页中的排序,数字越大越靠前,如果为负数或者0,则不加入到列表页中。',
+			'default' 	=> '1',
+			'desc' 		=> '是否作为搜索条件',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'show'      => 'type=1,2,7,9,10,11,12',
+			'search'	=> 'order',
+			'order'		=> 'desc',
+			'edit'		=> true,
+			//'list'		=> true,
+		),
+
+		'search_reorder'	  => array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '搜索条件排序-设置前台搜索条件中的排序,数字越大越靠前,如果为负数或者0,则不加入到搜索条件中。',
+			'default' 	=> '1',
+			'desc' 		=> '是否作为搜索条件',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'show'      => 'type=1,2,7,9,10,11,12',
+			'search'	=> 'order',
+			'order'		=> 'desc',
+			'edit'		=> true,
+			//'list'		=> true,
+		),
+
+		'view_reorder'	  => array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '详情页排序-设置该属性在前台详情页中的排序,数字越大越靠前,如果为负数或者0,则不加入到详情页中。',
+			'default' 	=> '1',
+			'desc' 		=> '详情页排序',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'show'      => 'type=1,2,7,9,10,11,12',
+			'search'	=> 'order',
+			'order'		=> 'desc',
+			'edit'		=> true,
+			//'list'		=> true,
+		),
+
+		'hr3'		=> array
+		(
+			'name' 		=> '扩展设置',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
+		'unit'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '单位-填写属性单位,选填项',
+			'default' 	=> '',
+			'desc' 		=> '单位',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+		),
+
+		'ename'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '英文标识-该标识一般为前台样式名称,选填项',
+			'default' 	=> '',
+			'desc' 		=> '英文名称',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'icon'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '图标-属性图标,选填项',
+			'default' 	=> '',
+			'desc' 		=> '图标',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key'		=> 1,
+		),
+
+		'color'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '字体颜色-请填写颜色代码,选填项',
+			'default' 	=> '',
+			'desc' 		=> '字体颜色',
+			'match' 	=> 'option',
+			'update'	=> 'color',
+		),
+
+		'bgcolor'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '背景颜色-请填写颜色代码,选填项',
+			'default' 	=> '',
+			'desc' 		=> '背景颜色',
+			'match' 	=> 'option',
+			'update'	=> 'color',
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'tab' => array('基本配置', '扩展设置', '排序规则'),
+		# 列表
+		'list_button' => array
+		(
+			'list1' => array('属性值设置', '"value&project=attr&search_type=4&search_option_info_id={id}&oper_table=info&oper_project=attr"' , '{type} > 9'),
+			'list2' => array('搜索值设置', '"search&project=attr&search_type=4&search_option_info_id={id}&oper_table=info&oper_project=attr"' , '{type} == 1 || {type} == 9'),
+		),
+	),
+
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				//'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('list_reorder`+`search_reorder`+`view_reorder' => 'desc', 'id' => 'desc'),
+			'col' => $col. '|id',
+		),
+
+		'getAllByIds' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				//'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('list_reorder`+`search_reorder`+`view_reorder' => 'desc', 'id' => 'desc'),
+			'col' => $col. '|id',
+		),
+
+		'getListByIds' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'list_reorder' => array('yes', '>='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('list_reorder' => 'desc', 'id' => 'desc'),
+			'col' => $col. '|id',
+		),
+
+		'getSearchByIds' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'search_reorder' => array('yes', '>='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('search_reorder' => 'desc', 'id' => 'desc'),
+			'col' => $col. '|id',
+		),
+
+		'getViewByIds' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'view_reorder' => array('yes', '>='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('view_reorder' => 'desc', 'id' => 'desc'),
+			'col' => $col. '|id',
+		),
+
+		/*
+		'getSearch' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'search_reorder' => array('yes', '>='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('search_reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
+		*/
+	)
+);

+ 346 - 0
database/info.php

@@ -0,0 +1,346 @@
+<?php
+
+$audit = Dever::config('base')->audit;
+
+$status = Dever::config('base')->status;
+
+$config = array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '商品列表',
+	'order' => 200,
+	'auto' => 10000000,
+	# 需要设置语言包的字段
+	'lang_col' => array('name', 'content'),
+	'set' => array
+	(
+		'status' => $status,
+		'audit' => $audit,
+	),
+
+	'end' => array
+	(
+		//'insert' => 'product/lib/manage.infoUpdate',
+		//'update' => 'product/lib/manage.infoUpdate',
+	),
+
+	# 同步更新另外一个或多个表的数据,将数据同步到关联表中
+	'sync' => array
+	(
+		'product/info_category' => array
+		(
+			# 更新另外一个表的字段 => 本表的字段
+			'where' => array('info_id', 'id'),
+			# 要更新的数据
+			'update' => array('category_id' => 'category'),
+			# 同步更新的类型,delete为先删再插入,update为直接更新
+			'type' => 'delete',
+		)
+	),
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'textarea',
+			'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'category'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '分类',
+			'default' 	=> '',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_string',
+			'search'	=> 'linkage',
+			'update'	=> 'linkage',
+			'option'	=> Dever::url('category.get', 'product'),
+			//'list'		=> 'Dever::load("product/category.string", "{category}")',
+		),
+
+		# 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
+		'top_category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '顶级分类ID-顶级分类,用于分类查询',
+			'default' 	=> '-1',
+			'desc' 		=> '顶级分类ID',
+			'match' 	=> 'is_numeric',
+		),
+
+		'second_category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '二级分类ID-二级分类,用于分类查询',
+			'default' 	=> '-1',
+			'desc' 		=> '二级分类ID',
+			'match' 	=> 'is_numeric',
+		),
+
+		'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '子分类ID-最后一个级别的分类,用于分类查询',
+			'default' 	=> '-1',
+			'desc' 		=> '子分类ID',
+			'match' 	=> 'is_numeric',
+		),
+
+		'pic'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '商品主图-图片尺寸500*500px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,用户上传图片之后会自动进行居中裁剪',
+			'default' 	=> '',
+			'desc' 		=> '多张图片',
+			'match' 	=> 'option',
+			'update'	=> 'images',
+			'key' 		=> '1',
+			'place'		=> '500*500',
+		),
+
+		'audit'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '审核',
+			'default' 	=> '1',
+			'desc' 		=> '审核',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $audit,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '状态',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越大越靠前,相当于置顶',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'content'		=> array
+		(
+			'type' 		=> 'text-800',
+			'name' 		=> '内容介绍',
+			'default' 	=> '',
+			'desc' 		=> '内容介绍',
+			'match' 	=> 'is_string',
+			'update'	=> 'editor',
+			'key'		=> '1',
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '数据状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'udate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '更新时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'category,top_category_id,second_category_id,category_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+		// 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
+		'res' => array
+		(
+			//'css' => 'demo',
+		),
+		//'insert' => false,
+		//'delete' => false,
+		'mul' => true,
+		# 自定义快捷新增和编辑
+        'button' => array
+        (
+        	//'类别管理' => array('list', 'cate&project=demand&search_option_key=cate&search_option_tablename=类别&oper_parent=info&oper_project=demand'),
+        ),
+
+		# 列表里的按钮
+		'list_button' => array
+		(
+			'add' => array('属性设置', '"info_attr
+				&project=goods
+				&search_option_info_id={id}
+				&search_option_category={category}
+				&oper_parent=info&oper_project=goods
+				&oper_save_jump=info
+				&where_id={id}"', '{price_type} == 2'),
+
+			'list' => array('sku设置', '"info_sku
+				&project=goods
+				&search_option_info_id={id}
+				&oper_parent=info&oper_project=goods
+				&oper_save_jump=info&page_type=1"', '{price_type} == 2'),
+			'br1' => array('<br />'),
+			'delete' => '删除',
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		# 后台搜索用到
+		'search' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'name' => array('yes', 'like'),
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'limit' => '0,1000',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+
+		# 列表
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'audit' => 2,
+				'category' => array('yes', 'like'),
+				'top_category_id' => 'yes',
+				'second_category_id' => 'yes',
+				'category_id' => 'yes',
+				//'status' => 1,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'limit' => '0,10',
+			//'page' => array(10, 'list'),
+			'col' => '*',
+		),
+
+		# 分页
+		'getPageAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'shop_id' => 'yes',
+				'brand_id' => 'yes',
+				'name' => array('yes', 'like'),
+				'audit' => 2,
+				'category' => array('yes', 'like'),
+				'top_category_id' => 'yes',
+				'second_category_id' => 'yes',
+				'category_id' => 'yes',
+				//'status' => 1,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		),
+		
+		# 更新售出量
+		'updateSell' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'sell_num' => array('yes', '+='),
+			),
+		),
+
+		'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+            ),
+            'type' => 'one',
+            'col' => 'id,name,category,pic,content',
+        ),
+	),
+);
+
+return $config;

+ 65 - 0
database/info_category.php

@@ -0,0 +1,65 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'info_category',
+	# 显示给用户看的名称
+	'lang' => '商品分类关联表',
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+		
+		'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '商品ID',
+			'default' 	=> '',
+			'desc' 		=> '商品ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类ID',
+			'default' 	=> '',
+			'desc' 		=> '分类ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', DEVER_TIME),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+	),
+);

+ 63 - 0
database/info_extend.php

@@ -0,0 +1,63 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'info_extend',
+	# 显示给用户看的名称
+	'lang' => '商品扩展信息表',
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+		
+		'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '商品ID',
+			'default' 	=> '',
+			'desc' 		=> '商品ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'extend'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '扩展信息',
+			'default' 	=> '',
+			'desc' 		=> '扩展信息',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', DEVER_TIME),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+	),
+);

+ 261 - 0
database/info_sku.php

@@ -0,0 +1,261 @@
+<?php
+
+$col = 'id,info_id,`key`,price,s_price,code';
+
+$config = array
+(
+	# 表名
+	'name' => 'info_sku',
+	# 显示给用户看的名称
+	'lang' => '商品规格设置',
+	'order' => 200,
+	'menu' => false,
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '商品ID',
+			'default' 	=> '',
+			'desc' 		=> '商品ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '规格标识',
+			'default' 	=> '-1',
+			'desc' 		=> '规格标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'attr'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '规格组合规则',
+			'default' 	=> '',
+			'desc' 		=> '规格组合规则',
+			'match' 	=> 'is_string',
+			'update'	=> 'textarea',
+			'list'		=> true,
+		),
+
+		'code'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '商品条码号',
+            'default'   => '',
+            'desc'      => '商品条码号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+		'price'		=> array
+		(
+			'type' 		=> 'decimal-10,2',
+			'name' 		=> '售价',
+			'default' 	=> '',
+			'desc' 		=> '售价',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		's_price'		=> array
+		(
+			'type' 		=> 'decimal-10,2',
+			'name' 		=> '原价',
+			'default' 	=> '',
+			'desc' 		=> '原价',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越大越靠前,相当于置顶',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '数据状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'num' => false,
+        'page_list_table' => 'sku',
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'自定义属性' => array('fast', 1, 'config&where_id=1'),
+        ),
+    ),
+
+    # request 请求接口定义
+	'request' => array
+	(
+		# 后台搜索用到 也可以不加,自动生成
+        'search' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'info_id' => 'yes',
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,10',
+            'col' => 'key as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+
+        # 列表
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => $col,
+        ),
+
+        # 列表
+        'getDataByKeys' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => $col . '|key',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => $col,
+        ),
+
+        'getMinOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('price' => 'asc', 'id' => 'desc'),
+            'col' => $col,
+        ),
+
+        'getMaxOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('price' => 'desc', 'id' => 'desc'),
+            'col' => $col,
+        ),
+
+        # 更新售出量
+        'updateSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'sell_num' => array('yes', '+='),
+            ),
+        ),
+
+        'like' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'code' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*|id',
+        ),
+	),
+);
+
+return $config;

+ 10 - 0
index.php

@@ -0,0 +1,10 @@
+<?php
+
+define('DEVER_APP_NAME', 'product');
+define('DEVER_APP_LANG', '商品管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 98);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
+define('DEVER_GROUP_ORDER', -1);
+define('DEVER_GROUP_NAME', '电商系统');
+include(DEVER_APP_PATH . '../boot.php');

+ 32 - 0
lib/Manage.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace Product\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function updateCategory($id, $name, $data)
+    {
+        $info = Dever::param('category', $data);
+        if ($info && $info != -1) {
+            $update['top_category_id'] = $info[0];
+            $num = count($info)+1;
+            $update['level'] = $num;
+            $parent = Dever::param('category_id', $data);
+            $child = Dever::db('product/category')->one(array('category_id' => $id));
+            if (!$child) {
+                $update['level'] = -1;
+            }
+            Dever::db('product/category')->update(array('where_id' => $parent, 'level' => $num - 1));
+        } else {
+            $update['level'] = 1;
+            $update['top_category_id'] = -1;
+        }
+
+        if (isset($update)) {
+            $update['where_id'] = $id;
+            Dever::db('product/category')->update($update);
+        }
+    }
+}

+ 211 - 0
src/Category.php

@@ -0,0 +1,211 @@
+<?php
+
+namespace Product\Src;
+
+use Dever;
+
+class Category
+{
+    private $default = array
+    (
+        'value' => -1,
+        'name' => '不选择',
+    );
+
+    private $search_default = array
+    (
+        'value' => -1,
+        'name' => '分类',
+    );
+
+    # 测试语言包
+    public function test()
+    {
+        $info = Dever::db('product/category')->select();
+        print_r($info);die;
+    }
+
+	/**
+     * 获取分类数据
+     *
+     * @return mixed
+     */
+    public function get()
+    {
+        # 联动总数
+        $level_total = 100;
+
+        # 当前联动级别
+        $level_num = Dever::input('level_num');
+
+        # 一般为id
+        $level_id = Dever::input('level_id');
+
+        # 传入的参数
+        $level_param = Dever::input('level_param');
+        if ($level_param) {
+            parse_str($level_param, $param);
+            $where['id'] = $param['id'];
+        }
+
+        # 是否是搜索列表页
+        $level_search = Dever::input('level_search');
+        if ($level_search) {
+            $default = $this->search_default;
+            $default['name'] = $level_num . '级' . $default['name'];
+        } else {
+            $default = $this->default;
+        }
+
+        $data = array();
+
+        # 三级联动
+        if ($level_num == 1) {
+            $where['category_id'] = -1;
+        } elseif($level_id > 0) {
+            $where['category_id'] = $level_id;
+        }
+
+        if (isset($where['category_id'])) {
+            $data = Dever::db('product/category')->getAll($where);
+        }
+
+        if ($data || $level_num == 1) {
+            array_unshift($data, $default);
+        }
+
+        if (!$data) {
+            Dever::alert('error');
+        }
+
+        $result['level_total'] = $level_total;
+        $result['list'] = $data;
+        return $result;
+    }
+
+    /**
+     * 根据分类id转成名称
+     *
+     * @return mixed
+     */
+    public function string($cate, $im = ',')
+    {
+        if ($cate) {
+            $cate = explode(',', $cate);
+            $result = array();
+            foreach ($cate as $k => $v) {
+                $result[$k] = $this->getName($v);
+            }
+            $result = implode($im, $result);
+            return $result;
+            $table[] = $result;
+            return Dever::table($table);
+        }
+        return '';
+    }
+
+    /**
+     * 获取顶级分类
+     *
+     * @return mixed
+     */
+    public function getTop($project = false)
+    {
+        $where = array();
+        if ($project > 0) {
+            $where['project_id'] = $project;
+        }
+        $result = Dever::db('product/category')->getTop($where);
+        return $result;
+    }
+
+    /**
+     * 获取所有信息
+     *
+     * @return mixed
+     */
+    public function getAll($project, $cate = false)
+    {
+        $where = array();
+        if ($project > 0) {
+            $where['project_id'] = $project;
+        }
+        if ($cate) {
+            $where['category_id'] = $cate;
+        }
+        $result = Dever::db('product/category')->getList($where);
+        return $result;
+    }
+
+    /**
+     * 获取详细信息
+     *
+     * @return mixed
+     */
+    public function getInfo($cate)
+    {
+        if ($cate) {
+            $cate = explode(',', $cate);
+            $result = array();
+            foreach ($cate as $k => $v) {
+                $result[$k] = $this->getName($v, true);
+            }
+            return $result;
+        }
+        return array();
+    }
+
+
+    private function getName($id, $state = false)
+    {
+        $name = '';
+        if ($id > 0) {
+            $data = Dever::db('product/category')->one($id);
+            if ($state) {
+                return $data;
+            }
+            if ($data) {
+                $name = $data['name'];
+            }
+        }
+        return $name;
+    }
+
+    # 根据上级分类获取下级分类 按照category_id进行索引
+    public function getChild($category_id)
+    {
+        if (is_numeric($category_id)) {
+            $where['category_id'] = $category_id;
+        } else {
+            $where['category_id_in'] = $category_id;
+        }
+        
+        $data = Dever::db('product/category')->getChild($where);
+
+        return $data;
+    }
+
+    # 根据上级分类获取下级分类 
+    public function getList($category_id)
+    {
+        if (is_numeric($category_id)) {
+            $where['category_id'] = $category_id;
+        } else {
+            $where['category_id_in'] = $category_id;
+        }
+        
+        $data = Dever::db('product/category')->getList($where);
+
+        return $data;
+    }
+
+    # 根据顶级分类获取最低级的分类
+    public function getChildByTop($top_category_id, $level = -1)
+    {
+        $where['top_category_id'] = $top_category_id;
+        $where['level'] = $level;
+        $data = Dever::db('product/category')->getList($where);
+
+        return $data;
+    }
+}