rabin 2 years ago
parent
commit
029f90c02d

+ 12 - 0
database/category.php

@@ -228,6 +228,18 @@ return array
 
 
 	'request' => array
 	'request' => array
 	(
 	(
+		'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'id,name,parent_id',
+        ),
+
 		# 获取顶级分类
 		# 获取顶级分类
 		'getTop' => array
 		'getTop' => array
 		(
 		(

+ 12 - 0
database/category_attr.php

@@ -333,6 +333,18 @@ return array
 
 
 	'request' => array
 	'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
 		'getAll' => array
 		(
 		(
 			# 匹配的正则或函数 选填项
 			# 匹配的正则或函数 选填项

+ 5 - 3
database/info.php

@@ -504,8 +504,8 @@ $config = array
 			# 接口
 			# 接口
 			'api' => array
 			'api' => array
 			(
 			(
-				'spec' => 'product/lib/sku.spec',
-				'sku' => 'product/lib/sku.sku',
+				'spec' => 'product/lib/spec.get',
+				'sku' => 'product/lib/sku.get',
 				# 上传接口
 				# 上传接口
 				'upload' => 'upload/save.start?key=1',
 				'upload' => 'upload/save.start?key=1',
 			),
 			),
@@ -631,9 +631,11 @@ $config = array
             'option' => array
             'option' => array
             (
             (
                 'id' => 'yes',
                 'id' => 'yes',
+                'status' => 1,
+                'state' => 1,
             ),
             ),
             'type' => 'one',
             'type' => 'one',
-            'col' => 'id,name,category,pic,content',
+            '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',
         ),
         ),
 	),
 	),
 );
 );

+ 1 - 0
database/info_attr.php

@@ -19,6 +19,7 @@ $config = array
             'desc'      => '',
             'desc'      => '',
             'match'     => 'is_numeric',
             'match'     => 'is_numeric',
             'search'    => 'order',
             'search'    => 'order',
+            'order'		=> 'asc',
             'update'    => 'hidden',
             'update'    => 'hidden',
 		),
 		),
 
 

+ 14 - 0
database/info_spec.php

@@ -123,6 +123,20 @@ $config = array
 			'order' => array('reorder' => 'asc', 'id' => 'asc'),
 			'order' => array('reorder' => 'asc', 'id' => 'asc'),
 			'col' => 'id, name as title',
 			'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',
+		),
 	),
 	),
 );
 );
 
 

+ 15 - 1
database/info_spec_value.php

@@ -150,7 +150,7 @@ $config = array
 			'col' => 'id, value as title, case is_checked when 1 then true else false end as checked',
 			'col' => 'id, value as title, case is_checked when 1 then true else false end as checked',
 		),
 		),
 
 
-		'getData' => array
+		'getGroupData' => array
         (
         (
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
@@ -164,6 +164,20 @@ $config = array
             'order' => array('reorder' => 'desc', 'id' => 'desc'),
             'order' => array('reorder' => 'desc', 'id' => 'desc'),
             'col' => 'id,info_id,value,group_concat(value) as name',
             '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',
+        ),
 	),
 	),
 );
 );
 
 

+ 1 - 1
index.php

@@ -6,5 +6,5 @@ define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 define('DEVER_MANAGE_ORDER', 98);
 define('DEVER_MANAGE_ORDER', 98);
 define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
 define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');
 define('DEVER_GROUP_ORDER', -1);
 define('DEVER_GROUP_ORDER', -1);
-define('DEVER_GROUP_NAME', '电商系统');
+define('DEVER_GROUP_NAME', '资料库');
 include(DEVER_APP_PATH . '../boot.php');
 include(DEVER_APP_PATH . '../boot.php');

+ 37 - 65
lib/Attr.php

@@ -89,44 +89,49 @@ class Attr
 	 *
 	 *
 	 * @return mixed
 	 * @return mixed
 	 */
 	 */
-	public function getInfo($ids, $value)
+	public function getInfo($id, $value)
 	{
 	{
-		$result = array();
-		if ($ids) {
-			$where['ids'] = $ids;
-			$cate = Dever::db('product/category')->state();
-			$data = Dever::db('product/category_attr')->getAllByIds($where);
-
-			$ids = explode(',', $ids);
-			$value = explode(',', $value);
-			if ($data) {
-				foreach ($ids as $k => $v) {
-					if (isset($data[$v])) {
-						$cate_id = $data[$v]['category_id'];
-						if (!isset($cate[$cate_id])) {
-							continue;
-						}
+		$info = Dever::db('product/category_attr')->getOne($id);
+        if ($info) {
+        	$info['value'] = $value;
+        	$info = $this->getValue($info);
+        }
 
 
-						if (!isset($result[$cate_id])) {
-							$result[$cate_id] = array
-							(
-								'name' => $cate[$cate_id]['name'],
-								'id' => $cate_id
-							);
-						}
+		return $info;
+	}
 
 
-						$result[$cate_id]['attr'][$v] = array
-						(
-							'name' => $data[$v]['name'],
-							'value' => isset($value[$k]) ? $value[$k] : '',
-							'id' => $v
-						);
-					}
+	/**
+	 * 获取属性的值
+	 *
+	 * @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('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'];	
 		}
 		}
-
-		return $result;
+		unset($info['unit']);
+		return $info;
 	}
 	}
 
 
 	/**
 	/**
@@ -310,39 +315,6 @@ class Attr
 		return $data;
 		return $data;
 	}
 	}
 
 
-	/**
-	 * 获取属性的值
-	 *
-	 * @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('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'];
-		}
-		return $info['value'];
-	}
-
 	/**
 	/**
 	 * 获取属性的名称,字符类型
 	 * 获取属性的名称,字符类型
 	 *
 	 *

+ 1 - 1
lib/Category.php

@@ -157,7 +157,7 @@ class Category
     {
     {
         $name = '';
         $name = '';
         if ($id > 0) {
         if ($id > 0) {
-            $data = Dever::db('product/category')->one($id);
+            $data = Dever::db('product/category')->getOne($id);
             if ($state) {
             if ($state) {
                 return $data;
                 return $data;
             }
             }

+ 140 - 12
lib/Info.php

@@ -13,23 +13,56 @@ class Info
     }
     }
 
 
     # 获取商品详情
     # 获取商品详情
-    public function getInfo($id)
+    public function getInfo_api($id)
     {
     {
-        $info = Dever::db('product/info')->find($id);
+        $info = Dever::db('product/info')->getOne($id);
 
 
         $info = $this->get($info);
         $info = $this->get($info);
 
 
+        print_r($info);die;
+
         return $info;
         return $info;
     }
     }
 
 
     private function get($info)
     private function get($info)
     {
     {
+        # 基本信息
+        $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('product/lib/category')->getInfo($info['category']);
+
         # 获取属性
         # 获取属性
-        
+        $attr = Dever::db('product/info_attr')->select(array('info_id' => $info['id']));
+        if ($attr) {
+            foreach ($attr as $k => $v) {
+                $attr_info = Dever::load('product/lib/attr')->getInfo($v['attr_id'], $v['attr_value']);
+                if ($attr_info) {
+                    $info['attr'][] = $attr_info;
+                }
+            }
+        }
 
 
         # 获取规格
         # 获取规格
+        $info['spec'] = Dever::load('product/lib/spec')->getData($info['id'], 'getData');
+
+        # 获取价格
+        $info['sku'] = Dever::load('product/lib/sku')->getData($info['id']);
+
+        # 获取组合商品
+        if ($info['type'] > 10) {
+            $info['goods'] = Dever::json_decode($info['goods']);
+        } else {
+            unset($info['goods']);
+        }
+
+        # 获取单位信息
+        if ($info['unit'] > 0) {
+            $info['unit'] = Dever::db('product/unit')->find($info['unit']);
+        }
 
 
-        # 获取其他
+        return $info;
     }
     }
 
 
     # 获取商品及其属性列表
     # 获取商品及其属性列表
@@ -88,11 +121,11 @@ class Info
                         if (isset($other['min']) && $other['min']) {
                         if (isset($other['min']) && $other['min']) {
                             $result[$i]['min'] = $other['min'];
                             $result[$i]['min'] = $other['min'];
                         }
                         }
-                        if (isset($other['total_num'])) {
-                            if (isset($other['sell_num'])) {
-                                $result[$i]['total'] = $other['total_num'] - $other['sell_num'];
+                        if (isset($other['in_num'])) {
+                            if (isset($other['out_num'])) {
+                                $result[$i]['total'] = $other['in_num'] - $other['out_num'];
                             } else {
                             } else {
-                                $result[$i]['total'] = $other['total_num'];
+                                $result[$i]['total'] = $other['in_num'];
                             }
                             }
                             
                             
                         } elseif (isset($other['num'])) {
                         } elseif (isset($other['num'])) {
@@ -169,11 +202,11 @@ class Info
                                 if (isset($other_sku['min']) && $other_sku['min']) {
                                 if (isset($other_sku['min']) && $other_sku['min']) {
                                     $children['min'] = $other_sku['min'];
                                     $children['min'] = $other_sku['min'];
                                 }
                                 }
-                                if (isset($other_sku['total_num'])) {
-                                    if (isset($other_sku['sell_num'])) {
-                                        $children['total'] = $other_sku['total_num'] - $other_sku['sell_num'];
+                                if (isset($other_sku['in_num'])) {
+                                    if (isset($other_sku['out_num'])) {
+                                        $children['total'] = $other_sku['in_num'] - $other_sku['out_num'];
                                     } else {
                                     } else {
-                                        $children['total'] = $other_sku['total_num'];
+                                        $children['total'] = $other_sku['in_num'];
                                     }
                                     }
                                 } elseif (isset($other_sku['num'])) {
                                 } elseif (isset($other_sku['num'])) {
                                     $children['total'] = $other_sku['num'];
                                     $children['total'] = $other_sku['num'];
@@ -193,4 +226,99 @@ class Info
 
 
         return $result;
         return $result;
     }
     }
+
+    # 获取支付所需要的信息
+    public function getPayInfo($id, $sku = 0, $type = 1, $value = '')
+    {
+        $info = is_array($id) ? $id : Dever::db($this->table_info)->one($id);
+
+        if ($info) {
+            if ($type == 2) {
+                $info['price'] = $info['f_price'];
+                unset($info['s_price']);
+            } else {
+                unset($info['f_price']);
+            }
+            $info['sku_name'] = '';
+            $sku = $sku > 0 ? $sku : $info['sku_id'];
+            if ($sku > 0) {
+                $where['info_id'] = $info['id'];
+                $where['id'] = $sku;
+                $sku = Dever::db('goods/info_sku')->find($where);
+                if ($sku) {
+
+                    if ($sku['type'] == 3) {
+                        $price = $sku['price'];
+                        $s_price = $sku['s_price'];
+                        $f_price = $sku['f_price'];
+                        $c_price = $sku['c_price'];
+                        $sku['price'] = 0;
+                        $sku['s_price'] = 0;
+                        $sku['f_price'] = 0;
+                        $sku['c_price'] = 0;
+                        # 计算价格
+                        $key = explode('_', $sku['key']);
+                        $attr = Dever::db('attr/info')->find($key[0]);
+                        if ($attr) {
+                            if ($value >= $attr['sell_value']) {
+                                $sku['price'] = $price;
+                                $sku['s_price'] = $s_price;
+                                $sku['f_price'] = $f_price;
+                                $sku['c_price'] = $c_price;
+                            }
+                        }
+                    }
+
+                    $info['sku_id'] = $sku['id'];
+                    if ($type == 2) {
+                        $info['price'] = $sku['f_price'];
+                    } else {
+                        $info['price'] = $sku['price'];
+                        $info['s_price'] = $sku['s_price'];
+                        $info['c_price'] = $sku['c_price'];
+                    }
+
+                    $info['min'] = $sku['min'];
+                    //$info['attr_json'] = $sku['attr'];
+                    $info['attr'] = Dever::json_decode($sku['attr']);
+
+                    if ($info['attr']) {
+                        $info['attr'] = Dever::load('attr/api')->getInfoByJson($info['attr']);
+                        $info['sku_name'] = $info['attr']['string'];
+                    }
+                }
+            }
+            $this->getGroup($info);
+            if (floor($info['min']) == $info['min']) {
+                $info['min'] = intval($info['min']);
+            }
+            /*
+            $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);
+        }
+
+        if (isset($info['price'])) {
+            $info['price'] = trim($info['price']);
+        }
+        if (isset($info['s_price'])) {
+            $info['s_price'] = trim($info['s_price']);
+        }
+        if (isset($info['c_price'])) {
+            $info['c_price'] = trim($info['c_price']);
+        }
+        if (isset($info['f_price'])) {
+            $info['f_price'] = trim($info['f_price']);
+        }
+
+        return $info;
+    }
 }
 }

+ 30 - 19
lib/Sku.php

@@ -6,24 +6,8 @@ use Dever;
 
 
 class Sku
 class Sku
 {
 {
-    # 获取当前的规格
-    public function spec_api()
-    {
-    	$id = Dever::input('id');
-    	$result = array();
-    	if ($id) {
-    		$result = Dever::db('product/info_spec')->getAll(array('info_id' => $id));
-    		if ($result) {
-    			foreach ($result as $k => $v) {
-    				$result[$k]['child'] = Dever::db('product/info_spec_value')->getAll(array('info_id' => $id, 'spec_id' => $v['id']));
-    			}
-    		}
-    	}
-    	return $result;
-    }
-
     # 获取当前的sku
     # 获取当前的sku
-    public function sku_api()
+    public function get_api()
     {
     {
     	$id = Dever::input('id');
     	$id = Dever::input('id');
     	$result = array();
     	$result = array();
@@ -33,7 +17,7 @@ class Sku
     	return $result;
     	return $result;
     }
     }
 
 
-    # 获取某个商品的sku
+    # 获取某个商品的sku商品列表
     public function getList($info, &$data)
     public function getList($info, &$data)
     {
     {
         if ($info['spec_type'] == 2) {
         if ($info['spec_type'] == 2) {
@@ -43,7 +27,7 @@ class Sku
                 foreach ($sku as $k => $v) {
                 foreach ($sku as $k => $v) {
                     $copy = $info;
                     $copy = $info;
                     $key = str_replace('-', ',', $v['key']);
                     $key = str_replace('-', ',', $v['key']);
-                    $spec = Dever::db('product/info_spec_value')->getData(array('ids' => $key));
+                    $spec = Dever::db('product/info_spec_value')->getGroupData(array('ids' => $key));
                     if ($spec) {
                     if ($spec) {
                         $copy['name'] .= '-' . $spec['name'];
                         $copy['name'] .= '-' . $spec['name'];
                         $copy['id'] .= '-' . $v['key'];
                         $copy['id'] .= '-' . $v['key'];
@@ -61,4 +45,31 @@ class Sku
         
         
         return $data;
         return $data;
     }
     }
+
+    # 获取基本信息列表
+    public function getData($info_id, $sku_id = false)
+    {
+        $where['info_id'] = $info_id;
+        if ($sku_id) {
+            $where['id'] = $sku_id;
+        }
+        $sku = Dever::db('product/info_sku')->select($where);
+        return $sku;
+        if ($sku) {
+            foreach ($sku as $k => $v) {
+                $key = str_replace('-', ',', $v['key']);
+                $spec = Dever::db('product/info_spec_value')->getData(array('ids' => $key));
+                if ($spec) {
+                    $copy['name'] .= '-' . $spec['name'];
+                    $copy['id'] .= '-' . $v['key'];
+                    if (isset($copy['value'])) {
+                        $copy['value'] = $copy['id'];
+                    }
+                }
+                
+                $data[] = $copy;
+            }
+        }
+        return $data;
+    }
 }
 }

+ 30 - 0
lib/Spec.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace 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('product/info_spec')->$method(array('info_id' => $info_id));
+    		if ($result) {
+    			foreach ($result as $k => $v) {
+    				$result[$k]['child'] = Dever::db('product/info_spec_value')->$method(array('info_id' => $info_id, 'spec_id' => $v['id']));
+    			}
+    		}
+    	}
+    	return $result;
+    }
+}

+ 363 - 0
module/order/database/buy.php

@@ -0,0 +1,363 @@
+<?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 => '已过期',
+);
+
+$audit = array
+(
+    //1 => '待审核',
+    2 => '审核通过',
+    3 => '审核未通过',
+);
+
+$seller = function()
+{
+    $array = array();
+    $info = Dever::db('role/sell')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'buy',
+    # 显示给用户看的名称
+    'lang' => '订货订单',
+    'order' => 99,
+    '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("order/lib/buy.info#order", {id})',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => array
+            (
+                'api' => '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("order/lib/sell.info#address", {id})',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买总数量',
+            'default'   => '',
+            'desc'      => '购买总数量',
+            'match'     => 'is_numeric',
+            'list_name'	=> '金额信息',
+            'list'      => 'Dever::load("order/lib/sell.info#cash", {id})',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '订单总金额',
+            'default'   => '0',
+            'desc'      => '订单总金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'pay_account'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付账号',
+            'default'   => '1',
+            'desc'      => '支付账号',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'	=> $pay_account,
+        ),
+
+        '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 => '确认收货'),
+        ),
+
+        '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}) : "-"',
+        ),
+
+        '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/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',
+        ),
+    ),
+);

+ 153 - 0
module/order/database/buy_ps.php

@@ -0,0 +1,153 @@
+<?php
+
+$status = array
+(
+    1 => '待处理',
+    2 => '配送中',
+    3 => '已配送',
+    4 => '未配送',
+);
+
+$service = function()
+{
+    $info = Dever::db('role/servicer')->select();
+    return $info;
+};
+
+return array
+(
+    # 表名
+    'name' => 'buy_ps',
+    # 显示给用户看的名称
+    'lang' => '订单配送表',
+    'menu' => false,
+    'status' => $status,
+    'end' => array
+    (
+        'insert' => 'order/lib/buy.ps',
+        'update' => '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'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '快递信息',
+            'default'   => '',
+            'desc'      => '配送发货',
+            'match'     => 'is_string',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'service_id',
+                    'name'      => '配送服务商',
+                    'default'   => '-1',
+                    'desc'      => '配送服务商',
+                    'match'     => 'is_numeric',
+                    'update'    => 'select',
+                    'option'    => $service,
+                ),
+
+                array
+                (
+                    'col'       => 'order_num',
+                    '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/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
+    (
+        
+    ),
+);

+ 433 - 0
module/order/database/sell.php

@@ -0,0 +1,433 @@
+<?php
+$pay_account = function()
+{
+    $array = array
+    (
+    	-1 => '其他',
+    );
+    $info = Dever::db('pay/account')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$method = array
+(
+    1 => '自提',
+    2 => '外送',
+);
+
+$status = array
+(
+    1 => '待支付',
+    2 => '待处理',
+    3 => '处理中',
+    4 => '待收货确认',
+    5 => '已完成',
+    6 => '已完成(有退款)',
+    7 => '已取消',
+    8 => '已退款',
+    11 => '已过期',
+);
+
+$seller = function()
+{
+    $array = array();
+    $info = Dever::db('role/sell')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'sell',
+    # 显示给用户看的名称
+    'lang' => '销售订单',
+    'order' => 100,
+    'set' => array
+    (
+    	'status' => $status,
+	    'method' => $method,
+    ),
+    
+    '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("order/lib/sell.info#order", {id})',
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => array
+            (
+                'api' => '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',
+            ),
+        ),
+
+        'address'      => array
+        (
+            'type'      => 'varchar-2000',
+            'name'      => '收货信息',
+            'default'   => '',
+            'desc'      => '收货信息',
+            'match'     => 'is_numeric',
+            'search'	=> 'fulltext',
+            'list'      => 'Dever::load("order/lib/sell.info#address", {id})',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买总数量',
+            'default'   => '',
+            'desc'      => '购买总数量',
+            'match'     => 'is_numeric',
+            'list_name'	=> '金额信息',
+            'list'      => 'Dever::load("order/lib/sell.info#cash", {id})',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '订单总金额',
+            'default'   => '0',
+            'desc'      => '订单总金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'pay_account'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付账号',
+            'default'   => '1',
+            'desc'      => '支付账号',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+        ),
+
+        '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',
+        ),
+
+        'card_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户的礼品卡id',
+            'default'   => '',
+            'desc'      => '礼品卡id',
+            'match'     => 'option',
+        ),
+
+        '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',
+        ),
+
+        'coupon_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户的优惠券id',
+            'default'   => '',
+            'desc'      => '用户的优惠券id',
+            'match'     => 'option',
+        ),
+
+        'coupon_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '优惠金额',
+            'default'   => '0',
+            'desc'      => '优惠金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'discount_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '折扣ID',
+            'default'   => '',
+            'desc'      => '折扣ID',
+            'match'     => 'option',
+        ),
+
+        'discount_cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '折扣优惠金额',
+            'default'   => '0',
+            'desc'      => '折扣优惠金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'method'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配送类型',
+            'default'   => '1',
+            'desc'      => '配送类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $method,
+        ),
+
+        'code'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '自提码或者核销码',
+            'default'   => '',
+            'desc'      => '自提码或者核销码',
+            'match'     => 'is_numeric',
+        ),
+
+        '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',
+                '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' => '*',
+        ),
+    ),
+);

+ 322 - 0
module/order/database/sell_goods.php

@@ -0,0 +1,322 @@
+<?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,
+        ),
+
+        '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',
+        ),
+
+        'coupon_cash'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '优惠金额',
+            'default'   => '0',
+            'desc'      => '优惠金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'discount_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '使用的折扣id',
+            'default'   => '',
+            'desc'      => '使用的折扣id',
+            'match'     => 'option',
+        ),
+
+        'discount_cash'      => array
+        (
+            'type'      => 'varchar-300',
+            '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' => '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',
+        ),
+    ),
+);

+ 153 - 0
module/order/database/sell_ps.php

@@ -0,0 +1,153 @@
+<?php
+
+$status = array
+(
+    1 => '待处理',
+    2 => '配送中',
+    3 => '已配送',
+    4 => '未配送',
+);
+
+$service = function()
+{
+    $info = Dever::db('role/servicer')->select();
+    return $info;
+};
+
+return array
+(
+    # 表名
+    'name' => 'sell_ps',
+    # 显示给用户看的名称
+    'lang' => '订单配送表',
+    'menu' => false,
+    'status' => $status,
+    'end' => array
+    (
+        'insert' => 'order/lib/sell.ps',
+        'update' => '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'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '快递信息',
+            'default'   => '',
+            'desc'      => '配送发货',
+            'match'     => 'is_string',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'service_id',
+                    'name'      => '配送服务商',
+                    'default'   => '-1',
+                    'desc'      => '配送服务商',
+                    'match'     => 'is_numeric',
+                    'update'    => 'select',
+                    'option'    => $service,
+                ),
+
+                array
+                (
+                    'col'       => 'order_num',
+                    '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/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
+    (
+        
+    ),
+);

+ 10 - 0
module/order/index.php

@@ -0,0 +1,10 @@
+<?php
+
+define('DEVER_APP_NAME', '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');
+define('DEVER_GROUP_ORDER', -1);
+define('DEVER_GROUP_NAME', '资料库');
+include(DEVER_APP_PATH . '../boot.php');

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

@@ -0,0 +1,68 @@
+<?php
+
+namespace Order\Lib;
+
+use Dever;
+
+class Buy
+{
+	# 获取订单信息
+    public function info($id)
+    {
+    	Dever::load('manage/auth.init');
+
+    	$info = Dever::db('order/sell')->find($id);
+
+    	$data['order'] = array();
+
+    	$data['order']['订单号'] = $info['order_num'];
+
+    	$seller = Dever::db('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('order/sell')->find(array('id' => $order_id));
+            if ($info && $info['status'] < 3) {
+                Dever::load('shop/lib/sell')->notice($info);
+            }*/
+        }
+    }
+}

+ 452 - 0
module/order/lib/Sell.php

@@ -0,0 +1,452 @@
+<?php
+
+namespace Order\Lib;
+
+use Dever;
+
+class Sell
+{
+	# 获取订单信息
+    public function info($id)
+    {
+    	Dever::load('manage/auth.init');
+
+    	$info = Dever::db('order/sell')->find($id);
+
+    	$data['order'] = array();
+
+    	$data['order']['订单号'] = $info['order_num'];
+
+    	$seller = Dever::db('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('order/sell')->find(array('id' => $order_id));
+            if ($info && $info['status'] < 3) {
+                Dever::load('shop/lib/sell')->notice($info);
+            }*/
+        }
+    }
+
+    # 得到商品和总价
+    public function goods(&$data)
+    {
+        # 1自提,2配送
+        $data['method'] = Dever::input('method', 1);
+
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        if (!$goods) {
+        	Dever::alert('商品信息不存在');
+        }
+
+        # 总价
+        $data['cash'] = 0;
+        # 支付价格
+        $data['pay_cash'] = 0;
+        # 钱包金额
+        $data['wallet_cash'] = 0;
+        # 配送金额
+        $data['ps_cash'] = 0;
+        $data['num'] = 0;
+
+        # 获取角色
+        $role = $this->getRole($data);
+        $data['discount_goods'] = array();
+        $data['discount_cash'] = 0;
+        $data['discount_id'] = 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('product/lib/info')->getInfo($v['goods_id'], $v['sku_id']);
+
+            $w = array();
+            $w['goods_id'] = $v;
+            $w['sku_id'] = $s;
+            $w['shop_id'] = $data['shop']['id'];
+            $goods_sku = Dever::db('shop/goods_sku')->find($w);
+            if ($goods_sku) {
+                if (isset($goods_sku['min'])) {
+                    $data['list'][$k]['min'] = $goods_sku['min'];
+                }
+                if (isset($goods_sku['price_id']) && $goods_sku['price_id'] > 0) {
+                    $price_template = Dever::load('price/lib/data')->get($v, $s, $goods_sku['price_id']);
+                    if ($price_template) {
+                        /*
+                        if ($goods_sku['min'] <= 0 && $price_template['price_num'] > 0) {
+                            $data['list'][$k]['min'] = $price_template['price_num'];
+                        }
+                        */
+                        if ($price_template['price_sell'] && $price_template['price_sell'] > 0) {
+                            $data['list'][$k]['price'] = $price_template['price_sell'];
+                        }
+                    }
+                }
+            }
+            
+            $data['list'][$k]['cash'] = $data['list'][$k]['price'];
+            $data['list'][$k]['num'] = $n;
+
+            # 2是库存不足
+            $data['list'][$k]['ku_state'] = 1;
+
+            if ($data['list'][$k]['status'] == 2) {
+                $total = 0;
+            } else {
+                # 验证是否有货
+                $total = Dever::load('shop/lib/info')->checkTotal($n, $v, $data['shop']['id'], $s);
+
+                if (isset($data['list'][$k]['min']) && $data['list'][$k]['min'] > 0) {
+                    if ($total < $data['list'][$k]['min']) {
+                        $total = 0;
+                    }
+                }
+            }
+
+            if ($total <= 0) {
+                $data['list'][$k]['ku_state'] = 2;
+                $data['list'][$k]['buy_num'] = 0;
+            }
+
+            if ($data['list'][$k]['ku_state'] == 1) {
+                $data['list'][$k]['buy_num'] = $n;
+                $data['num'] += $n;
+
+                # 根据角色设置折扣
+                if ($role) {
+                    $role_set = false;
+
+                    foreach ($role as $rk => $rv) {
+                        $discount_goods = Dever::db('act/discount_goods')->getData(array('discount_id' => $rv['id']));
+                        if ($discount_goods) {
+                            $discount_goods = array_keys($discount_goods);
+                            if (in_array($data['list'][$k]['id'], $discount_goods)) {
+                                $role_set = $rv;
+                                break;
+                            }
+                        } elseif ($rv['category'] && in_array($data['list'][$k]['top_category_id'], $rv['category'])) {
+                            $role_set = $rv;
+                            break;
+                        }
+                    }
+
+                    if ($role_set) {
+                        $discount_cash = round($data['list'][$k]['price'] * ($role_set['num']/10), 2);
+                        $data['list'][$k]['discount_id'] = $role_set['id'];
+                        $data['discount_goods'][] = $data['list'][$k];
+                        $data['discount_id'] = $role_set['id'];
+                        $data['list'][$k]['discount_cash'] = round(($data['list'][$k]['price'] - $discount_cash) * $n, 2);
+                        $data['discount_cash'] += $data['list'][$k]['discount_cash'];
+                        $data['price'] += $discount_cash * $n;
+                    } else {
+                        $data['price'] += $data['list'][$k]['price'] * $n;
+                    }
+                } else {
+                    $data['price'] += $data['list'][$k]['price'] * $n;
+                }
+                
+                $data['oprice'] += $data['list'][$k]['cash'] * $n;
+                $data['name'][] = $data['list'][$k]['name'];
+            }
+        }
+
+        $data['name'] = implode(',', $data['name']);
+
+        if ($data['method'] == 2) {
+            $data['ps_cash'] = $data['shop']['ps_cash'];
+            if ($data['shop']['free_ps_cash'] && $data['shop']['free_ps_cash'] > 0 && $data['price'] >= $data['shop']['free_ps_cash']) {
+                $data['ps_cash'] = 0;
+            }
+            if (!$data['ps_cash']) {
+                $data['ps_cash'] = 0;
+            }
+        }
+
+        return $data;
+    }
+
+    public function getRole($data)
+    {
+        if(isset($data['uid']) && $data['uid'] > 0) {
+            return Dever::load('shop/lib/info')->getRole($data['uid']);
+        }
+        return false;
+    }
+
+    # 发起支付
+	public function pay($method, $pay_method, $pay_type, $user, $shop, $name, $num, $goods, $oprice, $price, $cash, $address_id, $invoice_id, $info, $card, $wallet_cash, $coupon_id, $user_coupon_id, $coupon_cash, $discount_id, $discount_cash, $cart = false, $system_source = 5, $refer = '')
+    {
+        if (!$user) {
+            Dever::alert('错误的用户信息');
+        }
+
+        $uid = $user['id'];
+
+        if ($uid > 0) {
+            $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid, 'type' => 1, 'system_id' => 1));
+
+            if (!$wechat) {
+                //Dever::alert('错误的用户信息');
+            }
+        }
+
+        if ($method == 2) {
+            $ps_cash = $shop['ps_cash'];
+            if ($shop['free_ps_cash'] && $shop['free_ps_cash'] > 0 && $price >= $shop['free_ps_cash']) {
+                $ps_cash = 0;
+            }
+
+            if (!$ps_cash) {
+                $ps_cash = 0;
+            }
+
+            $order_data['ps_cash'] = $ps_cash;
+            $price += $order_data['ps_cash'];
+        }
+        
+        $order_data['shop_id'] = $shop['id'];
+        if ($shop['type'] == 10) {
+            $order_data['shop_type'] = 2;
+        } else {
+            $order_data['shop_type'] = 1;
+        }
+        
+        $order_data['area'] = $shop['area'] . ',' . $shop['id'];
+        $order_data['uid'] = $uid;
+        $order_data['mobile'] = $user['mobile'];
+        $order_data['address_id'] = $address_id;
+        $order_data['invoice_id'] = $invoice_id;
+        $order_data['name'] = $name;
+        $order_data['num'] = $num;
+        $order_data['info'] = $info;
+        $order_data['oprice'] = $oprice;
+        $order_data['price'] = $price;
+        $order_data['kou_cash'] = $cash;
+
+        $order_data['method'] = $method;
+        $order_data['pay_method'] = $pay_method;
+        $order_data['pay_type'] = $pay_type;
+        $order_data['refund_cash'] = 0;
+
+        if ($card) {
+            // $order_data['card_id'] = $card['info']['id'];
+        	$order_data['card_code_id'] = $card['id'];
+            $order_data['card_code_card'] = $card['card'];
+            $order_data['card_code_cash'] = $card['cash'];
+        } elseif ($wallet_cash && $wallet_cash > 0) {
+            $order_data['wallet_cash'] = $wallet_cash;
+        }
+        if ($user_coupon_id) {
+            $order_data['user_coupon_id'] = $user_coupon_id;
+        }
+        if ($coupon_id) {
+            $order_data['coupon_id'] = $coupon_id;
+        }
+        if ($coupon_cash) {
+            $order_data['coupon_cash'] = $coupon_cash;
+        }
+
+        if ($discount_id) {
+            $order_data['discount_id'] = $discount_id;
+        }
+        if ($discount_cash) {
+            $order_data['discount_cash'] = $discount_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('shop/sell_order')->find($order_data_where);
+
+        $order_data['order_num'] = $this->getOrderId();
+        
+        if (!$info) {
+            $id = Dever::db('shop/sell_order')->insert($order_data);
+        } else {
+            return array
+            (
+                'order' => '',
+                'order_num' => $info['order_num'],
+                'order_id' => $info['id'],
+                'type' => 'test',
+            );
+        }
+
+        if (!$id) {
+            Dever::alert('支付失败');
+        }
+
+        foreach($goods as $k => $v) {
+            if ($v['ku_state'] == 1) {
+                $data['uid'] = $uid;
+                $data['order_id'] = $id;
+                $data['shop_id'] = $shop['id'];
+                $data['goods_id'] = $v['id'];
+                $data['sku_id'] = $v['sku_id'];
+                $data['price'] = $v['price'];
+                $data['num'] = $v['buy_num'];
+
+                if (isset($v['user_coupon_id']) && $v['user_coupon_id']) {
+                    $data['user_coupon_id'] = $v['user_coupon_id'];
+                }
+                if (isset($v['coupon_id']) && $v['coupon_id']) {
+                    $data['coupon_id'] = $v['coupon_id'];
+                }
+                if (isset($v['coupon_cash']) && $v['coupon_cash']) {
+                    $data['coupon_cash'] = $v['coupon_cash'];
+                } else {
+                    $data['coupon_cash'] = 0;
+                }
+
+                if (isset($v['discount_id']) && $v['discount_id']) {
+                    $data['discount_id'] = $v['discount_id'];
+                }
+
+                if (isset($v['discount_cash']) && $v['discount_cash']) {
+                    $data['discount_cash'] = $v['discount_cash'];
+                }
+
+                Dever::db('shop/sell_order_goods')->insert($data);
+            }
+        }
+
+        # 减少库存 增加销量
+        $order_data['id'] = $id;
+        $this->updateSell($order_data);
+
+        if ($price <= 0 || $pay_type == 2) {
+
+        	$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, $goods, $shop['id']);
+            }
+            # 使用优惠券
+            $this->useCoupon($order_data, $coupon_id, $user_coupon_id, $card, $wallet_cash);
+
+            /*
+            if ($card) {
+                # 更新礼品卡状态
+                $card_update['where_id'] = $card['id'];
+                $card_update['status'] = 3;
+                $card_update['order_id'] = $id;
+                $card_update['shop_id'] = $shop['id'];
+                Dever::db('goods/card_code')->update($card_update);
+            }*/
+        	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;
+    }
+}

+ 424 - 0
module/role/assets/pc/html/set_supplier_goods.html

@@ -0,0 +1,424 @@
+<!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>';
+            }
+            
+            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>

+ 14 - 1
module/role/database/seller.php

@@ -419,6 +419,19 @@ return array
 
 
 	'request' => array
 	'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',
+        ),
 	)
 	)
 );
 );

+ 19 - 19
module/role/database/seller_goods_sku.php

@@ -75,21 +75,21 @@ $config = array
             'match'     => 'is_numeric',
             'match'     => 'is_numeric',
         ),
         ),
 
 
-        'total_num'        => array
+        'in_num'        => array
         (
         (
-            'type'      => 'float-11,2',
-            'name'      => '库存',
+            'type'      => 'decimal-11,2',
+            'name'      => '入库库存',
             'default'   => '0',
             'default'   => '0',
-            'desc'      => '库存',
+            'desc'      => '入库库存',
             'match'     => 'is_numeric',
             'match'     => 'is_numeric',
         ),
         ),
 
 
-        'sell_num'      => array
+        'out_num'      => array
         (
         (
-            'type'      => 'float-11,2',
-            'name'      => '销量',
+            'type'      => 'decimal-11,2',
+            'name'      => '出库库存',
             'default'   => '0',
             'default'   => '0',
-            'desc'      => '请填写销量',
+            'desc'      => '出库库存',
             'match'     => 'option',
             'match'     => 'option',
         ),
         ),
 
 
@@ -145,7 +145,7 @@ $config = array
             (
             (
                 'seller_id' => array('yes-t_1.seller_id'),
                 'seller_id' => array('yes-t_1.seller_id'),
                 'name' => array('yes-t_2.name', 'like'),
                 'name' => array('yes-t_2.name', 'like'),
-                'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
+                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
                 'category' => array('yes-t_2.category', 'like'),
                 'category' => array('yes-t_2.category', 'like'),
                 'top_category_id' => array('yes-t_2.top_category_id'),
                 'top_category_id' => array('yes-t_2.top_category_id'),
                 'second_category_id' => array('yes-t_2.second_category_id'),
                 'second_category_id' => array('yes-t_2.second_category_id'),
@@ -168,7 +168,7 @@ $config = array
             'type' => 'all',
             'type' => 'all',
             'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
             'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
             'page' => array(30, 'list'),
             'page' => array(30, 'list'),
-            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.total_num-t_1.sell_num as total,t_1.sell_num',
+            '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
         'getData' => array
@@ -178,7 +178,7 @@ $config = array
             (
             (
                 'seller_id' => array('yes-t_1.seller_id'),
                 'seller_id' => array('yes-t_1.seller_id'),
                 'name' => array('yes-t_2.name', 'like'),
                 'name' => array('yes-t_2.name', 'like'),
-                'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
+                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
                 'category' => array('yes-t_2.category', 'like'),
                 'category' => array('yes-t_2.category', 'like'),
                 'top_category_id' => array('yes-t_2.top_category_id'),
                 'top_category_id' => array('yes-t_2.top_category_id'),
                 'second_category_id' => array('yes-t_2.second_category_id'),
                 'second_category_id' => array('yes-t_2.second_category_id'),
@@ -200,7 +200,7 @@ $config = array
             ),
             ),
             'type' => 'all',
             'type' => 'all',
             'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
             '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.total_num-t_1.sell_num as total,t_1.sell_num',
+            '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',
         ),
         ),
 
 
        	# 列表
        	# 列表
@@ -216,7 +216,7 @@ $config = array
             ),
             ),
             'type' => 'all',
             'type' => 'all',
             'order' => array('id' => 'desc'),
             'order' => array('id' => 'desc'),
-            'col' => '*,total_num-sell_num as total|sku_id',
+            'col' => '*,in_num-out_num as total|sku_id',
         ),
         ),
 
 
         # 获取单条数据
         # 获取单条数据
@@ -231,7 +231,7 @@ $config = array
                 'state' => 1,
                 'state' => 1,
             ),
             ),
             'type' => 'one',
             'type' => 'one',
-            'col' => '*,total_num-sell_num as total',
+            'col' => '*,in_num-out_num as total',
         ),
         ),
 
 
         # 更新售出量
         # 更新售出量
@@ -246,7 +246,7 @@ $config = array
             ),
             ),
             'set' => array
             'set' => array
             (
             (
-                'sell_num' => array('yes', '+='),
+                'out_num' => array('yes', '+='),
             ),
             ),
         ),
         ),
 
 
@@ -262,7 +262,7 @@ $config = array
             ),
             ),
             'set' => array
             'set' => array
             (
             (
-                'sell_num' => array('yes', '-='),
+                'out_num' => array('yes', '-='),
             ),
             ),
         ),
         ),
 
 
@@ -276,7 +276,7 @@ $config = array
             ),
             ),
             'set' => array
             'set' => array
             (
             (
-                'total_num' => array('yes', '+='),
+                'in_num' => array('yes', '+='),
             ),
             ),
         ),
         ),
 
 
@@ -292,7 +292,7 @@ $config = array
             ),
             ),
             'set' => array
             'set' => array
             (
             (
-                'total_num' => array('yes', '+='),
+                'in_num' => array('yes', '+='),
             ),
             ),
         ),
         ),
 
 
@@ -308,7 +308,7 @@ $config = array
             ),
             ),
             'set' => array
             'set' => array
             (
             (
-                'total_num' => array('yes', '-='),
+                'in_num' => array('yes', '-='),
             ),
             ),
         ),
         ),
     ),
     ),

+ 119 - 0
module/role/database/servicer.php

@@ -0,0 +1,119 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('role/servicer_type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'servicer',
+	# 显示给用户看的名称
+	'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,
+		),
+
+		'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
+	(
+		'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/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
+	(
+		
+	)
+);

+ 195 - 0
module/role/database/supplier.php

@@ -11,6 +11,24 @@ $type = function()
 	return $array;
 	return $array;
 };
 };
 
 
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
 return array
 return array
 (
 (
 	# 表名
 	# 表名
@@ -58,6 +76,177 @@ return array
             'option'    => $type,
             '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,
+        ),
+
+        '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
 		'reorder'		=> array
 		(
 		(
 			'type' 		=> 'int-11',
 			'type' 		=> 'int-11',
@@ -97,10 +286,16 @@ return array
 
 
 	'manage' => array
 	'manage' => array
 	(
 	(
+		'tab' => array('基本设置', '联系人信息', '认证信息'),
 		'button' => array
 		'button' => array
         (
         (
             '类型配置' => array('list', 'supplier_type&oper_parent=supplier'),
             '类型配置' => array('list', 'supplier_type&oper_parent=supplier'),
         ),
         ),
+        'list_button' => array
+        (
+        	'location' => array('商品列表', Dever::url('lib/supplier.setGoods', 'role')),
+            //'fast_add' => array('账户操作', 'push&project=account&oper_table=supplier&oper_project=role&uid={id}'),
+        )
 	),
 	),
 
 
 	'default' => array
 	'default' => array

+ 155 - 0
module/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' => 'role/lib/seller.goodsUpdate',
+        'update' => '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("role/supplier-one#name", {supplier_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'product/lib/manage.search',
+            'list'      => 'Dever::load("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' => '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' => '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/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' => 'role/lib/seller.skuUpdate',
+        'update' => '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("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' => 'product/lib/manage.search',
+            'list'      => 'Dever::load("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' => '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' => '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;

+ 1 - 1
module/role/index.php

@@ -6,5 +6,5 @@ define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 define('DEVER_MANAGE_ORDER', 97);
 define('DEVER_MANAGE_ORDER', 97);
 define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-username');
 define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-username');
 define('DEVER_GROUP_ORDER', -1);
 define('DEVER_GROUP_ORDER', -1);
-define('DEVER_GROUP_NAME', '电商系统');
+define('DEVER_GROUP_NAME', '资料库');
 include(DEVER_APP_PATH . '../boot.php');
 include(DEVER_APP_PATH . '../boot.php');

+ 4 - 4
module/role/lib/Seller.php

@@ -98,12 +98,12 @@ class Seller
                 $w['seller_id'] = $seller_id;
                 $w['seller_id'] = $seller_id;
                 $info = Dever::db('role/seller_goods')->one($w);
                 $info = Dever::db('role/seller_goods')->one($w);
 
 
-                $w['total_num'] = $v['num'];
+                $w['in_num'] = $v['num'];
                 $w['min'] = $v['min'];
                 $w['min'] = $v['min'];
                 if (!$info) {
                 if (!$info) {
                     Dever::db('role/seller_goods')->insert($w);
                     Dever::db('role/seller_goods')->insert($w);
                 } else {
                 } else {
-                    $w['total_num'] += $info['total_num'];
+                    $w['in_num'] += $info['in_num'];
                     $w['where_id'] = $info['id'];
                     $w['where_id'] = $info['id'];
                     $w['state'] = 1;
                     $w['state'] = 1;
                     Dever::db('role/seller_goods')->update($w);
                     Dever::db('role/seller_goods')->update($w);
@@ -115,12 +115,12 @@ class Seller
                 $w['sku_id'] = $sku_id;
                 $w['sku_id'] = $sku_id;
                 $info = Dever::db('role/seller_goods_sku')->one($w);
                 $info = Dever::db('role/seller_goods_sku')->one($w);
 
 
-                $w['total_num'] = $v['num'];
+                $w['in_num'] = $v['num'];
                 $w['min'] = $v['min'];
                 $w['min'] = $v['min'];
                 if (!$info) {
                 if (!$info) {
                     Dever::db('role/seller_goods_sku')->insert($w);
                     Dever::db('role/seller_goods_sku')->insert($w);
                 } else {
                 } else {
-                    $w['total_num'] += $info['total_num'];
+                    $w['in_num'] += $info['in_num'];
                     $w['where_id'] = $info['id'];
                     $w['where_id'] = $info['id'];
                     $w['state'] = 1;
                     $w['state'] = 1;
                     Dever::db('role/seller_goods_sku')->update($w);
                     Dever::db('role/seller_goods_sku')->update($w);

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

@@ -0,0 +1,127 @@
+<?php
+
+namespace Role\Lib;
+
+use Dever;
+
+class Supplier
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取门店
+    public function search_api()
+    {
+        return Dever::search('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('product/lib/info')->getSetList('role/supplier_goods_sku', $where, $goods_category));
+    }
+
+    # 配置商品
+    public function setGoods_api()
+    {
+        $data = array();
+        $data['supplier_id'] = Dever::input('id', 1);
+        $info = Dever::db('role/supplier')->find($data['supplier_id']);
+        $data['info'] = $info;
+        $goods_category = $info['category'];
+
+        $data['host'] = Dever::url('lib/supplier.setGoods', 'role');
+        $data['url'] = Dever::url('lib/supplier.goods?supplier_id=' . $data['supplier_id'] . '&goods_category=' . $goods_category, 'role');
+        //$data['search'] = Dever::url('lib/supplier.search?yes='.$data['supplier_id'].'&json=1', 'role');
+        $data['submit'] = Dever::url('lib/supplier.setGoods_action_commit?json=1', '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('role/supplier')->one($supplier_id);
+        $where['option_supplier_id'] = $supplier_id;
+        $where['set_state'] = 2;
+        Dever::db('role/supplier_goods')->updates($where);
+
+        Dever::db('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('role/supplier_goods_sku')->one($w);
+
+                if ($sku_info) {
+                    Dever::db('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('role/supplier_goods_sku')->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db('role/supplier_goods')->one($w);
+                    if ($info) {
+                        Dever::db('role/supplier_goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('product/info')->one($goods_id);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['supplier_id'] = $supplier_id;
+                $info = Dever::db('role/supplier_goods')->one($w);
+                if (!$info) {
+                    Dever::db('role/supplier_goods')->insert($w);
+                } else {
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('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('role/supplier_goods_sku')->one($w);
+
+                $w['in_num'] = $v['num'];
+                if (!$info) {
+                    Dever::db('role/supplier_goods_sku')->insert($w);
+                } else {
+                    $w['in_num'] += $info['in_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('role/supplier_goods_sku')->update($w);
+                }
+            }
+        }
+        return 'refer';
+    }
+}