dever 2 years ago
parent
commit
4c6c99bc3a

+ 187 - 0
lib/Order.php

@@ -55,4 +55,191 @@ class Order
             return $this->getOrderNum($table);
         }
     }
+
+    # 查看订单详情
+    public function show($order_table)
+    {
+        $id = Dever::input('order_id');
+        $order_db = Dever::db($order_table);
+        $order = $order_db->one($id);
+        $order['config'] = $order_db->config['set'];
+        $content = array();
+        if (isset($order['type'])) {
+            $type = Dever::db($order_table . '_type')->one($order['type']);
+            $content[0][] = array('订单类型', $type['name']);
+        }
+
+        $content[0][] = array('订单状态', Dever::status($order['config']['status'], $order['status']));
+        $content[0][] = array('下单时间', date('Y-m-d H:i', $order['cdate']));
+        $order['info'] && $content[0][] = array('订单备注', $order['info']);
+
+        $content[1] = $content[2] = array();
+        $role = $this->show_role(array
+        (
+            'seller' => '经销商',
+            'servicer' => '配送商',
+            'servicer_store' => '仓库',
+            'supplier' => '供应商',
+        ), $order, $content[1]);
+
+        $this->show_audit($order, $content[2]);
+
+        $result = array();
+        $result[$order['order_num']] = array
+        (
+            'type' => 'info',
+            'content' => $content
+        );
+
+        $this->show_address($order, $role, $result);
+
+        $this->show_goods($order, $order_table, $result);
+
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => $this->show_button($order, $order_table),
+        );
+        $html = Dever::show($head, $result);
+        return $html;
+    }
+
+    # 显示订单角色
+    private function show_role($role, $order, &$data)
+    {
+        $result = array();
+        foreach ($role as $k => $v) {
+            $col = $k . '_id';
+            if (isset($order[$col]) && $order[$col] > 0) {
+                $project = $k;
+                $name = 'info';
+                if (strstr($k, '_')) {
+                    $temp = explode('_', $k);
+                    $project = $temp[0];
+                    $name = $temp[1];
+                }
+                $table = 'scm_' . $project . '/' . $name;
+                $result[$k] = Dever::db($table)->one($order[$col]);
+                if ($result[$k]) {
+                    $data[] = array($v, $result[$k]['name']);
+                }
+            }
+        }
+        return $result;
+    }
+
+    # 显示审核信息
+    private function show_audit($order, &$data)
+    {
+        if (isset($order['audit_admin']) && $order['audit_admin']) {
+            $admin = Dever::db('manage/admin')->find($order['audit_admin']);
+            $data = array
+            (
+                array('审核人', $admin['username']),
+                array('审核状态', Dever::status($order['config']['audit'], $order['audit'])),
+                array('审核备注', $order['audit_desc']),
+            );
+        }
+    }
+
+    # 显示订单地址
+    private function show_address($order, $role, &$result)
+    {
+        if (!$order['address'] && isset($role['servicer_store']['address'])) {
+            $order['address'] = $role['servicer_store']['address'];
+        }
+        if ($order['address']) {
+            $temp = explode('、', $order['address']);
+            $result['收货信息'] = array
+            (
+                'type' => 'info',
+                'content' => array
+                (
+                    array
+                    (
+                        array('联系人', $temp[1]),
+                        array('联系电话', $temp[2]),
+                        array('收货地址', $temp[0]),
+                    ),
+                ),
+            );
+        }
+    }
+
+    # 显示订单商品清单
+    private function show_goods($order, $order_table, &$result)
+    {
+        $data = Dever::db($order_table . '_goods')->select(array('order_id' => $order['id']));
+        if ($data) {
+            $table['head'] = array('商品编码', '商品名称', '商品规格', '批次', '单价', '数量', '总价', '状态');
+            $table['body'] = array();
+            $total_price = $total_num = 0;
+            $status = Dever::db($order_table . '_goods')->config['status'];
+            foreach ($data as $k => $v) {
+                $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id'], $v['unit_id']);
+                $status_name = Dever::status($status, $v['status']);
+
+                $num = $v['num'];
+                if ($v['status'] == 2 && $v['unit_id'] != $goods_info['base_unit_id']) {
+                    if (!isset($order['supplier_id'])) {
+                        $order['supplier_id'] = false;
+                    }
+                    $unit = Dever::load('scm/lib/unit')->convertBase($v['goods_id'], $v['sku_id'], $v['unit_id'], $v['num'], $v['cash'], 0, $order['supplier_id']);
+                    if ($unit) {
+                        $base_unit = Dever::db('scm/unit')->find($unit['unit_id']);
+                        $goods_info['unit'] .= ' => '.$unit['num'].''.$base_unit['name'].'';
+                        $num = $unit['num'];
+                    }
+                }
+
+                $sdate = isset($v['sdate']) && $v['sdate'] ? '[' . date('Y-m-d', $v['sdate']) . '生产]' : '';
+                $cash = Dever::number($v['cash'] * $v['num']);
+
+                $detail = array
+                (
+                    $goods_info['code'],
+                    $goods_info['name'],
+                    $goods_info['spec_name'],
+                    $v['batch'] . $sdate,
+                    $v['cash'],
+                    $v['num'] . $goods_info['unit'],
+                    $cash,
+                    $status_name,
+                );
+
+                if ($goods_info['goods']) {
+                    $detail['goods'] = $goods_info['goods'];
+                }
+
+                $table['body'][] = $detail;
+                $total_price += $cash;
+                $total_num += $num;
+            }
+            $result['商品清单'] = array
+            (
+                'type' => 'table',
+                'head' => array('name' => '', 'btn' => ''),
+                'content' => $table,
+                'total' => '合计金额:' . Dever::number($total_price) . ',合计数量:' . $total_num
+            );
+        }
+    }
+
+    # 显示按钮
+    private function show_button($order, $order_table)
+    {
+        $button = array();
+        if ($order['status'] == 1) {
+            list($project, $table) = explode('/', $order_table);
+            $url = Dever::url('project/database/update?project='.$project.'&table='.$table.'&where_id='.$order['id'].'&col=audit,audit_desc', 'manage');
+
+            $button[] = array
+            (
+                'type' => 'edit',
+                'link' => $url,
+                'name' => '审核',
+            );
+        }
+        return $button;
+    }
 }

+ 0 - 43
lib/Price.php

@@ -10,47 +10,4 @@ class Price
     {
         Dever::load('manage/auth.init');
     }
-
-    # 根据单位获取价格
-    public function getByUnit($goods_id, $sku_id, $unit_id, $num, $cash, $in_num = 0, $supplier_id = false)
-    {
-        $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
-        $result = array();
-
-        if ($goods_info) {
-            $where['goods_id'] = $goods_id;
-            $where['sku_id'] = $sku_id;
-
-            # 获取供应商供货价
-            if ($supplier_id) {
-                $where['supplier_id'] = $supplier_id;
-                $sku = Dever::db('scm_supplier/goods_sku')->getOne($where);
-            }
-
-            $result['unit_id'] = $unit_id;
-            $result['base_unit_id'] = $goods_info['unit_id'];
-            if (!is_numeric($cash)) {
-                $cash = isset($sku[$cash]) && $sku[$cash] ? $sku[$cash] : $goods_info[$cash];
-            }
-            $result['base_cash'] = $result['cash'] = $cash;
-            $result['base_num'] = $result['num'] = $num;
-            $result['in_num'] = $in_num;
-                
-            $unit = Dever::db('scm_product/info_unit')->find(array('info_id' => $goods_info['id'], 'unit_id' => $unit_id));
-
-            if ($unit && $unit_id != $goods_info['unit_id'] && $unit['discount'] > 0) {
-                $result['cash'] = $result['cash'] * $unit['radio'] * $unit['discount'];
-                $result['base_num'] = $num * $unit['radio'];
-                $result['in_num'] = round($in_num / $unit['radio'], 2);
-            }
-            $unit_info = Dever::db('scm/unit')->one($unit_id);
-
-            $result = Dever::number(array(array('cash', 'base_cash', 'num', 'base_num', 'in_num'), $result));
-            if ($result['in_num'] > 0) {
-                $result['goods_id'] = $result['in_num'] . $unit_info['name'];
-            }
-        }
-
-        return $result;
-    }
 }

+ 47 - 25
lib/Stock.php

@@ -8,35 +8,47 @@ class Stock
 {
 	public function out_check($id, $name, $data)
 	{
+		$goods = Dever::param('goods', $data);
+		if (!$goods) {
+			$this->alert('未选择商品', $data);
+		}
+		$unit_id = Dever::param('unit_id', $data);
+		if (!$unit_id) {
+			$this->alert('未选择单位', $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);
+
+		$info = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit_id, false, false, $table, $where);
 		$error = false;
-		$total = '';
 		if ($info) {
 			$num = Dever::param('num', $data);
-			if ($info['total'] < $num) {
+			if ($info['num'] < $num) {
 				$error = true;
-				$total = $info['total'];
 			}
 		} else {
 			$error = true;
-			$total = 0;
 		}
 		if ($error) {
-			$order_table = Dever::input('order_table');
-			if ($order_table) {
-				$order_id = Dever::param('order_id', $data);
+			$goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
+			$unit = Dever::db('scm/unit')->find($unit_id);
+			$this->alert('下单失败!【' . $goods_info['aname'] . '】下单数量(' . $num . $unit['name'] . ')少于剩余库存(' . $info['num'] . $unit['name'] . ')', $data);
+		}
+	}
+
+	private function alert($msg, $data)
+	{
+		$order_table = Dever::input('order_table');
+		if ($order_table) {
+			$order_id = Dever::param('order_id', $data);
+			if ($order_id) {
 				Dever::db($order_table)->delete($order_id);
 			}
-			$goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
-			Dever::alert('【' . $goods_info['aname'] . '】剩余库存:' . $total . $goods_info['unit'] . ',已不足出库');
 		}
+		Dever::alert($msg);
 	}
 
     # 更新库存
@@ -76,58 +88,68 @@ class Stock
     		$order_goods = Dever::db($table . '_goods')->select(array('order_id' => $info['id'], 'status' => 1));
 			if ($order_goods) {
 				foreach ($order_goods as $k => $v) {
-					$update = array('goods_id' => $v['goods_id'], $col => $info[$col]);
+					$update = array('goods_id' => $v['goods_id'], $col => $info[$col], 'clear' => true);
 					$goods = Dever::db($stock)->find($update);
 					if (!$goods) {
 						Dever::db($stock)->insert($update);
 					}
 
-					$result = Dever::load('scm/lib/price')->getByUnit($v['goods_id'], $v['sku_id'], $v['unit_id'], $v['num'], $v['cash'], Dever::input('supplier_id'));
+					$result = Dever::load('scm/lib/unit')->convertBase($v['goods_id'], $v['sku_id'], $v['unit_id'], $v['num'], $v['cash']);
 					if ($result) {
-						$v['unit_id'] = $result['base_unit_id'];
-						$v['cash'] = $result['base_cash'];
-						$v['num'] = $result['base_num'];
+						$v['unit_id'] = $result['unit_id'];
+						$v['cash'] = $result['cash'];
+						$v['num'] = $result['num'];
 					} else {
 						Dever::db($table)->delete($info['id']);
     					Dever::alert('商品不存在');
 					}
 
+					$temp = explode('/', $stock);
+					$list_table = $stock . '_list';
+					$goods_list_id = $temp[1] . '_list_id';
+
 					if ($type == 'in') {
 						# 入库
 						if (!$v['batch']) {
 							$v['batch'] = date('Ymd');
 						}
 						$update['sku_id'] = $v['sku_id'];
+						$update['unit_id'] = $v['unit_id'];
 						$update['batch'] = $v['batch'];
+						$update['cash'] = $v['cash'];
 						if ($v['sdate']) {
 							$update['sdate'] = $v['sdate'];
 						}
-						$goods = Dever::db($stock . '_sku')->find($update);
+						$goods = Dever::db($list_table)->find($update);
 						if (!$goods) {
 							$update['cash'] = $v['cash'];
 							$update['unit_id'] = $v['unit_id'];
-							$id = Dever::db($stock . '_sku')->insert($update);
+							$id = Dever::db($list_table)->insert($update);
 							$where['where_id'] = $id;
 						} else {
 							$where['where_id'] = $goods['id'];
 						}
 
+						Dever::db($table . '_goods')->update(array('where_id' => $v['id'], $goods_list_id => $where['where_id']));
+
 						$where[$type . '_num'] = $v['num'];
 						$method = $type . 'Update';
-						Dever::db($stock . '_sku')->$method($where);
+						Dever::db($list_table)->$method($where);
 					} elseif ($type == 'out') {
 						# 出库
 						$update['sku_id'] = $v['sku_id'];
-						$goods = Dever::db($stock . '_sku')->getList($update);
+						# **** 出库形式,现在按照先入先出,之后这里可以根据商品,改成加权平均出库
+						$goods = Dever::db($list_table)->getList($update);
 						if ($goods) {
 							$num = $v['num'];
 							foreach ($goods as $k1 => $v1) {
 								if ($v1['total'] >= $num) {
-									Dever::db($stock . '_sku')->outUpdate(array('where_id' => $v1['id'], 'out_num' => $num));
-									break;
+									Dever::db($list_table)->outUpdate(array('where_id' => $v1['id'], 'out_num' => $num));
+									Dever::db($table . '_goods')->update(array('where_id' => $v['id'], $goods_list_id => $v1['id']));
 								} else {
 									$num = $num - $v1['total'];
-									Dever::db($stock . '_sku')->outUpdate(array('where_id' => $v1['id'], 'out_num' => $v1['total']));
+									Dever::db($list_table)->outUpdate(array('where_id' => $v1['id'], 'out_num' => $v1['total']));
+									Dever::db($table . '_goods')->update(array('where_id' => $v['id'], $goods_list_id => $v1['id']));
 								}
 							}
 						}

+ 117 - 0
lib/Unit.php

@@ -75,4 +75,121 @@ class Unit
         }
         return $info;
     }
+
+    # 获取库中的基础单位的总价和总数
+    public function getData($goods_id, $sku_id, $unit_id = false, $supplier_id = false, $cash_col = false, $table = false, $where = array())
+    {
+        $where['goods_id'] = $goods_id;
+        $where['sku_id'] = $sku_id;
+
+        # 仓库
+        $servicer_store_id = Dever::input('servicer_store_id');
+        if ($servicer_store_id) {
+            $where['servicer_store_id'] = $servicer_store_id;
+            $table = 'scm_servicer/store_goods_list';
+        }
+
+        $result = array();
+        $result['num'] = $result['cash'] = 0;
+
+        if ($table) {
+            $list = Dever::db($table)->getUnit($where);
+            if ($list) {
+                foreach ($list as $k => $v) {
+                    $base = $this->convertBase($goods_id, $sku_id, $v['unit_id'], $v['total'], $v['cash'], $supplier_id);
+                    if ($base) {
+                        $result['num'] += $base['num'];
+                        $result['cash'] += $base['cash'];
+                    }
+                }
+            }
+        }
+
+        if ($unit_id) {
+            if ($cash_col) {
+                $result['cash'] = $cash_col;
+            }
+            $unit = $this->convertUnit($goods_id, $sku_id, $unit_id, $result['num'], $result['cash'], $supplier_id);
+            if ($unit) {
+                $result['num'] = $unit['num'];
+                $result['cash'] = $unit['cash'];
+            }
+        }
+
+        $result['num'] = Dever::number($result['num'], 2);
+        $result['cash'] = Dever::number($result['cash'], 2);
+
+        return $result;
+    }
+
+    # 将单位转换成基础单位,并获取基础价格和基础数量 unit_id 当前单位,num当前单位数量, cash当前单位价格
+    public function convertBase($goods_id, $sku_id, $unit_id, $num, $cash, $supplier_id = false)
+    {
+        $result = $this->getInfo($goods_id, $sku_id, $unit_id, $num, $cash, $supplier_id);
+        if ($result) {
+            # 基础单位和当前单位不同
+            if ($result['unit']) {
+                $unit = $result['unit'];
+                if ($unit && $unit['discount'] > 0) {
+                    $result['cash'] = $result['cash'] / $unit['radio'] / $unit['discount'];
+                    $result['num'] = $num * $unit['radio'];
+                }
+            }
+            $result = Dever::number(array(array('cash', 'num'), $result));
+        }
+
+        return $result;
+    }
+
+    # 获取当前单位对应基础单位的价格和数量 unit_id 当前单位,base_num基础单位数量, base_cash基础单位价格
+    public function convertUnit($goods_id, $sku_id, $unit_id, $base_num, $base_cash, $supplier_id = false)
+    {
+        $result = $this->getInfo($goods_id, $sku_id, $unit_id, $base_num, $base_cash, $supplier_id);
+        if ($result) {
+            # 基础单位和当前单位不同
+            if ($result['unit']) {
+                $unit = $result['unit'];
+                $result['unit_id'] = $unit['unit_id'];
+                if ($unit && $unit['discount'] > 0) {
+                    $result['cash'] = $result['cash'] * $unit['radio'] * $unit['discount'];
+                    $result['num'] = round($result['num'] / $unit['radio'], 2);
+                }
+            }
+
+            $result = Dever::number(array(array('cash', 'num'), $result));
+        }
+
+        return $result;
+    }
+
+    private function getInfo($goods_id, $sku_id, $unit_id, $num, $cash, $supplier_id = false)
+    {
+        $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
+        $result = array();
+        if ($goods_info) {
+            # 获取供应商供货价
+            if ($supplier_id) {
+                $where['supplier_id'] = $supplier_id;
+                $where['goods_id'] = $goods_id;
+                $where['sku_id'] = $sku_id;
+                $sku = Dever::db('scm_supplier/goods')->getOne($where);
+            }
+            if (!is_numeric($cash)) {
+                $cash = isset($sku[$cash]) && $sku[$cash] ? $sku[$cash] : $goods_info[$cash];
+            }
+
+            # 当前单位和价格
+            $result['unit_id'] = $unit_id;
+            $result['num'] = $num;
+            $result['cash'] = $cash;
+
+            # 单位基本信息
+            $result['unit'] = array();
+            if ($unit_id != $goods_info['unit_id']) {
+                $result['unit_id'] = $goods_info['unit_id'];
+                $result['unit'] = Dever::db('scm_product/info_unit')->find(array('info_id' => $goods_info['id'], 'unit_id' => $unit_id));
+            }
+        }
+        return $result;
+    }
 }

+ 2 - 2
module/scm_product/assets/pc/html/set_supplier_goods.html

@@ -121,13 +121,13 @@
             var url = '<{$submit}>';
             var id = '<{$id}>';
             var project = '<{$project}>';
-            var goods = '<{$goods}>';
+            var table = '<{$table}>';
 
             layui.layer.confirm('确定进行此项设置吗?', function() {
                 var goods_string = JSON.stringify(goods);
 
                 var data = {};
-                data = {id:id, project:project, goods:goods, goods:goods_string};
+                data = {id:id, project:project, table:table, goods:goods_string};
                 $.post(url, data, function(t) {
                     t = JSON.parse(t);
                     if (t.status == 1) {

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

@@ -352,7 +352,11 @@ class Info
                 }
             }
         }
-        $info['spec_name'] = implode(',', $info['spec_name']);
+        if (!$info['spec_name']) {
+            $info['spec_name'] = '无';
+        } else {
+            $info['spec_name'] = implode(',', $info['spec_name']);
+        }
 
         $pic = explode(',', $info['pic']);
         $info['cover'] = $pic[0];

+ 20 - 36
module/scm_product/lib/Manage.php

@@ -119,7 +119,7 @@ class Manage
             $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);
+                $data = Dever::search('scm_servicer/store_goods_list', $where);
             } else {
                 # 没有库存
                 return array();
@@ -179,7 +179,7 @@ class Manage
     public function getGoods($id, $table = 'scm_servicer/in_order_goods', $cash = true)
     {
         $result = array();
-        $result['head'] = array('名称', '批次', '单位', '单价', '数量', '状态');
+        $result['head'] = array('名称', '批次', '单价', '数量', '状态');
         if (!$cash) {
             unset($result['head'][1]);
         }
@@ -195,9 +195,8 @@ class Manage
                 $unit = Dever::db('scm/unit')->one($v['unit_id']);
                 $result['body'][$k][] = $goods_info['aname'];
                 $result['body'][$k][] = $v['batch'];
-                $result['body'][$k][] = $unit['name'];
                 $result['body'][$k][] = $v['cash'];
-                $result['body'][$k][] = $v['num'];
+                $result['body'][$k][] = $v['num'] . $unit['name'];
                 $result['body'][$k][] = $status_name;
 
                 if (!$cash) {
@@ -235,7 +234,7 @@ class Manage
     {
         $goods = Dever::input('value');
         $cash_col = Dever::input('cash_col', 'cost_price');
-        list($goods_id, $sku_id, $cash) = explode('-', $goods);
+        list($goods_id, $sku_id) = explode('-', $goods);
         $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($goods_id, $sku_id);
         $option = array();
         $result = array();
@@ -244,33 +243,17 @@ class Manage
         $result['cash'] = '0.00';
 
         if ($goods_info) {
-            $where['goods_id'] = $goods_id;
-            $where['sku_id'] = $sku_id;
-
             $result['cash'] = $goods_info[$cash_col];
-
-            $info = array();
-
-            # 仓库
-            $servicer_store_id = Dever::input('servicer_store_id');
-            if ($servicer_store_id) {
-                $where['servicer_store_id'] = $servicer_store_id;
-                $info = Dever::db('scm_servicer/store_goods_sku')->getOne($where);
+            $string = '';
+            $table = Dever::input('table');
+            $unit_id = false;
+            if ($table == 'in_order') {
+                $unit_id = -1;
             }
-
-            if ($info) {
-                $result['cash'] = $info['cash'];
-                $result['goods_id'] = $info['total'] . $goods_info['unit'];
-            }
-
-            # 获取供应商供货价
-            $supplier_id = Dever::input('supplier_id');
-            if ($supplier_id) {
-                $where['supplier_id'] = $supplier_id;
-                $sku = Dever::db('scm_supplier/goods_sku')->getOne($where);
-                if ($sku && isset($sku[$cash_col]) && $sku[$cash_col]) {
-                    $result['cash'] = $sku['cost_price'];
-                }
+            $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit_id, Dever::input('supplier_id'), Dever::input('cash_col'));
+            if ($data) {
+                $result['cash'] = $data['cash'];
+                $result['goods_id'] = $data['num'] . $goods_info['unit'] . $string;
             }
 
             $result['unit_id'] = $goods_info['unit_id'];
@@ -302,12 +285,13 @@ class Manage
         $temp = explode('-', $goods);
         $goods_id = $temp[0];
         $sku_id = $temp[1];
-        $cash = $temp[2];
-        $in_num = 0;
-        if (isset($temp[3])) {
-            $in_num = $temp[3];
+        $data = Dever::load('scm/lib/unit')->getData($goods_id, $sku_id, $unit, Dever::input('supplier_id'), Dever::input('cash_col'));
+        if ($data && $data['num'] > 0) {
+            $unit = Dever::db('scm/unit')->one($unit);
+            $data['goods_id'] = $data['num'] . $unit['name'];
         }
-
-        return array('data' => Dever::load('scm/lib/price')->getByUnit($goods_id, $sku_id, $unit, 1, $cash, $in_num, Dever::input('supplier_id')), 'html' => '');
+        unset($data['num']);
+        
+        return array('data' => $data, 'html' => '');
     }
 }

+ 18 - 42
module/scm_product/lib/Set.php

@@ -11,11 +11,11 @@ class Set
     {
         $id = Dever::input('id', 1);
         $project = Dever::input('project');
-        $goods = Dever::input('goods');
+        $table = Dever::input('table');
         $price_id = Dever::input('price_id', -1);
         $type = Dever::input('type', 1);
         $source = '';
-        $table = 'scm_'.$project.'/' . $goods;
+        $table = 'scm_'.$project . '/' . $table;
         if ($type == 2) {
             $source = $table;
             $table = '';
@@ -32,13 +32,13 @@ class Set
         $data['id'] = Dever::input('id', 1);
         $data['project'] = Dever::input('project');
         $data['info'] = Dever::input('info');
-        $data['goods'] = Dever::input('goods');
+        $data['table'] = Dever::input('table');
         $info = Dever::db('scm_' . $data['project'] . '/' . $data['info'])->find($data['id']);
         $data['info'] = $info;
 
         $data['host'] = Dever::url('lib/set.home', 'scm_product');
 
-        $uri = 'lib/set.goods?id=' . $data['id'] . '&project=' . $data['project'] . '&goods=' . $data['goods'];
+        $uri = 'lib/set.goods?id=' . $data['id'] . '&project=' . $data['project'] . '&table=' . $data['table'];
 
         if (isset($info['category'])) {
         	$uri .= '&goods_category=' . $info['category'];
@@ -59,19 +59,18 @@ class Set
         if (!$goods) {
             Dever::alert('请传入商品');
         }
-        $role = Dever::input('role');
+        $project = Dever::input('project');
+        $table = Dever::input('table');
         $goods = Dever::json_decode($goods);
         $id = Dever::input('id');
 
-        $col = $role . '_id';
-        $table_goods = 'scm_'.$role.'/goods';
-        $table_goods_sku = 'scm_'.$role.'/goods_sku';
+        $col = $project . '_id';
+        $table_goods = 'scm_' . $project . '/' . $table;
 
-        $info = Dever::db('scm_' . $role . '/info')->one($id);
+        $info = Dever::db('scm_' . $project . '/info')->one($id);
         $where['option_' . $col] = $id;
         $where['set_state'] = 2;
         Dever::db($table_goods)->updates($where);
-        Dever::db($table_goods_sku)->updates($where);
 
         foreach ($goods as $k => $v) {
             $temp = explode('-', $k);
@@ -90,50 +89,27 @@ class Set
             $w['sku_id'] = $sku_id;
 
             if ($v['del'] == 2) {
-                $sku_info = Dever::db($table_goods_sku)->one($w);
-
-                if ($sku_info) {
-                    Dever::db($table_goods_sku)->update(array('where_id' => $sku_info['id'], 'state' => 2));
-                }
-                unset($w['sku_id']);
-                $t = $w;
-                $t['state'] = 1;
-                $total = Dever::db($table_goods_sku)->total($t);
-                if ($total <= 0) {
-                    $info = Dever::db($table_goods)->one($w);
-                    if ($info) {
-                        Dever::db($table_goods)->update(array('where_id' => $info['id'], 'state' => 2));
-                    }
+                $info = Dever::db($table_goods)->one($w);
+                if ($info) {
+                    Dever::db($table_goods)->update(array('where_id' => $info['id'], 'state' => 2));
                 }
             } else {
                 $goods_info = Dever::db('scm_product/info')->one($goods_id);
                 $info = Dever::db($table_goods)->one($w);
 
-                $u = $w;
                 if (isset($v['min'])) {
-                	$u['min'] = $v['min'];
+                	$w['min'] = $v['min'];
                 }
                 if (isset($v['cost_price'])) {
-                	$u['cost_price'] = $v['cost_price'];
+                	$w['cost_price'] = $v['cost_price'];
                 }
                 
                 if (!$info) {
-                    Dever::db($table_goods)->insert($u);
-                } else {
-                    $u['where_id'] = $info['id'];
-                    $u['state'] = 1;
-                    Dever::db($table_goods)->update($u);
-                }
-
-                $u['sku_id'] = $w['sku_id'] = $sku_id;
-                $info = Dever::db($table_goods_sku)->one($w);
-
-                if (!$info) {
-                    Dever::db($table_goods_sku)->insert($u);
+                    Dever::db($table_goods)->insert($w);
                 } else {
-                    $u['where_id'] = $info['id'];
-                    $u['state'] = 1;
-                    Dever::db($table_goods_sku)->update($u);
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db($table_goods)->update($w);
                 }
             }
         }

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

@@ -44,12 +44,6 @@ class Sku
                         if (isset($copy['value'])) {
                             $copy['value'] = $copy['id'];
                         }
-                        if (isset($copy['cash'])) {
-                            $copy['value'] .= '-' . $copy['cash'];
-                            if (isset($copy['in_num'])) {
-                                $copy['value'] .= '-' . $copy['in_num'];
-                            }
-                        }
                     }
                     
                     $data[] = $copy;

+ 0 - 0
module/scm_servicer/assets/manage/html/in_order_goods.html → module/scm_servicer/assets/manage/html/order_goods.html


+ 0 - 6
module/scm_servicer/assets/manage/html/out_order_goods.html

@@ -1,6 +0,0 @@
-
-<form class="layui-form form10" action="" target="f10" method="post">
-<iframe id="f10" name="f10" style="display:none;"></iframe>
-<div class="layui-form-item" id="show">
-</div>
-</form>

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

@@ -46,6 +46,7 @@ return array
     'set' => array
     (
     	'status' => $status,
+        'audit' => $audit,
     ),
     'end' => array
     (
@@ -76,7 +77,7 @@ return array
             'match'     => 'is_string',
             'search'    => 'fulltext',
             'list_name'	=> '订单信息',
-            'list'      => 'Dever::load("scm_servicer/lib/in.info", {id})',
+            'list'      => 'Dever::load("scm_servicer/lib/manage.info", "in", {id})',
         ),
 
         'servicer_id'      => array
@@ -255,6 +256,8 @@ return array
 
     'manage' => array
     (
+        # 后台提交时,检测该值是否为空,多个用逗号隔开
+        'update_check' => 'scm_servicer-in_order_goods',
         'delete' => false,
         'edit' => false,
         'insert' => false,
@@ -269,7 +272,7 @@ return array
 
         'list_button' => array
         (
-            'list' => array('查看详情', '"in_order_goods&page_type=1&order_id={id}"'),
+            'list' => array('查看详情', '"in_order_goods&type=in&page_type=1&order_id={id}"'),
 
             'fast' => array('审核', '"in_order&where_id={id}&col=audit,audit_desc"', '{status} == 1'),
         ),

+ 15 - 6
module/scm_servicer/database/in_order_goods.php

@@ -59,7 +59,7 @@ return array
             'match'     => 'option',
             'update'    => 'select',
             'update_search' => 'scm_product/lib/manage.searchProduct?{supplier_id}',
-            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showInfo', 'scm_product'), 'col' => 'servicer_store_id,supplier_id')),
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showInfo?cash_col=cost_price', 'scm_product'), 'col' => 'servicer_store_id,supplier_id')),
         ),
 
         'goods_id'      => array
@@ -82,6 +82,16 @@ return array
             'match'     => 'is_numeric',
         ),
 
+        'store_goods_list_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联仓库商品id',
+            'default'   => '',
+            'desc'      => '关联仓库商品id',
+            'match'     => 'is_numeric',
+            'value'     => '暂无',
+        ),
+
         'unit_id'      => array
         (
             'type'      => 'int-11',
@@ -91,7 +101,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'select',
             'option'    => array(0 => '请先选择商品'),
-            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit', 'scm_product'), 'col' => 'supplier_id,goods')),
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit?cash_col=cost_price', 'scm_product'), 'col' => 'supplier_id,goods')),
         ),
 
         'batch'      => array
@@ -128,12 +138,11 @@ return array
 
         'num'        => array
         (
-            'type'      => 'int-11',
+            'type'      => 'decimal-11,2',
             'name'      => '数量',
             'default'   => '1',
             'desc'      => '数量',
-            'match'     => 'is_numeric',
-            'search'    => 'select',
+            'match'     => 'option',
             'update'	=> 'text',
         ),
 
@@ -177,7 +186,7 @@ return array
     (
         'insert' => false,
         'delete' => false,
-        'page_list' => 'in_order_goods',
+        'page_list' => 'order_goods',
     ),
 
     'request' => array

+ 5 - 2
module/scm_servicer/database/out_order.php

@@ -50,6 +50,7 @@ return array
     'set' => array
     (
     	'status' => $status,
+        'audit' => $audit,
     ),
     'end' => array
     (
@@ -80,7 +81,7 @@ return array
             'match'     => 'is_string',
             'search'    => 'fulltext',
             'list_name'	=> '订单信息',
-            'list'      => 'Dever::load("scm_servicer/lib/out.info", {id})',
+            'list'      => 'Dever::load("scm_servicer/lib/manage.info", "out", {id})',
         ),
 
         'servicer_id'      => array
@@ -271,6 +272,8 @@ return array
 
     'manage' => array
     (
+        # 后台提交时,检测该值是否为空,多个用逗号隔开
+        'update_check' => 'scm_servicer-out_order_goods',
         'delete' => false,
         'edit' => false,
         'insert' => false,
@@ -285,7 +288,7 @@ return array
 
         'list_button' => array
         (
-            'list' => array('查看详情', '"out_order_goods&page_type=1&order_id={id}"'),
+            'list' => array('查看详情', '"out_order_goods&type=out&page_type=1&order_id={id}"'),
 
             'fast' => array('审核', '"out_order&where_id={id}&col=audit,audit_desc"', '{status} == 1'),
         ),

+ 19 - 10
module/scm_servicer/database/out_order_goods.php

@@ -18,7 +18,7 @@ return array
     # 验证库存
     'start' => array
     (
-    	'insert' => 'scm/lib/stock.out_check?table=scm_servicer/store_goods_sku&order_table=scm_servicer/out_order&col=servicer_store_id',
+    	'insert' => 'scm/lib/stock.out_check?table=scm_servicer/store_goods_list&order_table=scm_servicer/out_order&col=servicer_store_id',
     ),
     'end' => array
     (
@@ -71,7 +71,7 @@ return array
             'match'     => 'is_numeric',
             'update'	=> 'show',
             'value'		=> '暂无',
-        ),	
+        ),
 
         'sku_id'      => array
         (
@@ -82,6 +82,16 @@ return array
             'match'     => 'is_numeric',
         ),
 
+        'store_goods_list_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联仓库商品id',
+            'default'   => '',
+            'desc'      => '关联仓库商品id',
+            'match'     => 'is_numeric',
+            'value'     => '暂无',
+        ),
+
         'unit_id'      => array
         (
             'type'      => 'int-11',
@@ -91,7 +101,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'select',
             'option'    => array(0 => '请先选择商品'),
-            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit', 'scm_product'), 'col' => 'supplier_id,goods')),
+            'bind'        => array('onchange', 'loading', array('url' => Dever::url('lib/manage.showPriceByUnit', 'scm_product'), 'col' => 'servicer_store_id,goods')),
         ),
 
         'batch'      => array
@@ -108,7 +118,7 @@ return array
         'cash'      => array
         (
             'type'      => 'decimal-11,2',
-            'name'      => '单价',
+            'name'      => '单价(入库价平均价)',
             'default'   => '',
             'desc'      => '单价',
             'match'     => 'option',
@@ -117,13 +127,12 @@ return array
 
         'num'        => array
         (
-            'type'      => 'int-11',
-            'name'      => '出库数量',
+            'type'      => 'decimal-11,2',
+            'name'      => '数量',
             'default'   => '1',
             'desc'      => '数量',
-            'match'     => 'is_numeric',
-            'search'    => 'select',
-            'update'	=> 'text',
+            'match'     => 'option',
+            'update'    => 'text',
         ),
 
         'status'        => array
@@ -166,7 +175,7 @@ return array
     (
         'insert' => false,
         'delete' => false,
-        'page_list' => 'out_order_goods',
+        'page_list' => 'order_goods',
     ),
 
     'request' => array

+ 50 - 0
module/scm_servicer/database/store_goods.php

@@ -38,6 +38,18 @@ return array
             'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_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',
@@ -50,6 +62,15 @@ return array
             'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
         ),
 
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -81,6 +102,35 @@ return array
 
     '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'),
+            'page' => array(10, 'list'),
+            'col' => '*, t_2.*,t_2.id as value, "" as selected, "" as disabled',
+        ),
+
         'getData' => array
         (
             # 匹配的正则或函数 选填项

+ 38 - 135
module/scm_servicer/database/store_goods_sku.php → module/scm_servicer/database/store_goods_list.php

@@ -3,7 +3,7 @@
 $config = array
 (
     # 表名
-    'name' => 'store_goods_sku',
+    'name' => 'store_goods_list',
     # 显示给用户看的名称
     'lang' => '商品价格设置',
     'order' => 200,
@@ -36,36 +36,12 @@ $config = array
             'list'      => 'Dever::load("scm_servicer/store-one#name", {servicer_store_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
+        'store_goods_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '商品名称',
+            'name'      => '仓库商品id',
             'default'   => '',
-            'desc'      => '商品名称',
-            'match'     => 'is_numeric',
-            'update'    => 'select',
-            'update_search' => 'scm_product/lib/manage.search',
-            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
-        ),
-
-        'sku_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '规格型号',
-            'default'   => '-1',
-            'desc'      => '规格型号',
+            'desc'      => '仓库商品id',
             'match'     => 'is_numeric',
         ),
 
@@ -126,15 +102,6 @@ $config = array
             'match'     => 'option',
         ),
 
-        'on_num'        => array
-        (
-            'type'      => 'decimal-11,2',
-            'name'      => '在途库存',
-            'default'   => '0',
-            'desc'      => '在途库存',
-            'match'     => 'is_numeric',
-        ),
-
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -169,102 +136,24 @@ $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
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'servicer_store_id' => array('yes-t_1.servicer_store_id'),
-                'name' => array('yes-t_2.name', 'like'),
-                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
-                'category' => array('yes-t_2.category', 'like'),
-                'top_category_id' => array('yes-t_2.top_category_id'),
-                'second_category_id' => array('yes-t_2.second_category_id'),
-                'category_id' => array('yes-t_2.category_id'),
-                'status' => array('yes-t_2.status', 1),
-                'state' => array('yes-t_2.state', 1),
-                'state_1' => array('yes-t_1.state', 1),
-            ),
-            # 联表
-            'join' => array
-            (
-                array
-                (
-                    'table' => 'scm_product/info',
-                    'type' => 'left join',
-                    'on' => array('goods_id','id'),
-                    'col' => 'goods_id',
-                ),
-            ),
-            'type' => 'all',
-            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
-            'page' => array(30, 'list'),
-            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
-        ),
-
-        'getData' => array
+       	# 列表 先入先出
+        'getList' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'servicer_store_id' => array('yes-t_1.servicer_store_id'),
-                'name' => array('yes-t_2.name', 'like'),
-                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
-                'category' => array('yes-t_2.category', 'like'),
-                'top_category_id' => array('yes-t_2.top_category_id'),
-                'second_category_id' => array('yes-t_2.second_category_id'),
-                'category_id' => array('yes-t_2.category_id'),
-                'status' => array('yes-t_2.status', 1),
-                'state' => array('yes-t_2.state', 1),
-                'state_1' => array('yes-t_1.state', 1),
-            ),
-            # 联表
-            'join' => array
-            (
-                array
-                (
-                    'table' => 'scm_product/info',
-                    'type' => 'left join',
-                    'on' => array('goods_id','id'),
-                    'col' => 'goods_id',
-                ),
+                'servicer_store_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
             ),
             'type' => 'all',
-            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
-            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num,t_1.in_num,t_2.type,t_2.stock,t_2.commission,t_2.sell_type,t_2.buy_type',
+            'order' => array('sdate' => 'asc', 'batch' => 'asc', 'id' => 'asc'),
+            'col' => '*,in_num-out_num as total',
         ),
 
-       	# 列表
-        'getList' => array
+        # 获取某个sku的单条数据
+        'getOne' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
@@ -274,13 +163,12 @@ $config = array
                 'sku_id' => 'yes',
                 'state' => 1,
             ),
-            'type' => 'all',
-            'order' => array('sdate' => 'asc', 'batch' => 'asc', 'id' => 'desc'),
-            'col' => '*,in_num-out_num as total|sku_id',
+            'type' => 'one',
+            'col' => '*,(sum(in_num)-sum(out_num)) as total,AVG(cash) as cash',
         ),
 
-        # 获取单数据
-        'getOne' => array
+        # 获取单位下的数据
+        'getUnit' => array
         (
             # 匹配的正则或函数 选填项
             'option' => array
@@ -290,8 +178,9 @@ $config = array
                 'sku_id' => 'yes',
                 'state' => 1,
             ),
-            'type' => 'one',
-            'col' => '*,in_num-out_num as total',
+            'type' => 'all',
+            'group' => 'unit_id',
+            'col' => '*,(sum(in_num)-sum(out_num)) as total,AVG(cash) as cash|unit_id',
         ),
 
         # 更新入库库存
@@ -322,8 +211,22 @@ $config = array
             ),
         ),
 
-        # 更新在途库存
-        'onUpdate' => array
+        # 更新入库在途库存
+        'onInUpdate' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'on_in_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 更新出库在途库存
+        'onOutUpdate' => array
         (
             'type' => 'update',
             'where' => array
@@ -332,7 +235,7 @@ $config = array
             ),
             'set' => array
             (
-                'on_num' => array('yes', '+='),
+                'on_out_num' => array('yes', '+='),
             ),
         ),
     ),

+ 0 - 166
module/scm_servicer/lib/In.php

@@ -1,166 +0,0 @@
-<?php
-
-namespace Scm_servicer\Lib;
-
-use Dever;
-
-class In
-{
-	# 获取订单信息
-    public function info($id)
-    {
-    	Dever::load('manage/auth.init');
-
-    	$info = Dever::db('scm_servicer/in_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'];
-
-        $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('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']);
-
-        $type = Dever::db('scm_servicer/in_order_type')->one($info['type']);
-
-        $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('入库类型', $type['name']),
-                    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'], $v['unit_id']);
-                $status_name = Dever::status($status, $v['status']);
-
-                if ($v['unit_id'] != $goods_info['base_unit_id']) {
-                    $unit = Dever::load('scm/lib/price')->getByUnit($v['goods_id'], $v['sku_id'], $v['unit_id'], $v['num'], $v['cash'], $info['supplier_id']);
-                    if ($unit) {
-                        $base_unit = Dever::db('scm/unit')->find($goods_info['base_unit_id']);
-                        $goods_info['unit'] .= '(审核成功将转换成:'.$unit['base_num'].''.$base_unit['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'];
-            }
-        }
-        $result['商品清单'] = array
-        (
-            'type' => 'list',
-            'content' => $body,
-            'total' => $body_total,
-        );
-
-        $head = array
-        (
-            'name' => '基本信息',
-            'btn' => '',
-        );
-        $html = Dever::show($head, $result);
-        return $html;
-    }
-}

+ 43 - 1
module/scm_servicer/lib/Manage.php

@@ -11,6 +11,48 @@ class Manage
         Dever::load('manage/auth.init');
     }
 
+    # 获取订单信息
+    public function info($type = 'in', $id)
+    {
+        Dever::load('manage/auth.init');
+
+        $info = Dever::db('scm_servicer/'.$type.'_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'];
+
+        if (isset($info['supplier_id'])) {
+            $supplier = Dever::db('scm_supplier/info')->one($info['supplier_id']);
+
+            $string .= '<br />' . $supplier['name'];
+        }
+
+        $type = Dever::db('scm_servicer/'.$type.'_order_type')->one($info['type']);
+
+        $string .= '<br />' . $type['name'];
+
+        $string .= '<br />' . $info['info'];
+
+        return $string;
+    }
+
+    # 查看详情
+    public function show()
+    {
+        $type = Dever::input('type');
+        return Dever::load('scm/lib/order')->show('scm_servicer/'.$type.'_order', 'scm_servicer/info', 'servicer_id', '配送商');
+    }
+
+
     public function getStore($id)
     {
         $table = array();
@@ -26,7 +68,7 @@ class Manage
             	if ($v['status'] == 2) {
             		$status_name = '(已禁用)';
             	}
-            	$oper = '<a class="layui-btn" href="'.Dever::url('lib/set.home?role=servicer/store&id=' . $v['id'], 'scm_product').'">仓库明细</a>';
+            	$oper = '<a class="layui-btn" href="'.Dever::url('lib/set.home?role=servicer/store&id=' . $v['id'], 'scm_product').'">库存清单</a>';
                 $table['body'][$k][] = $v['name'] . $status_name;
                 $table['body'][$k][] = $v['code'];
                 $table['body'][$k][] = $oper;

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

@@ -1,153 +0,0 @@
-<?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/out_order')->config['set'];
-
-        $info = Dever::db('scm_servicer/out_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']);
-
-        $type = Dever::db('scm_servicer/out_order_type')->one($info['type']);
-
-        $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
-                (
-                    array('出库类型', $type['name']),
-                    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/out_order_goods')->select(array('order_id' => $id));
-
-        if ($data) {
-            $status = Dever::db('scm_servicer/out_order_goods')->config['status'];
-            foreach ($data as $k => $v) {
-                $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id'], $v['unit_id']);
-                $status_name = Dever::status($status, $v['status']);
-
-                if ($v['unit_id'] != $goods_info['base_unit_id']) {
-                    $unit = Dever::load('scm/lib/price')->getByUnit($v['goods_id'], $v['sku_id'], $v['unit_id'], $v['num'], $v['cash']);
-                    if ($unit) {
-                        $base_unit = Dever::db('scm/unit')->find($goods_info['base_unit_id']);
-                        $goods_info['unit'] .= '(审核成功将转换成:'.$unit['base_num'].''.$base_unit['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'];
-            }
-        }
-        $result['商品清单'] = array
-        (
-            'type' => 'list',
-            'content' => $body,
-            'total' => $body_total,
-        );
-
-        $head = array
-        (
-            'name' => '基本信息',
-            'btn' => '',
-        );
-        $html = Dever::show($head, $result);
-        return $html;
-    }
-}

+ 0 - 5
module/scm_servicer/template/manage/in_order_goods.php

@@ -1,5 +0,0 @@
-<?php
-
-$view
-->fetch('#show', 'scm_servicer/lib/in.show')
-->display();

+ 5 - 0
module/scm_servicer/template/manage/order_goods.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'scm_servicer/lib/manage.show')
+->display();

+ 0 - 5
module/scm_servicer/template/manage/out_order_goods.php

@@ -1,5 +0,0 @@
-<?php
-
-$view
-->fetch('#show', 'scm_servicer/lib/out.show')
-->display();

+ 34 - 0
module/scm_supplier/database/goods.php

@@ -58,6 +58,26 @@ return array
             'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
         ),
 
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'cost_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '成本价',
+            'default'   => '',
+            'desc'      => '成本价',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -178,5 +198,19 @@ return array
             'page' => array(10, 'list'),
             'col' => '*,t_2.*',
         ),
+
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'supplier_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*',
+        ),
     ),
 );

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

@@ -1,345 +0,0 @@
-<?php
-
-$config = array
-(
-    # 表名
-    'name' => 'goods_sku',
-    # 显示给用户看的名称
-    'lang' => '商品价格设置',
-    'order' => 200,
-    'menu' => false,
-    /*
-    'end' => array
-    (
-        'insert' => 'scm_role/lib/seller.skuUpdate',
-        'update' => 'scm_role/lib/seller.skuUpdate',
-    ),
-    */
-
-    # 数据结构 不同的字段放这里
-    'struct' => array
-    (
-        'id'        => array
-        (
-            'type'      => 'int-11',
-            'name'      => 'ID',
-            'default'   => '',
-            'desc'      => '',
-            'match'     => 'is_numeric',
-            //'list'        => true,
-        ),
-
-        'supplier_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '所属供应商',
-            'default'   => '',
-            'desc'      => '所属供应商',
-            'match'     => 'is_numeric',
-            'update'    => 'hidden',
-            'search'    => 'hidden',
-            'value'     => Dever::input('search_option_supplier_id'),
-            'list'      => 'Dever::load("scm_supplier/info-one#name", {supplier_id})',
-        ),
-
-        'goods-info_sku-code'=> array
-        (
-            'name'      => '商品编码',
-            'default'   => '',
-            'desc'      => '商品编码',
-            'match'     => 'option',
-            # 读取另外表的关联方式
-            'sync'      => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
-            'list'      => true,
-            'list_order' => 4,
-        ),
-
-        'goods_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '商品名称',
-            'default'   => '',
-            'desc'      => '商品名称',
-            'match'     => 'is_numeric',
-            'update'    => 'select',
-            'update_search' => 'scm_product/lib/manage.search',
-            'list'      => 'Dever::load("scm_product/info-one#name", {goods_id})',
-        ),
-
-        'sku_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '规格型号',
-            'default'   => '-1',
-            'desc'      => '规格型号',
-            'match'     => 'is_numeric',
-        ),
-
-        'cost_price'       => array
-        (
-            'type'      => 'varchar-100',
-            'name'      => '成本价',
-            'default'   => '',
-            'desc'      => '成本价',
-            'match'     => 'option',
-            'update'    => 'text',
-            //'list'      => true,
-        ),
-
-        '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
-    (
-        # 后台搜索用到,也可以不加,自动生成
-        'search' => 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',
-                '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
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'supplier_id' => array('yes-t_1.supplier_id'),
-                'name' => array('yes-t_2.name', 'like'),
-                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
-                'category' => array('yes-t_2.category', 'like'),
-                'top_category_id' => array('yes-t_2.top_category_id'),
-                'second_category_id' => array('yes-t_2.second_category_id'),
-                'category_id' => array('yes-t_2.category_id'),
-                'status' => array('yes-t_2.status', 1),
-                'state' => array('yes-t_2.state', 1),
-                'state_1' => array('yes-t_1.state', 1),
-            ),
-            # 联表
-            'join' => array
-            (
-                array
-                (
-                    'table' => 'scm_product/info',
-                    'type' => 'left join',
-                    'on' => array('goods_id','id'),
-                    'col' => 'goods_id',
-                ),
-            ),
-            'type' => 'all',
-            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
-            'page' => array(30, 'list'),
-            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
-        ),
-
-        'getData' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'supplier_id' => array('yes-t_1.supplier_id'),
-                'name' => array('yes-t_2.name', 'like'),
-                'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
-                'category' => array('yes-t_2.category', 'like'),
-                'top_category_id' => array('yes-t_2.top_category_id'),
-                'second_category_id' => array('yes-t_2.second_category_id'),
-                'category_id' => array('yes-t_2.category_id'),
-                'status' => array('yes-t_2.status', 1),
-                'state' => array('yes-t_2.state', 1),
-                'state_1' => array('yes-t_1.state', 1),
-            ),
-            # 联表
-            'join' => array
-            (
-                array
-                (
-                    'table' => 'scm_product/info',
-                    'type' => 'left join',
-                    'on' => array('goods_id','id'),
-                    'col' => 'goods_id',
-                ),
-            ),
-            'type' => 'all',
-            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
-            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
-        ),
-
-       	# 列表
-        'getList' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'supplier_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
-            (
-                'supplier_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
-            (
-                'supplier_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
-            ),
-            'set' => array
-            (
-                'out_num' => array('yes', '+='),
-            ),
-        ),
-
-        # 减少售出量
-        'decSell' => array
-        (
-            'type' => 'update',
-            'where' => array
-            (
-                'supplier_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
-            (
-                'supplier_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
-            ),
-            'set' => array
-            (
-                'in_num' => array('yes', '+='),
-            ),
-        ),
-
-        # 减少总库存
-        'decTotal' => array
-        (
-            'type' => 'update',
-            'where' => array
-            (
-                'supplier_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
-            ),
-            'set' => array
-            (
-                'in_num' => array('yes', '-='),
-            ),
-        ),
-    ),
-);
-
-return $config;

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

@@ -339,7 +339,7 @@ return array
         ),
         'list_button' => array
         (
-        	'location' => array('商品设置', Dever::url('lib/set.home?project=supplier&goods=goods_sku&info=info', 'scm_product')),
+        	'location' => array('商品设置', Dever::url('lib/set.home?project=supplier&table=goods&info=info', 'scm_product')),
         )
 	),