rabin 2 years ago
parent
commit
832344c343

+ 1 - 1
module/scm_product/database/info.php

@@ -161,7 +161,7 @@ $config = array
 		'type'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '商品类型-套餐商品和组合商品都是由多个商品组成,区别是组合商品的库存由组成的商品的最少库存决定,套餐商品可以单独设置库存',
+			'name' 		=> '商品类型-套餐商品和组合商品都是由多个商品组成,区别是组合商品的库存由组成的商品的最少库存决定,套餐商品可以单独设置库存,组合商品在售卖时可以拆解',
 			'default' 	=> '1',
 			'desc' 		=> '商品类型',
 			'match' 	=> 'is_numeric',

+ 53 - 1
module/scm_product/lib/Info.php

@@ -316,17 +316,69 @@ class Info
         if ($sku && $sku > 0) {
             $where['id'] = $sku;
         }
+
+        if ($info['unit']) {
+            $unit = Dever::db('scm_product/unit')->find($info['unit']);
+            if ($unit) {
+                $info['unit'] = $unit['name'];
+            }
+        }
+
+        if (!$info['unit']) {
+            $info['unit'] = '个';
+        }
+        $info['aname'] = $info['name'];
+        $info['spec_name'] = array();
         $sku = Dever::db('scm_product/info_sku')->select($where);
         if ($sku) {
             foreach ($sku as $k => $v) {
                 $key = str_replace('-', ',', $v['key']);
                 $spec = Dever::db('scm_product/info_spec_value')->getGroupData(array('ids' => $key));
                 if ($spec) {
-                    $info['name'] .= '-' . $spec['name'];
+                    $info['aname'] .= '-' . $spec['name'];
+                    $info['spec_name'][] = $spec['name'];
+                }
+                if ($sku && $sku > 0) {
+                    $info['code'] = $v['code'];
+                    $info['price'] = $v['price'];
+                    $info['buy_price'] = $v['buy_price'];
+                    $info['cost_price'] = $v['cost_price'];
                 }
             }
         }
+        $info['spec_name'] = implode(',', $info['spec_name']);
+
+        $pic = explode(',', $info['pic']);
+        $info['cover'] = $pic[0];
+
+        $this->getGroup($info);
 
         return $info;
     }
+
+    # 获取组合商品
+    public function getGroup(&$info)
+    {
+        $info['goods'] = array();
+        if ($info['type'] == 11 || $info['type'] == 12) {
+            $goods = Dever::db('scm_product/info_goods')->select(array('info_id' => $info['id']));
+            $info['goods'] = array();
+            foreach ($goods as $k => $v) {
+                $goods_info = $this->getBaseInfo($v['goods_id'], $v['sku_id']);
+                if ($goods_info) {
+                    $info['goods'][] = array
+                    (
+                        'id' => $goods_info['id'],
+                        'code' => $goods_info['code'],
+                        'name' => $goods_info['aname'],
+                        'price' => $goods_info['price'],
+                        'buy_price' => $goods_info['buy_price'],
+                        'cover' => $goods_info['cover'],
+                        'unit' => $goods_info['unit'],
+                        'num' => $v['num'],
+                    );
+                }
+            }
+        }
+    }
 }

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

@@ -91,7 +91,11 @@ class Manage
 
     public function searchProduct_api()
     {
+        $keyword = Dever::input('keyword');
         $where = array();
+        if ($keyword) {
+            $where['name'] = $keyword;
+        }
         $data = array();
         $cate = '';
         $supplier_id = Dever::input('supplier_id');
@@ -108,6 +112,19 @@ class Manage
             }
         }
 
+        $service_id = Dever::input('service_id');
+        $servicer_store_id = Dever::input('servicer_store_id');
+        if ($servicer_store_id) {
+            $store_goods = Dever::db('scm_servicer/store_goods')->one(array('servicer_store_id' => $servicer_store_id));
+            if ($store_goods) {
+                $where['servicer_store_id'] = $servicer_store_id;
+                $data = Dever::search('scm_servicer/store_goods_sku', $where);
+            } else {
+                # 没有库存
+                return array();
+            }
+        }
+
         if (!$data) {
             $id = Dever::input('where_id');
             if ($id) {
@@ -129,4 +146,44 @@ class Manage
 
         return $data;
     }
+
+    public function getGoods($id, $table = 'scm_servicer/in_order_goods', $cash = true)
+    {
+        $result = array();
+        $result['head'] = array('名称', '批次', '单价', '数量', '状态');
+        if (!$cash) {
+            unset($result['head'][1]);
+        }
+        $result['body'] = array();
+
+        $data = Dever::db($table)->select(array('order_id' => $id));
+
+        if ($data) {
+            $status = Dever::db($table)->config['status'];
+            foreach ($data as $k => $v) {
+                $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id']);
+                $status_name = Dever::status($status, $v['status']);
+                $result['body'][$k][] = $goods_info['aname'];
+                $result['body'][$k][] = $v['batch'];
+                $result['body'][$k][] = $v['cash'];
+                $result['body'][$k][] = $v['num'];
+                $result['body'][$k][] = $status_name;
+
+                if (!$cash) {
+                    unset($result['body'][$k][1]);
+                }
+            }
+        }
+        $body[''] = array
+        (
+            'type' => 'table',
+            'content' => $result,
+        );
+
+        if ($result['body']) {
+            return Dever::show('', $body);
+        } else {
+            return '暂无';
+        }
+    }
 }

+ 4 - 0
module/scm_product/lib/Order.php

@@ -16,6 +16,10 @@ class Order
             $update['where_id'] = $id;
             $update['goods_id'] = $temp[0];
             $update['sku_id'] = $temp[1];
+            $batch = Dever::param('batch', $data);
+            if (!$batch) {
+                $update['batch'] = date('Ymd');
+            }
             if (isset($temp[2])) {
                 $update['cash'] = $temp[2];
             }

+ 54 - 0
module/scm_product/lib/Stock.php

@@ -6,6 +6,49 @@ use Dever;
 
 class Stock
 {
+	public function show_api()
+	{
+		$goods = Dever::input('value');
+		list($goods_id, $sku_id) = explode('-', $goods);
+		$where['goods_id'] = $goods_id;
+		$where['sku_id'] = $sku_id;
+		$where['servicer_store_id'] = Dever::input('servicer_store_id');
+		$info = Dever::db('scm_servicer/store_goods_sku')->getOne($where);
+		if ($info) {
+			$goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
+			$supplier_id = Dever::input('supplier_id');
+			if ($supplier_id) {
+				$where['supplier_id'] = $supplier_id;
+				$sku = Dever::db('scm_supplier/goods_sku')->getOne($where);
+				$info['cash'] = isset($sku['cost_price']) && $sku['cost_price'] ? $sku['cost_price'] : $goods_info['cost_price'];
+			}
+			return '单价:' . $info['cash'] . '元 库存:' . $info['total'] . $goods_info['unit'];
+		}
+		return '暂无';
+	}
+
+	public function out_check($id, $name, $data)
+	{
+		$table = Dever::input('table');
+		$col = Dever::input('col');
+		$goods = Dever::param('goods', $data);
+		list($goods_id, $sku_id) = explode('-', $goods);
+		$where['goods_id'] = $goods_id;
+		$where['sku_id'] = $sku_id;
+		$where[$col] = Dever::input('update_' . $col);
+		$info = Dever::db($table)->getOne($where);
+		if ($info) {
+			$num = Dever::param('num', $data);
+			if ($info['total'] < $num) {
+				$goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
+				return Dever::alert('【' . $goods_info['aname'] . '】剩余库存:' . $info['total'] . $goods_info['unit'] . ',已不足出库');
+			}
+		} else {
+			$goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
+			return Dever::alert('【' . $goods_info['aname'] . '】剩余库存:0' . $goods_info['unit'] . ',已不足出库');
+		}
+	}
+
     # 更新库存
     public function update_commit($id, $name, $data)
     {
@@ -28,6 +71,7 @@ class Stock
     			# 审核通过 更新库存
     			$this->up($table, $type, $col, $stock, $info);
     		}
+    		Dever::db($table . '_goods')->updates(array('option_order_id' => $info['id'], 'set_status' => $update['status']));
     	}
     }
 
@@ -45,14 +89,24 @@ class Stock
 					$update['sku_id'] = $v['sku_id'];
 					$goods = Dever::db($stock . '_sku')->find($update);
 					if (!$goods) {
+						if ($type == 'in') {
+							if (!$v['batch']) {
+								$v['batch'] = date('Ymd');
+							}
+							$where['batch'] = $v['batch'];
+							$where['cash'] = $v['cash'];
+						}
 						$id = Dever::db($stock . '_sku')->insert($update);
 						$where['where_id'] = $id;
 					} else {
 						$where['where_id'] = $goods['id'];
 					}
+
 					$where[$type . '_num'] = $v['num'];
 					$method = $type . 'Update';
 					Dever::db($stock . '_sku')->$method($where);
+
+					//Dever::db($table . '_goods')->update(array('where_id' => $v['id'], 'status' => 2));
 				}
 			}
 		}

+ 2 - 2
module/scm_seller/database/info.php

@@ -166,7 +166,7 @@ return array
             'default'   => '1',
             'desc'      => '库存设置',
             'match'     => 'is_numeric',
-            'update'    => 'radio',
+            //'update'    => 'radio',
             'option'    => $stock,
             'control'	=> 'stock',
         ),
@@ -178,7 +178,7 @@ return array
             'default'   => '-1',
             'desc'      => '共享经销商',
             'match'     => 'is_numeric',
-            'update'    => 'select',
+            //'update'    => 'select',
             'option'    => $seller,
             'show'		=> 'stock=2'
         ),

+ 48 - 5
module/scm_servicer/database/in_order.php

@@ -14,6 +14,10 @@ $audit = array
     3 => '审核未通过',
 );
 
+$type = function() {
+    return Dever::db('scm_servicer/in_order_type')->state();
+};
+
 $store = array();
 $servicer_id = Dever::input('search_option_servicer_id');
 if ($servicer_id) {
@@ -30,6 +34,8 @@ $servicer = function() {
     return Dever::db('scm_servicer/info')->state();
 };
 
+$col = Dever::input('col');
+
 return array
 (
     # 表名
@@ -43,7 +49,7 @@ return array
     ),
     'end' => array
     (
-        'insert' => 'scm_product/lib/order.updateOrderNum?table=scm_servicer/in_order&prefix=C',
+        'insert' => 'scm_product/lib/order.updateOrderNum?table=scm_servicer/in_order&prefix=CI',
         'update' => 'scm_product/lib/stock.update_commit?table=scm_servicer/in_order&stock=scm_servicer/store_goods&type=in&col=servicer_store_id',
     ),
 
@@ -114,7 +120,31 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'select',
             'option'    => $supplier,
-            'list'      => 'Dever::load("scm_supplier/info-one#name", {supplier_id})',
+            //'list'      => 'Dever::load("scm_supplier/info-one#name", {supplier_id})',
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '入库类型',
+            'default'   => '1',
+            'desc'      => '入库类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'search'    => 'select',
+            'option'    => $type,
+            //'list'      => true,
+        ),
+
+        'relate_order_num'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '关联单据号',
+            'default'   => '',
+            'desc'      => '关联单据号',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
         ),
 
         'info'      => array
@@ -128,6 +158,18 @@ return array
             //'list'      => true,
         ),
 
+        'address'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '收货信息',
+            'default'   => '',
+            'desc'      => '收货信息',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'search'    => 'fulltext',
+            //'list'      => true,
+        ),
+
         'scm_servicer-in_order_goods'=> array
 		(
 			'name' 		=> '商品设置',
@@ -140,7 +182,7 @@ return array
 			# 1纵向展示 2横向展示
 			'update_type' => 2,
             'list_name' => '商品信息',
-			'list'		=> 'Dever::load("scm_servicer/lib/manage.getGoods", {id})',
+			'list'		=> 'Dever::load("scm_product/lib/manage.getGoods", {id}, "scm_servicer/in_order_goods")',
 		),
 
         'audit'        => array
@@ -151,7 +193,7 @@ return array
             'desc'      => '审核状态',
             'match'     => 'is_numeric',
             'option'    => $audit,
-            //'update'    => 'radio',
+            'update'    => $col ? 'radio' : false,
         ),
 
         'audit_desc'        => array
@@ -161,7 +203,7 @@ return array
             'default'   => '',
             'desc'      => '审核备注',
             'match'     => 'option',
-            //'update'    => 'textarea',
+            'update'    => $col ? 'textarea' : false,
         ),
 
         'audit_admin'     => array
@@ -222,6 +264,7 @@ return array
         'button' => array
         (
             //'导出订单明细' => array('excel', 'shop/excel.sell_order'),
+            '类型配置' => array('list', 'in_order_type&oper_parent=in_order'),
         ),
 
         'list_button' => array

+ 22 - 4
module/scm_servicer/database/in_order_goods.php

@@ -2,9 +2,9 @@
 
 $status = array
 (
-    1 => '正常',
-    2 => '申请退款中',
-    3 => '已退款',
+    1 => '待审',
+    2 => '已审核',
+    3 => '未通过',
 );
 
 return array
@@ -15,6 +15,11 @@ return array
     'lang' => '订单商品表',
     'menu' => false,
     'status' => $status,
+    # 验证供应商商品是否存在
+    'start' => array
+    (
+        'insert' => 'scm_supplier/lib/manage.check',
+    ),
     'end' => array
     (
         'insert' => 'scm_product/lib/order.updateGoods?table=scm_servicer/in_order_goods',
@@ -54,15 +59,18 @@ return array
             'match'     => 'option',
             'update'    => 'select',
             'update_search' => 'scm_product/lib/manage.searchProduct?{supplier_id}',
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/stock.show', 'scm_product'), 'col' => 'servicer_store_id,supplier_id')),
         ),
 
         'goods_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '商品',
+            'name'      => '商品信息',
             'default'   => '',
             'desc'      => '商品',
             'match'     => 'is_numeric',
+            'update'    => 'show',
+            'value'     => '暂无',
         ),
 
         'sku_id'      => array
@@ -74,6 +82,16 @@ return array
             'match'     => 'is_numeric',
         ),
 
+        'batch'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '批次号-不输入将自动生成',
+            'default'   => '',
+            'desc'      => '批次号',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
         'cash'      => array
         (
             'type'      => 'decimal-11,2',

+ 116 - 0
module/scm_servicer/database/in_order_type.php

@@ -0,0 +1,116 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'in_order_type',
+	# 显示给用户看的名称
+	'lang' => '入库单类型',
+	# 是否显示在后台菜单
+	'order' => 1,
+	'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,
+		),
+
+		'table'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '关联表名-如该类型关联某个表,这里要加上表名,影响关联单据号',
+			'default' 	=> '',
+			'desc' 		=> '关联表名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'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
+	(
+		
+	)
+);

+ 2 - 2
module/scm_servicer/database/info.php

@@ -338,8 +338,8 @@ return array
         (
         	'location' => array('供应商', Dever::url('lib/set.home?role=servicer', 'scm_supplier')),
             'br3' => array('<br />'),
-            'add' => array('入库下单', 'in_order&oper_table=info&search_option_servicer_id={id}&oper_save_jump=info'),
-            'add2' => array('出库下单', 'out_order&oper_table=info&search_option_servicer_id={id}&oper_save_jump=info'),
+            'add' => array('入库下单', 'in_order&oper_table=info&search_option_servicer_id={id}&oper_save_jump=in_order'),
+            'add2' => array('出库下单', 'out_order&oper_table=info&search_option_servicer_id={id}&oper_save_jump=out_order'),
         )
 	),
 

+ 274 - 0
module/scm_servicer/database/out_order.php

@@ -0,0 +1,274 @@
+<?php
+
+$status = array
+(
+    1 => array('name' => '待审核', 'style' => 'font-weight:bold;color:#436EEE'),
+    2 => array('name' => '已审核', 'style' => 'font-weight:bold;color:#003366'),
+    3 => array('name' => '已驳回', 'style' => 'font-weight:bold;color:#993333'),
+);
+
+$audit = array
+(
+    //1 => '待审核',
+    2 => '审核通过',
+    3 => '审核未通过',
+);
+
+$type = function() {
+	return Dever::db('scm_servicer/out_order_type')->state();
+};
+
+$store = array();
+$servicer_id = Dever::input('search_option_servicer_id');
+if ($servicer_id) {
+	$store = function() use($servicer_id) {
+		return Dever::db('scm_servicer/store')->state(array('servicer_id' => $servicer_id));
+	};
+}
+
+$servicer = function() {
+    return Dever::db('scm_servicer/info')->state();
+};
+
+return array
+(
+    # 表名
+    'name' => 'out_order',
+    # 显示给用户看的名称
+    'lang' => '出库单查询',
+    'order' => 8,
+    'set' => array
+    (
+    	'status' => $status,
+    ),
+    'end' => array
+    (
+        'insert' => 'scm_product/lib/order.updateOrderNum?table=scm_servicer/out_order&prefix=CO',
+        'update' => 'scm_product/lib/stock.update_commit?table=scm_servicer/out_order&stock=scm_servicer/store_goods&type=out&col=servicer_store_id',
+    ),
+
+    # 数据结构
+    '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',
+            'search'    => 'fulltext',
+            'list_name'	=> '订单信息',
+            'list'      => 'Dever::load("scm_servicer/lib/out.info", {id})',
+        ),
+
+        'servicer_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配送商',
+            'default'   => '',
+            'desc'      => '配送商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'searchs'    => array
+            (
+                'api' => 'scm_role/seller-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'search'    => 'select',
+            'option'    => $servicer,
+            'value'     => $servicer_id,
+            //'list'      => 'Dever::load("scm_servicer/info-one#name", {servicer_id})',
+        ),
+
+        'servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '出库仓库',
+            'default'   => '',
+            'desc'      => '出库仓库',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $store,
+            //'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_id})',
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '出库类型',
+            'default'   => '1',
+            'desc'      => '出库类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'      => true,
+            'control'	=> 'type',
+        ),
+
+        'relate_order_num'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '关联单据号',
+            'default'   => '',
+            'desc'      => '关联单据号',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'in_servicer_store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '入库仓库',
+            'default'   => '',
+            'desc'      => '入库仓库',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $store,
+            'show'		=> 'type=1',
+            //'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_id})',
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '订单备注',
+            'default'   => '',
+            'desc'      => '订单备注',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'address'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '收货信息',
+            'default'   => '',
+            'desc'      => '收货信息',
+            'match'     => 'is_string',
+        ),
+
+        'scm_servicer-out_order_goods'=> array
+		(
+			'name' 		=> '商品设置',
+			'default' 	=> '',
+			'desc' 		=> '商品设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'order_id'),
+			'update'	=> array(1),
+			# 1纵向展示 2横向展示
+			'update_type' => 2,
+            'list_name' => '商品信息',
+			'list'		=> 'Dever::load("scm_product/lib/manage.getGoods", {id}, "scm_servicer/out_order_goods")',
+		),
+
+        'audit'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'option'    => $audit,
+            //'update'    => 'radio',
+        ),
+
+        'audit_desc'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '审核备注',
+            'default'   => '',
+            'desc'      => '审核备注',
+            'match'     => 'option',
+            //'update'    => 'textarea',
+        ),
+
+        'audit_admin'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核人',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '审核人',
+            //'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            //'search_after' => '<br />',
+            //'mul'   => true,
+            //'mul_option' => array(2 => '批量审核', 5 => '确认收货'),
+        ),
+
+        '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'),
+            '类型配置' => array('list', 'out_order_type&oper_parent=out_order'),
+        ),
+
+        'list_button' => array
+        (
+            'list' => array('查看详情', '"out_order_goods&page_type=1&order_id={id}"'),
+
+            'fast' => array('审核', '"out_order&where_id={id}&col=audit,audit_desc"', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 192 - 0
module/scm_servicer/database/out_order_goods.php

@@ -0,0 +1,192 @@
+<?php
+
+$status = array
+(
+    1 => '待审',
+    2 => '已审核',
+    3 => '未通过',
+);
+
+return array
+(
+    # 表名
+    'name' => 'out_order_goods',
+    # 显示给用户看的名称
+    'lang' => '订单商品表',
+    'menu' => false,
+    'status' => $status,
+    # 验证库存
+    'start' => array
+    (
+    	'insert' => 'scm_product/lib/stock.out_check?table=scm_servicer/store_goods_sku&col=servicer_store_id',
+    ),
+    'end' => array
+    (
+        'insert' => 'scm_product/lib/order.updateGoods?table=scm_servicer/out_order_goods',
+        'update' => 'scm_product/lib/order.updateGoods?table=scm_servicer/out_order_goods',
+    ),
+    # 数据结构
+    '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',
+        ),
+
+        'goods'      => array
+        (
+            'type'      => 'varchar-2000',
+            'name'      => '商品',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'option',
+            'update'    => 'select',
+            'update_search' => 'scm_product/lib/manage.searchProduct?{servicer_id,servicer_store_id}',
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/stock.show', 'scm_product'), 'col' => 'servicer_store_id')),
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品信息',
+            'default'   => '',
+            'desc'      => '商品',
+            'match'     => 'is_numeric',
+            'update'	=> 'show',
+            'value'		=> '暂无',
+        ),	
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'batch'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '批次号-不输入将自动生成',
+            'default'   => '',
+            'desc'      => '批次号',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '单价',
+            'default'   => '',
+            'desc'      => '单价',
+            'match'     => 'option',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '出库数量',
+            'default'   => '1',
+            'desc'      => '数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            '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' => 'in_order_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', '<='),
+                'servicer_id' => array('yes-t_2.servicer_id'),
+                'servicer_store_id' => array('yes-t_2.servicer_store_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' => 'scm_servicer/out_order',
+                    'type' => 'left join',
+                    'on' => array('order_id','id'),
+                ),
+            ),
+            'type' => 'all',
+            'group' => 't_2.servicer_id, t_2.servicer_store_id, t_1.goods_id',
+            'col' => 'id,t_2.servicer_id, t_2.servicer_store_id, t_1.goods_id,sum(t_1.num) as num',
+        ),
+    ),
+);

+ 135 - 0
module/scm_servicer/database/out_order_type.php

@@ -0,0 +1,135 @@
+<?php
+
+$in_type = array
+(
+    1 => '不生成',
+    2 => '生成仓库入库单',
+    3 => '生成经销商入库单',
+);
+
+return array
+(
+	# 表名
+	'name' => 'out_order_type',
+	# 显示给用户看的名称
+	'lang' => '出库单类型',
+	# 是否显示在后台菜单
+	'order' => 1,
+	'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,
+		),
+
+		'table'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '关联表名-如该类型关联某个表,这里要加上表名,影响关联单据号',
+			'default' 	=> '',
+			'desc' 		=> '关联表名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'in_type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '同时生成入库单',
+            'default'   => '1',
+            'desc'      => '同时生成入库单',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $in_type,
+            //'list'      => 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
+	(
+		
+	)
+);

+ 13 - 1
module/scm_servicer/database/store.php

@@ -67,6 +67,18 @@ return array
             'list'      => true,
         ),
 
+        'address'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '收货信息-用叹号隔开,格式如:收件地址、收件人名称、收件人电话',
+            'default'   => '',
+            'desc'      => '收货信息',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
 		'reorder'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -74,7 +86,7 @@ return array
 			'default' 	=> '1',
 			'desc' 		=> '请输入排序',
 			'match' 	=> 'option',
-			'update'	=> 'text',
+			//'update'	=> 'text',
 			'search'	=> 'order',
 			'list_name' => '排序',
 			'list'		=> true,

+ 47 - 0
module/scm_servicer/database/store_goods_sku.php

@@ -69,6 +69,24 @@ $config = array
             'match'     => 'is_numeric',
         ),
 
+        'batch'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '入库批次号',
+            'default'   => '',
+            'desc'      => '入库批次号',
+            'match'     => 'option',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '入库单价',
+            'default'   => '',
+            'desc'      => '入库单价',
+            'match'     => 'option',
+        ),
+
         'in_num'        => array
         (
             'type'      => 'decimal-11,2',
@@ -130,6 +148,35 @@ $config = array
     # request 请求接口定义
     'request' => array
     (
+        # 后台搜索用到,也可以不加,自动生成
+        'search' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'name' => array('yes-t_2.name', 'like'),
+                'servicer_store_id' => array('yes-t_1.servicer_store_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'scm_product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => '*,t_2.*,t_2.id as value, "" as selected, "" as disabled',
+        ),
+
+
         'getDataPage' => array
         (
             # 匹配的正则或函数 选填项

+ 64 - 11
module/scm_servicer/lib/In.php

@@ -25,15 +25,25 @@ class In
 
     	$string .= '.' . $store['name'];
 
+        $supplier = Dever::db('scm_supplier/info')->one($info['supplier_id']);
+
+        $string .= '<br />' . $supplier['name'];
+
+        $type = Dever::db('scm_servicer/in_order_type')->one($info['type']);
+
+        $string .= '<br />' . $type['name'];
+
     	$string .= '<br />' . $info['info'];
 
+        
+
     	return $string;
     }
 
     # 查看详情
     public function show_api()
     {
-        $id = Dever::input('id');
+        $id = Dever::input('order_id');
 
         $config = Dever::db('scm_servicer/in_order')->config['set'];
 
@@ -47,6 +57,8 @@ class In
 
         $supplier = Dever::db('scm_supplier/info')->one($info['supplier_id']);
 
+        $type = Dever::db('scm_servicer/in_order_type')->one($info['type']);
+
         $cdate = date('Y-m-d H:i', $info['cdate']);
 
         $result = array();
@@ -65,15 +77,41 @@ class In
 
                 array
                 (
+                    array('入库类型', $type['name']),
                     array('订单状态', $status),
                     array('订单备注', $info['info']),
                 ),
             ),
         );
 
-        $table = array();
-        $table['head'] = array('名称', '单价', '数量', '状态');
-        $table['body'] = array();
+        if (!$info['address']) {
+            $info['address'] = $store['address'];
+        }
+        if ($info['address']) {
+            $temp = explode('、', $store['address']);
+            $result['收货信息'] = array
+            (
+                'type' => 'info',
+                'content' => array
+                (
+                    array
+                    (
+                        array('联系人', $temp[1]),
+                        array('联系电话', $temp[2]),
+                    ),
+
+                    array
+                    (
+                        array('收货地址', $temp[0]),
+                    ),
+                ),
+            );
+        }
+
+        $body = array();
+        $body_total = array();
+        $body_total['price'] = 0;
+        $body_total['num'] = 0;
 
         $data = Dever::db('scm_servicer/in_order_goods')->select(array('order_id' => $id));
 
@@ -82,16 +120,31 @@ class In
             foreach ($data as $k => $v) {
                 $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id']);
                 $status_name = Dever::status($status, $v['status']);
-                $table['body'][$k][] = $goods_info['name'];
-                $table['body'][$k][] = $v['cash'];
-                $table['body'][$k][] = $v['num'];
-                $table['body'][$k][] = $status_name;
+
+                $detail = array
+                (
+                    'pic' => $goods_info['cover'],
+                    'name' => $goods_info['name'] . ' [批次:'.$v['batch'].']',
+                    'sku' => $goods_info['spec_name'],
+                    'price' => $v['cash'],
+                    'num' => $v['num'] . $goods_info['unit'],
+                    'status' => $status_name,
+                );
+
+                if ($goods_info['goods']) {
+                    $detail['goods'] = $goods_info['goods'];
+                }
+
+                $body[] = $detail;
+                $body_total['price'] += $v['cash'] * $v['num'];
+                $body_total['num'] += $v['num'];
             }
         }
-        $body[''] = array
+        $result['商品清单'] = array
         (
-            'type' => 'table',
-            'content' => $table,
+            'type' => 'list',
+            'content' => $body,
+            'total' => $body_total,
         );
 
         $head = array

+ 0 - 32
module/scm_servicer/lib/Manage.php

@@ -44,36 +44,4 @@ class Manage
             return '暂无';
         }
     }
-
-    public function getGoods($id)
-    {
-        $table = array();
-        $table['head'] = array('名称', '单价', '数量', '状态');
-        $table['body'] = array();
-
-        $data = Dever::db('scm_servicer/in_order_goods')->select(array('order_id' => $id));
-
-        if ($data) {
-            $status = Dever::db('scm_servicer/in_order_goods')->config['status'];
-            foreach ($data as $k => $v) {
-                $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id']);
-                $status_name = Dever::status($status, $v['status']);
-                $table['body'][$k][] = $goods_info['name'];
-                $table['body'][$k][] = $v['cash'];
-                $table['body'][$k][] = $v['num'];
-                $table['body'][$k][] = $status_name;
-            }
-        }
-        $body[''] = array
-        (
-            'type' => 'table',
-            'content' => $table,
-        );
-
-        if ($table['body']) {
-            return Dever::show('', $body);
-        } else {
-            return '暂无';
-        }
-    }
 }

+ 145 - 0
module/scm_servicer/lib/Out.php

@@ -0,0 +1,145 @@
+<?php
+
+namespace Scm_servicer\Lib;
+
+use Dever;
+
+class Out
+{
+	# 获取订单信息
+    public function info($id)
+    {
+    	Dever::load('manage/auth.init');
+
+    	$info = Dever::db('scm_servicer/out_order')->find($id);
+
+    	$string = '';
+
+    	$string = $info['order_num'];
+
+    	$servicer = Dever::db('scm_servicer/info')->one($info['servicer_id']);
+
+    	$string .= '<br />' . $servicer['name'];
+
+    	$store = Dever::db('scm_servicer/store')->one($info['servicer_store_id']);
+
+    	$string .= '.' . $store['name'];
+
+    	$string .= '<br />' . $info['info'];
+
+    	return $string;
+    }
+
+    # 查看详情
+    public function show_api()
+    {
+        $id = Dever::input('order_id');
+
+        $config = Dever::db('scm_servicer/in_order')->config['set'];
+
+        $info = Dever::db('scm_servicer/in_order')->one($id);
+
+        $status = Dever::status($config['status'], $info['status']);
+
+        $member = Dever::db('scm_servicer/info')->one($info['servicer_id']);
+
+        $store = Dever::db('scm_servicer/store')->one($info['servicer_store_id']);
+
+        $supplier = Dever::db('scm_supplier/info')->one($info['supplier_id']);
+
+        $cdate = date('Y-m-d H:i', $info['cdate']);
+
+        $result = array();
+
+        $result[$info['order_num']] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('配送商', $member['name']),
+                    array('仓库', $store['name']),
+                    array('供应商', $supplier['name']),
+                ),
+
+                array
+                (
+                    array('订单状态', $status),
+                    array('订单备注', $info['info']),
+                ),
+            ),
+        );
+
+        if (!$info['address']) {
+            $info['address'] = $store['address'];
+        }
+        if ($info['address']) {
+            $temp = explode('、', $store['address']);
+            $result['收货信息'] = array
+            (
+                'type' => 'info',
+                'content' => array
+                (
+                    array
+                    (
+                        array('联系人', $temp[1]),
+                        array('联系电话', $temp[2]),
+                    ),
+
+                    array
+                    (
+                        array('收货地址', $temp[0]),
+                    ),
+                ),
+            );
+        }
+
+        $body = array();
+        $body_total = array();
+        $body_total['price'] = 0;
+        $body_total['num'] = 0;
+
+        $data = Dever::db('scm_servicer/in_order_goods')->select(array('order_id' => $id));
+
+        if ($data) {
+            $status = Dever::db('scm_servicer/in_order_goods')->config['status'];
+            foreach ($data as $k => $v) {
+                $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id']);
+                $status_name = Dever::status($status, $v['status']);
+
+                $detail = array
+                (
+                    'pic' => $goods_info['cover'],
+                    'name' => $goods_info['name'],
+                    'sku' => $goods_info['spec_name'],
+                    'price' => $v['cash'],
+                    'num' => $v['num'] . $goods_info['unit'],
+                    'status' => $status_name,
+                );
+
+                if ($goods_info['goods']) {
+                    $detail['goods'] = $goods_info['goods'];
+                }
+
+                $body[] = $detail;
+                $body_total['price'] += $v['cash'] * $v['num'];
+                $body_total['num'] += $v['num'];
+            }
+        }
+        $result['商品清单'] = array
+        (
+            'type' => 'list',
+            'content' => $body,
+            'total' => $body_total,
+        );
+
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => '',
+        );
+        $html = Dever::show($head, $result);
+        return $html;
+    }
+}

+ 1 - 0
module/scm_supplier/database/goods_sku.php

@@ -144,6 +144,7 @@ $config = array
             # 匹配的正则或函数 选填项
             'option' => array
             (
+                'name' => array('yes-t_2.name', 'like'),
                 'supplier_id' => array('yes-t_1.supplier_id'),
                 'status' => 'yes-t_2.status-1',
                 'state' => 'yes-t_2.state-1',

+ 28 - 0
module/scm_supplier/lib/Manage.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace Scm_supplier\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    public function check($id, $name, $data)
+	{
+		$goods = Dever::param('goods', $data);
+		list($goods_id, $sku_id) = explode('-', $goods);
+		$where['goods_id'] = $goods_id;
+		$where['sku_id'] = $sku_id;
+		$where['supplier_id'] = Dever::input('update_supplier_id');
+		$info = Dever::db('scm_supplier/goods_sku')->getOne($where);
+		if (!$info) {
+			$supplier = Dever::db('scm_supplier/supplier')->one($where['supplier_id']);
+			$goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
+			return Dever::alert($supplier['name'] . '无此商品:【' . $goods_info['aname'] . '】');
+		}
+	}
+}