rabin 2 years ago
parent
commit
82d34780c6
11 changed files with 388 additions and 98 deletions
  1. 2 2
      database/category.php
  2. 207 23
      database/info.php
  3. 26 1
      database/info_sku.php
  4. 15 0
      database/info_spec_value.php
  5. 2 24
      lib/Attr.php
  6. 11 11
      lib/Category.php
  7. 34 0
      lib/Info.php
  8. 25 0
      lib/Manage.php
  9. 64 0
      lib/Sku.php
  10. 2 2
      lib/Unit.php
  11. 0 35
      src/Sku.php

+ 2 - 2
database/category.php

@@ -56,7 +56,7 @@ return array
 			'match' 	=> 'is_string',
 			'match' 	=> 'is_string',
 			'update'	=> 'linkage',
 			'update'	=> 'linkage',
 			'linkage' 	=> 'id=' . Dever::input('where_id'),
 			'linkage' 	=> 'id=' . Dever::input('where_id'),
-			'option'	=> Dever::url('category.get', 'product'),
+			'option'	=> Dever::url('lib/category.get', 'product'),
 			//'list'		=> 'Dever::load("product/api.string", "{parent}")',
 			//'list'		=> 'Dever::load("product/api.string", "{parent}")',
 		),
 		),
 
 
@@ -70,7 +70,7 @@ return array
 			'value'		=> Dever::input('option_parent_id', -1),
 			'value'		=> Dever::input('option_parent_id', -1),
 			//'list'		=> '{parent_id} > 0 ? Dever::load("product/category-one#name", {parent_id}) : "父级分类"',
 			//'list'		=> '{parent_id} > 0 ? Dever::load("product/category-one#name", {parent_id}) : "父级分类"',
 			'list_name'	=> '属性',
 			'list_name'	=> '属性',
-			'list'		=> 'Dever::load("product/attr.getInfoByCate", {id})',
+			'list'		=> 'Dever::load("product/lib/attr.getInfoByCate", {id})',
 		),
 		),
 
 
 		'top_parent_id'		=> array
 		'top_parent_id'		=> array

+ 207 - 23
database/info.php

@@ -1,8 +1,10 @@
 <?php
 <?php
 
 
-$audit = Dever::config('base')->audit;
-
-$status = Dever::config('base')->status;
+$status = array
+(
+	1 => '上架',
+	2 => '下架',
+);
 
 
 $id = Dever::input('where_id');
 $id = Dever::input('where_id');
 
 
@@ -17,6 +19,55 @@ $unit = function()
 	return $array;
 	return $array;
 };
 };
 
 
+$type = array
+(
+	1 => '实物商品',
+	2 => '虚拟商品',//虚拟商品可以通过分类设置
+	//3 => '功能商品',//对应道具市场
+	11 => '套餐商品',
+	12 => '组合商品',
+);
+
+$pay_money = array
+(
+	1 => '法定货币',
+	2 => '积分',
+);
+
+$money = function()
+{
+	$array = array();
+	$data = Dever::load('score/money-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$score = function()
+{
+	$array = array();
+	$data = Dever::load('score/config-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$sell_type = array
+(
+    1 => '可售卖',
+    2 => '不可售卖',
+);
+
+$buy_type = array
+(
+    1 => '可采购',
+    2 => '不可采购',
+);
+
 $config = array
 $config = array
 (
 (
 	# 表名
 	# 表名
@@ -28,7 +79,6 @@ $config = array
 	'set' => array
 	'set' => array
 	(
 	(
 		'status' => $status,
 		'status' => $status,
-		'audit' => $audit,
 	),
 	),
 
 
 	'start' => array
 	'start' => array
@@ -63,7 +113,7 @@ $config = array
 		'id' 		=> array
 		'id' 		=> array
 		(
 		(
 			'type' 		=> 'int-11',
 			'type' 		=> 'int-11',
-			'name' 		=> 'ID',
+			'name' 		=> '商品ID',
 			'default' 	=> '',
 			'default' 	=> '',
 			'desc' 		=> '',
 			'desc' 		=> '',
 			'match' 	=> 'is_numeric',
 			'match' 	=> 'is_numeric',
@@ -94,7 +144,124 @@ $config = array
 			'lang'		=> '请选择',
 			'lang'		=> '请选择',
 			'update'	=> 'select',
 			'update'	=> 'select',
 			'option'	=> $unit,
 			'option'	=> $unit,
-			'option_add' => array('[添加新单位]', 'product/unit.add'),
+			'option_add' => array('[添加新单位]', 'product/lib/unit.add'),
+			'tab'		=> 1,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '商品类型-套餐商品和组合商品都是由多个商品组成,区别是组合商品的库存由组成的商品的最少库存决定,套餐商品可以单独设置库存',
+			'default' 	=> '1',
+			'desc' 		=> '商品类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+			'tab'		=> 1,
+			'control'	=> 'type',
+		),
+
+		'goods'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '商品配置-套餐和组合商品可以选择多个套餐或者组合内的商品',
+            'default'   => '',
+            'desc'      => '商品配置',
+            'match'     => 'is_string',
+            'show'      => 'type=11,12',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'goods_id',
+                    'name'      => '选择商品',
+                    'default'   => '',
+                    'desc'      => '选择商品',
+                    'match'     => 'option',
+                    'update'    => 'select',
+                    'update_search' => 'product/lib/manage.searchProduct?{id}',
+                ),
+
+                array
+                (
+                    'col'       => 'num',
+                    'name'      => '数量',
+                    'default'   => '1',
+                    'desc'      => '数量',
+                    'match'     => 'is_string',
+                    'update'    => 'text',
+                ),
+            ),
+            'tab'		=> 1,
+        ),
+
+		'sell_type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '售卖类型',
+            'default'   => '1',
+            'desc'      => '售卖类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $sell_type,
+            'control'   => 'sell_type',
+            'tab'		=> 1,
+        ),
+
+        'buy_type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '采购类型',
+            'default'   => '1',
+            'desc'      => '采购类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $buy_type,
+            'control'   => 'buy_type',
+            'tab'		=> 1,
+        ),
+
+		'pay_money'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '支付货币-默认用该货币购买商品',
+			'default' 	=> '1',
+			'desc' 		=> '支付货币',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $pay_money,
+			'search'	=> 'select',
+			//'list'		=> true,
+			'tab'		=> 1,
+			'control'	=> 'pay_money',
+		),
+
+		'money_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '法定货币',
+			'default' 	=> '',
+			'desc' 		=> '法定货币',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $money,
+			'tab'		=> 1,
+			'show'		=> 'pay_money=1',
+		),
+
+		'score_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '积分',
+			'default' 	=> '',
+			'desc' 		=> '积分',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $score,
+			'tab'		=> 1,
+			'show'		=> 'pay_money=2',
 		),
 		),
 
 
 		'category'		=> array
 		'category'		=> array
@@ -107,12 +274,12 @@ $config = array
 			'search'	=> 'linkage',
 			'search'	=> 'linkage',
 			//'update'	=> $id ? false : 'linkage',
 			//'update'	=> $id ? false : 'linkage',
 			'update'	=> 'linkage',
 			'update'	=> 'linkage',
-			'option'	=> Dever::url('category.get', 'product'),
+			'option'	=> Dever::url('lib/category.get?type=1', 'product'),
 			//'update'	=> 'radio',
 			//'update'	=> 'radio',
 			//'option'	=> Dever::db('product/category')->select(),
 			//'option'	=> Dever::db('product/category')->select(),
-			'list'		=> 'Dever::load("product/category.string", "{category}")',
+			'list'		=> 'Dever::load("product/lib/category.string", "{category}")',
 			'load'		=> 'product-info_attr',
 			'load'		=> 'product-info_attr',
-			'tab'		=> 1,
+			'tab'		=> 2,
 		),
 		),
 
 
 		'product-info_attr'=> array
 		'product-info_attr'=> array
@@ -125,19 +292,19 @@ $config = array
 			'sync'		=> array('id', 'info_id'),
 			'sync'		=> array('id', 'info_id'),
 			# 根据category字段的值,获取product/attr.search接口的内容
 			# 根据category字段的值,获取product/attr.search接口的内容
 			'update'	=> 'load',
 			'update'	=> 'load',
-			'update_load' => array('product/attr.getManageByCate', 'category'),
-			'tab'		=> 1,
+			'update_load' => array('product/lib/attr.getManageByCate', 'category'),
+			'tab'		=> 2,
 		),
 		),
 
 
 		'product-info_spec'=> array
 		'product-info_spec'=> array
 		(
 		(
-			'name' 		=> '规格设置',
+			'name' 		=> '规格设置-成本价为平台进货成本价格,采购价为销售商采购商品价格,销售价为用户购买价格,划线价为用户购买价的划线价格',
 			'default' 	=> '',
 			'default' 	=> '',
 			'desc' 		=> '规格设置',
 			'desc' 		=> '规格设置',
 			'match' 	=> 'option',
 			'match' 	=> 'option',
 			'sync'		=> array('id', 'info_id'),
 			'sync'		=> array('id', 'info_id'),
 			'update'	=> 'sku',
 			'update'	=> 'sku',
-			'tab'		=> 2,
+			'tab'		=> 3,
 		),
 		),
 
 
 		'spec_type'		=> array
 		'spec_type'		=> array
@@ -191,6 +358,21 @@ $config = array
 			'place'		=> '500*500',
 			'place'		=> '500*500',
 		),
 		),
 
 
+		'video'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '商品视频-视频格式mp4,上传大小不能超过4G',
+            'default'   => '',
+            'desc'      => '商品视频',
+            'match'     => 'option',
+            'update'    => 'video',
+            'key'       => '3',
+            'place'     => '150',
+            'upload'    => 'yun',
+            'large'     => true,
+            //'cover'     => 'pic',//封面图字段名
+        ),
+
 		'status'		=> array
 		'status'		=> array
 		(
 		(
 			'type' 		=> 'tinyint-1',
 			'type' 		=> 'tinyint-1',
@@ -245,6 +427,7 @@ $config = array
 			'name' 		=> '更新时间',
 			'name' 		=> '更新时间',
 			'match' 	=> array('is_numeric', time()),
 			'match' 	=> array('is_numeric', time()),
 			'desc' 		=> '',
 			'desc' 		=> '',
+			'search'	=> 'date',
 		),
 		),
 
 
 		'cdate'		=> array
 		'cdate'		=> array
@@ -286,20 +469,21 @@ $config = array
 			(
 			(
 				'pic' => array('name' => '图片', 'verify' => 'string', 'type' => 'image'),
 				'pic' => array('name' => '图片', 'verify' => 'string', 'type' => 'image'),
 				'code' => array('name' => '商品编码', 'verify' => 'string', 'type' => 'input'),
 				'code' => array('name' => '商品编码', 'verify' => 'string', 'type' => 'input'),
-				'price' => array('name' => '销售价(元)', 'verify' => 'number', 'type' => 'input'),
-				'buy_price' => array('name' => '采购价(元)', 'verify' => 'number', 'type' => 'input'),
-				'cost_price' => array('name' => '成本价(元)', 'verify' => 'number', 'type' => 'input'),
+				'cost_price' => array('name' => '成本价', 'verify' => 'number', 'type' => 'input'),
+				'buy_price' => array('name' => '采购价', 'verify' => 'number', 'type' => 'input'),
+				'price' => array('name' => '销售价', 'verify' => 'number', 'type' => 'input'),
+				'un_price' => array('name' => '划线价', 'verify' => 'number', 'type' => 'input'),
 			),
 			),
 			# 接口
 			# 接口
 			'api' => array
 			'api' => array
 			(
 			(
-				'spec' => 'product/sku.spec',
-				'sku' => 'product/sku.sku',
+				'spec' => 'product/lib/sku.spec',
+				'sku' => 'product/lib/sku.sku',
 				# 上传接口
 				# 上传接口
 				'upload' => 'upload/save.start?key=1',
 				'upload' => 'upload/save.start?key=1',
 			),
 			),
 		),
 		),
-		'tab' => array('基本设置', '属性设置', '规格设置'),
+		'tab' => array('内容设置', '基础设置', '属性设置', '规格设置'),
 		// 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
 		// 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
 		'res' => array
 		'res' => array
 		(
 		(
@@ -337,7 +521,7 @@ $config = array
 	# request 请求接口定义
 	# request 请求接口定义
 	'request' => array
 	'request' => array
 	(
 	(
-		# 后台搜索用到
+		# 后台搜索用到,也可以不加,自动生成
 		'search' => array
 		'search' => array
 		(
 		(
 			# 匹配的正则或函数 选填项
 			# 匹配的正则或函数 选填项
@@ -345,13 +529,13 @@ $config = array
 			(
 			(
 				'ids' => array('yes-id', 'in'),
 				'ids' => array('yes-id', 'in'),
 				'name' => array('yes', 'like'),
 				'name' => array('yes', 'like'),
-				'id' => 'yes',
+				'id_no' => array('yes-id', '!='),
 				'state' => 1,
 				'state' => 1,
 			),
 			),
 			'type' => 'all',
 			'type' => 'all',
 			'order' => array('reorder' => 'desc', 'id' => 'desc'),
 			'order' => array('reorder' => 'desc', 'id' => 'desc'),
-			'limit' => '0,1000',
-			'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+			'limit' => '0,10',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled,spec_type|id',
 		),
 		),
 
 
 		# 列表
 		# 列表

+ 26 - 1
database/info_sku.php

@@ -78,10 +78,21 @@ $config = array
             'list'      => true,
             'list'      => true,
         ),
         ),
 
 
+        'un_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '划线价',
+            'default'   => '',
+            'desc'      => '划线价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
         'buy_price'       => array
         'buy_price'       => array
         (
         (
             'type'      => 'varchar-100',
             'type'      => 'varchar-100',
-            'name'      => '门店采购价',
+            'name'      => '采购价',
             'default'   => '',
             'default'   => '',
             'desc'      => '采购价',
             'desc'      => '采购价',
             'match'     => 'option',
             'match'     => 'option',
@@ -182,6 +193,20 @@ $config = array
             'order' => array('id' => 'desc'),
             'order' => array('id' => 'desc'),
             'col' => '*|key',
             'col' => '*|key',
         ),
         ),
+
+        # 列表
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*|key',
+        ),
     ),
     ),
 );
 );
 
 

+ 15 - 0
database/info_spec_value.php

@@ -149,6 +149,21 @@ $config = array
 			'order' => array('reorder' => 'asc', 'id' => 'asc'),
 			'order' => array('reorder' => 'asc', 'id' => 'asc'),
 			'col' => 'id, value as title, case is_checked when 1 then true else false end as checked',
 			'col' => 'id, value as title, case is_checked when 1 then true else false end as checked',
 		),
 		),
+
+		'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'ids' => array('yes-id', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'group' => 'info_id',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => 'id,info_id,value,group_concat(value) as name',
+        ),
 	),
 	),
 );
 );
 
 

+ 2 - 24
src/Attr.php → lib/Attr.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 
 
-namespace Product\Src;
+namespace Product\Lib;
 
 
 use Dever;
 use Dever;
 
 
@@ -11,7 +11,7 @@ class Attr
 	 *
 	 *
 	 * @return mixed
 	 * @return mixed
 	 */
 	 */
-	public function getManageByCate()
+	public function getManageByCate_api()
 	{
 	{
 		$id = Dever::input('id');
 		$id = Dever::input('id');
 		$data = array();
 		$data = array();
@@ -129,28 +129,6 @@ class Attr
 		return $result;
 		return $result;
 	}
 	}
 
 
-	public function getInfoAttr($category)
-	{
-	    //$all = Dever::db('category/attr')->all();
-
-	    $table = '';
-	    $attr = array();
-	    $create = Dever::config('database')->create;
-
-	    if ($category) {
-	        if (is_array($category)) {
-	            $category = implode(',', $category);
-	        }
-	        $table = '_' . str_replace(',', '_', $category);
-	        # 自动建表开启并且自动添加字段
-	        $create = false;
-	        $attr = $this->getAttrByCate($category);
-	        $table = str_replace('_-1', '', $table);
-	    }
-
-	    return array($category, $attr, $table, $create);
-	}
-
 	/**
 	/**
 	 * 设置数据库的结构信息
 	 * 设置数据库的结构信息
 	 *
 	 *

+ 11 - 11
src/Category.php → lib/Category.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 
 
-namespace Product\Src;
+namespace Product\Lib;
 
 
 use Dever;
 use Dever;
 
 
@@ -18,19 +18,12 @@ class Category
         'name' => '分类',
         'name' => '分类',
     );
     );
 
 
-    # 测试语言包
-    public function test()
-    {
-        $info = Dever::db('product/category')->select();
-        print_r($info);die;
-    }
-
 	/**
 	/**
      * 获取分类数据
      * 获取分类数据
      *
      *
      * @return mixed
      * @return mixed
      */
      */
-    public function get()
+    public function get_api()
     {
     {
         # 关闭语言包
         # 关闭语言包
         Dever::config('base')->lang = false;
         Dever::config('base')->lang = false;
@@ -73,8 +66,15 @@ class Category
             $data = Dever::db('product/category')->getAll($where);
             $data = Dever::db('product/category')->getAll($where);
         }
         }
 
 
-        if ($data && $level_num == 1) {
-            array_unshift($data, $default);
+        $type = Dever::input('type');
+        if ($data) {
+            if ($type && $type == 1) {
+                if ($level_num == 1) {
+                    array_unshift($data, $default);
+                }
+            } else {
+                array_unshift($data, $default);
+            }
         }
         }
 
 
         if (!$data) {
         if (!$data) {

+ 34 - 0
lib/Info.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace Product\Lib;
+
+use Dever;
+
+class Info
+{
+    # 获取商品列表
+    public function getList()
+    {
+    	
+    }
+
+    # 获取商品详情
+    public function getInfo($id)
+    {
+        $info = Dever::db('product/info')->find($id);
+
+        $info = $this->get($info);
+
+        return $info;
+    }
+
+    private function get($info)
+    {
+        # 获取属性
+        
+
+        # 获取规格
+
+        # 获取其他
+    }
+}

+ 25 - 0
lib/Manage.php

@@ -52,4 +52,29 @@ class Manage
             Dever::db('product/category_attr')->update($update);
             Dever::db('product/category_attr')->update($update);
         }
         }
     }
     }
+
+    public function searchProduct_api()
+    {
+        $where = array();
+
+        $cate = Dever::input('cate');
+        if ($cate) {
+            $where['cate_id'] = $cate;
+        }
+
+        $id = Dever::input('where_id');
+        if ($id) {
+            $where['id_no'] = $id;
+        }
+        $data = Dever::search('product/info', $where);
+        if ($data) {
+            $old = $data;
+            $data = array();
+            foreach ($old as $k => $v) {
+                Dever::load('product/lib/sku')->getList($v, $data);
+            }
+        }
+
+        return $data;
+    }
 }
 }

+ 64 - 0
lib/Sku.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace Product\Lib;
+
+use Dever;
+
+class Sku
+{
+    # 获取当前的规格
+    public function spec_api()
+    {
+    	$id = Dever::input('id');
+    	$result = array();
+    	if ($id) {
+    		$result = Dever::db('product/info_spec')->getAll(array('info_id' => $id));
+    		if ($result) {
+    			foreach ($result as $k => $v) {
+    				$result[$k]['child'] = Dever::db('product/info_spec_value')->getAll(array('info_id' => $id, 'spec_id' => $v['id']));
+    			}
+    		}
+    	}
+    	return $result;
+    }
+
+    # 获取当前的sku
+    public function sku_api()
+    {
+    	$id = Dever::input('id');
+    	$result = array();
+    	if ($id) {
+    		$result = Dever::db('product/info_sku')->getAll(array('info_id' => $id));
+    	}
+    	return $result;
+    }
+
+    # 获取某个商品的sku
+    public function getList($info, &$data)
+    {
+        if ($info['spec_type'] == 2) {
+            $where['info_id'] = $info['id'];
+            $sku = Dever::db('product/info_sku')->select($where);
+            if ($sku) {
+                foreach ($sku as $k => $v) {
+                    $copy = $info;
+                    $key = str_replace('-', ',', $v['key']);
+                    $spec = Dever::db('product/info_spec_value')->getData(array('ids' => $key));
+                    if ($spec) {
+                        $copy['name'] .= '-' . $spec['name'];
+                        $copy['id'] .= '-' . $v['key'];
+                        if (isset($copy['value'])) {
+                            $copy['value'] = $copy['id'];
+                        }
+                    }
+                    
+                    $data[] = $copy;
+                }
+            }
+        } else {
+            $data[] = $info;
+        }
+        
+        return $data;
+    }
+}

+ 2 - 2
src/Unit.php → lib/Unit.php

@@ -1,13 +1,13 @@
 <?php
 <?php
 
 
-namespace Product\Src;
+namespace Product\Lib;
 
 
 use Dever;
 use Dever;
 
 
 class Unit
 class Unit
 {
 {
     # 添加新单位
     # 添加新单位
-    public function add()
+    public function add_api()
     {
     {
     	$where['name'] = Dever::input('value');
     	$where['name'] = Dever::input('value');
     	if (!$where['name']) {
     	if (!$where['name']) {

+ 0 - 35
src/Sku.php

@@ -1,35 +0,0 @@
-<?php
-
-namespace Product\Src;
-
-use Dever;
-
-class Sku
-{
-    # 获取当前的规格
-    public function spec()
-    {
-    	$id = Dever::input('id');
-    	$result = array();
-    	if ($id) {
-    		$result = Dever::db('product/info_spec')->getAll(array('info_id' => $id));
-    		if ($result) {
-    			foreach ($result as $k => $v) {
-    				$result[$k]['child'] = Dever::db('product/info_spec_value')->getAll(array('info_id' => $id, 'spec_id' => $v['id']));
-    			}
-    		}
-    	}
-    	return $result;
-    }
-
-    # 获取当前的sku
-    public function sku()
-    {
-    	$id = Dever::input('id');
-    	$result = array();
-    	if ($id) {
-    		$result = Dever::db('product/info_sku')->getAll(array('info_id' => $id));
-    	}
-    	return $result;
-    }
-}