rabin 2 лет назад
Сommit
20a3267041
59 измененных файлов с 11560 добавлено и 0 удалено
  1. 118 0
      database/rate.php
  2. 8 0
      index.php
  3. 4 0
      module/boot.php
  4. 277 0
      module/scm_order/database/buy.php
  5. 190 0
      module/scm_order/database/buy_goods.php
  6. 141 0
      module/scm_order/database/buy_ps.php
  7. 204 0
      module/scm_order/database/buy_refund.php
  8. 257 0
      module/scm_order/database/in.php
  9. 265 0
      module/scm_order/database/sell.php
  10. 283 0
      module/scm_order/database/sell_goods.php
  11. 29 0
      module/scm_order/database/sell_log.php
  12. 141 0
      module/scm_order/database/sell_ps.php
  13. 214 0
      module/scm_order/database/sell_refund.php
  14. 8 0
      module/scm_order/index.php
  15. 68 0
      module/scm_order/lib/Buy.php
  16. 323 0
      module/scm_order/lib/Sell.php
  17. 71 0
      module/scm_order/src/Sell.php
  18. 384 0
      module/scm_product/assets/pc/html/set_price_goods.html
  19. 310 0
      module/scm_product/database/category.php
  20. 446 0
      module/scm_product/database/category_attr.php
  21. 144 0
      module/scm_product/database/category_attr_search.php
  22. 153 0
      module/scm_product/database/category_attr_value.php
  23. 664 0
      module/scm_product/database/info.php
  24. 142 0
      module/scm_product/database/info_attr.php
  25. 65 0
      module/scm_product/database/info_category.php
  26. 63 0
      module/scm_product/database/info_extend.php
  27. 215 0
      module/scm_product/database/info_sku.php
  28. 143 0
      module/scm_product/database/info_spec.php
  29. 184 0
      module/scm_product/database/info_spec_value.php
  30. 124 0
      module/scm_product/database/price.php
  31. 243 0
      module/scm_product/database/price_rule.php
  32. 187 0
      module/scm_product/database/price_rule_sku.php
  33. 86 0
      module/scm_product/database/unit.php
  34. 8 0
      module/scm_product/index.php
  35. 536 0
      module/scm_product/lib/Attr.php
  36. 213 0
      module/scm_product/lib/Category.php
  37. 297 0
      module/scm_product/lib/Info.php
  38. 116 0
      module/scm_product/lib/Manage.php
  39. 132 0
      module/scm_product/lib/Price.php
  40. 79 0
      module/scm_product/lib/Sku.php
  41. 30 0
      module/scm_product/lib/Spec.php
  42. 22 0
      module/scm_product/lib/Unit.php
  43. 27 0
      module/scm_product/src/Seller.php
  44. 437 0
      module/scm_role/assets/pc/html/buy_seller_goods.html
  45. 485 0
      module/scm_role/assets/pc/html/set_seller_goods.html
  46. 426 0
      module/scm_role/assets/pc/html/set_supplier_goods.html
  47. 466 0
      module/scm_role/database/seller.php
  48. 157 0
      module/scm_role/database/seller_goods.php
  49. 317 0
      module/scm_role/database/seller_goods_sku.php
  50. 107 0
      module/scm_role/database/seller_type.php
  51. 120 0
      module/scm_role/database/servicer.php
  52. 106 0
      module/scm_role/database/servicer_type.php
  53. 359 0
      module/scm_role/database/supplier.php
  54. 155 0
      module/scm_role/database/supplier_goods.php
  55. 306 0
      module/scm_role/database/supplier_goods_sku.php
  56. 122 0
      module/scm_role/database/supplier_type.php
  57. 8 0
      module/scm_role/index.php
  58. 248 0
      module/scm_role/lib/Seller.php
  59. 127 0
      module/scm_role/lib/Supplier.php

+ 118 - 0
database/rate.php

@@ -0,0 +1,118 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'rate',
+	# 显示给用户看的名称
+	'lang' => '税率设置',
+	# 是否显示在后台菜单
+	'order' => 10,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '税率名称',
+			'default' 	=> '',
+			'desc' 		=> '税率名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'value'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '税率值',
+			'default' 	=> '',
+			'desc' 		=> '税率值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> '{value} ? {value} : 0',
+			'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
+	(
+		'insert' => false,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,value,state,cdate',
+		'value' => array
+		(
+			'"0税率", "0", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 8 - 0
index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'scm');
+define('DEVER_APP_LANG', '基础设置');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 1);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-vercode');
+include(DEVER_APP_PATH . 'module/boot.php');

+ 4 - 0
module/boot.php

@@ -0,0 +1,4 @@
+<?php
+define('DEVER_GROUP_ORDER', -1);
+define('DEVER_GROUP_NAME', '供应链管理');
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../boot.php');

+ 277 - 0
module/scm_order/database/buy.php

@@ -0,0 +1,277 @@
+<?php
+
+$status = array
+(
+    1 => '待支付',
+    2 => '待处理',
+    3 => '处理中',
+    4 => '待收货确认',
+    5 => '已完成',
+    6 => '已完成(有退款)',
+    7 => '已取消',
+    8 => '已退款',
+    11 => '已过期',
+);
+
+$audit = array
+(
+    //1 => '待审核',
+    2 => '审核通过',
+    3 => '审核未通过',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy',
+    # 显示给用户看的名称
+    'lang' => '订货订单',
+    'order' => 99,
+    'set' => array
+    (
+    	'status' => $status,
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
+            'default'   => '',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name'	=> '订单信息',
+            'list'      => 'Dever::load("scm_order/lib/buy.info#order", {id})',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'value'     => Dever::input('search_option_seller_id'),
+        ),
+
+        'address'      => array
+        (
+            'type'      => 'varchar-2000',
+            'name'      => '收货信息',
+            'default'   => '',
+            'desc'      => '收货信息',
+            'match'     => 'is_numeric',
+            'search'	=> 'fulltext',
+            'list'      => 'Dever::load("scm_order/lib/sell.info#address", {id})',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买总数量',
+            'default'   => '',
+            'desc'      => '购买总数量',
+            'match'     => 'is_numeric',
+            'list_name'	=> '金额信息',
+            'list'      => 'Dever::load("scm_order/lib/sell.info#cash", {id})',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '订单总金额',
+            'default'   => '0',
+            'desc'      => '订单总金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'pay_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '支付金额',
+            'default'   => '0',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'ps_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '配送费',
+            'default'   => '0',
+            'desc'      => '配送费',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'wallet_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '钱包抵扣金额',
+            'default'   => '0',
+            'desc'      => '钱包抵扣金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            //'search_after' => '<br />',
+            //'mul'   => true,
+            //'mul_option' => array(2 => '批量审核', 5 => '确认收货'),
+        ),
+
+        'audit'        => array
+	    (
+	        'type'      => 'tinyint-1',
+	        'name'      => '审核状态',
+	        'default'   => '1',
+	        'desc'      => '审核状态',
+	        'match'     => 'is_numeric',
+	        'option'    => $audit,
+	        //'search'    => 'select',
+	        'update'    => 'radio',
+	    ),
+
+	    'audit_desc'        => array
+	    (
+	        'type'      => 'varchar-500',
+	        'name'      => '审核备注',
+	        'default'   => '',
+	        'desc'      => '审核备注',
+	        'match'     => 'option',
+	        'update'    => 'textarea',
+	    ),
+
+        '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'    => 'sdate',
+            'list'        => 'date("Y-m-d H:i", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        //'excel' => $excel,
+        //'mul' => $mul,
+
+        'button' => array
+        (
+            //'导出订单明细' => array('excel', 'shop/excel.sell_order'),
+        ),
+
+        'list_button' => array
+        (
+            //fast_list
+            /*
+            'list' => array('查看详情', '"sell_order_goods&project=shop&order_id={id}&page_type=&search_option_shop_type='.$search_option_shop_type.'"'),
+
+            'list11' => array('查看采购单', '"buy_order&project=shop&search_option_type=1&&search_option_parent_type=2&search_option_parent_order_id={id}&oper_table=sell_order&search_option_shop_type='.$search_option_shop_type.'"', '{status} >= 3 && {audit} == 2 && {shop_type} == 2'),
+
+            'list1' => array('审核', '"sell_order_goods&project=shop&order_id={id}&audit=1&page_type=&search_option_shop_type='.$search_option_shop_type.'"', '{status} == 2 && {shop_type} == 2'),
+
+            'oper'  => array('确认收货', '"shop/lib/manage.setSellOrderStatus?shop_id={shop_id}&order_id={id}"', '{status} == 4 && {shop_type} == 2'),
+            */
+        ),
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'uid' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(5, 'list'),
+            'col' => '*',
+        ),
+
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'name' => array('yes', 'like'),
+                'shop_id' => 'yes',
+                'mobile' => 'yes',
+                'method' => 'yes',
+                'pay_method' => 'yes',
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 190 - 0
module/scm_order/database/buy_goods.php

@@ -0,0 +1,190 @@
+<?php
+
+$status = array
+(
+    1 => '正常',
+    2 => '申请退款中',
+    3 => '已退款',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy_goods',
+    # 显示给用户看的名称
+    'lang' => '订单商品表',
+    'menu' => false,
+    'status' => $status,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '单价',
+            'default'   => '',
+            'desc'      => '单价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买数量',
+            'default'   => '',
+            'desc'      => '购买数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
+        'pay_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
+        ),
+
+        'wallet_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '钱包抵扣金额',
+            'default'   => '0',
+            'desc'      => '钱包抵扣金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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,
+        'delete' => false,
+        'page_list' => 'buy_goods',
+    ),
+
+    'request' => array
+    (
+        # 获取总金额
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-t_2.cdate', '>='),
+                'end' => array('yes-t_2.cdate', '<='),
+                'start_o' => array('yes-t_2.operdate', '>='),
+                'end_o' => array('yes-t_2.operdate', '<='),
+                'shop_id' => array('yes-t_2.shop_id'),
+                'goods_id' => array('yes-t_1.goods_id'),
+                'status' => array('yes-t_2.status', 'in'),
+                'state_2' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+                'status_1' => 'yes-t_1.status-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'shop/sell_order',
+                    'type' => 'left join',
+                    'on' => array('order_id','id'),
+                ),
+            ),
+            'type' => 'all',
+            'group' => 't_2.shop_id, t_1.goods_id',
+            'col' => 'id,t_2.shop_id, t_1.goods_id,sum(t_1.price*t_1.num) as cash,sum(t_1.num) as num',
+        ),
+    ),
+);

+ 141 - 0
module/scm_order/database/buy_ps.php

@@ -0,0 +1,141 @@
+<?php
+
+$status = array
+(
+    1 => '待处理',
+    2 => '配送中',
+    3 => '已配送',
+    4 => '未配送',
+);
+
+$service = function()
+{
+    $info = Dever::db('scm_role/servicer')->select();
+    return $info;
+};
+
+return array
+(
+    # 表名
+    'name' => 'buy_ps',
+    # 显示给用户看的名称
+    'lang' => '订单配送表',
+    'menu' => false,
+    'status' => $status,
+    'end' => array
+    (
+        'insert' => 'scm_order/lib/buy.ps',
+        'update' => 'scm_order/lib/buy.ps',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+            'update'      => 'hidden',
+            'value'     => Dever::input('search_option_order_id'),
+        ),
+
+        'service_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配送服务商',
+            'default'   => '-1',
+            'desc'      => '配送服务商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $service,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '快递单号',
+            'default'   => '',
+            'desc'      => '快递单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'qu_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '取件时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '取件时间',
+        ),
+
+        'qs_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '签收时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '签收时间',
+        ),
+
+        '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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 204 - 0
module/scm_order/database/buy_refund.php

@@ -0,0 +1,204 @@
+<?php
+
+$scope = array
+(
+    1 => '整个订单',
+    2 => '单一商品',
+);
+
+$type = array
+(
+    1 => '仅退款',
+    2 => '退货退款',
+);
+
+$process = array
+(
+    1 => '申请退款中',
+    2 => '审核通过',
+    3 => '审核驳回',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy_refund',
+    # 显示给用户看的名称
+    'lang' => '订单退款申请',
+    'menu' => false,
+    'set' => array
+    (
+    	'type' => $type,
+    	'process' => $process,
+    ),
+    
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'order_goods_id'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单商品表id',
+            'default'   => '',
+            'desc'      => '订单商品表id',
+            'match'     => 'option',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '退款金额',
+            'default'   => '0',
+            'desc'      => '退款金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'pay_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '支付金额',
+            'default'   => '0',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
+        ),
+
+        'wallet_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '钱包抵扣金额',
+            'default'   => '0',
+            'desc'      => '钱包抵扣金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款数量',
+            'default'   => '',
+            'desc'      => '退款数量',
+            'match'     => 'is_numeric',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款描述',
+            'default'   => '',
+            'desc'      => '退款描述',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'pic'      => array
+        (
+            'type'      => 'varchar-8000',
+            'name'      => '退款图片',
+            'default'   => '',
+            'desc'      => '退款图片',
+            'match'     => 'option',
+            'update'    => 'images',
+            'key'       => '1',
+            'place'     => '660*660',
+        ),
+
+        'scope'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '范围',
+            'default'   => '1',
+            'desc'      => '范围',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $scope,
+            'search'    => 'select',
+            'list'      => true,
+            //'edit'      => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $type,
+            'search'    => 'select',
+            'list'      => true,
+            //'edit'      => true,
+        ),
+
+        'process'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核进度',
+            'default'   => '1',
+            'desc'      => '审核进度',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $process,
+            'search'    => 'select',
+            'list'      => true,
+            '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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 257 - 0
module/scm_order/database/in.php

@@ -0,0 +1,257 @@
+<?php
+
+$status = array
+(
+    1 => '待审核',
+    2 => '已审核',
+    3 => '已驳回',
+);
+
+$seller = function()
+{
+    $array = array();
+    $info = Dever::db('scm_role/sell')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'in',
+    # 显示给用户看的名称
+    'lang' => '入库单',
+    'order' => 98,
+    'set' => array
+    (
+    	'status' => $status,
+    ),
+    
+    'ends' => array
+    (
+        'insert' => 'shop/lib/manage.sellOrderUpdate',
+        'update' => 'shop/lib/manage.sellOrderUpdate',
+        'updatemul' => 'shop/lib/manage.setSellOrderStatusMul_commit',
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
+            'default'   => '',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name'	=> '订单信息',
+            'list'      => 'Dever::load("scm_order/lib/sell.info#order", {id})',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'value'     => Dever::input('search_option_seller_id'),
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买人',
+            'default'   => '0',
+            'desc'      => '购买人',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'passport/user-like',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            //'search_after' => '<br />',
+            //'mul'   => true,
+            //'mul_option' => array(2 => '批量审核', 5 => '确认收货'),
+        ),
+
+        'pay_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '付款时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'list'      => '"{paydate}" > 0 ? date("Y-m-d H:i", {paydate}) : "-"',
+        ),
+
+        'finish_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '完成时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'date',
+            'list'      => '"{finish_date}" ? date("Y-m-d H:i", {finish_date}) : "-"',
+        ),
+
+        'oper_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            //'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i:s", {operdate}) : "-"',
+            //'list_name' => '发货时间',
+            //'list_order' => 8,
+        ),
+
+        'fa_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发货时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'date',
+            'list'      => '"{fa_date}" > 0 ? date("Y-m-d H:i:s", {fa_date}) : "-"',
+        ),
+
+        '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'    => 'sdate',
+            'list'        => 'date("Y-m-d H:i", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        //'excel' => $excel,
+        //'mul' => $mul,
+
+        'button' => array
+        (
+            //'导出订单明细' => array('excel', 'shop/excel.sell_order'),
+        ),
+
+        'list_button' => array
+        (
+            //fast_list
+            /*
+            'list' => array('查看详情', '"sell_order_goods&project=shop&order_id={id}&page_type=&search_option_shop_type='.$search_option_shop_type.'"'),
+
+            'list11' => array('查看采购单', '"buy_order&project=shop&search_option_type=1&&search_option_parent_type=2&search_option_parent_order_id={id}&oper_table=sell_order&search_option_shop_type='.$search_option_shop_type.'"', '{status} >= 3 && {audit} == 2 && {shop_type} == 2'),
+
+            'list1' => array('审核', '"sell_order_goods&project=shop&order_id={id}&audit=1&page_type=&search_option_shop_type='.$search_option_shop_type.'"', '{status} == 2 && {shop_type} == 2'),
+
+            'oper'  => array('确认收货', '"shop/lib/manage.setSellOrderStatus?shop_id={shop_id}&order_id={id}"', '{status} == 4 && {shop_type} == 2'),
+            */
+        ),
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'uid' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(5, 'list'),
+            'col' => '*',
+        ),
+
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'name' => array('yes', 'like'),
+                'shop_id' => 'yes',
+                'method' => 'yes',
+                'pay_method' => 'yes',
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 265 - 0
module/scm_order/database/sell.php

@@ -0,0 +1,265 @@
+<?php
+$pay_account = function()
+{
+    $array = array
+    (
+    	-1 => '其他',
+    );
+    $info = Dever::db('pay/account')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$status = array
+(
+    1 => '待支付',
+    2 => '待处理',
+    3 => '处理中',
+    4 => '待收货确认',
+    5 => '已完成',
+    6 => '已完成(有退款)',
+    7 => '已取消',
+    8 => '已退款',
+    11 => '已过期',
+);
+
+return array
+(
+    # 表名
+    'name' => 'sell',
+    # 显示给用户看的名称
+    'lang' => '销售订单',
+    'order' => 100,
+    'set' => array
+    (
+    	'status' => $status,
+    ),
+    
+    'ends' => array
+    (
+        'insert' => 'shop/lib/manage.sellOrderUpdate',
+        'update' => 'shop/lib/manage.sellOrderUpdate',
+        'updatemul' => 'shop/lib/manage.setSellOrderStatusMul_commit',
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
+            'default'   => '',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name'	=> '订单信息',
+            'list'      => 'Dever::load("scm_order/lib/sell.info#order", {id})',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'value'     => Dever::input('search_option_seller_id'),
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买人',
+            'default'   => '0',
+            'desc'      => '购买人',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'passport/user-like',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            //'search_after' => '<br />',
+            //'mul'   => true,
+            //'mul_option' => array(2 => '批量审核', 5 => '确认收货'),
+        ),
+
+        'pay_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '付款时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'list'      => '"{paydate}" > 0 ? date("Y-m-d H:i", {paydate}) : "-"',
+        ),
+
+        'finish_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '完成时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'date',
+            'list'      => '"{finish_date}" ? date("Y-m-d H:i", {finish_date}) : "-"',
+        ),
+
+        'oper_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            //'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i:s", {operdate}) : "-"',
+            //'list_name' => '发货时间',
+            //'list_order' => 8,
+        ),
+
+        'fa_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发货时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'date',
+            'list'      => '"{fa_date}" > 0 ? date("Y-m-d H:i:s", {fa_date}) : "-"',
+        ),
+
+        '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'    => 'sdate',
+            'list'        => 'date("Y-m-d H:i", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        //'excel' => $excel,
+        //'mul' => $mul,
+
+        'button' => array
+        (
+            //'导出订单明细' => array('excel', 'shop/excel.sell_order'),
+        ),
+
+        'list_button' => array
+        (
+            //fast_list
+            /*
+            'list' => array('查看详情', '"sell_order_goods&project=shop&order_id={id}&page_type=&search_option_shop_type='.$search_option_shop_type.'"'),
+
+            'list11' => array('查看采购单', '"buy_order&project=shop&search_option_type=1&&search_option_parent_type=2&search_option_parent_order_id={id}&oper_table=sell_order&search_option_shop_type='.$search_option_shop_type.'"', '{status} >= 3 && {audit} == 2 && {shop_type} == 2'),
+
+            'list1' => array('审核', '"sell_order_goods&project=shop&order_id={id}&audit=1&page_type=&search_option_shop_type='.$search_option_shop_type.'"', '{status} == 2 && {shop_type} == 2'),
+
+            'oper'  => array('确认收货', '"shop/lib/manage.setSellOrderStatus?shop_id={shop_id}&order_id={id}"', '{status} == 4 && {shop_type} == 2'),
+            */
+        ),
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'uid' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(5, 'list'),
+            'col' => '*',
+        ),
+
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'name' => array('yes', 'like'),
+                'shop_id' => 'yes',
+                'method' => 'yes',
+                'pay_method' => 'yes',
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 283 - 0
module/scm_order/database/sell_goods.php

@@ -0,0 +1,283 @@
+<?php
+
+$status = array
+(
+    1 => '正常',
+    2 => '申请退款中',
+    3 => '已退款',
+);
+
+return array
+(
+    # 表名
+    'name' => 'sell_goods',
+    # 显示给用户看的名称
+    'lang' => '订单商品表',
+    'menu' => false,
+    'status' => $status,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '单价',
+            'default'   => '',
+            'desc'      => '单价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买数量',
+            'default'   => '',
+            'desc'      => '购买数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
+        'pay_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
+        ),
+
+        'pay_money'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '支付货币',
+            'default'   => '1',
+            'desc'      => '支付货币',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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,
+        'delete' => false,
+        'page_list' => 'sell_goods',
+    ),
+
+    'request' => array
+    (
+        # 获取单条数据
+        'getIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'shop_id' => 'yes',
+                'order_id' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|id',
+        ),
+
+        # 获取多条数据
+        'getDataByIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'uid' => 'yes',
+                'shop_id' => 'yes',
+                'order_id' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*',
+        ),
+
+        # 获取多条数据
+        'getTotal' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
+
+        # 获取订单数量
+        'getOrderNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
+
+        # 获取总金额
+        'getCashNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(price*num) as total',
+        ),
+
+        'getGoods' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => 'id,goods_id',
+        ),
+
+        # 获取总金额
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-t_2.cdate', '>='),
+                'end' => array('yes-t_2.cdate', '<='),
+                'start_o' => array('yes-t_2.operdate', '>='),
+                'end_o' => array('yes-t_2.operdate', '<='),
+                'shop_id' => array('yes-t_2.shop_id'),
+                'goods_id' => array('yes-t_1.goods_id'),
+                'status' => array('yes-t_2.status', 'in'),
+                'state_2' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+                'status_1' => 'yes-t_1.status-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'shop/sell_order',
+                    'type' => 'left join',
+                    'on' => array('order_id','id'),
+                ),
+            ),
+            'type' => 'all',
+            'group' => 't_2.shop_id, t_1.goods_id',
+            'col' => 'id,t_2.shop_id, t_1.goods_id,sum(t_1.price*t_1.num) as cash,sum(t_1.num) as num',
+        ),
+    ),
+);

+ 29 - 0
module/scm_order/database/sell_log.php

@@ -0,0 +1,29 @@
+<?php
+$pay_account = function()
+{
+    $array = array
+    (
+    	-1 => '其他',
+    );
+    $info = Dever::db('pay/account')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$status = array
+(
+    1 => '待支付',
+    2 => '待处理',
+    3 => '处理中',
+    4 => '待收货确认',
+    5 => '已完成',
+    6 => '已完成(有退款)',
+    7 => '已取消',
+    8 => '已退款',
+    11 => '已过期',
+);
+
+return Dever::load('scm_order/lib/db')->set('sell', '销售订单状态变化记录表')->log();

+ 141 - 0
module/scm_order/database/sell_ps.php

@@ -0,0 +1,141 @@
+<?php
+
+$status = array
+(
+    1 => '待处理',
+    2 => '配送中',
+    3 => '已配送',
+    4 => '未配送',
+);
+
+$service = function()
+{
+    $info = Dever::db('scm_role/servicer')->select();
+    return $info;
+};
+
+return array
+(
+    # 表名
+    'name' => 'sell_ps',
+    # 显示给用户看的名称
+    'lang' => '订单配送表',
+    'menu' => false,
+    'status' => $status,
+    'end' => array
+    (
+        'insert' => 'scm_order/lib/sell.ps',
+        'update' => 'scm_order/lib/sell.ps',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+            'update'      => 'hidden',
+            'value'     => Dever::input('search_option_order_id'),
+        ),
+
+        'service_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配送服务商',
+            'default'   => '-1',
+            'desc'      => '配送服务商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $service,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '快递单号',
+            'default'   => '',
+            'desc'      => '快递单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'qu_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '取件时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '取件时间',
+        ),
+
+        'qs_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '签收时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '签收时间',
+        ),
+
+        '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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 214 - 0
module/scm_order/database/sell_refund.php

@@ -0,0 +1,214 @@
+<?php
+
+$scope = array
+(
+    1 => '整个订单',
+    2 => '单一商品',
+);
+
+$type = array
+(
+    1 => '仅退款',
+    2 => '退货退款',
+);
+
+$process = array
+(
+    1 => '申请退款中',
+    2 => '审核通过',
+    3 => '审核驳回',
+);
+
+return array
+(
+    # 表名
+    'name' => 'sell_refund',
+    # 显示给用户看的名称
+    'lang' => '订单退款申请',
+    'menu' => false,
+    'set' => array
+    (
+    	'type' => $type,
+    	'process' => $process,
+    ),
+    
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'order_goods_id'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单商品表id',
+            'default'   => '',
+            'desc'      => '订单商品表id',
+            'match'     => 'option',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '退款金额',
+            'default'   => '0',
+            'desc'      => '退款金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'pay_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '支付金额',
+            'default'   => '0',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
+        ),
+
+        'card_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '礼品卡抵扣金额',
+            'default'   => '0',
+            'desc'      => '礼品卡抵扣金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'wallet_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '钱包抵扣金额',
+            'default'   => '0',
+            'desc'      => '钱包抵扣金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款数量',
+            'default'   => '',
+            'desc'      => '退款数量',
+            'match'     => 'is_numeric',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款描述',
+            'default'   => '',
+            'desc'      => '退款描述',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'pic'      => array
+        (
+            'type'      => 'varchar-8000',
+            'name'      => '退款图片',
+            'default'   => '',
+            'desc'      => '退款图片',
+            'match'     => 'option',
+            'update'    => 'images',
+            'key'       => '1',
+            'place'     => '660*660',
+        ),
+
+        'scope'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '范围',
+            'default'   => '1',
+            'desc'      => '范围',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $scope,
+            'search'    => 'select',
+            'list'      => true,
+            //'edit'      => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $type,
+            'search'    => 'select',
+            'list'      => true,
+            //'edit'      => true,
+        ),
+
+        'process'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核进度',
+            'default'   => '1',
+            'desc'      => '审核进度',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $process,
+            'search'    => 'select',
+            'list'      => true,
+            '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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 8 - 0
module/scm_order/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'scm_order');
+define('DEVER_APP_LANG', '订单库');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 100);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-email');
+include(DEVER_APP_PATH . '../boot.php');

+ 68 - 0
module/scm_order/lib/Buy.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace Scm_order\Lib;
+
+use Dever;
+
+class Buy
+{
+	# 获取订单信息
+    public function info($id)
+    {
+    	Dever::load('manage/auth.init');
+
+    	$info = Dever::db('scm_order/sell')->find($id);
+
+    	$data['order'] = array();
+
+    	$data['order']['订单号'] = $info['order_num'];
+
+    	$seller = Dever::db('scm_role/seller')->find($info['seller_id']);
+
+    	$data['order']['销售商'] = $seller['name'];
+
+    	if ($info['uid'] && $info['uid'] > 0) {
+    		$user = Dever::db('passport/api')->info($info['uid']);
+
+    		$data['order']['购买人'] = $user;
+    	}
+
+    	$data['order'] = Dever::table($data['order']);
+
+    	if ($info['address']) {
+    		$data['address'] = array();
+
+    		$info['address'] = Dever::json_encode($info['address']);
+
+    		if ($info['address']) {
+    			$data['address']['收件人'] = $info['address']['name'];
+    			$data['address']['手机号'] = $info['address']['mobile'];
+    			$data['address']['地址'] = $info['address']['address'];
+    		}
+    		$data['address'] = Dever::table($data['address']);
+    	}
+
+    	$data['cash'] = array();
+
+    	$data['cash']['总数量'] = $info['num'];
+    	$data['cash']['总金额'] = $info['cash'];
+    	$data['cash']['支付金额'] = $info['pay_cash'];
+
+    	$data['cash'] = Dever::table($data['cash']);
+
+        return $data;
+    }
+
+    public function ps($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $order_id = Dever::param('order_id', $data);
+        if ($order_id) {
+        	/*
+            $info = Dever::db('scm_order/sell')->find(array('id' => $order_id));
+            if ($info && $info['status'] < 3) {
+                Dever::load('shop/lib/sell')->notice($info);
+            }*/
+        }
+    }
+}

+ 323 - 0
module/scm_order/lib/Sell.php

@@ -0,0 +1,323 @@
+<?php
+
+namespace Scm_order\Lib;
+
+use Dever;
+
+class Sell
+{
+	# 获取订单信息
+    public function info($id)
+    {
+    	Dever::load('manage/auth.init');
+
+    	$info = Dever::db('scm_order/sell')->find($id);
+
+    	$data['order'] = array();
+
+    	$data['order']['订单号'] = $info['order_num'];
+
+    	$seller = Dever::db('scm_role/seller')->find($info['seller_id']);
+
+    	$data['order']['销售商'] = $seller['name'];
+
+    	if ($info['uid'] && $info['uid'] > 0) {
+    		$user = Dever::db('passport/api')->info($info['uid']);
+
+    		$data['order']['购买人'] = $user;
+    	}
+
+    	$data['order'] = Dever::table($data['order']);
+
+    	if ($info['address']) {
+    		$data['address'] = array();
+
+    		$info['address'] = Dever::json_encode($info['address']);
+
+    		if ($info['address']) {
+    			$data['address']['收件人'] = $info['address']['name'];
+    			$data['address']['手机号'] = $info['address']['mobile'];
+    			$data['address']['地址'] = $info['address']['address'];
+    		}
+    		$data['address'] = Dever::table($data['address']);
+    	}
+
+    	$data['cash'] = array();
+
+    	$data['cash']['总数量'] = $info['num'];
+    	$data['cash']['总金额'] = $info['cash'];
+    	$data['cash']['支付金额'] = $info['pay_cash'];
+
+    	$data['cash'] = Dever::table($data['cash']);
+
+        return $data;
+    }
+
+    public function ps($id, $name, $data)
+    {
+        Dever::config('base')->hook = true;
+        $order_id = Dever::param('order_id', $data);
+        if ($order_id) {
+        	/*
+            $info = Dever::db('scm_order/sell')->find(array('id' => $order_id));
+            if ($info && $info['status'] < 3) {
+                Dever::load('shop/lib/sell')->notice($info);
+            }*/
+        }
+    }
+
+    # 得到商品和总价
+    public function goods($uid, $seller_id = 1)
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        if (!$goods) {
+        	Dever::alert('商品信息不存在');
+        }
+
+        $data = array();
+        # 总价
+        $data['cash'] = 0;
+        # 支付价格
+        $data['pay_cash'] = 0;
+        # 钱包金额
+        $data['wallet_cash'] = 0;
+        # 配送金额
+        $data['ps_cash'] = 0;
+        # 总数量
+        $data['num'] = 0;
+
+        # 计算总价格
+        foreach ($goods as $k => $v) {
+        	if (!isset($v['goods_id']) || !isset($v['sku_id'])) {
+        		continue;
+        	}
+            $v['num'] = isset($v['num']) ? $v['num'] : 1;
+
+            $data['list'][$k] = Dever::load('scm_product/lib/info')->getPayInfo($v['goods_id'], $v['sku_id'], $seller_id);
+            if (!$data['list'][$k]) {
+                continue;
+            }
+            if ($data['list'][$k]['sell_type'] == 2) {
+                continue;
+            }
+            
+            $data['list'][$k]['pay_cash'] = $data['list'][$k]['cash'] = $data['list'][$k]['price'];
+            unset($data['list'][$k]['price']);
+            $data['list'][$k]['num'] = $v['num'];
+
+            # 1可以购买 2不可以购买
+            $data['list'][$k]['buy_state'] = 1;
+
+            if ($data['list'][$k]['stock'] == 1) {
+                if ($data['list'][$k]['status'] == 2) {
+                    $stock = 0;
+                } else {
+                    # 获取库存
+                    $stock = $this->stock($data['list'][$k]['num'], $v['goods_id'], $v['sku_id'], $seller_id);
+
+                    if (isset($data['list'][$k]['min']) && $data['list'][$k]['min'] > 0) {
+                        if ($stock < $data['list'][$k]['min']) {
+                            $stock = 0;
+                        }
+                    }
+                }
+
+                if ($stock <= 0) {
+                    # 如果没有库存了
+                    $data['list'][$k]['buy_state'] = 2;
+                    $data['list'][$k]['buy_num'] = 0;
+                }
+            }
+
+            if ($data['list'][$k]['buy_state'] == 1) {
+                $data['list'][$k]['buy_num'] = $v['num'];
+                $data['num'] += $v['num'];
+                $data['cash'] += $data['list'][$k]['cash'] * $v['num'];
+                $data['pay_cash'] += $data['list'][$k]['pay_cash'] * $v['num'];
+            }
+        }
+
+        /*
+        if ($data['method'] == 2) {
+            # 获取配送商的价格
+            $data['ps_cash'] = $data['shop']['ps_cash'];
+            if ($data['shop']['free_ps_cash'] && $data['shop']['free_ps_cash'] > 0 && $data['cash'] >= $data['shop']['free_ps_cash']) {
+                $data['ps_cash'] = 0;
+            }
+            if (!$data['ps_cash']) {
+                $data['ps_cash'] = 0;
+            }
+        }*/
+
+        return $data;
+    }
+
+    # 实时获取库存 之后改成从redis中获取
+    public function stock($num, $goods_id, $sku_id, $seller_id)
+    {
+        $seller = Dever::db('scm_role/seller')->find($seller_id);
+        if ($seller['stock'] == 2 && $seller['stock_seller'] > 0) {
+            $seller_id = $seller['stock_seller'];
+        }
+        $where['seller_id'] = $seller_id;
+        $where['goods_id'] = $goods_id;
+        $where['sku_id'] = $sku_id;
+        $info = Dever::db('scm_role/seller_goods_sku')->getOne($where);
+        if (!$info) {
+            return 0;
+        }
+        $total = $info['total'];
+
+        return $total;
+    }
+
+    # 发起支付
+	public function pay($data, $uid, $seller_id, $info = '', $cart = false, $refer = '')
+    {
+        if (!$uid) {
+            Dever::alert('错误的用户信息');
+        }
+
+        if ($uid > 0) {
+            $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid, 'type' => 1, 'system_id' => 1));
+
+            if (!$wechat) {
+                //Dever::alert('错误的用户信息');
+            }
+        }
+        
+        $order_data['seller_id'] = $seller_id;
+        $order_data['uid'] = $uid;
+        //$order_data['address'] = $address;
+        $order_data['num'] = $data['num'];
+        $order_data['info'] = $info;
+        $order_data['cash'] = $data['cash'];
+        $order_data['pay_cash'] = $data['pay_cash'];
+        $order_data['wallet_cash'] = $data['wallet_cash'];
+        $order_data['ps_cash'] = $data['ps_cash'];
+
+        $time = time();
+        $order_data_where = $order_data;
+        $order_data_where['start'] = $time - 60;
+        $order_data_where['end'] = $time;
+        $order_data_where['option']['start'] = array('yes-cdate', '>=');
+        $order_data_where['option']['end'] = array('yes-cdate', '<=');
+
+        $info = Dever::db('scm_order/sell')->find($order_data_where);
+
+        $order_data['order_num'] = $this->getOrderId();
+        
+        if (!$info) {
+            $id = Dever::db('scm_order/sell')->insert($order_data);
+        } else {
+            return array
+            (
+                'order' => '',
+                'order_num' => $info['order_num'],
+                'order_id' => $info['id'],
+                'type' => 'test',
+            );
+        }
+
+        if (!$id) {
+            Dever::alert('支付失败');
+        }
+
+        foreach($data['list'] as $k => $v) {
+            if ($v['buy_state'] == 1) {
+                $data['uid'] = $uid;
+                $data['order_id'] = $id;
+                $data['seller_id'] = $seller_id;
+                $data['goods_id'] = $v['id'];
+                $data['sku_id'] = $v['sku_id'];
+                $data['cash'] = $v['cash'];
+                $data['pay_cash'] = $v['pay_cash'];
+                $data['num'] = $v['buy_num'];
+
+                Dever::db('scm_order/sell_goods')->insert($data);
+            }
+        }
+
+        # 减少库存 增加销量
+        $order_data['id'] = $id;
+        $this->updateStock($order_data);
+
+        if ($price <= 0) {
+
+        	$param['pay_product_id'] = $id;
+        	$param['pay_order_id'] = $order_data['order_num'];
+        	$param['pay_status'] = 2;
+        	$param['pay_cash'] = $price;
+        	$param['pay_msg'] = '';
+        	$this->success($param);
+
+            if ($cart) {
+                # 来自购物车,要清空一下
+                $this->dropCart($cart, $uid, $seller_id, $data['list']);
+            }
+            # 使用优惠券
+            //$this->useCoupon($order_data, $coupon_id, $user_coupon_id, $card, $wallet_cash);
+        	return array
+            (
+                'order' => '',
+                'order_num' => $order_data['order_num'],
+                'order_id' => $id,
+                'type' => 'test',
+            );
+        }
+
+        $sell_config = Dever::db('main/sell_config')->one();
+
+        # 分账
+        $other = false;
+        if (isset($shop['mid']) && $shop['mid']) {
+            $other = array
+            (
+                'mid' => $shop['mid'],
+                'order_id' => $order_data['order_num'] . '_' . $shop['id'],
+                'per' => $sell_config['per'],
+                'oprice' => $oprice,
+            );
+        }
+
+        $param = array
+        (
+            'project_id' => 1,
+            'channel_id' => 1,
+            'system_source' => $system_source,
+            'uid' => $uid,
+            'name' => $order_data['name'],
+            'cash' => $price,
+            'product_id' => $id,
+            'order_id' => $order_data['order_num'],
+            'other' => $other,
+            'refer' => $refer,
+        );
+
+        if ($uid > 0 && isset($wechat) && $wechat) {
+            $param['openid'] = $wechat['openid'];
+        }
+
+        $receipt = Dever::input('receipt');
+        if ($receipt) {
+            $param['receipt'] = $receipt;
+        }
+
+        $result = Dever::load('pay/api.pay', $param);
+        //$result['type'] = 'test';
+        //$result['order'] = '';
+        if ($cart) {
+            # 来自购物车,要清空一下
+            $this->dropCart($cart, $uid, $goods, $shop['id']);
+        }
+        # 使用优惠券
+        $this->useCoupon($order_data, $coupon_id, $user_coupon_id, $card, $wallet_cash);
+        $result['order_num'] = $order_data['order_num'];
+        $result['order_id'] = $id;
+        return $result;
+    }
+}

+ 71 - 0
module/scm_order/src/Sell.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace Scm_order\Src;
+
+use Dever;
+
+class Sell
+{
+	public function __construct()
+	{
+		$this->uid = 1;
+		$this->seller_id = Dever::input('seller_id', 1);
+	}
+
+	public function test_confirm()
+	{
+		$data['goods'] = array();
+		$data['goods'][0]['goods_id'] = '10000001';
+		$data['goods'][0]['sku_id'] = '8';
+		$data['goods'][0]['num'] = '1';
+
+		return $data;
+	}
+
+	# 确认订单页面
+	public function confirm()
+	{
+		$data = Dever::load('scm_order/lib/sell')->goods($this->uid, $this->seller_id);
+		//$data = Dever::load('scm_order/lib/sell')->coupon($data);
+
+		return $data;
+	}
+
+	# 开始下单
+	public function pay_commit()
+	{
+		$refer = Dever::input('refer');
+		$cart = Dever::input('cart', 1);
+		$address_id = Dever::input('address_id');
+		
+		$info = Dever::input('info');
+
+		$data = Dever::load('scm_order/lib/sell')->goods($this->uid, $this->seller_id);
+		//Dever::load('scm_order/lib/sell')->coupon($this->data, 2);
+
+		$pay = Dever::load('scm_order/lib/sell')->pay($data, $this->uid, $this->seller_id);
+		return $pay;
+	}
+
+	# 再次付款
+	public function r_pay()
+	{
+		$refer = Dever::input('refer');
+		$order_id = Dever::input('order_id');
+
+		$pay = Dever::load('scm_order/lib/sell')->rpay($order_id, 5, $refer);
+
+		return $pay;
+	}
+
+	# 查询是否支付
+	public function c_pay()
+	{
+		$refer = Dever::input('refer');
+		$order_id = Dever::input('order_id');
+
+		$pay = Dever::load('scm_order/lib/sell')->cpay($order_id, 5, $refer);
+
+		return $pay;
+	}
+}

+ 384 - 0
module/scm_product/assets/pc/html/set_price_goods.html

@@ -0,0 +1,384 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
+<meta name="author" content="siweiyong 2602812659@qq.com"/>
+<title>设置商品</title>
+<link rel="stylesheet" href="../script/lib/miniui/themes/default/miniui.css">
+<link rel="stylesheet" href="../script/lib/layui/css/layui.css" />
+<link rel="stylesheet" href="../script/lib/cashier/common.css">
+<link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/miniui/miniui.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+</head>
+<body style="background: #F6F7F9;">
+<div class="main">
+<form class="layui-form" lay-filter="form">
+    <div class="layui-row">
+        <div class="main_left layui-col-xs12 layui-col-md3">
+            <div class="layui-row">
+                <div class="top">
+                    <i class="layui-icon layui-icon-app"></i>商品列表
+                </div>
+                <div class="left_main">
+                    <input id="key" class="mini-textbox" onenter="onKeyEnter" value="请输入商品名称" onclick="setVal('key')"/>
+                    <a class="mini-button" onclick="search()">查询</a> 
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="addGoods()">一键添加</button>
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="delGoods()">一键删除</button>
+                    <ul id="tree1" class="mini-tree" url="<{$url}>" showTreeIcon="true" textField="name" idField="id" expandOnLoad="true" onNodeClick="onNodeClick">
+                    </ul>
+                </div>
+            </div>
+        </div>
+        <div class="main_right layui-col-xs12 layui-col-md9">
+            <div class="layui-row">
+                <div class="top">
+                    <div class="layui-input-inline" style="margin-left:20px">
+                        <input id="search_key" class="mini-textbox" value="请输入商品名称" onclick="setVal('search_key')"/>
+                        <a class="mini-button" onclick="searchGoods()">搜索</a> 
+                    </div>
+                </div>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <!--<th lay-data="{field:'id'}" width="15%">商品编码</th>-->
+                                <th lay-data="{field:'name'}" width="15%">商品名称</th>
+                                <{if($type == 1):}>
+                                <th lay-data="{field:'price', edit: 'text'}" width="10%">原销售价</th>
+                                <th lay-data="{field:'price', edit: 'text'}" width="10%">销售调价</th>
+                                <th lay-data="{field:'price', edit: 'text'}" width="10%">新销售价</th>
+
+                                <th lay-data="{field:'buy_price', edit: 'text'}" width="10%">原采购价</th>
+                                <th lay-data="{field:'buy_price', edit: 'text'}" width="10%">采购调价</th>
+                                <th lay-data="{field:'buy_price', edit: 'text'}" width="10%">新采购价</th>
+
+                                <{else:}>
+                                <th lay-data="{field:'price', edit: 'text'}" width="15%">原销售价</th>
+                                <th lay-data="{field:'price', edit: 'text'}" width="15%">新销售价</th>
+                                <th lay-data="{field:'buy_price', edit: 'text'}" width="15%">原采购价</th>
+                                <th lay-data="{field:'buy_price', edit: 'text'}" width="15%">新采购价</th>
+                                <{endif;}>
+                                <th lay-data="{field:'operation'}" width="15%">操作</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认设置">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    var goods = {};
+    var del_goods = {};
+    var tree = {};
+    var type = "<{$type}>";
+    var num = "<{$num}>";
+    layui.config(
+    {
+        base: '../script/lib/layui/admin/' //静态资源所在路径
+        ,version: true
+    }).extend(
+    {
+        index: 'lib/index', //主入口模块
+        formSelects: 'plugin/formselects/formselects'
+    }).use(['index', 'contlist', 'table', 'form', 'formSelects','layer'], function()
+    {
+        var table = layui.table;
+        form = layui.form; 
+        var formSelects = layui.formSelects;
+
+        mini.parse();
+        tree = mini.get("tree1");
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if(tree.data[i].children[j].select == 1) {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else if(tree.data[i].select == 1) {
+                    setGoods(tree.data[i]);
+                }
+            }
+        }
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var price_rule_id = '<{$price_rule_id}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {price_rule_id:price_rule_id, goods:goods_string};
+                $.post(url, data, function(t) {
+                    t = JSON.parse(t);
+                    if (t.status == 1) {
+                        layui.layer.alert('商品设置成功', function(index){
+                          if (t.data == 'refer') {
+                                history.back();
+                            } else {
+                                location.href = t.data;
+                            }
+                          layer.close(index);
+                        });
+                    } else {
+                        layui.layer.alert(t.msg);
+                    }
+                });
+            });
+        });
+
+        $("#goods").on("keyup", ".goods_price", function() {
+        	var num = $(this).find('input').val();
+            var id = $(this).parent().attr('value');
+            goods[id].price = num;
+            setTotal();
+
+            goods[id].new_price = getPrice(goods[id].old_price, goods[id].price);
+            $(this).parent().find('.goods_new_price').html(goods[id].new_price);
+        });
+
+        $("#goods").on("keyup", ".goods_buy_price", function() {
+        	var num = $(this).find('input').val();
+            var id = $(this).parent().attr('value');
+            goods[id].buy_price = num;
+            setTotal();
+
+            goods[id].new_buy_price = getPrice(goods[id].old_buy_price, goods[id].buy_price);
+            $(this).parent().find('.goods_new_buy_price').html(goods[id].new_buy_price);
+        });
+    })
+
+    function onNodeClick()
+    {
+        var tree=mini.get("tree1");
+        node=tree.getSelectedNode();
+        if(node.end) {
+            setGoods(node);
+        }
+    }
+
+    function setVal(e)
+    {
+        mini.get(e).setValue('');
+    }
+
+    function searchGoods() 
+    {
+        var key = mini.get("search_key").getValue();
+
+        if (key == "") {
+            $(".mytr").show();
+        } else {
+            key = key.toLowerCase(); 
+            $(".mytr").show();               
+            $(".goods_name").each(function(t) {
+                var name = $(this).html();
+                name = name.toLowerCase(); 
+                if (name.indexOf(key) == -1) {
+                    $(this).parent().hide();
+                }
+            });
+        }
+    }
+
+    // 一键添加
+    function addGoods()
+    {
+        var key = mini.get("key").getValue();
+        if (key == '请输入商品名称') {
+            key = '';
+        }
+        if (key) {
+            key = key.toLowerCase();
+        }
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if (key) {
+                            var name = tree.data[i].children[j].name;
+                            if (name.indexOf(key) != -1) {
+                                setGoods(tree.data[i].children[j]);
+                            }
+                        } else {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else {
+                    if (key) {
+                        var name = tree.data[i].name;
+                        if (name.indexOf(key) != -1) {
+                            setGoods(tree.data[i]);
+                        }
+                    } else {
+                        setGoods(tree.data[i]);
+                    }
+                }
+            }
+        }
+    }
+
+    // 一键删除
+    function delGoods()
+    {
+        if (confirm('确定删除吗?')) {
+            var key = mini.get("key").getValue();
+            if (key == '请输入商品名称') {
+                key = '';
+            }
+            if (key) {
+                key = key.toLowerCase();
+            }
+            for (var i in tree.data) {
+                if (typeof(tree.data[i].children) == 'object') {
+                    if (tree.data[i].children.length > 0) {
+                        for (var j in tree.data[i].children) {
+                            if (key) {
+                                var name = tree.data[i].children[j].name;
+                                if (name.indexOf(key) != -1) {
+                                    unsetGoods(tree.data[i].children[j]);
+                                }
+                            } else {
+                                unsetGoods(tree.data[i].children[j]);
+                            }
+                        }
+                    } else {
+                        if (key) {
+                            var name = tree.data[i].name;
+                            if (name.indexOf(key) != -1) {
+                                unsetGoods(tree.data[i]);
+                            }
+                        } else {
+                            unsetGoods(tree.data[i]);
+                        }
+                    }
+                }
+            }
+            setTotal();
+        }
+    }
+
+    function unsetGoods(node)
+    {
+        if (node.id) {
+            if (goods[node.id]) {
+                goods[node.id].del = 2;
+                goods[node.id].num = 0;
+                goods[node.id].total = 0;
+                get(node.id).remove();
+            }
+        }
+    }
+
+    function setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
+                goods[key] = node;
+                goods[key].type = parseInt(goods[key].type);
+                goods[key].total = parseFloat(goods[key].total);
+                goods[key].min = goods[key].min ? parseFloat(goods[key].min) : 1;
+                goods[key].num = 0;
+                goods[key].del = 1;
+                create(node);
+                setTotal();
+            } else if(node.type < 4) {
+                add(key);
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var select = '';
+
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'" value="'+node.id+'">';
+            //addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>';
+            addtr += '<td class="goods_old_price">'+node.old_price+'</td>'; 
+            addtr += '<td class="goods_price"><span><input type="text" value="'+node.price+'" class="layui-input"></span></td>'; 
+            if (type == 1) {
+                node.new_price = getPrice(node.old_price, node.price);
+                addtr += '<td class="goods_new_price">'+node.new_price+'</td>'; 
+            }
+            addtr += '<td class="goods_old_buy_price">'+node.old_buy_price+'</td>'; 
+            addtr += '<td class="goods_buy_price"><span><input type="text" value="'+node.buy_price+'" class="layui-input"></span></td>'; 
+            if (type == 1) {
+                node.new_buy_price = getPrice(node.old_buy_price, node.buy_price);
+                addtr += '<td class="goods_new_buy_price">'+node.new_buy_price+'</td>'; 
+            }
+            
+            addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+                                  
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+            form.render();
+            //$('.goods_price_template').change();
+        }
+    }
+
+    function getPrice(price, num)
+    {
+        if (num.indexOf('%') > -1) {
+            num = num.replace('%', '');
+            price = parseFloat(price) + parseFloat(parseFloat(price) * (num/100));
+        } else {
+            // 数字
+            price = parseFloat(price) + parseFloat(num);
+        }
+
+        price = price.toFixed(2);
+
+        return price;
+    }
+
+    function del(id)
+    {
+        if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            goods[id].num = 0;
+            get(id).remove();
+            setTotal();
+        }
+    }
+
+    function setTotal()
+    {
+    	return;
+    }
+
+    function add(id)
+    {
+        
+    }
+
+</script>
+</body>
+</html>

+ 310 - 0
module/scm_product/database/category.php

@@ -0,0 +1,310 @@
+<?php
+
+$status = array
+(
+	1 => '启用',
+	2 => '不启用',
+);
+
+return array
+(
+	# 表名
+	'name' => 'category',
+	# 显示给用户看的名称
+	'lang' => '属性分类',
+	# 是否显示在后台菜单
+	'order' => 300,
+
+	'end' => array
+	(
+		'insert' => 'scm_product/lib/manage.updateCategory',
+		'update' => 'scm_product/lib/manage.updateCategory',
+	),
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '分类名称',
+			'default' 	=> '',
+			'desc' 		=> '分类名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'parent'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '上级分类',
+			'default' 	=> Dever::input('option_parent', -1),
+			'desc' 		=> '请选择上级分类',
+			'match' 	=> 'option',
+			'update'	=> 'linkage',
+			'linkage' 	=> 'id=' . Dever::input('where_id'),
+			'option'	=> Dever::url('lib/category.get', 'scm_product'),
+			//'list'		=> 'Dever::load("scm_product/api.string", "{parent}")',
+		),
+
+		'parent_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '上级分类',
+			'default' 	=> -1,
+			'desc' 		=> '请选择上级分类',
+			'match' 	=> 'option',
+			'value'		=> Dever::input('option_parent_id', -1),
+			//'list'		=> '{parent_id} > 0 ? Dever::load("scm_product/category-one#name", {parent_id}) : "父级分类"',
+			'list_name'	=> '属性',
+			'list'		=> 'Dever::load("scm_product/lib/attr.getInfoByCate", {id})',
+		),
+
+		'top_parent_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '顶级分类',
+			'default' 	=> -1,
+			'desc' 		=> '请选择顶级分类',
+			'match' 	=> 'is_numeric',
+		),
+
+		'scm_product-category_attr'=> array
+		(
+			'name' 		=> '属性设置',
+			'default' 	=> '',
+			'desc' 		=> '请先选择属性分类',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'category_id'),
+			# 根据category字段的值,获取scm_product/attr.search接口的内容
+			'update'	=> array(1),
+		),
+
+		'level'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类级别-1为顶级分类、2为2级分类,-1为最后一级分类',
+			'default' 	=> 1,
+			'desc' 		=> '分类级别',
+			'match' 	=> 'is_numeric',
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '分类标识-该标识一般为前台样式名称,选填项',
+			'default' 	=> '',
+			'desc' 		=> '标识',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+			'tab'		=> 1,
+		),
+
+		'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('新增子分类', '"{parent}" == -1 ? "category&option_parent={id}" : "category&option_parent={parent},{id}"'),
+
+			'list' => array('属性设置', '"category_attr&search_option_category_id={id}&oper_table=category"'),
+		),
+	),
+
+	'request' => array
+	(
+		'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'id,name,parent_id',
+        ),
+
+		# 获取顶级分类
+		'getTop' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'name' => array('yes', 'like'),
+                'id' => 'yes',
+				'parent_id' => -1,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => '*,name as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+
+		'getChild' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'parent_id' => 'yes',
+				'top_parent_id' => 'yes',
+				'level' => 'yes',
+				'parent_id_in' => array('yes-parent_id', 'in'),
+				'id' => array('yes', '!='),
+				'parent' => array('yes', 'like'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => '*|parent_id|',
+		),
+
+		'getList' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'parent_id' => 'yes',
+				'top_parent_id' => 'yes',
+				'level' => 'yes',
+				'parent_id_in' => array('yes-parent_id', 'in'),
+				'id' => array('yes', '!='),
+				'parent' => array('yes', 'like'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => '*',
+		),
+
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'parent_id' => 'yes',
+				'id' => array('yes', '!='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'asc'),
+			'col' => 'id as value, name',
+		),
+	)
+);

+ 446 - 0
module/scm_product/database/category_attr.php

@@ -0,0 +1,446 @@
+<?php
+
+$col = 'id,name,is_must,`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 => '选填项',
+);
+
+$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,
+	'end' => array
+    (
+        'insert' => 'scm_product/lib/manage.updateAttr',
+        'update' => 'scm_product/lib/manage.updateAttr',
+    ),
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'desc',
+			'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',
+			'value'		=> Dever::input('search_option_category_id'),
+			//'list'		=> '{category_id} > 0 ? Dever::load("scm_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,
+			'edit'		=> true,
+			'tab'		=> 0,
+		),
+
+		'type'	  => array
+		(
+			'type' 		=> 'tinyint-11',
+			'name' 		=> '录入类型-配置录入类型后可以在商品录入时进行属性设置',
+			'default' 	=> '1',
+			'desc' 		=> '录入类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+			//'search'	=> 'select',
+			//'list'		=> true,
+			'control'	=> 'type',
+			'tab'		=> 0,
+		),
+
+        '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',
+			'tab'		=> 0,
+		),
+
+		'match'		=> array
+		(
+			'type' 		=> 'varchar-600',
+			'name' 		=> '正则匹配规则-直接输入正则表达式即可',
+			'default' 	=> '',
+			'desc' 		=> '正则匹配规则',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+			'show'		=> array('data_type' => 3),
+			'tab'		=> 0,
+		),
+
+		'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,
+			'tab'		=> 2,
+		),
+
+		'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,
+			'tab'		=> 2,
+		),
+
+		'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,
+			'tab'		=> 2,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '标识-该标识一般为前台样式名称,选填项',
+			'default' 	=> '',
+			'desc' 		=> '标识',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+			'tab'		=> 1,
+		),
+
+		'unit'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '单位-填写属性单位,选填项',
+			'default' 	=> '',
+			'desc' 		=> '单位',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'tab'		=> 1,
+		),
+
+		'icon'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '图标-属性图标,选填项',
+			'default' 	=> '',
+			'desc' 		=> '图标',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key'		=> 1,
+			'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,
+		),
+		
+		'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,unit',
+		'tab' => array('基本配置', '扩展设置', '排序规则'),
+
+		'insert' => false,
+        'edit' => false,
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+
+		# 列表
+		'list_button' => array
+		(
+			'fast' => array('编辑'),
+
+			'list1' => array('属性值设置', '"category_attr_value&search_type=4&search_option_category_id={category_id}&search_option_attr_id={id}&oper_table=category_attr&top_table=category"' , '{type} > 9'),
+			'list2' => array('搜索值设置', '"category_attr_search&search_type=4&search_option_attr_id={id}&search_option_category_id={category_id}&oper_table=category_attr&top_table=category"' , '{type} == 1 || {type} == 9'),
+		),
+	),
+
+	'request' => array
+	(
+		'getOne' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'one',
+			'col' => 'id,type,unit,name,icon as front_icon,color as front_color,bgcolor as front_bgcolor',
+		),
+
+		'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',
+		),
+
+		'getCateAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'category_id' => array('yes', 'in'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('list_reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
+
+		/*
+		'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' => '*',
+		),
+		*/
+	)
+);

+ 144 - 0
module/scm_product/database/category_attr_search.php

@@ -0,0 +1,144 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'category_attr_search',
+    # 显示给用户看的名称
+    'lang' => '搜索值设置',
+    # 是否显示在后台菜单
+    'order' => 9,
+    'menu'  => false,
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+
+        'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类',
+			'default' 	=> '-1',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_category_id'),
+		),
+
+        'attr_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '属性id',
+            'default'   => '1',
+            'desc'      => '属性id',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_attr_id'),
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '搜索名称-如设置为100万以下',
+            'default'   => '',
+            'desc'      => '搜索名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'value'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '搜索值-直接输入要搜索的值即可,也可以设置为公式,如{v}<=100,{v}为当前值,如果是区间输入框,则{s}为区间最小值,{e}为区间最大值',
+            'default'   => '',
+            'desc'      => '搜索值',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+            'search'    => 'fulltext',
+            '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,value',
+
+        'insert' => false,
+        'edit' => false,
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+        # 列表
+        'list_button' => array
+        (
+            'fast' => array('编辑'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'ids' => array('yes-id', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+    )
+);

+ 153 - 0
module/scm_product/database/category_attr_value.php

@@ -0,0 +1,153 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'category_attr_value',
+    # 显示给用户看的名称
+    'lang' => '属性值设置',
+    # 是否显示在后台菜单
+    'order' => 9,
+    'menu'  => false,
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+
+        'category_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类',
+			'default' 	=> '-1',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_category_id'),
+		),
+
+        'attr_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '属性id',
+            'default'   => '1',
+            'desc'      => '属性id',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_attr_id'),
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '属性值名称-如绿色',
+            'default'   => '',
+            'desc'      => '属性值名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'value'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '属性具体值-如上述名称为绿色,这里可以是绿色的色值,选填项,可以为空',
+            'default'   => '',
+            'desc'      => '属性具体值',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+        ),
+
+        'icon'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图标-选填项',
+            'default'   => '',
+            'desc'      => '图标',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => 1,
+        ),
+
+        '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',
+
+        'insert' => false,
+        'edit' => false,
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+        # 列表
+        'list_button' => array
+        (
+            'fast' => array('编辑'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'attr_id' => 'yes',
+                'ids' => array('yes-id', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => 'id,attr_id,name,value,icon,concat(attr_id, "-", id) as price_key|id',
+        ),
+    )
+);

+ 664 - 0
module/scm_product/database/info.php

@@ -0,0 +1,664 @@
+<?php
+
+$status = array
+(
+	1 => '上架',
+	2 => '下架',
+);
+
+$id = Dever::input('where_id');
+
+$unit = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/unit-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$type = array
+(
+	1 => '实物商品',
+	2 => '虚拟商品',//虚拟商品可以通过分类设置
+	//3 => '功能商品',//对应道具市场
+	11 => '套餐商品',
+	12 => '组合商品',
+);
+
+$pay_type = array
+(
+	1 => '货币支付',
+	2 => '积分支付',
+);
+
+$commission_type = array
+(
+	1 => '货币账户',
+	2 => '积分账户',
+);
+
+$account = function()
+{
+	$array = array();
+	$data = Dever::load('account/config-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 => '不可采购',
+);
+$stock = array
+(
+	1 => '是',
+	2 => '否',
+);
+$config = array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '商品资料',
+	'order' => 200,
+	'auto' => 10000000,
+	'set' => array
+	(
+		'status' => $status,
+	),
+
+	'start' => array
+    (
+        'insert' => 'scm_product/lib/manage.check',
+        'update' => 'scm_product/lib/manage.check',
+    ),
+
+	'end' => array
+	(
+		'insert' => 'scm_product/lib/manage.infoUpdate',
+		'update' => 'scm_product/lib/manage.infoUpdate',
+	),
+
+	# 同步更新另外一个或多个表的数据,将数据同步到关联表中
+	'sync' => array
+	(
+		'scm_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' 		=> '商品编码',
+			'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,
+		),
+
+		'unit'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '商品单位',
+			'default' 	=> '',
+			'desc' 		=> '商品单位',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'select',
+			'lang'		=> '请选择',
+			'update'	=> 'select',
+			'option'	=> $unit,
+			'option_add' => array('[添加新单位]', 'scm_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' => 'scm_product/lib/manage.searchProduct?{id}',
+                ),
+
+                array
+                (
+                    'col'       => 'num',
+                    'name'      => '数量',
+                    'default'   => '1',
+                    'desc'      => '数量',
+                    'match'     => 'is_string',
+                    'update'    => 'text',
+                ),
+            ),
+            'tab'		=> 1,
+        ),
+
+        'stock'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否有库存',
+            'default'   => '1',
+            'desc'      => '是否有库存',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $stock,
+            '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_type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '支付方式-使用哪种方式购买该商品',
+			'default' 	=> '1',
+			'desc' 		=> '支付类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $pay_type,
+			'search'	=> 'select',
+			//'list'		=> true,
+			'tab'		=> 1,
+			//'control'	=> 'pay_type',
+		),
+
+		'commission'		=> array
+		(
+			'type' 		=> 'varchar-20',
+			'name' 		=> '销售商佣金-设置佣金之后,销售商销售了商品,能得到的相应佣金,也可以在销售商里单独设置,填写10%就是销售价的百分之10,直接填写数字就是佣金数额,填0就是无佣金,填负数会扣减佣金账户',
+			'default' 	=> '0',
+			'desc' 		=> '销售商佣金',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'tab'		=> 1,
+		),
+
+		'commission_type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '佣金账户类型-设置获取佣金的账户类型',
+			'default' 	=> '1',
+			'desc' 		=> '佣金类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $commission_type,
+			'search'	=> 'select',
+			//'list'		=> true,
+			'tab'		=> 1,
+			'control'	=> 'commission_type',
+		),
+
+		'commission_account_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '货币账户',
+			'default' 	=> '',
+			'desc' 		=> '货币账户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $account,
+			'tab'		=> 1,
+			'show'		=> 'commission_type=1',
+		),
+
+		'commission_score_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '积分账户',
+			'default' 	=> '',
+			'desc' 		=> '积分账户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $score,
+			'tab'		=> 1,
+			'show'		=> 'commission_type=2',
+		),
+
+		'category'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '属性分类',
+			'default' 	=> '',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_string',
+			'search'	=> 'linkage',
+			//'update'	=> $id ? false : 'linkage',
+			'update'	=> 'linkage',
+			'option'	=> Dever::url('lib/category.get?type=1', 'scm_product'),
+			//'update'	=> 'radio',
+			//'option'	=> Dever::db('scm_product/category')->select(),
+			'list'		=> 'Dever::load("scm_product/lib/category.string", "{category}")',
+			'load'		=> 'scm_product-info_attr',
+			'tab'		=> 2,
+		),
+
+		'scm_product-info_attr'=> array
+		(
+			'name' 		=> '属性设置',
+			'default' 	=> '',
+			'desc' 		=> '请先选择属性分类',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'info_id'),
+			# 根据category字段的值,获取scm_product/attr.search接口的内容
+			'update'	=> 'load',
+			'update_load' => array('scm_product/lib/attr.getManageByCate', 'category'),
+			'tab'		=> 2,
+		),
+
+		'scm_product-info_spec'=> array
+		(
+			'name' 		=> '规格设置-成本价为平台进货成本价格,采购价为销售商采购商品价格,销售价为用户购买价格,划线价为用户购买价的划线价格',
+			'default' 	=> '',
+			'desc' 		=> '规格设置',
+			'match' 	=> 'option',
+			'sync'		=> array('id', 'info_id'),
+			'update'	=> 'sku',
+			'tab'		=> 3,
+		),
+
+		'spec_type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '规格类型',
+			'default' 	=> '1',
+			'desc' 		=> '规格类型',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> array(1 => '单规格', 2 => '多规格'),
+		), 
+
+		# 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
+		'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',
+		),
+
+		'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
+		(
+			'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' 		=> '',
+			'search'	=> 'date',
+		),
+
+		'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
+	(
+		# 定义sku对应的表,不填写则默认为info_spec和info_sku
+		'sku' => array
+		(
+			# 定义表名
+			'spec' => 'info_spec', 
+			'sku' => 'info_sku',
+			# 定义字段
+			'col' => array
+			(
+				'pic' => array('name' => '图片', 'verify' => 'string', 'type' => 'image'),
+				'code' => array('name' => '商品编码', 'verify' => 'string', 'type' => 'input'),
+				'price' => array('name' => '销售价', 'verify' => 'number', 'type' => 'input'),
+				'un_price' => array('name' => '划线价', 'verify' => 'number', 'type' => 'input'),
+				'cost_price' => array('name' => '成本价', 'verify' => 'number', 'type' => 'input'),
+				'buy_price' => array('name' => '采购价', 'verify' => 'number', 'type' => 'input'),
+			),
+			# 接口
+			'api' => array
+			(
+				'spec' => 'scm_product/lib/spec.get',
+				'sku' => 'scm_product/lib/sku.get',
+				# 上传接口
+				'upload' => 'upload/save.start?key=1',
+			),
+		),
+		'tab' => 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}"'),
+
+			'list' => array('规格', '"info_sku
+				&project=goods
+				&search_option_info_id={id}
+				&oper_parent=info&oper_project=goods
+				&oper_save_jump=info&page_type=1"'),
+		),*/
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		# 后台搜索用到,也可以不加,自动生成
+		'search' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'name' => array('yes', 'like'),
+				'id_no' => array('yes-id', '!='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'limit' => '0,10',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled,spec_type|id',
+		),
+
+		# 列表
+		'getData' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'category' => array('yes', 'like'),
+				'top_category_id' => array('yes', 'in'),
+				'second_category_id' => 'yes',
+				'category_id' => 'yes',
+				'status' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
+
+		# 列表
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'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',
+				'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' => '*',
+		),
+
+		'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,cdate',
+        ),
+	),
+);
+
+return $config;

+ 142 - 0
module/scm_product/database/info_attr.php

@@ -0,0 +1,142 @@
+<?php
+$config = array
+(
+	# 表名
+	'name' => 'info_attr',
+	# 显示给用户看的名称
+	'lang' => '属性规格',
+	'order' => 100,
+	'menu' => false,
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'order'		=> 'asc',
+            'update'    => 'hidden',
+		),
+
+		'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'attr_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '属性id',
+            'default'   => '',
+            'desc'      => '属性id',
+            'match'     => 'is_numeric',
+        ),
+
+        'attr_value'      => array
+        (
+            'type'      => 'varchar-3000',
+            'name'      => '属性值',
+            'default'   => '',
+            'desc'      => '属性值',
+            'match'     => 'is_string',
+        ),
+
+        '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,
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'search' => 'info_id,attr_id,attr_value',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		# 分页
+		'getPageAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'audit' => array('yes-t_2.audit', 2),
+				'category' => array('yes-t_2.category', 'like'),
+				'top_category_id' => array('yes-t_2.top_category_id'),
+				'second_category_id' => array('yes-t_2.second_category_id'),
+				'category_id' => array('yes-t_2.category_id'),
+				'state' => array('yes-t_2.state', 1),
+			),
+			# 联表
+			'join' => array
+			(
+				array
+				(
+					'table' => 'res/info',
+					'type' => 'left join',
+					'on' => array('info_id','id'),
+					'col' => 'info_id',
+				),
+			),
+			'type' => 'all',
+			'order' => array('t_1.id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		),
+
+		'getDataByInfoId' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('id' => 'desc'),
+			'col' => '*|attr_id',
+		),
+	),
+);
+
+return $config;

+ 65 - 0
module/scm_product/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
module/scm_product/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,
+	),
+);

+ 215 - 0
module/scm_product/database/info_sku.php

@@ -0,0 +1,215 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'info_sku',
+    # 显示给用户看的名称
+    'lang' => '商品SKU设置',
+    'order' => 200,
+    'menu' => false,
+    //'check' => 'code',
+
+    # 数据结构 不同的字段放这里
+    '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-500',
+            'name'      => '规格id',
+            'default'   => '',
+            'desc'      => '规格id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '商品条码',
+            'default'   => '',
+            'desc'      => '商品条码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '商品图',
+            'default'   => '',
+            'desc'      => '商品图',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'price'     => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '销售价',
+            'default'   => '',
+            'desc'      => '销售价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'un_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '划线价',
+            'default'   => '',
+            'desc'      => '划线价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'buy_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '采购价',
+            'default'   => '',
+            'desc'      => '采购价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'cost_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '成本价',
+            'default'   => '',
+            'desc'      => '成本价',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => 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})',
+        ),
+    ),
+
+    'index' => array
+    (
+        1 => array
+        (
+            # 索引名 => 索引id 如果有后缀.unique,则为建立索引的类型,如id,state.unique
+            'info' => 'info_id,`key`',
+        ),
+        
+        # 版本号 更改版本号会更新当前表的索引
+        'version' => 1,
+    ),
+
+    '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('id' => 'desc'),
+            'limit' => '0,10',
+            'col' => 'key as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+
+        # 列表
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*|key',
+        ),
+
+        # 列表
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => 'id,`key`,code,pic,price,un_price,buy_price,cost_price|key',
+        ),
+    ),
+);
+
+return $config;

+ 143 - 0
module/scm_product/database/info_spec.php

@@ -0,0 +1,143 @@
+<?php
+
+$col = 'id,info_id,`key`,price,s_price,code';
+
+$config = array
+(
+	# 表名
+	'name' => 'info_spec',
+	# 显示给用户看的名称
+	'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,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '规格名称',
+			'default' 	=> '',
+			'desc' 		=> '规格名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越小越靠前',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'asc',
+			'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})',
+		),
+	),
+
+	'index' => array
+    (
+        1 => array
+        (
+            # 索引名 => 索引id 如果有后缀.unique,则为建立索引的类型,如id,state.unique
+            'info' => 'info_id',
+        ),
+        
+        # 版本号 更改版本号会更新当前表的索引
+        'version' => 1,
+    ),
+
+	'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'num' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'自定义属性' => array('fast', 1, 'config&where_id=1'),
+        ),
+    ),
+
+    # request 请求接口定义
+	'request' => array
+	(
+		# 列表
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'asc', 'id' => 'asc'),
+			'col' => 'id, name as title',
+		),
+
+		# 列表
+		'getData' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'asc', 'id' => 'asc'),
+			'col' => 'id, name',
+		),
+	),
+);
+
+return $config;

+ 184 - 0
module/scm_product/database/info_spec_value.php

@@ -0,0 +1,184 @@
+<?php
+
+$option = array
+(
+	1 => '选中',
+	2 => '未选中',
+);
+$config = array
+(
+	# 表名
+	'name' => 'info_spec_value',
+	# 显示给用户看的名称
+	'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,
+		),
+
+		'spec_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '规格ID',
+			'default' 	=> '',
+			'desc' 		=> '规格ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'value'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '规格值',
+			'default' 	=> '',
+			'desc' 		=> '规格值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'is_checked'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否选中',
+			'default' 	=> '1',
+			'desc' 		=> '是否选中',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $option,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越小越靠前',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'asc',
+			'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})',
+		),
+	),
+
+	'index' => array
+    (
+        1 => array
+        (
+            # 索引名 => 索引id 如果有后缀.unique,则为建立索引的类型,如id,state.unique
+            'info' => 'info_id',
+        ),
+        
+        # 版本号 更改版本号会更新当前表的索引
+        'version' => 1,
+    ),
+
+	'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'num' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'自定义属性' => array('fast', 1, 'config&where_id=1'),
+        ),
+    ),
+
+    # request 请求接口定义
+	'request' => array
+	(
+		# 列表
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'spec_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'asc', 'id' => 'asc'),
+			'col' => 'id, value as title, case is_checked when 1 then true else false end as checked',
+		),
+
+		'getGroupData' => 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',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'spec_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => 'id,value as name',
+        ),
+	),
+);
+
+return $config;

+ 124 - 0
module/scm_product/database/price.php

@@ -0,0 +1,124 @@
+<?php
+$goods = array
+(
+	1 => '所有商品',
+	2 => '部分商品',
+);
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+$status = array
+(
+	1 => '有效',
+	2 => '失效',
+);
+$type = array
+(
+	1 => '统一调价',
+	2 => '手动调价',
+);
+$time = array
+(
+	1 => '长期有效',
+	2 => '短期有效',
+);
+return array
+(
+	# 表名
+	'name' => 'price',
+	# 显示给用户看的名称
+	'lang' => '价格模板',
+	'info' => '在商品中设置的价格是默认价格,如果一个SKU想设置不同的价格,则可以通过价格模板设置',
+	# 是否显示在后台菜单
+	'order' => 9,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '模板名称',
+			'default' 	=> '',
+			'desc' 		=> '模板名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'scm_product-price_rule'=> array
+		(
+			'name' 		=> '策略设置',
+			'default' 	=> '',
+			'desc' 		=> '策略设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'price_id'),
+			# 根据category字段的值,获取scm_product/attr.search接口的内容
+			'update'	=> array(1),
+		),
+		
+		'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,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	//'edit' => array('编辑'),
+        	'list' => array('策略管理', 'price_rule&oper_table=price&search_option_price_id={id}'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 243 - 0
module/scm_product/database/price_rule.php

@@ -0,0 +1,243 @@
+<?php
+$goods = array
+(
+	1 => '所有商品',
+	2 => '部分商品',
+);
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+$status = array
+(
+	1 => '有效',
+	2 => '失效',
+);
+$type = array
+(
+	1 => '统一调价',
+	2 => '手动改价',
+);
+$time = array
+(
+	1 => '长期有效',
+	2 => '短期有效',
+);
+return array
+(
+	# 表名
+	'name' => 'price_rule',
+	# 显示给用户看的名称
+	'lang' => '价格模板策略',
+	# 是否显示在后台菜单
+	'order' => 9,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'price_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属价格模板',
+            'default'   => '',
+            'desc'      => '所属价格模板',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_price_id'),
+            'list'      => 'Dever::load("scm_product/price-one#name", {price_id})',
+        ),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '策略名称',
+			'default' 	=> '',
+			'desc' 		=> '策略名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+        'category'		=> array
+		(
+			'type' 		=> 'varchar-2000',
+			'name' 		=> '影响分类-如不选择就是影响所有商品',
+			'default' 	=> '',
+			'desc' 		=> '模板影响分类',
+			'match' 	=> 'is_string',
+			'update'	=> 'checkbox',
+			'option'	=> $category,
+		),
+
+		'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '调价规则-手动调价需要在配置商品中进行手动调整',
+            'default'   => '1',
+            'desc'      => '调价规则',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+            'control'	=> 'type',
+        ),
+
+        'sell_num'		=> array
+		(
+			'type' 		=> 'varchar-30',
+			'name' 		=> '销售调价数值-直接输入数字就是统一调价的增减数值,负数就是减少,如果是百分比,就带上%号即可,如10%,模板下的商品将统一进行加价或者减价',
+			'default' 	=> '',
+			'desc' 		=> '销售调价数值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'type=1',
+		),
+
+		'buy_num'		=> array
+		(
+			'type' 		=> 'varchar-30',
+			'name' 		=> '采购调价数值-直接输入数字就是统一调价的增减数值,负数就是减少,如果是百分比,就带上%号即可,如10%,模板下的商品将统一进行加价或者减价',
+			'default' 	=> '',
+			'desc' 		=> '采购调价数值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'type=1',
+		),
+
+		'day'		=> array
+		(
+			'type' 		=> 'varchar-30',
+			'name' 		=> '临期天数-填写该天数,如果商品有保质期,在小于等于该天数的时间内,将是不同的价格,为0则不验证保质期',
+			'default' 	=> '0',
+			'desc' 		=> '临期天数',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'time'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '模板有效期',
+            'default'   => '1',
+            'desc'      => '模板有效期',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $time,
+            'list'		=> true,
+            'control'	=> 'time',
+        ),
+
+        'time_start'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '开始时间',
+			'default'   => '',
+			'match' 	=> 'is_numeric',
+			'desc' 		=> '开始时间',
+			'update'	=> 'date',
+			'show'		=> 'time=2',
+		),
+
+		'time_end'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '结束时间',
+			'default'   => '',
+			'match' 	=> 'is_numeric',
+			'desc' 		=> '结束时间',
+			'update'	=> 'date',
+			'show'		=> 'time=2',
+		),
+
+		'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否有效',
+            'default'   => '1',
+            'desc'      => '是否有效',
+            'match'     => 'is_numeric',
+            //'update'    => 'radio',
+            'option'    => $status,
+            '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,
+		),
+		
+		'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,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	//'edit' => array('编辑'),
+        	'location' => array('配置商品', Dever::url('lib/price.setGoods', 'scm_product')),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 187 - 0
module/scm_product/database/price_rule_sku.php

@@ -0,0 +1,187 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'price_rule_sku',
+    # 显示给用户看的名称
+    'lang' => '价格模板单价设置',
+    'order' => 200,
+    'menu' => false,
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.skuUpdate',
+        'update' => 'scm_role/lib/seller.skuUpdate',
+    ),
+    */
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'price_rule_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属价格策略',
+            'default'   => '',
+            'desc'      => '所属价格策略',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_price_rule_id'),
+            'list'      => 'Dever::load("scm_product/price_rule-one#name", {price_rule_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'price'     => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '销售价',
+            'default'   => '',
+            'desc'      => '销售价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'buy_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '采购价',
+            'default'   => '',
+            'desc'      => '采购价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 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,
+        //'excel' => array(array('导出门店库存', '门店库存', '')),
+        'page_list_table' => 'sku',
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'price_id' => array('yes-t_1.price_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
+            'page' => array(30, 'list'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'price_id' => array('yes-t_1.price_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id',
+        ),
+    ),
+);
+
+return $config;

+ 86 - 0
module/scm_product/database/unit.php

@@ -0,0 +1,86 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'unit',
+	# 显示给用户看的名称
+	'lang' => '单位管理',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '单位名称',
+			'default' 	=> '',
+			'desc' 		=> '单位名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'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
+	(
+		
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 8 - 0
module/scm_product/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'scm_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');
+include(DEVER_APP_PATH . '../boot.php');

+ 536 - 0
module/scm_product/lib/Attr.php

@@ -0,0 +1,536 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Attr
+{
+	public function test_api()
+	{
+		$url = 'http://192.168.33.10/sellking/package/scm/module/scm_product/?l=lib/attr.getManageByCate&json=1';
+
+		$data = Dever::curl($url, array('id' => 10000), 'post');
+
+		print_r($data);die;
+	}
+	/**
+	 * 根据分类id,获取属性更新信息,用于后台
+	 *
+	 * @return mixed
+	 */
+	public function getManageByCate_api()
+	{
+		$id = Dever::input('id');
+		$data = array();
+		if ($id) {
+			$data = Dever::db('scm_product/info_attr')->getDataByInfoId(array('info_id' => $id));
+		}
+
+		$where['category_id'] = Dever::input('category', 2);
+		$attr = Dever::db('scm_product/category_attr')->getCateAll($where);
+		if (!$attr) {
+			return '';
+		}
+		$config = array();
+
+		$this->setDatabaseConfig($attr, $config, $data);
+
+		$data = array();
+
+		$result = Dever::load('manage/database')->update_struct($config, false, $data, -1, 'scm_product-info_attr-', true);
+
+		return implode('', $result);
+	}
+
+	/**
+	 * 根据分类id,获取所有属性
+	 *
+	 * @return mixed
+	 */
+	public function getInfoByCate($cate_id)
+	{
+		$where['category_id'] = $cate_id;
+		$data = Dever::db('scm_product/category_attr')->select($where);
+		if ($data) {
+			$name = array();
+			foreach ($data as $k => $v) {
+				$name[] = $v['name'];
+			}
+			return implode('、', $name);
+		}
+		return '';
+	}
+
+	/**
+	 * 根据json格式获取信息
+	 *
+	 * @return mixed
+	 */
+	public function getInfoByJson($data)
+	{
+		$result = array();
+
+		$string = array();
+
+		foreach ($data as $k => $v) {
+
+			$info = Dever::db('scm_product/category_attr')->find($v['attr_id']);
+			$result[$k]['id'] = $info['id'];
+			$result[$k]['name'] = $info['name'];
+
+			if ($v['id']) {
+				$attr = Dever::db('scm_product/category_attr_value')->find($v['id']);
+				if ($attr) {
+					$result[$k]['value_id'] = $attr['id'];
+					$result[$k]['value_name'] = $attr['name'];
+					$string[] = $result[$k]['value_name'];
+				}
+			}
+		}
+
+		return array('data' => $result, 'string' => implode(',', $string));
+	}
+
+	/**
+	 * 获取属性详细信息,有类别
+	 *
+	 * @return mixed
+	 */
+	public function getInfo($id, $value)
+	{
+		$info = Dever::db('scm_product/category_attr')->getOne($id);
+        if ($info) {
+        	$info['value'] = $value;
+        	$info = $this->getValue($info);
+        }
+
+		return $info;
+	}
+
+	/**
+	 * 获取属性的值
+	 *
+	 * @return mixed
+	 */
+	public function getValue($info)
+	{
+		# 地区
+		if ($info['type'] == 7) {
+			$info['value'] = Dever::load("area/api.string", $info['value']);
+			/*
+			$info['value'] = explode(',', $info['value']);
+			$temp = end($info['value']);
+			$info['value'] = $temp;
+			*/
+		} elseif ($info['type'] == 9 && $info['value']) {
+			$info['value'] = explode(',', $info['value']);
+			$info['value'] = $info['value'][0] . $info['unit'];
+		} elseif ($info['type'] > 9 && $info['value']) {
+			$value = Dever::db('scm_product/category_attr_value')->getData(array('ids' => $info['value']));
+			if ($value) {
+				$name = array();
+				foreach ($value as $k => $v) {
+					$name[] = $v['name'] . $info['unit'];
+				}
+				$info['value'] = implode(',', $name);
+			}
+		} elseif ($info['unit']) {
+			$info['value'] = $info['value'] . $info['unit'];	
+		}
+		unset($info['unit']);
+		return $info;
+	}
+
+	/**
+	 * 设置数据库的结构信息
+	 *
+	 * @return mixed
+	 */
+	public function setDatabaseConfig($attr, &$config, $data = array())
+	{
+		if ($attr) {
+			foreach ($attr as $k => $v) {
+				if ($v['type'] == 9) {
+
+					$k = 'attr_' . $v['id'] . '_s';
+					$config['struct'][$k]['name'] = $v['name'];
+					$config['struct'][$k]['default'] = '';
+					$config['struct'][$k]['desc'] = $v['name'];
+					$config['struct'][$k]['update'] = 'hidden';
+					$config['struct'][$k]['type'] = 'varchar-800';
+					$config['struct'][$k]['match'] = 'is_numeric';
+
+					$k = 'attr_' . $v['id'] . '_e';
+					$config['struct'][$k]['name'] = $v['name'];
+					$config['struct'][$k]['default'] = '';
+					$config['struct'][$k]['desc'] = $v['name'];
+					$config['struct'][$k]['update'] = 'hidden';
+					$config['struct'][$k]['type'] = 'varchar-800';
+					$config['struct'][$k]['match'] = 'is_numeric';
+				}
+
+				$k = 'attr_' . $v['id'];
+				$config['struct'][$k] = array();
+				/*
+				$option = array();
+				if ($v['type_option']) {
+					$v['type_option'] = explode("\n", $v['type_option']);
+					foreach ($v['type_option'] as $k1 => $v1) {
+						$option[$k1+1] = $v1;
+					}
+				}*/
+				$option = Dever::db('scm_product/category_attr_value')->getData(array('attr_id' => $v['id']));
+
+				$config['struct'][$k]['name'] = $v['name'];
+				$config['struct'][$k]['default'] = '';
+				$config['struct'][$k]['desc'] = $v['name'];
+
+				switch ($v['type']) {
+					case 3:
+						$config['struct'][$k]['update'] = 'textarea';
+						$config['struct'][$k]['search'] = 'fulltext';
+						$config['struct'][$k]['type'] = 'varchar-800';
+						$config['struct'][$k]['match'] = 'is_string';
+						break;
+					case 4:
+						$config['struct'][$k]['type'] = 'text-255';
+						$config['struct'][$k]['update'] = 'editor';
+						$config['struct'][$k]['match'] = 'is_string';
+						$config['struct'][$k]['key'] = 1;
+					case 5:
+						$config['struct'][$k]['update'] = 'image';
+						$config['struct'][$k]['type'] = 'varchar-150';
+						$config['struct'][$k]['match'] = 'is_string';
+						$config['struct'][$k]['key'] = 1;
+						break;
+					case 6:
+						$config['struct'][$k]['update'] = 'images';
+						$config['struct'][$k]['type'] = 'text-255';
+						$config['struct'][$k]['match'] = 'is_string';
+						$config['struct'][$k]['key'] = 1;
+						break;
+					case 7:
+						$config['struct'][$k]['type'] = 'varchar-800';
+						$config['struct'][$k]['match'] = 'is_string';
+						$config['struct'][$k]['update'] = 'linkage';
+						$config['struct'][$k]['search'] = 'linkage';
+						$config['struct'][$k]['option'] = Dever::url('area/api.get');
+						//$config['struct'][$k]['list'] = 'Dever::load("area/api.string", "{area}")';
+						break;
+
+					case 10:
+						$config['struct'][$k]['update'] = 'radio';
+						$config['struct'][$k]['type'] = 'varchar-800';
+						$config['struct'][$k]['match'] = 'is_numeric';
+						$config['struct'][$k]['option'] = $option;
+						$config['struct'][$k]['search'] = 'select';
+						$config['struct'][$k]['default'] = '';
+
+						break;
+					case 11:
+						$config['struct'][$k]['update'] = 'checkbox';
+						$config['struct'][$k]['type'] = 'varchar-800';
+						$config['struct'][$k]['match'] = 'is_string';
+						$config['struct'][$k]['option'] = $option;
+						$config['struct'][$k]['search'] = 'select';
+						$config['struct'][$k]['default'] = '';
+						break;
+					case 12:
+						$config['struct'][$k]['update'] = 'select';
+						$config['struct'][$k]['type'] = 'varchar-800';
+						$config['struct'][$k]['match'] = 'is_numeric';
+						$config['struct'][$k]['option'] = $option;
+						$config['struct'][$k]['search'] = 'select';
+						$config['struct'][$k]['default'] = '';
+						break;
+					
+					default:
+						$config['struct'][$k]['update'] = 'text';
+						$config['struct'][$k]['search'] = 'fulltext';
+						if ($v['type'] == 9) {
+							$config['struct'][$k]['name'] .= '-这是一个区间数值,后台填写请用半角逗号,隔开';
+							$config['struct'][$k]['type'] = 'varchar-800';
+							$config['struct'][$k]['match'] = 'is_string';
+						} elseif ($v['data_type'] == 1 || $v['type'] == 1) {
+							$config['struct'][$k]['type'] = 'varchar-800';
+							$config['struct'][$k]['match'] = 'is_numeric';
+						} else {
+							$config['struct'][$k]['type'] = 'varchar-800';
+							$config['struct'][$k]['match'] = 'is_string';
+						}
+				}
+
+				if ($v['is_must'] && $v['is_must'] == 2) {
+					$config['struct'][$k]['match'] = 'option';
+				}
+
+				/*
+				if ($v['value']) {
+					$config['struct'][$k]['default'] = $v['value'];
+				}*/
+				if ($data && isset($data[$v['id']])) {
+					$config['struct'][$k]['default'] = $data[$v['id']]['attr_value'];
+				}
+
+				if ($v['state'] == 2) {
+					unset($config['struct'][$k]['update']);
+				}
+
+				# 还要根据搜索来建立索引,另外,如果数据结构改了怎么办。暂时用varchar
+			}
+		}
+	}
+
+	/**
+	 * 根据属性id,获取属性列表
+	 *
+	 * @return mixed
+	 */
+	public function getList($ids, $value, $order = 'list')
+	{
+		$data = array();
+		if ($ids) {
+			$where['ids'] = $ids;
+			$method = 'getAllByIds';
+			if ($order == 'list') {
+				$method = 'getListByIds';
+			} elseif ($order == 'search') {
+				$method = 'getSearchByIds';
+			} elseif ($order == 'search_reorder') {
+				$method = 'getSearchByIds';
+				$where['search_reorder'] = 1;
+			} elseif ($order == 'view') {
+				$method = 'getViewByIds';
+			}
+			$data = Dever::db('scm_product/category_attr')->$method($where);
+
+			$ids = explode(',', $ids);
+			$value = explode(',', $value);
+			if ($data) {
+				foreach ($ids as $k => $v) {
+					if (isset($data[$v])) {
+						if (isset($value) && isset($value[$k]) && $value[$k]) {
+							$data[$v]['value'] = $value[$k];
+						} else {
+							$data[$v]['value'] = '';
+						}
+					}
+				}
+			}
+		}
+
+		return $data;
+	}
+
+	/**
+	 * 获取属性的名称,字符类型
+	 *
+	 * @return mixed
+	 */
+	public function string($ids, $value = '')
+	{
+		$result = $this->getInfo($ids, $value);
+
+		$table = array();
+		foreach ($result as $k => $v) {
+			$table[$v['name']] = '';
+			foreach ($v['attr'] as $k1 => $v1) {
+				$table[$v['name']] .= $v1['name'] . "&nbsp;&nbsp;";
+			}
+		}
+
+		return Dever::table($table);
+	}
+
+
+
+	private function attrSort(&$attr, $reorder = 'list_reorder')
+	{
+		if ($reorder == 'list') {
+			$reorder = 'list_reorder';
+		}
+		$order = Dever::config('base')->attrOrder;
+		if ($order && $order != $reorder) {
+			$reorder = $order;
+		}
+		if ($attr) {
+			foreach ($attr as $k => $v) {
+				$sort[$k] = $v[$reorder];
+				$attr[$k]['option'] = Dever::db('scm_product/category_attr_value')->getData(array('attr_id' => $v['id']));
+				/*
+				if ($v['type_option']) {
+                    $attr[$k]['option'] = explode("\n", $v['type_option']);
+                }
+                */
+			}
+			array_multisort($sort, SORT_DESC, $attr);
+		}
+	}
+
+	public function getAttrByCate($category, $order = 'list_reorder', $total = false)
+	{
+		$data = array();
+		//print_r(Dever::db('category/attr')->all());
+		if ($category && Dever::project('category')) {
+			$array = explode(',', $category);
+			$cate = array();
+			$total = $total ? $total : count($array);
+			$total -= 1;
+			foreach ($array as $k => $v) {
+				$cate[$k] = $v;
+				if ($k < $total) {
+					$cate[] = '-1';
+				}
+				$where['category'] = $cate;
+				$info = Dever::db('category/attr')->one($where);
+				if ($info) {
+					$data += Dever::load('attr/api')->getList($info['attr'], $info['attr_input'], $order);
+				}
+			}
+			$this->attrSort($data, $order);
+		}
+
+		return $data;
+	}
+
+	/**
+	 * 获取某个分类下的搜索列表
+	 *
+	 * @return mixed
+	 */
+	public function getSearch($ids, $cate = true, $city = false, $search_value = false, $total = 3)
+	{
+		$value = array();
+		$search_value = Dever::preInput('attr_', array(), $search_value);
+
+		if ($cate && $ids && Dever::project('category')) {
+			$data = $this->getAttrByCate($ids, 'search_reorder', $total);
+			if (!$data) {
+				return array('search' => array(), 'value' => $value);
+			}
+		} else {
+			$where['ids'] = $ids;
+			$where['search_reorder'] = 1;
+			$data = Dever::db('scm_product/category_attr')->getSearchByIds($where);
+		}
+
+		if ($data) {
+			foreach ($data as $k => $v) {
+				if (isset($ids_input[$v['id']]) && $ids_input[$v['id']]) {
+					$data[$k]['name'] = $ids_input[$v['id']];
+				}
+				$data[$k]['key'] = 'attr_' . $v['id'];
+				if ($v['type'] == 7 && $city > 0) {
+					# 获取地区,获取最后一个级别的地区
+					$data[$k]['option'] = Dever::db('area/county')->state(array('city_id' => $city));
+				} elseif ($v['type'] == 1 || $v['type'] == 9) {
+					$data[$k]['option'] = Dever::db('scm_product/category_attr_search')->getData(array('attr_id' => $v['id']));
+				} else {
+					$data[$k]['option'] = Dever::db('scm_product/category_attr_value')->getData(array('attr_id' => $v['id']));
+				}
+				/*
+				elseif ($v['type_option']) {
+					$temp = explode("\n", $v['type_option']);
+					foreach ($temp as $k1 => $v1) {
+						$v1 = explode(',', $v1);
+						$k1 = $k1+1;
+						$data[$k]['option'][$k1] = array
+						(
+							'id' => $k1,
+							'name' => $v1[0],
+						);
+						if (isset($v1[1])) {
+							$data[$k]['option_match'][$k1] = $v1[1];
+						}
+					}
+				}
+				*/
+
+				if (isset($search_value[$data[$k]['key']])) {
+					$data[$k]['option_value'] = $search_value[$data[$k]['key']];
+					$value[$data[$k]['key']] = $data[$k]['option_value'];
+				}
+			}
+		}
+		
+
+		return array('search' => $data, 'value' => $value);
+	}
+
+	/**
+	 * 获取搜索sql
+	 *
+	 * @return mixed
+	 */
+	public function getSql($attr, $where, $sql = array(), $tname = 't_1')
+	{
+		if (!$attr) {
+			return $sql;
+		}
+		foreach ($attr as $k => $v) {
+            $key = 'attr_' . $v['id'];
+            if (isset($where[$key]) && $where[$key]) {
+                //$where['option'][$key] = array('yes', '=');
+                if ($v['type'] == 7) {
+                    # 地区有点复杂,暂时先这样,后续优化一下
+                    $county = Dever::db('area/county')->one($where[$key]);
+                    if ($county) {
+                        $city = Dever::db('area/city')->one($county['city_id']);
+                        if ($city) {
+                            $province = Dever::db('area/province')->one($city['province_id']);
+                            if ($province) {
+                                $value = $province['id'] . ',' . $city['id'] . ',' . $county['id'];
+                                //$where[$key] = $value;
+                                $sql[] = ' '.$tname.'.'.$key.' = "'.$value.'"';
+                            }
+                        }
+                    }
+                //} elseif ($v['type'] == 1 && $v['type_option']) {
+                } elseif ($v['type'] == 1) {
+
+                	$search = Dever::db('scm_product/category_attr_search')->getData(array('attr_id' => $v['id']));
+                	//print_r($where[$key]);die;
+                	/*
+                    $temp = explode("\n", $v['type_option']);
+                    if (isset($temp[$where[$key]-1])) {
+                        $temp = explode(',', $temp[$where[$key]-1]);
+                        $match = $temp[1];
+
+                        //$where['option'][$key] = array('yes', '<=');
+                        //$where[$key] = 100;
+
+                        $match = str_replace('{v}', $tname . '.' . $key, $match);
+                        $sql[] = $match;
+                    }
+                    */
+                //} elseif ($v['type'] == 9 && $v['type_option']) {
+                } elseif ($v['type'] == 9 && $v['type_option']) {
+
+                	$search = Dever::db('scm_product/category_attr_search')->getData(array('attr_id' => $v['id']));
+                	//print_r($where[$key]);die;
+
+                	/*
+                    $temp = explode("\n", $v['type_option']);
+                    if (isset($temp[$where[$key]-1])) {
+                        $temp = explode(',', $temp[$where[$key]-1]);
+                        $match = $temp[1];
+
+                        //$where['option'][$key] = array('yes', '<=');
+                        //$where[$key] = 100;
+
+                        $match = str_replace('{s}', $tname . '.' . $key . '_s', $match);
+                        $match = str_replace('{e}', $tname . '.' . $key . '_e', $match);
+                        $match = str_replace('{v}', $tname . '.' . $key . '_e', $match);
+                        $sql[] = $match;
+                    }
+                    */
+                } else {
+                    $sql[] = ' '.$tname.'.'.$key.' = "'.$where[$key].'"';
+                }
+            }
+        }
+
+        return $sql;
+	}
+}

+ 213 - 0
module/scm_product/lib/Category.php

@@ -0,0 +1,213 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Category
+{
+    private $default = array
+    (
+        'value' => -1,
+        'name' => '不选择',
+    );
+
+    private $search_default = array
+    (
+        'value' => -1,
+        'name' => '分类',
+    );
+
+	/**
+     * 获取分类数据
+     *
+     * @return mixed
+     */
+    public function get_api()
+    {
+        # 关闭语言包
+        Dever::config('base')->lang = false;
+        
+        # 联动总数
+        $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['parent_id'] = -1;
+        } elseif($level_id > 0) {
+            $where['parent_id'] = $level_id;
+        }
+
+        if (isset($where['parent_id'])) {
+            $data = Dever::db('scm_product/category')->getAll($where);
+        }
+
+        /*
+        $type = Dever::input('type');
+        if ($data) {
+            if ($type && $type == 1) {
+                if ($level_num == 1) {
+                    array_unshift($data, $default);
+                }
+            } else {
+                array_unshift($data, $default);
+            }
+        }*/
+
+        if ($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()
+    {
+        $where = array();
+        $result = Dever::db('scm_product/category')->getTop($where);
+        return $result;
+    }
+
+    /**
+     * 获取所有信息
+     *
+     * @return mixed
+     */
+    public function getAll($parent = false)
+    {
+        $where = array();
+        if ($parent) {
+            $where['parent_id'] = $parent;
+        }
+        $result = Dever::db('scm_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('scm_product/category')->getOne($id);
+            if ($state) {
+                return $data;
+            }
+            if ($data) {
+                $name = $data['name'];
+            }
+        }
+        return $name;
+    }
+
+    # 根据上级分类获取下级分类 按照category_id进行索引
+    public function getChild($parent_id)
+    {
+        if (is_numeric($parent_id)) {
+            $where['parent_id'] = $parent_id;
+        } else {
+            $where['parent_id_in'] = $parent_id;
+        }
+        
+        $data = Dever::db('scm_product/category')->getChild($where);
+
+        return $data;
+    }
+
+    # 根据上级分类获取下级分类 
+    public function getList($parent_id)
+    {
+        if (is_numeric($parent_id)) {
+            $where['parent_id'] = $parent_id;
+        } else {
+            $where['parent_id_in'] = $parent_id;
+        }
+        
+        $data = Dever::db('scm_product/category')->getList($where);
+
+        return $data;
+    }
+
+    # 根据顶级分类获取最低级的分类
+    public function getChildByTop($top_parent_id, $level = -1)
+    {
+        $where['top_parent_id'] = $top_parent_id;
+        $where['level'] = $level;
+        $data = Dever::db('scm_product/category')->getList($where);
+
+        return $data;
+    }
+}

+ 297 - 0
module/scm_product/lib/Info.php

@@ -0,0 +1,297 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Info
+{
+    # 获取商品列表
+    public function getList()
+    {
+    	
+    }
+
+    # 获取商品详情
+    public function getInfo($id, $type = 1)
+    {
+        # type == 1 是销售商品 2是采购商品
+        $info = is_array($id) ? $id : Dever::db('scm_product/info')->getOne($id);
+
+        if (!$info) {
+            Dever::alert('商品信息不存在');
+        }
+
+        $info = $this->get($info, $type);
+
+        return $info;
+    }
+
+    private function get($info, $type = 1)
+    {
+        # 基本信息
+        $info['udate'] = date('Y-m-d H:i', $info['udate']);
+        $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
+
+        # 获取分类
+        $info['category_info'] = Dever::load('scm_product/lib/category')->getInfo($info['category']);
+
+        # 获取属性
+        $attr = Dever::db('scm_product/info_attr')->select(array('info_id' => $info['id']));
+        if ($attr) {
+            foreach ($attr as $k => $v) {
+                $attr_info = Dever::load('scm_product/lib/attr')->getInfo($v['attr_id'], $v['attr_value']);
+                if ($attr_info) {
+                    $info['attr'][] = $attr_info;
+                }
+            }
+        }
+
+        # 获取规格
+        $info['spec'] = Dever::load('scm_product/lib/spec')->getData($info['id'], 'getData');
+
+        # 获取价格
+        $info['sku'] = Dever::load('scm_product/lib/sku')->getData($info['id'], false, $type);
+
+        # 获取组合商品
+        if ($info['type'] > 10) {
+            $info['goods'] = Dever::json_decode($info['goods']);
+        } else {
+            unset($info['goods']);
+        }
+
+        # 获取单位信息
+        if ($info['unit'] > 0) {
+            $info['unit'] = Dever::db('scm_product/unit')->find($info['unit']);
+        }
+
+        return $info;
+    }
+
+    # 获取商品及其属性列表
+    public function getSetList($table, $other_where, $cate_id = false, $col = 'goods_id', $set = array(), $price_id = -1, $source = '')
+    {
+        $price = Dever::input('price', 0);
+        $buy_price = Dever::input('buy_price', 0);
+        $total = Dever::input('total', 1);
+        if ($cate_id) {
+            $where['top_category_id'] = $cate_id;
+        }
+        $where['status'] = 1;
+
+        if (!$source) {
+            $source = 'scm_product/info';
+        }
+        $data = Dever::db($source)->getData($where);
+
+        $result = array();
+        if ($data) {
+            $i = 0;
+            foreach ($data as $k => $v) {
+                
+                $sku = Dever::db('scm_product/info_sku')->select(array('info_id' => $v['id']));
+
+                if ($sku) {
+                    $other = array();
+                    if ($table) {
+                        $other_where[$col] = $v['id'];
+                        $other_where['sku_id'] = -1;
+                        $other = Dever::db($table)->find($other_where);
+                    }
+                    
+                    if ($set) {
+                        $result[$i]['set'] = $set;
+                    }
+                    
+                    $result[$i]['id'] = $v['id'];
+                    $result[$i]['name'] = $v['name'];
+                    $result[$i]['type'] = $v['type'];
+                    $result[$i]['stock'] = $v['stock'];
+                    $result[$i]['commission'] = $v['commission'];
+                    $result[$i]['sell_type'] = $v['sell_type'];
+                    $result[$i]['buy_type'] = $v['buy_type'];
+
+                    $result[$i]['old_price'] = 0;
+                    $result[$i]['old_buy_price'] = 0;
+
+                    $result[$i]['price'] = $price ? $price : $sku[0]['price'];
+                    $result[$i]['buy_price'] = $buy_price ? $buy_price : $sku[0]['buy_price'];
+                    $result[$i]['select'] = 2;
+                    $result[$i]['del'] = 1;
+                    $result[$i]['total'] = isset($v['total']) ? $v['total'] : 0;
+
+                    if ($price_id > 0 && $sku[0]['key'] == -1) {
+                        list($result[$i]['price'], $result[$i]['buy_price']) = Dever::load('scm_product/lib/price')->get($price_id, $v, $sku[0], $result[$i]['price'], $result[$i]['buy_price']);
+                    }
+                    
+                    if ($other) {
+                        if (isset($other['commission']) && $other['commission']) {
+                            $result[$i]['commission'] = $other['commission'];
+                        }
+                        if (isset($other['price']) && $other['price']) {
+                            $result[$i]['price'] = $other['price'];
+                        }
+                        if (isset($other['buy_price']) && $other['buy_price']) {
+                            $result[$i]['buy_price'] = $other['buy_price'];
+                        }
+                        if (isset($other['min']) && $other['min']) {
+                            $result[$i]['min'] = $other['min'];
+                        }
+                        if (isset($other['in_num'])) {
+                            if (isset($other['out_num'])) {
+                                $result[$i]['total'] = $other['in_num'] - $other['out_num'];
+                            } else {
+                                $result[$i]['total'] = $other['in_num'];
+                            }
+                            
+                        } elseif (isset($other['num'])) {
+                            $result[$i]['total'] = $other['num'];
+                        }
+                        
+                        $result[$i]['select'] = $other['state'];
+                    }
+
+                    $result[$i]['total'] = $result[$i]['total'] * $total;
+                    $result[$i]['children'] = array();
+                    $num = count($sku);
+                    if ($sku[0]['key'] == -1) {
+                        $result[$i]['id'] .= '-' . $sku[0]['id'];
+                        $result[$i]['old_price'] = $sku[0]['price'];
+                        $result[$i]['old_buy_price'] = $sku[0]['buy_price'];
+
+                        if (!$price && $result[$i]['price'] <= 0) {
+                            $result[$i]['price'] = $sku[0]['price'];
+                        }
+                        if (!$buy_price && $result[$i]['buy_price'] <= 0) {
+                            $result[$i]['buy_price'] = $sku[0]['buy_price'];
+                        }
+                        
+                        //$result[$i]['id'] .=  '-' . $sku[0]['id'];
+                        $result[$i]['end'] = true;
+                    } else {
+                        foreach ($sku as $k1 => $v1) {
+                            $v1['sku_name'] = '';
+                            if ($v1['key']) {
+
+                                $key = str_replace('-', ',', $v1['key']);
+                                $spec = Dever::db('scm_product/info_spec_value')->getGroupData(array('ids' => $key));
+
+                                $v1['sku_name'] = $spec['name'];
+                            }
+
+                            $name = $v['name'];
+                            if ($v1['sku_name']) {
+                                $name .= '-' . $v1['sku_name'];
+                            }
+
+                            $children = array
+                            (
+                                'id' => $v['id'] . '-' . $v1['id'],
+                                'name' => $name,
+                                'stock' => $v['stock'],
+                                'commission' => $v['commission'],
+                                'sell_type' => $v['sell_type'],
+                                'buy_type' => $v['buy_type'],
+                                'old_price' => $v1['price'] ? $v1['price'] : 0,
+                                'old_buy_price' => $v1['buy_price'] ? $v1['buy_price'] : 0,
+                                'price' => $price ? $price : $v1['price'],
+                                'buy_price' => $buy_price ? $buy_price : $v1['buy_price'],
+                                'type' => $v['type'],
+                                'del' => 1,
+                                'end' => true,
+                                'total' => 0,
+                            );
+                            $other_sku = array();
+                            if ($table) {
+                                $other_where['sku_id'] = $v1['id'];
+                                $other_sku = Dever::db($table)->find($other_where);
+                            }
+
+                            $children['select'] = 2;
+                            $children['total'] = 0;
+                            if ($set) {
+                                $children['set'] = $set;
+                            }
+                            if ($price_id > 0) {
+                                list($children['price'], $children['buy_price']) = Dever::load('scm_product/lib/price')->get($price_id, $v, $v1, $children['price'], $children['buy_price']);
+                            }
+                            if ($other_sku) {
+                                if (isset($other_sku['commission']) && $other_sku['commission']) {
+                                    $children['commission'] = $other_sku['commission'];
+                                }
+                                if (isset($other_sku['price']) && $other_sku['price']) {
+                                    $children['price'] = $other_sku['price'];
+                                }
+                                if (isset($other_sku['buy_price']) && $other_sku['buy_price']) {
+                                    $children['buy_price'] = $other_sku['buy_price'];
+                                }
+                                if (isset($other_sku['min']) && $other_sku['min']) {
+                                    $children['min'] = $other_sku['min'];
+                                }
+                                if (isset($other_sku['in_num'])) {
+                                    if (isset($other_sku['out_num'])) {
+                                        $children['total'] = $other_sku['in_num'] - $other_sku['out_num'];
+                                    } else {
+                                        $children['total'] = $other_sku['in_num'];
+                                    }
+                                } elseif (isset($other_sku['num'])) {
+                                    $children['total'] = $other_sku['num'];
+                                }
+                                
+                                $children['select'] = $other_sku['state'];
+                            }
+
+                            $children['total'] = $children['total']*$total;
+                            $result[$i]['children'][] = $children;
+                        }
+                    }
+                    $i++;
+                }
+            }
+        }
+
+        return $result;
+    }
+
+    # 获取支付所需要的信息
+    public function getPayInfo($id, $sku = 0, $seller_id = false)
+    {
+        $info = is_array($id) ? $id : Dever::db('scm_product/info')->one($id);
+
+        if ($info) {
+            # 最小购买数1
+            $info['min'] = 1;
+            $sku = $sku > 0 ? $sku : -1;
+            $info['sku_id'] = $sku;
+            if ($sku > 0) {
+                $where['info_id'] = $info['id'];
+                $where['id'] = $sku;
+                $sku = Dever::db('scm_product/info_sku')->find($where);
+                if ($sku) {
+                    if ($seller_id) {
+                        $seller = Dever::db('scm_role/seller')->find($seller_id);
+                        if ($seller) {
+                            list($sku['price'], $sku['buy_price']) = Dever::load('scm_product/lib/price')->get($seller['price_id'], $info, $sku, $sku['price'], $sku['buy_price']);
+                        }
+                    }
+                    $info['price'] = $sku['price'];
+                    $info['buy_price'] = $sku['buy_price'];
+                }
+            }
+            /*
+            $info['freight_id'] = 0;
+            $info['freight_price'] = 0;
+            $freight = $this->freight($info, $info['price'], $user, $num);
+            if ($freight) {
+                $info['freight_id'] = $freight['id'];
+                $info['freight_price'] = $freight['price'];
+            }
+            */
+
+            # 佣金计算
+            //$info['reward'] = $this->reward($info, $info['price']*$num);
+        }
+
+        return $info;
+    }
+}

+ 116 - 0
module/scm_product/lib/Manage.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function check($id,$name,$data)
+    {
+        //Dever::alert('reload');
+    }
+
+    /**
+     * 更新信息
+     *
+     * @return mixed
+     */
+    public function infoUpdate($id, $name, $data)
+    {
+        # 更新分类id
+        $category = Dever::param('category', $data);
+        if ($category) {
+            if (is_array($category)) {
+                $category_id = end($category);
+                $top_category_id = $category[0];
+                if (isset($category[1])) {
+                    $second_category_id = $category[1];
+                } else {
+                    $second_category_id = $category[0];
+                }
+                
+            } else {
+                $category_id = $category;
+                $top_category_id = $category;
+                $second_category_id = $category;
+            }
+
+            $update['top_category_id'] = $top_category_id;
+            $update['second_category_id'] = $second_category_id;
+            $update['category_id'] = $category_id;
+        }
+
+        if (isset($update)) {
+            $update['where_id'] = $id;
+            Dever::db('scm_product/info')->update($update);
+        }
+    }
+
+    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('scm_product/category')->one(array('category_id' => $id));
+            if (!$child) {
+                $update['level'] = -1;
+            }
+            Dever::db('scm_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('scm_product/category')->update($update);
+        }
+    }
+
+    /**
+     * 更新属性信息
+     *
+     * @return mixed
+     */
+    public function updateAttr($id, $name, $data)
+    {
+        return;
+        $is_sell = Dever::param('is_sell', $data);
+        if ($is_sell > 1) {
+            $update['type'] = 11;
+        }
+        if (isset($update)) {
+            $update['where_id'] = $id;
+            Dever::db('scm_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('scm_product/info', $where);
+        if ($data) {
+            $old = $data;
+            $data = array();
+            foreach ($old as $k => $v) {
+                Dever::load('scm_product/lib/sku')->getList($v, $data);
+            }
+        }
+
+        return $data;
+    }
+}

+ 132 - 0
module/scm_product/lib/Price.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Price
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取价格模板信息
+    public function get($price_id, $product, $sku, $price, $buy_price)
+    {
+        # 暂时未增加临期价格
+
+        if ($price_id <= 0) {
+            return array($price, $buy_price);
+        }
+        $time = time();
+        $template = Dever::db('scm_product/price')->find($price_id);
+
+        if ($template) {
+
+            $rule = Dever::db('scm_product/price_rule')->select(array('price_id' => $template['id'], 'status' => 1));
+            if ($rule) {
+                foreach ($rule as $k => $v) {
+                    $get = false;
+                    if ($v['time'] == 1) {
+                        $get = true;
+                    } elseif ($v['time'] == 2 && $time >= $v['time_start'] && $time <= $v['time_end']) {
+                        $get = true;
+                    }
+                    if ($get) {
+                        $info = Dever::db('scm_product/price_rule_sku')->find(array('price_rule_id' => $v['id'], 'goods_id' => $product['id'], 'sku_id' => $sku['id']));
+                        if ($info) {
+                            $price = Dever::per($price, $info['price']);
+                            $buy_price = Dever::per($buy_price, $info['buy_price']);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+
+        return array($price, $buy_price);
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $price_rule_id = Dever::input('price_rule_id', 1);
+        $goods_category = Dever::input('goods_category');
+        $where['price_rule_id'] = $price_rule_id;
+        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList('scm_product/price_rule_sku', $where, $goods_category));
+    }
+
+    # 配置商品
+    public function setGoods_api()
+    {
+        $data = array();
+        $data['price_rule_id'] = Dever::input('id', 1);
+        $price = Dever::db('scm_product/price_rule')->find($data['price_rule_id']);
+        $goods_category = '';
+        $data['type'] = 1;
+        $data['sell_num'] = $data['sell_num'] = 0;
+        if ($price) {
+            $goods_category = $price['category'];
+            $data['type'] = $price['type'];
+            $data['sell_num'] = $price['sell_num'];
+            $data['buy_num'] = $price['buy_num'];
+        }
+        
+        $data['host'] = Dever::url('lib/price.setGoods', 'scm_product');
+        $data['url'] = Dever::url('lib/price.goods?price_rule_id=' . $data['price_rule_id'] . '&goods_category=' . $goods_category . '&price=' . $data['sell_num'] . '&buy_price=' . $data['buy_num'], 'scm_product');
+        $data['submit'] = Dever::url('lib/price.setGoods_action_commit?json=1', 'scm_product');
+
+        return Dever::render('set_price_goods', $data);
+    }
+
+    # 配置商品
+    public function setGoods_action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $price_rule_id = Dever::input('price_rule_id');
+
+        $shop = Dever::db('scm_product/price')->one($price_rule_id);
+        $where['option_price_rule_id'] = $price_rule_id;
+        $where['set_state'] = 2;
+        Dever::db('scm_product/price_rule_sku')->updates($where);
+
+        foreach ($goods as $k => $v) {
+            if ($v['del'] == 1) {
+            	$temp = explode('-', $k);
+	            $goods_id = $temp[0];
+	            $sku_id = -1;
+	            if (isset($temp[1])) {
+	                $sku_id = $temp[1];
+	            }
+
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['sku_id'] = $sku_id;
+                $w['price_rule_id'] = $price_rule_id;
+                $sku_info = Dever::db('scm_product/price_rule_sku')->one($w);
+
+                $w['status'] = $goods_info['status'];
+                if (isset($v['price']) && $v['price']) {
+                    $w['price'] = $v['price'];
+                }
+                if (isset($v['buy_price']) && $v['buy_price']) {
+                    $w['buy_price'] = $v['buy_price'];
+                }
+                if (!$sku_info) {
+                    Dever::db('scm_product/price_rule_sku')->insert($w);
+                } else {
+                    $w['where_id'] = $sku_info['id'];
+                    $w['state'] = 1;
+                    Dever::db('scm_product/price_rule_sku')->update($w);
+                }
+            }
+        }
+        return 'refer';
+    }
+}

+ 79 - 0
module/scm_product/lib/Sku.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Sku
+{
+    # 获取当前的sku
+    public function get_api()
+    {
+    	$id = Dever::input('id');
+    	$result = array();
+    	if ($id) {
+    		$result = Dever::db('scm_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('scm_product/info_sku')->select($where);
+            if ($sku) {
+                foreach ($sku as $k => $v) {
+                    $copy = $info;
+                    $key = str_replace('-', ',', $v['key']);
+                    $spec = Dever::db('scm_product/info_spec_value')->getGroupData(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;
+    }
+
+    # 获取基本信息列表
+    public function getData($info_id, $sku_id = false, $type = 1)
+    {
+        $seller_id = Dever::input('seller_id');
+        if ($seller_id) {
+            $seller = Dever::db('scm_role/seller')->find($seller_id);
+        }
+        $where['info_id'] = $info_id;
+        if ($sku_id) {
+            $where['id'] = $sku_id;
+        }
+        $sku = Dever::db('scm_product/info_sku')->getData($where);
+        if ($sku) {
+            foreach ($sku as $k => $v) {
+                unset($sku[$k]['key']);
+                if ($seller_id && $seller) {
+                    list($sku[$k]['price'], $sku[$k]['buy_price']) = Dever::load('scm_product/lib/price')->get($seller['price_id'], array('id' => $info_id), $v, $sku[$k]['price'], $sku[$k]['buy_price']);
+                }
+                
+                if ($type == 1) {
+                    unset($sku[$k]['buy_price']);
+                    unset($sku[$k]['cost_price']);
+                } elseif ($type == 2) {
+                    unset($sku[$k]['price']);
+                    unset($sku[$k]['un_price']);
+                }
+            }
+        }
+        return $sku;
+    }
+}

+ 30 - 0
module/scm_product/lib/Spec.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Spec
+{
+    # 获取当前的规格
+    public function get_api()
+    {
+    	$id = Dever::input('id');
+    	return $this->getData($id);
+    }
+
+    # 获取基本信息列表
+    public function getData($info_id, $method = 'getAll')
+    {
+        $result = array();
+    	if ($info_id) {
+    		$result = Dever::db('scm_product/info_spec')->$method(array('info_id' => $info_id));
+    		if ($result) {
+    			foreach ($result as $k => $v) {
+    				$result[$k]['child'] = Dever::db('scm_product/info_spec_value')->$method(array('info_id' => $info_id, 'spec_id' => $v['id']));
+    			}
+    		}
+    	}
+    	return $result;
+    }
+}

+ 22 - 0
module/scm_product/lib/Unit.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace Scm_product\Lib;
+
+use Dever;
+
+class Unit
+{
+    # 添加新单位
+    public function add_api()
+    {
+    	$where['name'] = Dever::input('value');
+    	if (!$where['name']) {
+    		Dever::alert('请输入单位名称');
+    	}
+        $info = Dever::db('scm_product/unit')->find($where);
+        if (!$info) {
+        	$info['id'] = Dever::db('scm_product/unit')->insert($where);
+        }
+        return $info;
+    }
+}

+ 27 - 0
module/scm_product/src/Seller.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace Scm_product\Src;
+
+use Dever;
+
+class Seller
+{
+    public function __construct()
+    {
+        $this->seller_id = Dever::input('seller_id', 1);
+    }
+
+    # 获取销售商信息
+    public function seller()
+    {
+        $data['shop'] = Dever::db('scm_role/seller')->find($this->seller_id);
+
+        return $data;
+    }
+
+    # 获取商品列表
+    public function getGoods()
+    {
+        return Dever::load('scm_role/lib/seller')->getGoods($this->seller_id);
+    }
+}

+ 437 - 0
module/scm_role/assets/pc/html/buy_seller_goods.html

@@ -0,0 +1,437 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
+<meta name="author" content="siweiyong 2602812659@qq.com"/>
+<title>设置商品</title>
+<link rel="stylesheet" href="../script/lib/miniui/themes/default/miniui.css">
+<link rel="stylesheet" href="../script/lib/layui/css/layui.css" />
+<link rel="stylesheet" href="../script/lib/cashier/common.css">
+<link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/miniui/miniui.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+</head>
+<body style="background: #F6F7F9;">
+<div class="main">
+<form class="layui-form" lay-filter="form">
+    <div class="layui-row">
+        <div class="main_left layui-col-xs12 layui-col-md3">
+            <div class="layui-row">
+                <div class="top">
+                    <i class="layui-icon layui-icon-app"></i>商品列表
+                </div>
+                <div class="left_main">
+                    <input id="key" class="mini-textbox" onenter="onKeyEnter" value="请输入商品名称" onclick="setVal('key')"/>
+                    <a class="mini-button" onclick="search()">查询</a> 
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="addGoods()">一键添加</button>
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="delGoods()">一键删除</button>
+                    <ul id="tree1" class="mini-tree" url="<{$url}>" showTreeIcon="true" textField="name" idField="id" expandOnLoad="true" onNodeClick="onNodeClick">
+                    </ul>
+                </div>
+            </div>
+        </div>
+        <div class="main_right layui-col-xs12 layui-col-md9">
+            <div class="layui-row">
+                <div class="top">
+                    <div style="display:none;">
+                        <label>选择商品分类:</label>
+                        <div class="layui-input-inline">
+
+                            <div><select xm-select="shop_id" xm-select-skin="normal" xm-select-search="<{$search}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="shop_id" id="shop_id"  ></select></div>
+
+                        </div>
+                        <div class="layui-input-inline">
+                            <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="setShop()">确认选择</button>
+                        </div>
+                    </div>
+                    <div class="layui-input-inline" style="margin-left:20px">
+                        <input id="search_key" class="mini-textbox" value="请输入商品名称" onclick="setVal('search_key')"/>
+                        <a class="mini-button" onclick="searchGoods()">搜索</a> 
+                    </div>
+                </div>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <th lay-data="{field:'id'}">商品编码</th>
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
+                                <th lay-data="{field:'buy_price', edit: 'text'}">采购价</th>
+                                <th lay-data="{field:'buy_min', edit: 'text'}">采购起订数</th>
+                                <th lay-data="{field:'number', edit: 'text'}">采购数量</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </div>
+                <div class="total ft16">
+                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】【<span> 采购总数量:<i class="buyNum">0</i> </span>】
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认购买">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    var goods = {};
+    var del_goods = {};
+    var tree = {};
+    var commission = '<{$info["commission"]}>';
+    layui.config(
+    {
+        base: '../script/lib/layui/admin/' //静态资源所在路径
+        ,version: true
+    }).extend(
+    {
+        index: 'lib/index', //主入口模块
+        formSelects: 'plugin/formselects/formselects'
+    }).use(['index', 'contlist', 'table', 'form', 'formSelects','layer'], function()
+    {
+        var table = layui.table;
+        form = layui.form; 
+        var formSelects = layui.formSelects;
+
+        mini.parse();
+        tree = mini.get("tree1");
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if(tree.data[i].children[j].select == 1) {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else if(tree.data[i].select == 1) {
+                    setGoods(tree.data[i]);
+                }
+            }
+        }
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var seller_id = '<{$seller_id}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {seller_id:seller_id, goods:goods_string};
+                $.post(url, data, function(t) {
+                    t = JSON.parse(t);
+                    if (t.status == 1) {
+                        layui.layer.alert('商品设置成功', function(index){
+                          if (t.data == 'refer') {
+                                history.back();
+                            } else {
+                                location.href = t.data;
+                            }
+                          layer.close(index);
+                        });
+                    } else {
+                        layui.layer.alert(t.msg);
+                    }
+                });
+            });
+        })
+
+        $("#goods").on("keyup", ".goods_num", function() {
+            var num = parseFloat($(this).val());
+            if (num < 0) {
+                num = 0;
+                $(this).val(0);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].num = num;
+            setTotal();
+        });
+    })
+
+    function search() 
+    {
+        var key = mini.get("key").getValue();
+        if (key == "") {
+            tree.clearFilter();
+        } else {
+            key = key.toLowerCase();                
+            tree.filter(function (node) {
+                var name = node.name ? node.name.toLowerCase() : "";
+                if (name.indexOf(key) != -1) {
+                    return true;
+                }
+            });
+        }
+    }
+    function onKeyEnter(e)
+    {
+        search();
+    }
+
+    function onNodeClick()
+    {
+        var tree=mini.get("tree1");
+        node=tree.getSelectedNode();
+        if(node.end) {
+            setGoods(node);
+        }
+    }
+
+    function setVal(e)
+    {
+        mini.get(e).setValue('');
+    }
+
+    function searchGoods() 
+    {
+        var key = mini.get("search_key").getValue();
+
+        if (key == "") {
+            $(".mytr").show();
+        } else {
+            key = key.toLowerCase(); 
+            $(".mytr").show();               
+            $(".goods_name").each(function(t) {
+                var name = $(this).html();
+                name = name.toLowerCase(); 
+                if (name.indexOf(key) == -1) {
+                    $(this).parent().hide();
+                }
+            });
+        }
+    }
+
+    // 一键添加
+    function addGoods()
+    {
+        var key = mini.get("key").getValue();
+        if (key == '请输入商品名称') {
+            key = '';
+        }
+        if (key) {
+            key = key.toLowerCase();
+        }
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if (key) {
+                            var name = tree.data[i].children[j].name;
+                            if (name.indexOf(key) != -1) {
+                                setGoods(tree.data[i].children[j]);
+                            }
+                        } else {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else {
+                    if (key) {
+                        var name = tree.data[i].name;
+                        if (name.indexOf(key) != -1) {
+                            setGoods(tree.data[i]);
+                        }
+                    } else {
+                        setGoods(tree.data[i]);
+                    }
+                }
+            }
+        }
+    }
+
+    // 一键删除
+    function delGoods()
+    {
+        if (confirm('确定删除吗?')) {
+            var key = mini.get("key").getValue();
+            if (key == '请输入商品名称') {
+                key = '';
+            }
+            if (key) {
+                key = key.toLowerCase();
+            }
+            for (var i in tree.data) {
+                if (typeof(tree.data[i].children) == 'object') {
+                    if (tree.data[i].children.length > 0) {
+                        for (var j in tree.data[i].children) {
+                            if (key) {
+                                var name = tree.data[i].children[j].name;
+                                if (name.indexOf(key) != -1) {
+                                    unsetGoods(tree.data[i].children[j]);
+                                }
+                            } else {
+                                unsetGoods(tree.data[i].children[j]);
+                            }
+                        }
+                    } else {
+                        if (key) {
+                            var name = tree.data[i].name;
+                            if (name.indexOf(key) != -1) {
+                                unsetGoods(tree.data[i]);
+                            }
+                        } else {
+                            unsetGoods(tree.data[i]);
+                        }
+                    }
+                }
+            }
+            setTotal();
+        }
+    }
+
+    function unsetGoods(node)
+    {
+        if (node.id) {
+            if (goods[node.id]) {
+                goods[node.id].del = 2;
+                goods[node.id].num = 0;
+                goods[node.id].total = 0;
+                get(node.id).remove();
+            }
+        }
+    }
+
+    function setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
+                goods[key] = node;
+                goods[key].price = parseFloat(goods[key].price);
+                goods[key].type = parseInt(goods[key].type);
+                goods[key].total = parseFloat(goods[key].total);
+                goods[key].min = goods[key].min ? parseFloat(goods[key].min) : 1;
+                goods[key].num = goods[key].min;
+                goods[key].del = 1;
+                create(node);
+                setTotal();
+            } else if(node.type < 4) {
+                add(key);
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var select = '';
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
+            addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>'; 
+            if (node.stock == 1) {
+                addtr += '<td class="goods_total">'+node.total+'</td>';
+            } else {
+                addtr += '<td class="goods_total"> - </td>';
+            }
+
+            addtr += '<td class="goods_prices">'+node.buy_price+'</td>';
+
+            addtr += '<td class="goods_prices">'+node.min+'</td>';
+
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.min+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
+                                  
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+            form.render();
+            //$('.goods_price_template').change();
+        }
+    }
+
+    function setPrice(e, id)
+    {
+        var val = e.val().split('_');
+        goods[id].price_template_id = val[0];
+        e.parent().find('span').html(val[1]);
+        //goods[id].min = val[2];
+        //e.parent().parent().find('.goods_min').val(val[2]);
+    }
+
+    function add(id)
+    {
+        goods[id].num += 1;
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+    
+    function dec(id)
+    {
+        goods[id].num -= 1;
+        if (goods[id].num < 1) {
+            goods[id].num = 0;
+        }
+
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+
+    function addMin(id)
+    {
+        goods[id].min += 1;
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+    
+    function decMin(id)
+    {
+        goods[id].min -= 1;
+        if (goods[id].min < 1) {
+            goods[id].min = 0;
+        }
+
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+
+    function del(id)
+    {
+        //if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            goods[id].num = 0;
+            get(id).remove();
+            setTotal();
+        //}
+    }
+
+    function setTotal()
+    {
+        var cash = 0;
+        var total = 0;
+        var buy = 0;
+        for (var i in goods) {
+            total += goods[i].total;
+            buy += goods[i].num;
+        }
+        $(".totalNum").html(total);
+        $(".buyNum").html(buy);
+    }
+
+    function setShop()
+    {
+        var shop_id = $('.xm-select-parent[fs_id="shop_id"] span[fsw="xm-select"]').attr('value');
+        if (!shop_id) {
+            layui.layer.alert('请选择门店');
+            return;
+        }
+        layui.layer.confirm('确定切换门店吗?切换后现在选择的商品都将清空', function() {
+            location.href = '<{$host}>&id=' + shop_id;
+        });
+    }
+</script>
+</body>
+</html>

+ 485 - 0
module/scm_role/assets/pc/html/set_seller_goods.html

@@ -0,0 +1,485 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
+<meta name="author" content="siweiyong 2602812659@qq.com"/>
+<title>设置商品</title>
+<link rel="stylesheet" href="../script/lib/miniui/themes/default/miniui.css">
+<link rel="stylesheet" href="../script/lib/layui/css/layui.css" />
+<link rel="stylesheet" href="../script/lib/cashier/common.css">
+<link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/miniui/miniui.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+</head>
+<body style="background: #F6F7F9;">
+<div class="main">
+<form class="layui-form" lay-filter="form">
+    <div class="layui-row">
+        <div class="main_left layui-col-xs12 layui-col-md3">
+            <div class="layui-row">
+                <div class="top">
+                    <i class="layui-icon layui-icon-app"></i>商品列表
+                </div>
+                <div class="left_main">
+                    <input id="key" class="mini-textbox" onenter="onKeyEnter" value="请输入商品名称" onclick="setVal('key')"/>
+                    <a class="mini-button" onclick="search()">查询</a> 
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="addGoods()">一键添加</button>
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="delGoods()">一键删除</button>
+                    <ul id="tree1" class="mini-tree" url="<{$url}>" showTreeIcon="true" textField="name" idField="id" expandOnLoad="true" onNodeClick="onNodeClick">
+                    </ul>
+                </div>
+            </div>
+        </div>
+        <div class="main_right layui-col-xs12 layui-col-md9">
+            <div class="layui-row">
+                <div class="top">
+                    <div style="display:none;">
+                        <label>选择商品分类:</label>
+                        <div class="layui-input-inline">
+
+                            <div><select xm-select="shop_id" xm-select-skin="normal" xm-select-search="<{$search}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="shop_id" id="shop_id"  ></select></div>
+
+                        </div>
+                        <div class="layui-input-inline">
+                            <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="setShop()">确认选择</button>
+                        </div>
+                    </div>
+                    <div class="layui-input-inline" style="margin-left:20px">
+                        <input id="search_key" class="mini-textbox" value="请输入商品名称" onclick="setVal('search_key')"/>
+                        <a class="mini-button" onclick="searchGoods()">搜索</a> 
+                    </div>
+                </div>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <th lay-data="{field:'id'}">商品编码</th>
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
+                                <th lay-data="{field:'price', edit: 'text'}">销售价</th>
+                                <th lay-data="{field:'commission', edit: 'text'}">销售佣金</th>
+                                <th lay-data="{field:'buy_price', edit: 'text'}">采购价</th>
+                                <th lay-data="{field:'number', edit: 'text'}">采购起订数</th>
+                                <th lay-data="{field:'operation'}">操作</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </div>
+                <div class="total ft16">
+                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认设置">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    var goods = {};
+    var del_goods = {};
+    var tree = {};
+    var commission = '<{$info["commission"]}>';
+    layui.config(
+    {
+        base: '../script/lib/layui/admin/' //静态资源所在路径
+        ,version: true
+    }).extend(
+    {
+        index: 'lib/index', //主入口模块
+        formSelects: 'plugin/formselects/formselects'
+    }).use(['index', 'contlist', 'table', 'form', 'formSelects','layer'], function()
+    {
+        var table = layui.table;
+        form = layui.form; 
+        var formSelects = layui.formSelects;
+
+        mini.parse();
+        tree = mini.get("tree1");
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if(tree.data[i].children[j].select == 1) {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else if(tree.data[i].select == 1) {
+                    setGoods(tree.data[i]);
+                }
+            }
+        }
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var seller_id = '<{$seller_id}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {seller_id:seller_id, goods:goods_string};
+                $.post(url, data, function(t) {
+                    t = JSON.parse(t);
+                    if (t.status == 1) {
+                        layui.layer.alert('商品设置成功', function(index){
+                          if (t.data == 'refer') {
+                                history.back();
+                            } else {
+                                location.href = t.data;
+                            }
+                          layer.close(index);
+                        });
+                    } else {
+                        layui.layer.alert(t.msg);
+                    }
+                });
+            });
+        })
+
+        $("#goods").on("keyup", ".goods_num", function() {
+            var num = parseFloat($(this).val());
+            if (num < 0) {
+                num = 0;
+                $(this).val(0);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].num = num;
+            setTotal();
+        });
+
+        $("#goods").on("keyup", ".goods_min", function() {
+            var min = parseFloat($(this).val());
+            if (min < 0) {
+                min = 1;
+                $(this).val(1);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].min = min;
+            setTotal();
+        });
+    })
+
+    function search() 
+    {
+        var key = mini.get("key").getValue();
+        if (key == "") {
+            tree.clearFilter();
+        } else {
+            key = key.toLowerCase();                
+            tree.filter(function (node) {
+                var name = node.name ? node.name.toLowerCase() : "";
+                if (name.indexOf(key) != -1) {
+                    return true;
+                }
+            });
+        }
+    }
+    function onKeyEnter(e)
+    {
+        search();
+    }
+
+    function onNodeClick()
+    {
+        var tree=mini.get("tree1");
+        node=tree.getSelectedNode();
+        if(node.end) {
+            setGoods(node);
+        }
+    }
+
+    function setVal(e)
+    {
+        mini.get(e).setValue('');
+    }
+
+    function searchGoods() 
+    {
+        var key = mini.get("search_key").getValue();
+
+        if (key == "") {
+            $(".mytr").show();
+        } else {
+            key = key.toLowerCase(); 
+            $(".mytr").show();               
+            $(".goods_name").each(function(t) {
+                var name = $(this).html();
+                name = name.toLowerCase(); 
+                if (name.indexOf(key) == -1) {
+                    $(this).parent().hide();
+                }
+            });
+        }
+    }
+
+    // 一键添加
+    function addGoods()
+    {
+        var key = mini.get("key").getValue();
+        if (key == '请输入商品名称') {
+            key = '';
+        }
+        if (key) {
+            key = key.toLowerCase();
+        }
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if (key) {
+                            var name = tree.data[i].children[j].name;
+                            if (name.indexOf(key) != -1) {
+                                setGoods(tree.data[i].children[j]);
+                            }
+                        } else {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else {
+                    if (key) {
+                        var name = tree.data[i].name;
+                        if (name.indexOf(key) != -1) {
+                            setGoods(tree.data[i]);
+                        }
+                    } else {
+                        setGoods(tree.data[i]);
+                    }
+                }
+            }
+        }
+    }
+
+    // 一键删除
+    function delGoods()
+    {
+        if (confirm('确定删除吗?')) {
+            var key = mini.get("key").getValue();
+            if (key == '请输入商品名称') {
+                key = '';
+            }
+            if (key) {
+                key = key.toLowerCase();
+            }
+            for (var i in tree.data) {
+                if (typeof(tree.data[i].children) == 'object') {
+                    if (tree.data[i].children.length > 0) {
+                        for (var j in tree.data[i].children) {
+                            if (key) {
+                                var name = tree.data[i].children[j].name;
+                                if (name.indexOf(key) != -1) {
+                                    unsetGoods(tree.data[i].children[j]);
+                                }
+                            } else {
+                                unsetGoods(tree.data[i].children[j]);
+                            }
+                        }
+                    } else {
+                        if (key) {
+                            var name = tree.data[i].name;
+                            if (name.indexOf(key) != -1) {
+                                unsetGoods(tree.data[i]);
+                            }
+                        } else {
+                            unsetGoods(tree.data[i]);
+                        }
+                    }
+                }
+            }
+            setTotal();
+        }
+    }
+
+    function unsetGoods(node)
+    {
+        if (node.id) {
+            if (goods[node.id]) {
+                goods[node.id].del = 2;
+                goods[node.id].num = 0;
+                goods[node.id].total = 0;
+                get(node.id).remove();
+            }
+        }
+    }
+
+    function setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
+                goods[key] = node;
+                goods[key].price = parseFloat(goods[key].price);
+                goods[key].type = parseInt(goods[key].type);
+                goods[key].total = parseFloat(goods[key].total);
+                goods[key].min = goods[key].min ? parseFloat(goods[key].min) : 1;
+                goods[key].num = 0;
+                goods[key].del = 1;
+                create(node);
+                setTotal();
+            } else if(node.type < 4) {
+                add(key);
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var select = '';
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
+            addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>'; 
+            if (node.stock == 1) {
+                addtr += '<td class="goods_total">'+node.total+'</td>';
+            } else {
+                addtr += '<td class="goods_total"> - </td>';
+            }
+
+            addtr += '<td class="goods_prices">'+node.price+'</td>';
+            var commission_price = 0;
+            var commission_string = '';
+            if (commission == 0) {
+                commission_string = '0';
+            } else {
+                if (!node.commission) {
+                    node.commission = '0';
+                }
+                commission_string = node.commission;
+                if (node.commission.indexOf('%') > -1) {
+                    node.commission = node.commission.replace('%', '');
+                    node.commission = parseFloat(node.commission);
+                    commission_price = (node.commission/100) * parseFloat(node.price);
+                } else {
+                    commission_price = parseFloat(node.commission);
+                }
+
+                if (commission) {
+                    commission_string += '+' + commission;
+                    if (commission.indexOf('%') > -1) {
+                        var commission_temp = commission.replace('%', '');
+                        commission_temp = parseFloat(commission_temp);
+                        commission_price += (commission_temp/100) * parseFloat(node.price);
+                    } else {
+                        commission_price += parseFloat(commission);
+                    }
+                    commission_price = commission_price.toFixed(2);
+                    commission_string += '=' + commission_price;
+                }
+            }
+            
+            addtr += '<td class="goods_commission"><span>'+commission_string+'</span></td>';
+
+            addtr += '<td class="goods_prices">'+node.buy_price+'</td>';
+
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="decMin(\''+node.id+'\')">-</span><input type="text" value="'+node.min+'" class="goods_min"><span class="jia" onclick="addMin(\''+node.id+'\')">+</span></div></td>';
+            
+            if (node.total <= 0 || node.stock != 1) {
+                addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+            } else {
+                addtr += '<td></td>';
+            }
+                                  
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+            form.render();
+            //$('.goods_price_template').change();
+        }
+    }
+
+    function setPrice(e, id)
+    {
+        var val = e.val().split('_');
+        goods[id].price_template_id = val[0];
+        e.parent().find('span').html(val[1]);
+        //goods[id].min = val[2];
+        //e.parent().parent().find('.goods_min').val(val[2]);
+    }
+
+    function add(id)
+    {
+        goods[id].num += 1;
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+    
+    function dec(id)
+    {
+        goods[id].num -= 1;
+        if (goods[id].num < 1) {
+            goods[id].num = 0;
+        }
+
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+
+    function addMin(id)
+    {
+        goods[id].min += 1;
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+    
+    function decMin(id)
+    {
+        goods[id].min -= 1;
+        if (goods[id].min < 1) {
+            goods[id].min = 0;
+        }
+
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+
+    function del(id)
+    {
+        //if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            goods[id].num = 0;
+            get(id).remove();
+            setTotal();
+        //}
+    }
+
+    function setTotal()
+    {
+        var cash = 0;
+        var total = 0;
+        for (var i in goods) {
+            total += goods[i].total;
+        }
+        $(".totalNum").html(total);
+    }
+
+    function setShop()
+    {
+        var shop_id = $('.xm-select-parent[fs_id="shop_id"] span[fsw="xm-select"]').attr('value');
+        if (!shop_id) {
+            layui.layer.alert('请选择门店');
+            return;
+        }
+        layui.layer.confirm('确定切换门店吗?切换后现在选择的商品都将清空', function() {
+            location.href = '<{$host}>&id=' + shop_id;
+        });
+    }
+</script>
+</body>
+</html>

+ 426 - 0
module/scm_role/assets/pc/html/set_supplier_goods.html

@@ -0,0 +1,426 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
+<meta name="author" content="siweiyong 2602812659@qq.com"/>
+<title>设置商品</title>
+<link rel="stylesheet" href="../script/lib/miniui/themes/default/miniui.css">
+<link rel="stylesheet" href="../script/lib/layui/css/layui.css" />
+<link rel="stylesheet" href="../script/lib/cashier/common.css">
+<link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/miniui/miniui.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+</head>
+<body style="background: #F6F7F9;">
+<div class="main">
+<form class="layui-form" lay-filter="form">
+    <div class="layui-row">
+        <div class="main_left layui-col-xs12 layui-col-md3">
+            <div class="layui-row">
+                <div class="top">
+                    <i class="layui-icon layui-icon-app"></i>商品列表
+                </div>
+                <div class="left_main">
+                    <input id="key" class="mini-textbox" onenter="onKeyEnter" value="请输入商品名称" onclick="setVal('key')"/>
+                    <a class="mini-button" onclick="search()">查询</a> 
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="addGoods()">一键添加</button>
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="delGoods()">一键删除</button>
+                    <ul id="tree1" class="mini-tree" url="<{$url}>" showTreeIcon="true" textField="name" idField="id" expandOnLoad="true" onNodeClick="onNodeClick">
+                    </ul>
+                </div>
+            </div>
+        </div>
+        <div class="main_right layui-col-xs12 layui-col-md9">
+            <div class="layui-row">
+                <div class="top">
+                    <div style="display:none;">
+                        <label>选择商品分类:</label>
+                        <div class="layui-input-inline">
+
+                            <div><select xm-select="shop_id" xm-select-skin="normal" xm-select-search="<{$search}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="shop_id" id="shop_id"  ></select></div>
+
+                        </div>
+                        <div class="layui-input-inline">
+                            <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="setShop()">确认选择</button>
+                        </div>
+                    </div>
+                    <div class="layui-input-inline" style="margin-left:20px">
+                        <input id="search_key" class="mini-textbox" value="请输入商品名称" onclick="setVal('search_key')"/>
+                        <a class="mini-button" onclick="searchGoods()">搜索</a> 
+                    </div>
+                </div>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <!--<th lay-data="{field:'id'}">商品编码</th>-->
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'buy_price', edit: 'text'}">采购价</th>
+                                <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
+                                <th lay-data="{field:'number', edit: 'text'}">新增库存</th>
+                                <th lay-data="{field:'operation'}">操作</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </div>
+                <div class="total ft16">
+                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】【<span> 当前新增库存:<i class="addNum">0</i> </span>】
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认设置">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    var goods = {};
+    var del_goods = {};
+    var tree = {};
+    var commission = '<{$info["commission"]}>';
+    layui.config(
+    {
+        base: '../script/lib/layui/admin/' //静态资源所在路径
+        ,version: true
+    }).extend(
+    {
+        index: 'lib/index', //主入口模块
+        formSelects: 'plugin/formselects/formselects'
+    }).use(['index', 'contlist', 'table', 'form', 'formSelects','layer'], function()
+    {
+        var table = layui.table;
+        form = layui.form; 
+        var formSelects = layui.formSelects;
+
+        mini.parse();
+        tree = mini.get("tree1");
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if(tree.data[i].children[j].select == 1) {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else if(tree.data[i].select == 1) {
+                    setGoods(tree.data[i]);
+                }
+            }
+        }
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var supplier_id = '<{$supplier_id}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {supplier_id:supplier_id, goods:goods_string};
+                $.post(url, data, function(t) {
+                    t = JSON.parse(t);
+                    if (t.status == 1) {
+                        layui.layer.alert('商品设置成功', function(index){
+                          if (t.data == 'refer') {
+                                history.back();
+                            } else {
+                                location.href = t.data;
+                            }
+                          layer.close(index);
+                        });
+                    } else {
+                        layui.layer.alert(t.msg);
+                    }
+                });
+            });
+        })
+
+        $("#goods").on("keyup", ".goods_num", function() {
+            var num = parseFloat($(this).val());
+            if (num < 0) {
+                num = 0;
+                $(this).val(0);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].num = num;
+            setTotal();
+        });
+    })
+
+    function search() 
+    {
+        var key = mini.get("key").getValue();
+        if (key == "") {
+            tree.clearFilter();
+        } else {
+            key = key.toLowerCase();                
+            tree.filter(function (node) {
+                var name = node.name ? node.name.toLowerCase() : "";
+                if (name.indexOf(key) != -1) {
+                    return true;
+                }
+            });
+        }
+    }
+    function onKeyEnter(e)
+    {
+        search();
+    }
+
+    function onNodeClick()
+    {
+        var tree=mini.get("tree1");
+        node=tree.getSelectedNode();
+        if(node.end) {
+            setGoods(node);
+        }
+    }
+
+    function setVal(e)
+    {
+        mini.get(e).setValue('');
+    }
+
+    function searchGoods() 
+    {
+        var key = mini.get("search_key").getValue();
+
+        if (key == "") {
+            $(".mytr").show();
+        } else {
+            key = key.toLowerCase(); 
+            $(".mytr").show();               
+            $(".goods_name").each(function(t) {
+                var name = $(this).html();
+                name = name.toLowerCase(); 
+                if (name.indexOf(key) == -1) {
+                    $(this).parent().hide();
+                }
+            });
+        }
+    }
+
+    // 一键添加
+    function addGoods()
+    {
+        var key = mini.get("key").getValue();
+        if (key == '请输入商品名称') {
+            key = '';
+        }
+        if (key) {
+            key = key.toLowerCase();
+        }
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if (key) {
+                            var name = tree.data[i].children[j].name;
+                            if (name.indexOf(key) != -1) {
+                                setGoods(tree.data[i].children[j]);
+                            }
+                        } else {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else {
+                    if (key) {
+                        var name = tree.data[i].name;
+                        if (name.indexOf(key) != -1) {
+                            setGoods(tree.data[i]);
+                        }
+                    } else {
+                        setGoods(tree.data[i]);
+                    }
+                }
+            }
+        }
+    }
+
+    // 一键删除
+    function delGoods()
+    {
+        if (confirm('确定删除吗?')) {
+            var key = mini.get("key").getValue();
+            if (key == '请输入商品名称') {
+                key = '';
+            }
+            if (key) {
+                key = key.toLowerCase();
+            }
+            for (var i in tree.data) {
+                if (typeof(tree.data[i].children) == 'object') {
+                    if (tree.data[i].children.length > 0) {
+                        for (var j in tree.data[i].children) {
+                            if (key) {
+                                var name = tree.data[i].children[j].name;
+                                if (name.indexOf(key) != -1) {
+                                    unsetGoods(tree.data[i].children[j]);
+                                }
+                            } else {
+                                unsetGoods(tree.data[i].children[j]);
+                            }
+                        }
+                    } else {
+                        if (key) {
+                            var name = tree.data[i].name;
+                            if (name.indexOf(key) != -1) {
+                                unsetGoods(tree.data[i]);
+                            }
+                        } else {
+                            unsetGoods(tree.data[i]);
+                        }
+                    }
+                }
+            }
+            setTotal();
+        }
+    }
+
+    function unsetGoods(node)
+    {
+        if (node.id) {
+            if (goods[node.id]) {
+                goods[node.id].del = 2;
+                goods[node.id].num = 0;
+                goods[node.id].total = 0;
+                get(node.id).remove();
+            }
+        }
+    }
+
+    function setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
+                goods[key] = node;
+                goods[key].price = parseFloat(goods[key].price);
+                goods[key].type = parseInt(goods[key].type);
+                goods[key].total = parseFloat(goods[key].total);
+                goods[key].min = goods[key].min ? parseFloat(goods[key].min) : 1;
+                goods[key].num = 0;
+                goods[key].del = 1;
+                create(node);
+                setTotal();
+            } else if(node.type < 4) {
+                add(key);
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var select = '';
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
+            //addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>'; 
+
+            addtr += '<td class="goods_prices">'+node.buy_price+'</td>';
+
+            if (node.stock == 1) {
+                addtr += '<td class="goods_total">'+node.total+'</td>';
+                addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
+            } else {
+                addtr += '<td class="goods_total"> - </td>';
+                addtr += '<td class="goods_total"> - </td>';
+            }
+            
+            addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+            /*
+            if (node.total <= 0 || node.stock != 1) {
+                addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+            } else {
+                addtr += '<td></td>';
+            }*/
+                                  
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+            form.render();
+            //$('.goods_price_template').change();
+        }
+    }
+
+    function setPrice(e, id)
+    {
+        var val = e.val().split('_');
+        goods[id].price_template_id = val[0];
+        e.parent().find('span').html(val[1]);
+        //goods[id].min = val[2];
+        //e.parent().parent().find('.goods_min').val(val[2]);
+    }
+
+    function add(id)
+    {
+        goods[id].num += 1;
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+    
+    function dec(id)
+    {
+        goods[id].num -= 1;
+        if (goods[id].num < 1) {
+            goods[id].num = 0;
+        }
+
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+
+    function del(id)
+    {
+        //if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            goods[id].num = 0;
+            get(id).remove();
+            setTotal();
+        //}
+    }
+
+    function setTotal()
+    {
+        var cash = 0;
+        var total = 0;
+        var num = 0;
+        for (var i in goods) {
+            total += goods[i].total;
+            num += goods[i].num;
+        }
+        $(".totalNum").html(total);
+        $(".addNum").html(num);
+    }
+
+    function setShop()
+    {
+        var shop_id = $('.xm-select-parent[fs_id="shop_id"] span[fsw="xm-select"]').attr('value');
+        if (!shop_id) {
+            layui.layer.alert('请选择门店');
+            return;
+        }
+        layui.layer.confirm('确定切换门店吗?切换后现在选择的商品都将清空', function() {
+            location.href = '<{$host}>&id=' + shop_id;
+        });
+    }
+</script>
+</body>
+</html>

+ 466 - 0
module/scm_role/database/seller.php

@@ -0,0 +1,466 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('scm_role/seller_type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$seller = function()
+{
+	$array = array();
+	$data = Dever::load('scm_role/seller-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$price = function()
+{
+    $array = array
+    (
+        -1 => '默认模板',
+    );
+    $data = Dever::load('scm_product/price-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+
+$sell_goods = array
+(
+	1 => '销售所有商品',
+	2 => '销售部分商品',
+);
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$stock = array
+(
+	1 => '独立库存',
+	2 => '共享库存',
+);
+
+$status = array
+(
+    1 => '启用',
+    2 => '禁用',
+);
+
+$account = function() {
+    return Dever::load('account/api')->getConfig('scm_role/seller');
+};
+
+return array
+(
+	# 表名
+	'name' => 'seller',
+	# 显示给用户看的名称
+	'lang' => '销售商',
+	# 是否显示在后台菜单
+	'order' => 9,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '销售商ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '销售商名称',
+			'default' 	=> '',
+			'desc' 		=> '销售商名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'info'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '销售商介绍',
+            'default'   => '',
+            'desc'      => '销售商介绍',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+		'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商类型',
+            'default'   => '1',
+            'desc'      => '销售商类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+        ),
+
+        'account'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '选择账户',
+            'default'   => '',
+            'desc'      => '选择账户',
+            'match'     => 'is_string',
+            'update'    => 'checkbox',
+            'option'    => $account,
+            'list_name' => '账户信息',
+            'list'      => 'Dever::load("account/api.getInfo", {id}, "{account}")',
+        ),
+
+        'stock'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '库存设置-如果商品有库存,这里设置库存是否独立或共享,独立库存就是该销售商自己使用一套库存,共享库存就是和其他销售商共享一套库存,共享库存将无法设置商品',
+            'default'   => '1',
+            'desc'      => '库存设置',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $stock,
+            'control'	=> 'stock',
+        ),
+
+        'stock_seller'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '共享销售商-选择和哪个销售商共享一套库存',
+            'default'   => '-1',
+            'desc'      => '共享销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $seller,
+            'show'		=> 'stock=2'
+        ),
+
+        'category'		=> array
+		(
+			'type' 		=> 'varchar-2000',
+			'name' 		=> '商品属性分类-如不选择就是可以销售所有商品属性分类下的商品',
+			'default' 	=> '',
+			'desc' 		=> '商品属性分类',
+			'match' 	=> 'is_string',
+			'update'	=> 'checkbox',
+			'option'	=> $category,
+            'show'      => 'stock=1'
+		),
+
+        'price_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品价格模板',
+            'default'   => '-1',
+            'desc'      => '商品价格模板',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $price,
+            'show'      => 'stock=1'
+        ),
+
+        'commission'        => array
+        (
+            'type'      => 'varchar-20',
+            'name'      => '销售佣金调整-针对每个商品的销售佣金做统一调整,如填写5%,就是在原有销售佣金的基础上增加5%佣金,不设置则不做任何调整,设置为0,则佣金为0',
+            'default'   => '0',
+            'desc'      => '销售佣金调整',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+		'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'area'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '联系人城市',
+            'default'   => '',
+            'desc'      => '联系人城市',
+            'match'     => 'option',
+            'search'    => 'linkage',
+            'update'    => 'linkage',
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
+            //'list'      => 'Dever::load("area/api.string", "{area}")',
+            'tab'		=> 1,
+        ),
+
+        'province'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '省份',
+            'default'   => '',
+            'desc'      => '省份',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'city'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '城市',
+            'default'   => '',
+            'desc'      => '城市',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'county'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '县区',
+            'default'   => '',
+            'desc'      => '县区',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '联系人地址',
+            'default'   => '',
+            'desc'      => '联系人地址',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'tab'		=> 1,
+        ),
+
+        'identity'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '销售商身份',
+            'default'   => '1',
+            'desc'      => '销售商身份',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $identity,
+            'control'	=> 'identity',
+            'tab'		=> 2,
+        ),
+
+        'idcard_front'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证正面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证正面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'tab'		=> 2,
+        ),
+
+        'idcard_back'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证背面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证背面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'tab'		=> 2,
+        ),
+
+        'company_name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '企业名称',
+            'default'   => '',
+            'desc'      => '企业名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+        'company_license'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '企业营业执照',
+            'default'   => '',
+            'desc'      => '企业营业执照',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+        'company_license_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '企业营业执照号码',
+            'default'   => '',
+            'desc'      => '营业执照号码',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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
+	(
+        'delete' => false,
+		'tab' => array('基本设置', '联系人信息', '认证信息'),
+		'button' => array
+        (
+            '类型配置' => array('list', 'seller_type&oper_parent=seller'),
+        ),
+        'list_button' => array
+        (
+        	'location' => array('商品设置', Dever::url('lib/seller.setGoods', 'scm_role'), '{stock} == 1'),
+            'br3' => array('<br />'),
+            'location1' => array('订货下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
+            'location2' => array('入库下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
+            'location3' => array('出库下单', Dever::url('lib/seller.buyGoods', 'scm_role'), '{stock} == 1'),
+            'br4' => array('<br />'),
+            'fast_add' => array('账户操作', 'push&project=account&oper_table=seller&oper_project=scm_role&uid={id}'),
+            'list' => array('账户流水', 'info_log&project=account&oper_table=seller&oper_project=scm_role&search_option_uid={id}'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,type_id,state,cdate',
+		'value' => array
+		(
+			'"平台销售", 1, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		'like' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*|id',
+        ),
+	)
+);

+ 157 - 0
module/scm_role/database/seller_goods.php

@@ -0,0 +1,157 @@
+<?php
+$status = Dever::config('base')->status;
+return array
+(
+    # 表名
+    'name' => 'seller_goods',
+    # 显示给用户看的名称
+    'lang' => '销售商商品列表',
+    'order' => 10,
+    'menu'  => false,
+
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.goodsUpdate',
+        'update' => 'scm_role/lib/seller.goodsUpdate',
+    ),
+    */
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属销售商',
+            'default'   => '',
+            'desc'      => '所属销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_seller_id'),
+            'list'      => 'Dever::load("scm_role/seller-one#name", {seller_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        '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,
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'sell_type' => array('yes-t_2.sell_type'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,cdate',
+        ),
+
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'sell_type' => array('yes-t_2.sell_type'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,t_1.cdate,t_1.id as id',
+        ),
+    ),
+);

+ 317 - 0
module/scm_role/database/seller_goods_sku.php

@@ -0,0 +1,317 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'seller_goods_sku',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.skuUpdate',
+        'update' => 'scm_role/lib/seller.skuUpdate',
+    ),
+    */
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属销售商',
+            'default'   => '',
+            'desc'      => '所属销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_seller_id'),
+            'list'      => 'Dever::load("scm_role/seller-one#name", {seller_id})',
+        ),
+
+        'goods-info_sku-code'=> array
+        (
+            'name'      => '商品编码',
+            'default'   => '',
+            'desc'      => '商品编码',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
+            'list'      => true,
+            'list_order' => 4,
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
+            'default'   => '0',
+            'desc'      => '入库库存',
+            'match'     => 'is_numeric',
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '出库库存',
+            'default'   => '0',
+            'desc'      => '出库库存',
+            'match'     => 'option',
+        ),
+
+        'min'       => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '起购数',
+            'default'   => '1',
+            'desc'      => '起购数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'list'      => 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,
+        //'excel' => array(array('导出门店库存', '门店库存', '')),
+        'page_list_table' => 'sku',
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'page' => array(30, 'list'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num,t_1.in_num,t_2.type,t_2.stock,t_2.commission,t_2.sell_type,t_2.buy_type',
+        ),
+
+       	# 列表
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,in_num-out_num as total|sku_id',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,in_num-out_num as total',
+        ),
+
+        # 更新售出量
+        'incSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少售出量
+        'decSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '-='),
+            ),
+        ),
+
+        # 更新总库存
+        'updateTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 增加总库存
+        'incTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少总库存
+        'decTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'seller_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '-='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 107 - 0
module/scm_role/database/seller_type.php

@@ -0,0 +1,107 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'seller_type',
+	# 显示给用户看的名称
+	'lang' => '销售商类型',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '类型名称',
+			'default' 	=> '',
+			'desc' 		=> '类型名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'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
+	(
+		'insert' => false,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"经销商", 1,' . DEVER_TIME,
+			'"分销商", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 120 - 0
module/scm_role/database/servicer.php

@@ -0,0 +1,120 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('scm_role/servicer_type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'servicer',
+	# 显示给用户看的名称
+	'lang' => '配送商',
+	# 是否显示在后台菜单
+	'order' => 10,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '配送商名称',
+			'default' 	=> '',
+			'desc' 		=> '配送商名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配送商类型',
+            'default'   => '1',
+            'desc'      => '配送商类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+        ),
+
+		'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
+	(
+		'delete' => false,
+		'button' => array
+        (
+            '类型配置' => array('list', 'servicer_type&oper_parent=servicer'),
+        ),
+	),
+
+	'default' => array
+	(
+		'col' => 'name,type_id,state,cdate',
+		'value' => array
+		(
+			'"默认配送商", 1, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 106 - 0
module/scm_role/database/servicer_type.php

@@ -0,0 +1,106 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'servicer_type',
+	# 显示给用户看的名称
+	'lang' => '供应商类型',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '类型名称',
+			'default' 	=> '',
+			'desc' 		=> '类型名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'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
+	(
+		'insert' => false,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"仓库", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 359 - 0
module/scm_role/database/supplier.php

@@ -0,0 +1,359 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('scm_role/supplier_type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('scm_product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$status = array
+(
+    1 => '启用',
+    2 => '禁用',
+);
+
+return array
+(
+	# 表名
+	'name' => 'supplier',
+	# 显示给用户看的名称
+	'lang' => '供应商',
+	# 是否显示在后台菜单
+	'order' => 11,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '供应商名称',
+			'default' 	=> '',
+			'desc' 		=> '供应商名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '供应商编码',
+            'default'   => '-1',
+            'desc'      => '供应商编码',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+		'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '供应商类型',
+            'default'   => '1',
+            'desc'      => '供应商类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+        ),
+
+        'category'		=> array
+		(
+			'type' 		=> 'varchar-2000',
+			'name' 		=> '商品属性分类-如不选择就是可以销售所有商品属性分类下的商品',
+			'default' 	=> '',
+			'desc' 		=> '商品属性分类',
+			'match' 	=> 'is_string',
+			'update'	=> 'checkbox',
+			'option'	=> $category,
+		),
+
+		'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'tel'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'email'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系人邮箱',
+            'default'   => '',
+            'desc'      => '联系人邮箱',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'       => 1,
+        ),
+
+        'area'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '联系人城市',
+            'default'   => '',
+            'desc'      => '联系人城市',
+            'match'     => 'option',
+            'search'    => 'linkage',
+            'update'    => 'linkage',
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
+            //'list'      => 'Dever::load("area/api.string", "{area}")',
+            'tab'		=> 1,
+        ),
+
+        'province'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '省份',
+            'default'   => '',
+            'desc'      => '省份',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'city'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '城市',
+            'default'   => '',
+            'desc'      => '城市',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'county'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '县区',
+            'default'   => '',
+            'desc'      => '县区',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '联系人地址',
+            'default'   => '',
+            'desc'      => '联系人地址',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'tab'		=> 1,
+        ),
+
+        'identity'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '销售商身份',
+            'default'   => '1',
+            'desc'      => '销售商身份',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $identity,
+            'control'	=> 'identity',
+            'tab'		=> 2,
+        ),
+
+        'idcard_front'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证正面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证正面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'tab'		=> 2,
+        ),
+
+        'idcard_back'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证背面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证背面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'tab'		=> 2,
+        ),
+
+        'company_name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '企业名称',
+            'default'   => '',
+            'desc'      => '企业名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+        'company_license'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '企业营业执照',
+            'default'   => '',
+            'desc'      => '企业营业执照',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+        'company_license_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '企业营业执照号码',
+            'default'   => '',
+            'desc'      => '营业执照号码',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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
+	(
+        'delete' => false,
+		'tab' => array('基本设置', '联系人信息', '认证信息'),
+		'button' => array
+        (
+            '类型配置' => array('list', 'supplier_type&oper_parent=supplier'),
+        ),
+        'list_button' => array
+        (
+        	'location' => array('商品列表', Dever::url('lib/supplier.setGoods', 'scm_role')),
+            //'fast_add' => array('账户操作', 'push&project=account&oper_table=supplier&oper_project=scm_role&uid={id}'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,type_id,state,cdate',
+		'value' => array
+		(
+			'"默认供应商", 1, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 155 - 0
module/scm_role/database/supplier_goods.php

@@ -0,0 +1,155 @@
+<?php
+$status = Dever::config('base')->status;
+return array
+(
+    # 表名
+    'name' => 'supplier_goods',
+    # 显示给用户看的名称
+    'lang' => '供应商商品列表',
+    'order' => 10,
+    'menu'  => false,
+
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.goodsUpdate',
+        'update' => 'scm_role/lib/seller.goodsUpdate',
+    ),
+    */
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'supplier_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属供应商',
+            'default'   => '',
+            'desc'      => '所属供应商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_supplier_id'),
+            'list'      => 'Dever::load("scm_role/supplier-one#name", {supplier_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        '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,
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'supplier_id' => array('yes-t_1.supplier_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => '*,t_2.*',
+        ),
+
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'supplier_id' => array('yes-t_1.supplier_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*,t_2.*',
+        ),
+    ),
+);

+ 306 - 0
module/scm_role/database/supplier_goods_sku.php

@@ -0,0 +1,306 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'supplier_goods_sku',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+    /*
+    'end' => array
+    (
+        'insert' => 'scm_role/lib/seller.skuUpdate',
+        'update' => 'scm_role/lib/seller.skuUpdate',
+    ),
+    */
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'supplier_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属供应商',
+            'default'   => '',
+            'desc'      => '所属供应商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_supplier_id'),
+            'list'      => 'Dever::load("scm_role/supplier-one#name", {supplier_id})',
+        ),
+
+        'goods-info_sku-code'=> array
+        (
+            'name'      => '商品编码',
+            'default'   => '',
+            'desc'      => '商品编码',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
+            'list'      => true,
+            'list_order' => 4,
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.search',
+            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'in_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
+            'default'   => '0',
+            'desc'      => '入库库存',
+            'match'     => 'is_numeric',
+        ),
+
+        'out_num'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '出库库存',
+            'default'   => '0',
+            'desc'      => '出库库存',
+            'match'     => 'option',
+        ),
+
+        '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,
+        //'excel' => array(array('导出门店库存', '门店库存', '')),
+        'page_list_table' => 'sku',
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
+            'page' => array(30, 'list'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
+        ),
+
+       	# 列表
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,in_num-out_num as total|sku_id',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,in_num-out_num as total',
+        ),
+
+        # 更新售出量
+        'incSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少售出量
+        'decSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'out_num' => array('yes', '-='),
+            ),
+        ),
+
+        # 更新总库存
+        'updateTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 增加总库存
+        'incTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少总库存
+        'decTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'in_num' => array('yes', '-='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 122 - 0
module/scm_role/database/supplier_type.php

@@ -0,0 +1,122 @@
+<?php
+
+$stock = array
+(
+	1 => '是',
+	2 => '否',
+);
+return array
+(
+	# 表名
+	'name' => 'supplier_type',
+	# 显示给用户看的名称
+	'lang' => '供应商类型',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '类型名称',
+			'default' 	=> '',
+			'desc' 		=> '类型名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'stock'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否有库存',
+            'default'   => '1',
+            'desc'      => '是否有库存',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $stock,
+        ),
+
+		'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
+	(
+		'insert' => false,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"默认类型", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 8 - 0
module/scm_role/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'scm_role');
+define('DEVER_APP_LANG', '角色库');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 97);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-username');
+include(DEVER_APP_PATH . '../boot.php');

+ 248 - 0
module/scm_role/lib/Seller.php

@@ -0,0 +1,248 @@
+<?php
+
+namespace Scm_role\Lib;
+
+use Dever;
+
+class Seller
+{
+    # 获取商品列表
+    public function getGoods($seller_id)
+    {
+        $where['seller_id'] = $seller_id;
+        $where['sell_type'] = 1;
+        $data = Dever::db('scm_role/seller_goods')->getDataPage($where);
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $v['id'] = $v['goods_id'];
+                $data[$k] = Dever::load('scm_product/lib/info')->getInfo($v);
+            }
+        }
+
+        return $data;
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $seller_id = Dever::input('seller_id', 1);
+        $price_id = Dever::input('price_id', -1);
+        $type = Dever::input('type', 1);
+        $source = '';
+        $table = 'scm_role/seller_goods_sku';
+        if ($type == 2) {
+            $source = 'scm_role/seller_goods_sku';
+            $table = '';
+        }
+        $goods_category = Dever::input('goods_category');
+        $where['seller_id'] = $seller_id;
+        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList($table, $where, $goods_category, 'goods_id', array(), $price_id, $source));
+    }
+
+    # 配置商品
+    public function setGoods_api()
+    {
+        $data = array();
+        $data['seller_id'] = Dever::input('id', 1);
+        $info = Dever::db('scm_role/seller')->find($data['seller_id']);
+        $data['info'] = $info;
+        $goods_category = $info['category'];
+
+        $data['host'] = Dever::url('lib/seller.setGoods', 'scm_role');
+        $data['url'] = Dever::url('lib/seller.goods?seller_id=' . $data['seller_id'] . '&goods_category=' . $goods_category . '&price_id=' . $info['price_id'], 'scm_role');
+        //$data['search'] = Dever::url('lib/seller.search?yes='.$data['seller_id'].'&json=1', 'scm_role');
+        $data['submit'] = Dever::url('lib/seller.setGoods_action_commit?json=1', 'scm_role');
+
+        return Dever::render('set_seller_goods', $data);
+    }
+
+    # 配置商品
+    public function setGoods_action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $seller_id = Dever::input('seller_id');
+
+        $seller = Dever::db('scm_role/seller')->one($seller_id);
+        $where['option_seller_id'] = $seller_id;
+        $where['set_state'] = 2;
+        Dever::db('scm_role/seller_goods')->updates($where);
+
+        Dever::db('scm_role/seller_goods_sku')->updates($where);
+
+        foreach ($goods as $k => $v) {
+            $temp = explode('-', $k);
+            $goods_id = $temp[0];
+            if (isset($temp[1])) {
+                $sku_id = $temp[1];
+            } else {
+                $sku_id = -1;
+            }
+            if ($v['num'] < 0) {
+            	continue;
+            }
+            if ($v['del'] == 2) {
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['seller_id'] = $seller_id;
+                $w['sku_id'] = $sku_id;
+                $sku_info = Dever::db('scm_role/seller_goods_sku')->one($w);
+
+                if ($sku_info) {
+                    Dever::db('scm_role/seller_goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db('scm_role/seller_goods_sku')->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db('scm_role/seller_goods')->one($w);
+                    if ($info) {
+                        Dever::db('scm_role/seller_goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['seller_id'] = $seller_id;
+                $info = Dever::db('scm_role/seller_goods')->one($w);
+
+                $w['in_num'] = $v['num'];
+                $w['min'] = $v['min'];
+                if (!$info) {
+                    Dever::db('scm_role/seller_goods')->insert($w);
+                } else {
+                    $w['in_num'] += $info['in_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('scm_role/seller_goods')->update($w);
+                }
+
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['seller_id'] = $seller_id;
+                $w['sku_id'] = $sku_id;
+                $info = Dever::db('scm_role/seller_goods_sku')->one($w);
+
+                $w['in_num'] = $v['num'];
+                $w['min'] = $v['min'];
+                if (!$info) {
+                    Dever::db('scm_role/seller_goods_sku')->insert($w);
+                } else {
+                    $w['in_num'] += $info['in_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('scm_role/seller_goods_sku')->update($w);
+                }
+            }
+        }
+        return 'refer';
+    }
+
+    # 采购商品
+    public function buyGoods_api()
+    {
+        $data = array();
+        $data['seller_id'] = Dever::input('id', 1);
+        $info = Dever::db('scm_role/seller')->find($data['seller_id']);
+        $data['info'] = $info;
+        $goods_category = $info['category'];
+
+        $data['host'] = Dever::url('lib/seller.buyGoods', 'scm_role');
+        $data['url'] = Dever::url('lib/seller.goods?seller_id=' . $data['seller_id'] . '&goods_category=' . $goods_category . '&price_id=' . $info['price_id'] . '&type=2', 'scm_role');
+        $data['submit'] = Dever::url('lib/seller.buyGoods_action_commit?json=1', 'scm_role');
+
+        return Dever::render('buy_seller_goods', $data);
+    }
+
+    # 采购商品
+    public function buyGoods_action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $seller_id = Dever::input('seller_id');
+
+        $seller = Dever::db('scm_role/seller')->one($seller_id);
+        $where['option_seller_id'] = $seller_id;
+        $where['set_state'] = 2;
+        Dever::db('scm_role/seller_goods')->updates($where);
+
+        Dever::db('scm_role/seller_goods_sku')->updates($where);
+
+        foreach ($goods as $k => $v) {
+            $temp = explode('-', $k);
+            $goods_id = $temp[0];
+            if (isset($temp[1])) {
+                $sku_id = $temp[1];
+            } else {
+                $sku_id = -1;
+            }
+            if ($v['num'] < 0) {
+                continue;
+            }
+            if ($v['del'] == 2) {
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['seller_id'] = $seller_id;
+                $w['sku_id'] = $sku_id;
+                $sku_info = Dever::db('scm_role/seller_goods_sku')->one($w);
+
+                if ($sku_info) {
+                    Dever::db('scm_role/seller_goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db('scm_role/seller_goods_sku')->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db('scm_role/seller_goods')->one($w);
+                    if ($info) {
+                        Dever::db('scm_role/seller_goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['seller_id'] = $seller_id;
+                $info = Dever::db('scm_role/seller_goods')->one($w);
+
+                $w['in_num'] = $v['num'];
+                $w['min'] = $v['min'];
+                if (!$info) {
+                    Dever::db('scm_role/seller_goods')->insert($w);
+                } else {
+                    $w['in_num'] += $info['in_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('scm_role/seller_goods')->update($w);
+                }
+
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['seller_id'] = $seller_id;
+                $w['sku_id'] = $sku_id;
+                $info = Dever::db('scm_role/seller_goods_sku')->one($w);
+
+                $w['in_num'] = $v['num'];
+                $w['min'] = $v['min'];
+                if (!$info) {
+                    Dever::db('scm_role/seller_goods_sku')->insert($w);
+                } else {
+                    $w['in_num'] += $info['in_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('scm_role/seller_goods_sku')->update($w);
+                }
+            }
+        }
+        return 'refer';
+    }
+}

+ 127 - 0
module/scm_role/lib/Supplier.php

@@ -0,0 +1,127 @@
+<?php
+
+namespace Scm_role\Lib;
+
+use Dever;
+
+class Supplier
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取门店
+    public function search_api()
+    {
+        return Dever::search('scm_product/category', array(), 'getTop');
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $supplier_id = Dever::input('supplier_id', 1);
+        $goods_category = Dever::input('goods_category');
+        $where['supplier_id'] = $supplier_id;
+        return Dever::outDiy(Dever::load('scm_product/lib/info')->getSetList('scm_role/supplier_goods_sku', $where, $goods_category));
+    }
+
+    # 配置商品
+    public function setGoods_api()
+    {
+        $data = array();
+        $data['supplier_id'] = Dever::input('id', 1);
+        $info = Dever::db('scm_role/supplier')->find($data['supplier_id']);
+        $data['info'] = $info;
+        $goods_category = $info['category'];
+
+        $data['host'] = Dever::url('lib/supplier.setGoods', 'scm_role');
+        $data['url'] = Dever::url('lib/supplier.goods?supplier_id=' . $data['supplier_id'] . '&goods_category=' . $goods_category, 'scm_role');
+        //$data['search'] = Dever::url('lib/supplier.search?yes='.$data['supplier_id'].'&json=1', 'scm_role');
+        $data['submit'] = Dever::url('lib/supplier.setGoods_action_commit?json=1', 'scm_role');
+
+        return Dever::render('set_supplier_goods', $data);
+    }
+
+    # 配置商品
+    public function setGoods_action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $supplier_id = Dever::input('supplier_id');
+
+        $supplier = Dever::db('scm_role/supplier')->one($supplier_id);
+        $where['option_supplier_id'] = $supplier_id;
+        $where['set_state'] = 2;
+        Dever::db('scm_role/supplier_goods')->updates($where);
+
+        Dever::db('scm_role/supplier_goods_sku')->updates($where);
+
+        foreach ($goods as $k => $v) {
+            $temp = explode('-', $k);
+            $goods_id = $temp[0];
+            if (isset($temp[1])) {
+                $sku_id = $temp[1];
+            } else {
+                $sku_id = -1;
+            }
+            if ($v['num'] < 0) {
+            	continue;
+            }
+            if ($v['del'] == 2) {
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['supplier_id'] = $supplier_id;
+                $w['sku_id'] = $sku_id;
+                $sku_info = Dever::db('scm_role/supplier_goods_sku')->one($w);
+
+                if ($sku_info) {
+                    Dever::db('scm_role/supplier_goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db('scm_role/supplier_goods_sku')->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db('scm_role/supplier_goods')->one($w);
+                    if ($info) {
+                        Dever::db('scm_role/supplier_goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('scm_product/info')->one($goods_id);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['supplier_id'] = $supplier_id;
+                $info = Dever::db('scm_role/supplier_goods')->one($w);
+                if (!$info) {
+                    Dever::db('scm_role/supplier_goods')->insert($w);
+                } else {
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('scm_role/supplier_goods')->update($w);
+                }
+
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['supplier_id'] = $supplier_id;
+                $w['sku_id'] = $sku_id;
+                $info = Dever::db('scm_role/supplier_goods_sku')->one($w);
+
+                $w['in_num'] = $v['num'];
+                if (!$info) {
+                    Dever::db('scm_role/supplier_goods_sku')->insert($w);
+                } else {
+                    $w['in_num'] += $info['in_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('scm_role/supplier_goods_sku')->update($w);
+                }
+            }
+        }
+        return 'refer';
+    }
+}