rabin 2 yıl önce
ebeveyn
işleme
05ff2dac09

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

@@ -311,5 +311,22 @@ class Info
     public function getBaseInfo($info, $sku = false)
     {
         $info = is_array($info) ? $info : Dever::db('scm_product/info')->one($info);
+
+        $where = array('info_id' => $info['id']);
+        if ($sku && $sku > 0) {
+            $where['id'] = $sku;
+        }
+        $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'];
+                }
+            }
+        }
+
+        return $info;
     }
 }

+ 40 - 6
module/scm_product/lib/Stock.php

@@ -7,20 +7,54 @@ use Dever;
 class Stock
 {
     # 更新库存
-    public function update($id, $name, $data)
+    public function update_commit($id, $name, $data)
     {
     	$table = Dever::input('table');
     	$type = Dever::input('type');
+    	$col = Dever::input('col');
+    	$stock = Dever::input('stock');
 
     	$info = Dever::db($table)->find($id);
-    	if ($info && $info['status'] == 1) {
+    	if ($table && $type && $info && $info['status'] == 1) {
     		$audit = Dever::param('audit', $data);
+    		$admin = Dever::load('manage/auth.info');
+    		if ($admin) {
+    			$update['audit_admin'] = $admin['id'];
+    		}
+    		$update['status'] = $audit;
+    		$update['where_id'] = $id;
+    		Dever::db($table)->update($update);
     		if ($audit == 2) {
-    			# 审核通过
-    		} else {
-    			# 审核未通过
-    			
+    			# 审核通过 更新库存
+    			$this->up($table, $type, $col, $stock, $info);
     		}
     	}
     }
+
+    public function up($table, $type, $col, $stock, $info)
+    {
+    	if ($col && $stock && isset($info[$col])) {
+    		$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]);
+					$goods = Dever::db($stock)->find($update);
+					if (!$goods) {
+						Dever::db($stock)->insert($update);
+					}
+					$update['sku_id'] = $v['sku_id'];
+					$goods = Dever::db($stock . '_sku')->find($update);
+					if (!$goods) {
+						$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);
+				}
+			}
+		}
+    }
 }

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

@@ -0,0 +1,6 @@
+
+<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>

+ 4 - 4
module/scm_servicer/database/in_order.php

@@ -44,7 +44,7 @@ return array
     'end' => array
     (
         'insert' => 'scm_product/lib/order.updateOrderNum?table=scm_servicer/in_order&prefix=C',
-        'update' => 'scm_product/lib/stock.update?table=scm_servicer/in_order&type=in',
+        'update' => 'scm_product/lib/stock.update_commit?table=scm_servicer/in_order&stock=scm_servicer/store_goods&type=in&col=servicer_store_id',
     ),
 
     # 数据结构
@@ -151,7 +151,7 @@ return array
             'desc'      => '审核状态',
             'match'     => 'is_numeric',
             'option'    => $audit,
-            'update'    => 'radio',
+            //'update'    => 'radio',
         ),
 
         'audit_desc'        => array
@@ -161,7 +161,7 @@ return array
             'default'   => '',
             'desc'      => '审核备注',
             'match'     => 'option',
-            'update'    => 'textarea',
+            //'update'    => 'textarea',
         ),
 
         'audit_admin'     => array
@@ -226,7 +226,7 @@ return array
 
         'list_button' => array
         (
-            'list' => array('查看详情', '"in_order_goods&&order_id={id}"'),
+            'list' => array('查看详情', '"in_order_goods&page_type=1&order_id={id}"'),
 
             'fast' => array('审核', '"in_order&where_id={id}&col=audit,audit_desc"', '{status} == 1'),
         ),

+ 1 - 0
module/scm_servicer/database/in_order_goods.php

@@ -134,6 +134,7 @@ return array
     (
         'insert' => false,
         'delete' => false,
+        'page_list' => 'in_order_goods',
     ),
 
     'request' => array

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

@@ -3,7 +3,7 @@
 $config = array
 (
     # 表名
-    'name' => 'servicer_store_goods_sku',
+    'name' => 'store_goods_sku',
     # 显示给用户看的名称
     'lang' => '商品价格设置',
     'order' => 200,
@@ -87,6 +87,15 @@ $config = array
             'match'     => 'option',
         ),
 
+        'on_num'        => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '在途库存',
+            'default'   => '0',
+            'desc'      => '在途库存',
+            'match'     => 'is_numeric',
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -217,40 +226,8 @@ $config = array
             'col' => '*,in_num-out_num as total',
         ),
 
-        # 更新售出量
-        'incSell' => array
-        (
-            'type' => 'update',
-            'where' => array
-            (
-                'servicer_store_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
-            ),
-            'set' => array
-            (
-                'out_num' => array('yes', '+='),
-            ),
-        ),
-
-        # 减少售出量
-        'decSell' => array
-        (
-            'type' => 'update',
-            'where' => array
-            (
-                'servicer_store_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
-            ),
-            'set' => array
-            (
-                'out_num' => array('yes', '-='),
-            ),
-        ),
-
-        # 更新总库存
-        'updateTotal' => array
+        # 更新入库库存
+        'inUpdate' => array
         (
             'type' => 'update',
             'where' => array
@@ -263,35 +240,31 @@ $config = array
             ),
         ),
 
-        # 增加总库存
-        'incTotal' => array
+        # 更新出库库存
+        'outUpdate' => array
         (
             'type' => 'update',
             'where' => array
             (
-                'servicer_store_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
+                'id' => 'yes',
             ),
             'set' => array
             (
-                'in_num' => array('yes', '+='),
+                'out_num' => array('yes', '+='),
             ),
         ),
 
-        # 减少总库存
-        'decTotal' => array
+        # 更新在途库存
+        'onUpdate' => array
         (
             'type' => 'update',
             'where' => array
             (
-                'servicer_store_id' => 'yes',
-                'goods_id' => 'yes',
-                'sku_id' => 'yes',
+                'id' => 'yes',
             ),
             'set' => array
             (
-                'in_num' => array('yes', '-='),
+                'on_num' => array('yes', '+='),
             ),
         ),
     ),

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

@@ -29,4 +29,77 @@ class In
 
     	return $string;
     }
+
+    # 查看详情
+    public function show_api()
+    {
+        $id = Dever::input('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']),
+                ),
+            ),
+        );
+
+        $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,
+        );
+
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => '',
+        );
+        $html = Dever::show($head, $result);
+        return $html;
+    }
 }

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

@@ -56,8 +56,9 @@ class Manage
         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][] = $v['goods'];
+                $table['body'][$k][] = $goods_info['name'];
                 $table['body'][$k][] = $v['cash'];
                 $table['body'][$k][] = $v['num'];
                 $table['body'][$k][] = $status_name;

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

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