dever 2 years ago
parent
commit
b0f199703e
3 changed files with 77 additions and 11 deletions
  1. 73 7
      database/info.php
  2. 1 1
      database/value.php
  3. 3 3
      src/Api.php

+ 73 - 7
database/info.php

@@ -11,7 +11,7 @@ $cate = function()
 	return $array;
 };
 
-$col = '*';
+$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 => '数字输入框',
@@ -38,8 +38,21 @@ $is_must = array
 $is_sell = array
 (
 	1 => '普通属性',
-	2 => '组合属性',
-	3 => '单选属性',
+	2 => '销售属性',
+);
+
+$sell_type = array
+(
+	1 => '组合',
+	2 => '单选',
+	3 => '输入',
+);
+
+$sell_compute = array
+(
+	1 => '相乘',
+	2 => '相加',
+	3 => '相减',
 );
 
 $data_type = array
@@ -90,6 +103,8 @@ return array
 	'lang' => '属性设置',
 	# 是否显示在后台菜单
 	'order' => 10,
+	'sell_type' => $sell_type,
+	'sell_compute' => $sell_compute,
 	'end' => array
     (
         'insert' => 'attr/lib/manage.infoUpdate',
@@ -154,13 +169,13 @@ return array
 			'option'	=> $is_must,
 			'search'	=> 'select',
 			'list'		=> true,
-			'edit'		=> true,
+			//'edit'		=> true,
 		),
 
 		'is_sell'	  => array
 		(
 			'type' 		=> 'tinyint-1',
-			'name' 		=> '属性类型-普通属性仅做展示用,需要在后台录入属性具体值;组合属性将会生成不同的SKU组合价格,根据不同的SKU组合生成总价和库存;单选属性将生成单独的属性价格,将影响总价,不影响库存',
+			'name' 		=> '是否销售属性-销售属性将可以配置价格,一般用于商品',
 			'default' 	=> '1',
 			'desc' 		=> '属性类型',
 			'match' 	=> 'is_numeric',
@@ -172,6 +187,44 @@ return array
 			'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',
@@ -182,7 +235,7 @@ return array
 			'update'	=> 'radio',
 			'option'	=> $type,
 			//'search'	=> 'select',
-			'list'		=> true,
+			//'list'		=> true,
 			'show'		=> 'is_sell=1',
 			'control'	=> 'type',
 		),
@@ -377,13 +430,26 @@ return array
 
 	'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,
+				//'state' => 1,
 			),
 			'type' => 'all',
 			'order' => array('list_reorder`+`search_reorder`+`view_reorder' => 'desc', 'id' => 'desc'),

+ 1 - 1
database/value.php

@@ -124,7 +124,7 @@ return array
             ),
             'type' => 'all',
             'order' => array('reorder' => 'desc', 'id' => 'desc'),
-            'col' => '*',
+            'col' => 'id,info_id,name,value,icon,concat(info_id, "-", id) as price_key|id',
         ),
     )
 );

+ 3 - 3
src/Api.php

@@ -53,7 +53,7 @@ class Api
 			}
 		}
 
-		return array('data' => $result, 'string' => implode(';', $string));
+		return array('data' => $result, 'string' => implode(',', $string));
 	}
 
 	/**
@@ -87,7 +87,7 @@ class Api
 						$result[$cate_id]['attr'][$v] = array
 						(
 							'name' => $data[$v]['name'],
-							'value' => $value[$k],
+							'value' => isset($value[$k]) ? $value[$k] : '',
 							'id' => $v
 						);
 					}
@@ -284,7 +284,7 @@ class Api
 			if ($data) {
 				foreach ($ids as $k => $v) {
 					if (isset($data[$v])) {
-						if (isset($value) && $value[$k]) {
+						if (isset($value) && isset($value[$k]) && $value[$k]) {
 							$data[$v]['value'] = $value[$k];
 						} else {
 							$data[$v]['value'] = '';