dever 3 năm trước cách đây
mục cha
commit
2d5ecd3893

+ 2 - 2
app/factory/assets/pc/html/order.html

@@ -23,7 +23,7 @@
 
           <div class="layui-form layui-card-header layuiadmin-card-header-auto">
             <div class="layui-form-item">
-              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button></div></div></div></div>
+              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">批量打印备货单</button></div></div></div></div>
             </div>
           </div>
         </div>
@@ -44,7 +44,7 @@
           <tbody id="list-tbody"><tr><td><input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="1"/></td><td>河北仓库1(18710001234)</td><td>测试工厂(15810090845)</td><td>F202111095151925058966182</td><td>38</td><td>2</td><td>待收货确认</td><td><a href="javascript:;" onclick="fastEdit($(this), 'http://zsmatest.nongxiaohe.com/package/manage/?l=project/database/list&amp;project=shop&amp;search_option_type=2&amp;page_type=2&amp;table=buy_order_goods&amp;project=shop&amp;order_id=1&amp;page_type=1&amp;menu=shop&amp;menu_id=99&amp;search_option_state=1', '查看详情', '', 1, 1)"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看详情</button></a>&nbsp;&nbsp;</td></tr></tbody>
       </table>
 
-      <div id="mul"><button class="btn btn-danger layui-btn layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:10px;">批量打印备货单</button></div>
+      <div id="mul"></div>
       <div id="page"></div>
       <div class="dever_desc" id="desc" style="display:none;"></div>
         </div>

+ 4 - 2
app/factory/lib/Goods.php

@@ -38,8 +38,10 @@ class Goods
                         'price' => $data[$k]['p_price'] ? $data[$k]['p_price'] : 0,
                         'end' => true,
                     );
-                } else {
-                	$result[$v['id']]['end'] = true;
+                }
+
+                if (!$result[$v['id']]['children']) {
+                    $result[$v['id']]['end'] = true;
                 }
             }
         }

+ 1 - 1
app/factory/lib/Set.php

@@ -23,7 +23,7 @@ class Set
     public function goods_api()
     {
         $factory_id = Dever::input('factory_id', 1);
-        return Dever::outDiy(Dever::load('goods/lib/manage')->getGoodsList($factory_id, 'factory_id', 'factory/goods_sku'));
+        return Dever::outDiy(Dever::load('goods/lib/set')->getGoodsList($factory_id, 'factory_id', 'factory/goods_sku'));
     }
 
     # 设置生产能力

+ 0 - 72
app/goods/lib/Manage.php

@@ -353,76 +353,4 @@ class Manage
 
         return $data;
     }
-
-    # 获取商品及其属性列表
-    public function getGoodsList($id, $type, $table)
-    {
-        $where['status'] = 1;
-        $data = Dever::db('goods/info')->select($where);
-
-        $result = array();
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $sku = Dever::db('goods/info_sku')->select(array('info_id' => $v['id']));
-
-                if ($sku) {
-                    $other = Dever::db($table)->one(array($type => $id, 'goods_id' => $v['id'], 'key' => -1));
-                    $result[$k]['id'] = $v['id'];
-                    $result[$k]['name'] = $v['name'];
-                    $result[$k]['price'] = $v['price'];
-                    $result[$k]['select'] = 2;
-                    if ($type == 'factory_id') {
-                        if ($other) {
-                            $result[$k]['p_price'] = $other['p_price'];
-                            $result[$k]['select'] = $other['state'];
-                        } else {
-                            $result[$k]['p_price'] = $v['price'];
-                        }
-                    }
-                    $result[$k]['children'] = array();
-                    $num = count($sku);
-                    if ($num == 1 && $sku[0]['key'] == -1) {
-                        $result[$k]['end'] = true;
-                    } else {
-                        foreach ($sku as $k1 => $v1) {
-                            $v1['sku_name'] = '';
-                            if ($v1['attr']) {
-                                $v1['attr'] = Dever::json_decode($v1['attr']);
-                                $v1['attr'] = Dever::load('attr/api')->getInfoByJson($v1['attr']);
-                                $v1['sku_name'] = $v1['attr']['string'];
-                            }
-
-                            $name = $v['name'];
-                            if ($v1['sku_name']) {
-                                $name .= '-' . $v1['sku_name'];
-                            }
-
-                            $children = array
-                            (
-                                'id' => $v['id'] . '-' . $v1['id'],
-                                'name' => $name,
-                                'price' => $v1['price'] ? $v1['price'] : 0,
-                                'end' => true,
-                            );
-
-                            $other_sku = Dever::db($table)->one(array($type => $id, 'goods_id' => $v['id'], 'sku_id' => $v1['id']));
-
-                            $children['select'] = 2;
-                            if ($type == 'factory_id') {
-                                $children['p_price'] = $v1['price'];
-                                if ($other_sku) {
-                                    $children['p_price'] = $other_sku['p_price'];
-                                    $children['select'] = $other_sku['state'];
-                                }
-                            }
-
-                            $result[$k]['children'][] = $children;
-                        }
-                    }
-                }
-            }
-        }
-
-        return $result;
-    }
 }

+ 96 - 0
app/goods/lib/Set.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace Goods\Lib;
+
+use Dever;
+
+class Set
+{
+    # 获取商品及其属性列表
+    public function getGoodsList($id, $type, $table)
+    {
+        $where['status'] = 1;
+        $data = Dever::db('goods/info')->select($where);
+
+        $result = array();
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $sku = Dever::db('goods/info_sku')->select(array('info_id' => $v['id']));
+
+                if ($sku) {
+                    $other = Dever::db($table)->one(array($type => $id, 'goods_id' => $v['id'], 'key' => -1));
+                    $result[$k]['id'] = $v['id'];
+                    $result[$k]['name'] = $v['name'];
+                    $result[$k]['price'] = $v['price'];
+                    $result[$k]['select'] = 2;
+                    if ($type == 'factory_id') {
+                        if ($other) {
+                            $result[$k]['p_price'] = $other['p_price'];
+                            $result[$k]['select'] = $other['state'];
+                        } else {
+                            $result[$k]['p_price'] = $v['price'];
+                        }
+                    } else {
+                        if ($other) {
+                            $result[$k]['total'] = $other['total_num'] - $other['sell_num'];
+                            $result[$k]['select'] = $other['state'];
+                        } else {
+                            $result[$k]['total'] = 0;
+                        }
+                    }
+                    $result[$k]['children'] = array();
+                    $num = count($sku);
+                    if ($num == 1 && $sku[0]['key'] == -1) {
+                        $result[$k]['end'] = true;
+                    } else {
+                        foreach ($sku as $k1 => $v1) {
+                            $v1['sku_name'] = '';
+                            if ($v1['attr']) {
+
+                                $v1['attr'] = Dever::json_decode($v1['attr']);
+                                if ($v1['attr']) {
+                                    $v1['attr'] = Dever::load('attr/api')->getInfoByJson($v1['attr']);
+                                    $v1['sku_name'] = $v1['attr']['string'];
+                                }
+                            }
+
+                            $name = $v['name'];
+                            if ($v1['sku_name']) {
+                                $name .= '-' . $v1['sku_name'];
+                            }
+
+                            $children = array
+                            (
+                                'id' => $v['id'] . '-' . $v1['id'],
+                                'name' => $name,
+                                'price' => $v1['price'] ? $v1['price'] : 0,
+                                'end' => true,
+                            );
+
+                            $other_sku = Dever::db($table)->one(array($type => $id, 'goods_id' => $v['id'], 'sku_id' => $v1['id']));
+
+                            $children['select'] = 2;
+                            if ($type == 'factory_id') {
+                                $children['p_price'] = $v1['price'];
+                                if ($other_sku) {
+                                    $children['p_price'] = $other_sku['p_price'];
+                                    $children['select'] = $other_sku['state'];
+                                }
+                            } else {
+                                $children['total'] = 0;
+                                if ($other_sku) {
+                                    $children['total'] = $other_sku['total_num'] - $other_sku['sell_num'];
+                                    $children['select'] = $other_sku['state'];
+                                }
+                            }
+
+                            $result[$k]['children'][] = $children;
+                        }
+                    }
+                }
+            }
+        }
+
+        return $result;
+    }
+}

+ 2 - 2
app/goods/lib/Sku.php

@@ -265,7 +265,7 @@ class Sku
                     $v = $temp[0];
                     $type = $temp[1];
                 }
-                if (isset($config['input_key'][$k])) {
+                if (isset($config['input_attr'][$k])) {
                     
                     $data = $where;
                     if ($config['other']) {
@@ -278,7 +278,7 @@ class Sku
                         $info = Dever::db($sku_table)->one($data);
                     } else {
                         $info = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
-                        $data['attr'] = $config['input_key'][$k];
+                        $data['attr'] = $config['input_attr'][$k];
                         $data[$key] = $v;
                     }
 

+ 1 - 1
app/mshop/lib/Buy.php

@@ -668,7 +668,7 @@ class Buy
             $button = array();
             $button[] = '<button class="layui-btn layui-btn-primary" onclick="print(\''.$info['id'].'\')">打印订单</button>';
             if ($info['status'] == 4) {
-                $url = Dever::url('admin/factory_order.action&order_id='.$info['id'], 'store');
+                $url = Dever::url('admin/factory_order.action?order_id='.$info['id'], 'store');
                 $button[] = '<button class="layui-btn layui-btn-primary" onclick="load(\''.$url.'\')">确认收货</button>';
             }
             $config['phone'] = '您的专属客服:' . $config['kf_name'] . ',联系电话:' . $config['phone'];

+ 318 - 93
app/mshop/lib/Out.php

@@ -6,14 +6,50 @@ use Dever;
 
 class Out
 {
+    # 1是门店,2是仓库
+    public $type = 1;
+    # 1是列表,2是详情
+    public $view = 1;
+    # 获取配置
+    public $config = array();
+    # table
+    public $table = 'shop/out_order';
+
+    public function __construct()
+    {
+        $this->config = Dever::db($this->table)->config;
+    }
+
+    # 设置订单的类型
+    public function set($type, $view)
+    {
+        $this->type = $type;
+        $this->view = $view;
+
+        return $this;
+    }
+
+    # 获取公共的where
+    public function where($id)
+    {
+        $where = array();
+        $where['type'] = $this->type;
+        $where['type_id'] = $id;
+        
+        if (!$where) {
+            Dever::alert('参数错误');
+        }
+
+        return $where;
+    }
+
     # 采购订单列表
-    public function getList($type, $id)
+    public function getList($id)
     {
-        $where['use_type'] = $type;
-        $where['use_id'] = $id;
+        $where = $this->where($id);
 
-        $this->data['search_value'] = $where;
-        $this->data['search_value']['day'] = $day = Dever::input('day');
+        $data['search_value'] = $where;
+        $data['search_value']['day'] = $day = Dever::input('day');
         if ($day) {
             $where['start'] = Dever::maketime($day . ' 00:00:00');
             $where['end'] = Dever::maketime($day . ' 23:59:59');
@@ -29,111 +65,52 @@ class Out
             $where['status'] = $status;
         }
 
-        $this->data['order'] = Dever::db('shop/out_order')->getAll($where);
+        $out_type = Dever::input('out_type');
+        if ($out_type) {
+            $where['out_type'] = $out_type;
+        }
+
+        $data['order'] = Dever::db('shop/out_order')->getAll($where);
 
-        if ($this->data['order']) {
-            foreach ($this->data['order'] as $k => $v) {
-                $this->data['order'][$k] = $this->getInfo($v);
+        if ($data['order']) {
+            foreach ($data['order'] as $k => $v) {
+                $data['order'][$k] = $this->getInfo($v);
             }
         }
 
-        return $this->data;
+        return $data;
     }
 
     # 查看订单详情
-    public function view($type, $id)
+    public function getView($id, $order_id, $show = true)
     {
-        $where['use_type'] = $type;
-        $where['use_id'] = $id;
-        $where['id'] = Dever::input('order_id');
+        $where = $this->where($id);
+        $where['id'] = $order_id;
 
-        $this->data = Dever::db('shop/out_order')->find($where);
+        $result = Dever::db($this->table)->find($where);
 
-        if (!$this->data) {
+        if (!$result) {
             Dever::alert('订单不存在');
         }
 
-        $this->data = $this->getInfo($this->data, true);
-
-        return $this->data;
-    }
-
-    # 确认订单页面
-    public function confirm()
-    {
-        $this->goods();
-
-        return $this->data;
-    }
-
-    # 得到商品和总价
-    private function goods()
-    {
-        $goods_id = Dever::input('goods_id');
-        if (!$goods_id) {
-            Dever::alert('请传入商品');
-        }
-        $goods_id = explode(',', $goods_id);
-
-        $sku_id = Dever::input('price_id');
-        if ($sku_id) {
-            $sku_id = explode(',', $sku_id);
+        if ($show) {
+            $result = $this->getInfo($result, true);
         }
-        
-        $num = Dever::input('num');
-        if (!$num) {
-            Dever::alert('请传入商品数量');
-        }
-        $num = explode(',', $num);
-
-        $this->data['price'] = 0;
-        $this->data['num'] = 0;
-        $this->data['name'] = array();
-        # 计算总价格
-        foreach ($goods_id as $k => $v) {
-            $s = isset($sku_id[$k]) ? $sku_id[$k] : -1;
-            $n = isset($num[$k]) ? $num[$k] : 1;
-            $this->data['list'][$k] = Dever::load('goods/lib/info')->getPayInfo($v, $s, $n);
-            $this->data['list'][$k]['num'] = $n;
-
-            # 2是库存不足
-            $this->data['list'][$k]['ku_state'] = 1;
-
-            # 验证是否有货
-            $total = Dever::load('shop/lib/info')->checkTotal($n, $v, $this->shop_id, $s);
-
-            if ($total <= 0) {
-                $this->data['list'][$k]['ku_state'] = 2;
-                $this->data['list'][$k]['buy_num'] = 0;
-            }
 
-            if ($this->data['list'][$k]['ku_state'] == 1) {
-                $this->data['list'][$k]['buy_num'] = $n;
-                $this->data['num'] += $n;
-                $this->data['price'] += $this->data['list'][$k]['price'] * $n;
-                $this->data['name'][] = $this->data['list'][$k]['name'];
-            }
-        }
-
-        $this->data['name'] = implode(',', $this->data['name']);
+        return $result;
     }
 
     # 出库下单
-    public function action_commit()
+    public function action($type_id, $name, $num, $goods, $price, $member_id, $out_type, $info, $status = 2)
     {
-        $info = Dever::input('info');
-        $type = Dever::input('type', 1);
-
-        $this->goods();
-        
-        $order_data['use_type'] = 1;
-        $order_data['use_id'] = $this->shop['id'];
-        $order_data['name'] = $this->data['name'];
-        $order_data['num'] = $this->data['num'];
+        $order_data = $this->where($type_id);
+        $order_data['name'] = $name;
+        $order_data['num'] = $num;
         $order_data['info'] = $info;
-        $order_data['type'] = $type;
-        $order_data['price'] = $this->data['price'];
-        $order_data['member_id'] = $this->uid;
+        $order_data['out_type'] = $out_type;
+        $order_data['price'] = $price;
+        $order_data['member_id'] = $member_id;
+        $order_data['status'] = $status;
 
         $order_data['order_num'] = $this->getOrderId();
         $id = Dever::db('shop/out_order')->insert($order_data);
@@ -142,7 +119,7 @@ class Out
             Dever::alert('出库失败');
         }
 
-        foreach($this->data['list'] as $k => $v) {
+        foreach($goods as $k => $v) {
             if ($v['ku_state'] == 1) {
                 $data['order_id'] = $id;
                 $data['goods_id'] = $v['id'];
@@ -174,6 +151,46 @@ class Out
         }
     }
 
+    # 审核出库单
+    public function yes_api()
+    {
+        $id = Dever::input('id');
+        $order_id = Dever::input('order_id');
+        $this->set(2, 1);
+
+        $info = $this->getView($id, $order_id, false);
+
+        if ($info && $info['status'] == 1) {
+            $where['where_id'] = $info['id'];
+            $where['status'] = 2;
+            $state = Dever::db('shop/out_order')->update($where);
+        }
+
+        return 'ok';
+    }
+
+    # 取消出库单
+    public function cancel($id, $order_id)
+    {
+        $info = $this->getView($id, $order_id, false);
+
+        if ($info && $info['status'] == 1) {
+            $where['where_id'] = $info['id'];
+            $where['status'] = 3;
+            $state = Dever::db('shop/out_order')->update($where);
+
+            if ($state) {
+                # 取消成功,恢复库存
+                $goods = Dever::db('shop/out_order_goods')->select(array('order_id' => $info['id']));
+                if ($goods) {
+                    Dever::load('shop/lib/goods')->oper($info, 1, 1, $goods);
+                }
+            }
+        }
+
+        return 'ok';
+    }
+
     # 获取订单详细信息
     private function getInfo($info, $view = false)
     {
@@ -181,8 +198,11 @@ class Out
         $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
 
         $type = Dever::db('shop/out_order')->config['config_type'];
-        $info['type_name'] = $type[$info['type']];
-        if ($view) {
+        $info['type_name'] = $type[$info['out_type']];
+
+        $status = Dever::db('shop/out_order')->config['config_status'];
+        $info['status_name'] = $status[$info['status']];
+        if ($view || $this->view == 2) {
             foreach ($info['goods'] as $k => $v) {
                 $info['goods'][$k]['info'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
             }
@@ -191,4 +211,209 @@ class Out
         }
         return $info;
     }
+
+    # 展示订单详情
+    public function show()
+    {
+        $id = Dever::input('order_id');
+
+        $type = Dever::input('type', 1);
+
+        $config = Dever::db('shop/out_order')->config;
+
+        $info = Dever::db('shop/out_order')->one($id);
+
+        $status = $config['config_status'][$info['status']];
+
+        $out_type = $config['config_type'][$info['out_type']];
+
+        $cdate = date('Y-m-d H:i', $info['cdate']);
+        
+        $html = '<div class="layui-col-md12"><div class="layui-card"><div class="layui-card-header">基本信息</div><div class="layui-card-body">';
+        $html .= '<table class="layui-table"><thead><tr><th style="width:20%">项目</th><th style="width:80%">详情</th></tr> </thead><tbody>';
+
+        $html .= '<tr>
+          <td>订单号</td>
+          <td>'.$this->table(false, array($info['order_num'])).'</td>
+
+        </tr>';
+
+        $html .= '<tr>
+          <td>出库单状态</td>
+          <td>'.$this->table(false, array($status)).'</td>
+
+        </tr>';
+
+        $html .= '<tr>
+          <td>填单时间</td>
+          <td>'.$this->table(false, array($cdate)).'</td>
+
+        </tr>';
+
+        if ($info['type'] == 1) {
+            $type_info = Dever::db('shop/info')->find($info['type_id']);
+            $member = Dever::db('shop/member')->find($info['member_id']);
+        } elseif ($info['type'] == 2) {
+            $type_info = Dever::db('store/info')->find($info['type_id']);
+            $member = Dever::db('store/member')->find($info['member_id']);
+        }
+
+        if ($type == 1) {
+            $html .= '<tr>
+              <td>来源信息</td>
+              <td>'.$this->table(false, array(array($type_info['name']  . ',' . $type_info['truename'] . ',' . $type_info['mobile'] . ',' . $type_info['address']))).'</td>
+
+            </tr>';
+        }
+
+        $html .= '<tr>
+              <td>操作人</td>
+              <td>'.$this->table(false, array($member['name'])).'</td>
+
+            </tr>';
+
+        $html .= '<tr>
+          <td>出库类别</td>
+          <td>'.$this->table(false, array($out_type)).'</td>
+
+        </tr>';
+        
+        if ($info['info']) {
+            $html .= '<tr>
+              <td>订单备注</td>
+              <td>'.$this->table(false, array(array($info['info']))).'</td>
+
+            </tr>';
+        }
+
+        if ($type == 2) {
+            $config = Dever::load('store/admin/auth.config');
+            $button = array();
+            if ($info['status'] == 1) {
+                $url = Dever::url('admin/out.cancel?order_id='.$info['id'], 'store');
+                $button[] = '&nbsp;&nbsp;<a href="javascript:;" onclick="load(\''.$url.'\')"><button type="button" class="layui-btn layui-btn-primary">取消</button></a>';
+            }
+            $button[] = '<button class="layui-btn layui-btn-primary" onclick="print(\''.$info['id'].'\')">打印出库单</button>';
+
+            $config['phone'] = '您的专属客服:' . $config['kf_name'] . ',联系电话:' . $config['phone'];
+            $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系平台</button>';
+            $html .= '<tr>
+                  <td>功能按钮</td>
+                  <td>'.$this->table(false, array($button)).'</td>
+
+                </tr>';
+        } elseif ($info['status'] == 1) {
+            $button = array();
+            $url = Dever::url('lib/out.yes?id='.$info['type_id'].'&order_id='.$info['id'], 'mshop');
+            $button[] = '&nbsp;&nbsp;<a href="javascript:;" onclick="load(\''.$url.'\')"><button type="button" class="layui-btn layui-btn-primary">审核</button></a>';
+            $html .= '<tr>
+                  <td>功能按钮</td>
+                  <td>'.$this->table(false, array($button)).'</td>
+
+                </tr>';
+        }
+
+        $html .= '</tbody></table></div></div>';
+
+        $body = array();
+        $body_total = array();
+        $body_total['price'] = 0;
+        $body_total['num'] = 0;
+        $goods = Dever::db('shop/out_order_goods')->select(array('order_id' => $info['id']));
+        $goods_status = Dever::db('shop/out_order_goods')->config['status'];
+
+        $refund_body = array();
+        $refund_body_total = array();
+        $refund_body_total['price'] = 0;
+        $refund_body_total['num'] = 0;
+        foreach ($goods as $k => $v) {
+            $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
+            $status = $goods_status[$v['status']];
+
+            if (isset($goods_info['sku'])) {
+                $sku = '[' . $goods_info['sku']['string'] . ']';
+            } else {
+                $sku = '';
+            }
+
+            $d = array
+            (
+                $goods_info['name'] . ' ' . $sku,
+                $v['price'],
+                $v['num'],
+            );
+            if ($type == 2) {
+                unset($d[1]);
+            }
+            $body[] = $d;
+            $body_total['price'] += $v['price'];
+            $body_total['num'] += $v['num'];
+        }
+
+        if ($body) {
+
+            $head = array('名称', '金额', '数量');
+
+            $d = array
+            (
+                '合计',
+                $body_total['price'],
+                $body_total['num'],
+            );
+
+            if ($type == 2) {
+                unset($head[1]);
+                unset($d[1]);
+            }
+            $body[] = $d;
+
+
+            $html .= '<div class="layui-card"><div class="layui-card-header">商品清单</div><div class="layui-card-body" style="max-heights: 500px;overflow: auto;">' . $this->table($head, $body) . '</div></div>';
+        }
+
+        $html .= '</div>';
+
+        return '<div class="layui-card-body">' . $html . '</div>';
+    }
+
+    private function table($head, $data)
+    {
+        $html = '';
+        if ($head) {
+            $html = '<table class="layui-table">';
+
+            $html .= '<thead><tr>';
+            foreach ($head as $k => $v) {
+                $html .= '<th>'.$v.'</th>';
+            }
+            $html .= '</tr></thead>';
+
+            $html .= '<tbody>';
+            foreach ($data as $k => $v) {
+                $html .= '<tr>';
+                foreach ($v as $k1 => $v1) {
+                    $html .= '<td>'.$v1.'</td>';
+                }
+                $html .= '</tr>';
+            }
+
+            $html .= '</tbody>';
+
+            $html .= '</table>';
+        } else {
+            foreach ($data as $k => $v) {
+                $html .= '';
+                if (is_array($v)) {
+                    foreach ($v as $k1 => $v1) {
+                        $html .= $v1 . '&nbsp;&nbsp;&nbsp;&nbsp;';
+                    }
+                } else {
+                    $html .= $v . '&nbsp;&nbsp;&nbsp;&nbsp;';
+                }
+                
+                $html .= '';
+            }
+        }
+        return $html;
+    }
 }

+ 4 - 96
app/mshop/src/Out.php

@@ -18,43 +18,15 @@ class Out extends Core
     # 采购订单列表
     public function getList()
     {
-        $where['use_type'] = 1;
-        $where['use_id'] = $this->shop_id;
-
-        $this->data['search_value'] = $where;
-        $this->data['search_value']['day'] = $day = Dever::input('day');
-        if ($day) {
-            $where['start'] = Dever::maketime($day . ' 00:00:00');
-            $where['end'] = Dever::maketime($day . ' 23:59:59');
-        }
-
-        $this->data['order'] = Dever::db('shop/out_order')->getAll($where);
-
-        if ($this->data['order']) {
-            foreach ($this->data['order'] as $k => $v) {
-                $this->data['order'][$k] = $this->getInfo($v);
-            }
-        }
-
-        return $this->data;
+        return Dever::load('mshop/lib/out')->set(1,1)->getList($this->shop_id);
     }
 
     # 查看订单详情
     public function view()
     {
-    	$where['use_type'] = 1;
-        $where['use_id'] = $this->shop_id;
-        $where['id'] = Dever::input('order_id');
+    	$order_id = Dever::input('order_id');
 
-        $this->data = Dever::db('shop/out_order')->find($where);
-
-        if (!$this->data) {
-            Dever::alert('订单不存在');
-        }
-
-        $this->data = $this->getInfo($this->data, true);
-
-        return $this->data;
+        return Dever::load('mshop/lib/out')->set(1,2)->getView($this->shop_id, $order_id);
     }
 
     # 下单填写用途信息
@@ -132,71 +104,7 @@ class Out extends Core
         $type = Dever::input('type', 1);
 
         $this->goods();
-        
-        $order_data['use_type'] = 1;
-        $order_data['use_id'] = $this->shop['id'];
-        $order_data['name'] = $this->data['name'];
-        $order_data['num'] = $this->data['num'];
-        $order_data['info'] = $info;
-        $order_data['type'] = $type;
-        $order_data['price'] = $this->data['price'];
-        $order_data['member_id'] = $this->uid;
-        $order_data['status'] = 2;
-
-        $order_data['order_num'] = $this->getOrderId();
-        $id = Dever::db('shop/out_order')->insert($order_data);
-
-        if (!$id) {
-            Dever::alert('出库失败');
-        }
-
-        foreach($this->data['list'] as $k => $v) {
-        	if ($v['ku_state'] == 1) {
-	            $data['order_id'] = $id;
-	            $data['goods_id'] = $v['id'];
-	            $data['sku_id'] = $v['sku_id'];
-	            $data['price'] = $v['price'] * $v['buy_num'];
-                $data['d_price'] = $v['price'];
-	            $data['num'] = $v['buy_num'];
-
-	            $state = Dever::db('shop/out_order_goods')->insert($data);
-	            if ($state) {
-	            	# 出库成功 去掉库存
-	            	Dever::load('shop/lib/goods')->oper($order_data, 2, 1, array($data));
-	            }
-	        }
-        }
 
-        return array('order_id' => $id);
-    }
-
-    # 生成订单号
-    public function getOrderId()
-    {
-        $where['order_num'] = Dever::order('OUT');
-        $state = Dever::db('shop/out_order')->one($where);
-        if (!$state) {
-            return $where['order_num'];
-        } else {
-            return $this->getOrderId();
-        }
-    }
-
-    # 获取订单详细信息
-    private function getInfo($info, $view = false)
-    {
-        $info['goods'] = Dever::db('shop/out_order_goods')->select(array('order_id' => $info['id']));
-        $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
-
-        $type = Dever::db('shop/out_order')->config['config_type'];
-        $info['type_name'] = $type[$info['type']];
-        if ($view) {
-            foreach ($info['goods'] as $k => $v) {
-                $info['goods'][$k]['info'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
-            }
-
-            $info['member'] = Dever::db('shop/member')->find($info['member_id']);
-        }
-        return $info;
+        return Dever::load('mshop/lib/out')->set(1,1)->action($this->shop_id, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $this->uid, $type, $info);
     }
 }

+ 26 - 0
app/shop/assets/manage/html/out_order_goods.html

@@ -0,0 +1,26 @@
+</form>
+<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">
+    <table class="layui-table">
+      <thead>
+        <tr>
+          <th>昵称</th>
+          <th>加入时间</th>
+          <th>签名</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>
+</div>

+ 2 - 3
app/shop/assets/manage/html/sell_order_goods.html

@@ -1,4 +1,4 @@
-
+</form>
 <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">
@@ -23,5 +23,4 @@
         </tr>
       </tbody>
     </table>
-</div>
-</form>
+</div>

+ 265 - 0
app/shop/assets/pc/html/setGoods.html

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

+ 15 - 0
app/shop/database/info.php

@@ -532,6 +532,20 @@ return array
             'edit'      => true,
         ),
 
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -571,6 +585,7 @@ return array
 
             'br1' => array('<br /><br />'),
 
+            'location' => array('批量设置商品', Dever::url('lib/set.home', 'shop')),
             //'add1' => array('批量设置商品', '"info&where_id={id}&col=goods&oper_save_jump=info&oper_table=info&oper_parent=info"'),
             'list22' => array('商品管理', '"goods&search_option_shop_id={id}&oper_table=info"'),
 

+ 67 - 22
app/shop/database/out_order.php

@@ -1,28 +1,65 @@
 <?php
 
-$type = array
+$out_type = array
 (
     1 => '店铺活动',
     2 => '礼品赠送',
-    3 => '超过保质期销毁',
+    3 => '保质期到期销毁',
+    4 => '库存损毁',
     10 => '其他',
 );
 
 $status = array
 (
-    1 => '未确认',
-    2 => '已确认',
+    1 => '待审核',
+    2 => '已审核',
+    3 => '取消',
 );
 
+$shop = function()
+{
+    $array = array();
+    $info = Dever::db('shop/info')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$store = function()
+{
+    $array = array();
+    $info = Dever::db('store/info')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+# 1是门店 2是仓库
+$search = Dever::input('search', 1);
+
+if ($search == 1) {
+    $search_name = '所属门店';
+    $search_option = $shop;
+    $search_url = 'shop/lib/manage.search';
+} elseif ($search == 2) {
+    $search_name = '所属仓库';
+    $search_option = $store;
+    $search_url = 'store/lib/manage.search';
+}
+
 return array
 (
     # 表名
     'name' => 'out_order',
     # 显示给用户看的名称
     'lang' => '出库订单',
-    'order' => 99,
-    'menu'	=> false,
-    'config_type' => $type,
+    'order' => 98,
+    'config_type' => $out_type,
+    'config_status' => $status,
     # 数据结构
     'struct' => array
     (
@@ -38,7 +75,7 @@ return array
             //'list'      => true,
         ), 
 
-        'use_type'      => array
+        'type'      => array
         (
             'type'      => 'int-11',
             'name'      => '拥有人类型',
@@ -47,13 +84,16 @@ return array
             'match'     => 'is_numeric',
         ),
 
-        'use_id'      => array
+        'type_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '拥有人',
+            'name'      => $search_name,
             'default'   => '',
             'desc'      => '拥有人',
             'match'     => 'is_numeric',
+            'search'    => $search == 3 ? '' : 'select',
+            'option'    => $search_option,
+            //'update_search' => $search_url,
             'list'      => 'Dever::load("shop/lib/manage.buyInfo", "{type}", "{type_id}")',
         ),
 
@@ -87,7 +127,7 @@ return array
             'desc'      => '价格',
             'match'     => 'option',
             'update'    => 'text',
-            'list'        => true,
+            'list'      => $search == 1 ? true : false,
         ),
 
         'num'        => array
@@ -121,14 +161,14 @@ return array
             //'update'  => 'text',
         ),
 
-        'type'        => array
+        'out_type'        => array
         (
             'type'      => 'tinyint-1',
             'name'      => '类型',
             'default'   => '1',
             'desc'      => '类型',
             'match'     => 'is_numeric',
-            'option'    => $type,
+            'option'    => $out_type,
             'search'    => 'select',
             'list'      => true,
         ),
@@ -182,8 +222,9 @@ return array
         'list_button' => array(
             //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} == 2'),
             //'delete' => array('删除', '', '{status} == 1'),
+            'fast_list' => array('查看详情', '"out_order_goods&project=shop&order_id={id}&page_type=1"'),
 
-            'fast_list' => array('查看详情', '"buy_order_goods&project=shop&order_id={id}&page_type=1"'),
+            'oper'  => array('审核', '"mshop/lib/out.yes?id={type_id}&order_id={id}"', '{status} == 1'),
         ),
     ),
 
@@ -195,8 +236,9 @@ return array
             'option' => array
             (
                 'order_num' => array('yes', 'like'),
-                'use_type' => 'yes',
-                'use_id' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'out_type' => 'yes',
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
                 'status' => array('yes', 'in'),
@@ -216,8 +258,9 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                'use_type' => 'yes',
-                'use_id' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'out_type' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -233,8 +276,9 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                'use_type' => 'yes',
-                'use_id' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'out_type' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -250,8 +294,9 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                'use_type' => 'yes',
-                'use_id' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'out_type' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),

+ 97 - 0
app/shop/lib/Set.php

@@ -0,0 +1,97 @@
+<?php
+
+namespace Shop\Lib;
+
+use Dever;
+
+# 批量设置商品
+class Set
+{
+    # 导出订单
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取门店
+    public function search_api()
+    {
+        return Dever::search('shop/info');
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $shop_id = Dever::input('shop_id', 1);
+        return Dever::outDiy(Dever::load('goods/lib/set')->getGoodsList($shop_id, 'shop_id', 'shop/goods_sku'));
+    }
+
+    # 设置生产能力
+    public function home_api()
+    {
+        $data = array();
+        $data['shop_id'] = Dever::input('id', 1);
+        $data['host'] = Dever::url('lib/set.home', 'shop');
+        $data['url'] = Dever::url('lib/set.goods?shop_id=' . $data['shop_id'], 'shop');
+        $data['search'] = Dever::url('lib/set.search?yes='.$data['shop_id'].'&json=1', 'shop');
+        $data['submit'] = Dever::url('lib/set.action_cmmmit?json=1', 'shop');
+
+        return Dever::render('setGoods', $data);
+    }
+
+    # 设置生产能力
+    public function action_cmmmit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $shop_id = Dever::input('shop_id');
+
+        foreach ($goods as $k => $v) {
+            $temp = explode('-', $k);
+            $goods_id = $temp[0];
+            if (isset($temp[1])) {
+                $sku_id = $temp[1];
+            } else {
+                $sku_id = -1;
+            }
+            if ($v['num'] < 1) {
+            	continue;
+            }
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w['shop_id'] = $shop_id;
+            $info = Dever::db('shop/goods')->one($w);
+
+            $w['total_num'] = $v['num'];
+            if (!$info) {
+                Dever::db('shop/goods')->insert($w);
+            } else {
+            	$w['total_num'] += $info['total_num'];
+                $w['where_id'] = $info['id'];
+                $w['state'] = 1;
+                Dever::db('shop/goods')->update($w);
+            }
+
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w['shop_id'] = $shop_id;
+            $w['sku_id'] = $sku_id;
+            $info = Dever::db('shop/goods_sku')->one($w);
+
+            $w['total_num'] = $v['num'];
+            if (!$info) {
+                Dever::db('shop/goods_sku')->insert($w);
+            } else {
+            	$w['total_num'] += $info['total_num'];
+                $w['where_id'] = $info['id'];
+                $w['state'] = 1;
+                Dever::db('shop/goods_sku')->update($w);
+            }
+        }
+
+        return Dever::url('project/database/list&project=shop&&table=info&menu=shop&search_option_state=1', 'manage');
+    }
+}

+ 5 - 0
app/shop/template/manage/out_order_goods.php

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

+ 1 - 1
app/store/admin/Help.php

@@ -8,7 +8,7 @@ class Help extends Core
     # 列表
     public function getList()
     {
-        $data = Dever::db('main/help')->select_page(array('type' => 4));
+        $data = Dever::db('main/help')->select_page(array('type' => 3));
 
         return $data;
     }

+ 127 - 36
app/store/admin/Out.php

@@ -8,51 +8,39 @@ class Out extends Core
     # 订单列表
     public function getList()
     {
-        $data = Dever::load('mshop/lib/buy')->set(2, 1)->getList($this->id);
+        $data = Dever::load('mshop/lib/out')->set(2, 1)->getList($this->id);
 
         $html = '';
         if ($data && $data['order']) {
             foreach ($data['order'] as $k => $v) {
-                if ($v['ps_info']) {
-                    $ps_date = $v['ps_info']['cdate'];
-                    $ydate = $v['ps_info']['ydate'] ? $v['ps_info']['ydate'] : '-';
-                } else {
-                    $ps_date = $ydate = '-';
-                }
-                $view = Dever::url('order_view?type=3&order_id=' . $v['id'], 'store');
-
-                $send = Dever::url('order_send?id=' . $v['id'], 'store');
+                $view = Dever::url('out_view?order_id=' . $v['id'] . '&type=2', 'store');
 
                 $button = '<a href="'.$view.'"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看详情</button></a>';
-
-                $button .= '&nbsp;&nbsp;<a href="javascript:;" id="print_'.$v['id'].'" onclick="layer.alert(\'开发中\')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">打印订单</button></a>';
                 
-                if ($v['status'] == 4) {
-                    $url = Dever::url('admin/factory_order.action&order_id='.$v['id'], 'store');
-                    $button .= '&nbsp;&nbsp;<a href="javascript:;" onclick="load(\''.$url.'\')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">确认收货</button></a>';
+                if ($v['status'] == 1) {
+                    $url = Dever::url('admin/out.cancel&order_id='.$v['id'], 'store');
+                    $button .= '&nbsp;&nbsp;<a href="javascript:;" onclick="load(\''.$url.'\')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">取消</button></a>';
                 }
 
-                if ($v['refund_status'] == 2 && $v['status'] != 8) {
-                    $v['status_name'] .= '[缺货报损中]';
-                }
-
-                $html .= '<tr><td>'.$v['order_num'].'</td><td>'.$ps_date.'</td><td>'.$v['source_info']['name'].'</td><td>'.$ydate.'</td><td>'.$v['num'].'</td><td>'.$v['status_name'].'</td><td>'.$button.'</td></tr>';
+                $html .= '<tr><td>'.$v['order_num'].'</td><td>'.$v['cdate'].'</td><td>'.$v['type_name'].'</td><td>'.$v['num'].'</td><td>'.$v['status_name'].'</td><td>'.$button.'</td></tr>';
             }
         }
         return $html;
     }
 
     # 获取列表页搜索信息
-    public function getSearch()
+    public function getStatus()
     {
+        $type = Dever::db('shop/out_order')->config['config_status'];
         $config = array
         (
-            array('value' => '0', 'name' => '全部'),
-            array('value' => 4, 'name' => '待收货确认'),
-            array('value' => '5,6', 'name' => '已完成'),
-            array('value' => 'refund', 'name' => '缺货与报损'),
+            array('value' => '0', 'name' => '全部')
         );
 
+        foreach ($type as $k => $v) {
+            $config[] = array('value' => $k, 'name' => $v);
+        }
+
         $status = Dever::input('status');
 
         $html = '';
@@ -69,17 +57,34 @@ class Out extends Core
     }
 
     # 获取列表页搜索信息
-    public function getService()
+    public function getType($state = 1)
     {
-        $service = Dever::db('shop/service')->select();
+        $type = Dever::db('shop/out_order')->config['config_type'];
+        $config = array
+        (
+            array('value' => '0', 'name' => '全部'),
+        );
+
+        foreach ($type as $k => $v) {
+            if ($k > 2) {
+                $config[] = array('value' => $k, 'name' => $v);
+            }
+        }
+
+        if ($state == 2) {
+            unset($config[0]);
+        }
+
+        $out_type = Dever::input('out_type');
+
         $html = '';
-        foreach ($service as $k => $v) {
+        foreach ($config as $k => $v) {
             $selected = '';
-            if ($k == 0) {
+            if ((!$out_type && $k == 0) || $out_type == $v['value']) {
                 $selected = 'selected=""';
             } 
 
-            $html .= '<option value="'.$v['id'].'" '.$selected.'>'.$v['name'].'</option>';
+            $html .= '<option value="'.$v['value'].'" '.$selected.'>'.$v['name'].'</option>';
         }
 
         return $html;
@@ -88,20 +93,106 @@ class Out extends Core
     # 获取基本信息
     public function getConfig()
     {
-        $data['search'] = Dever::url('factory_order', 'store');
+        $data['search'] = Dever::url('out', 'store');
+
+        # 取消
+        $data['cancel'] = Dever::url('admin/out.cancel', 'store');
 
-        # 确认收货
-        $data['action'] = Dever::url('admin/factory_order.action', 'store');
+        # 新增出库单
+        $data['add'] = Dever::url('admin/out.add', 'store');
         return $data;
     }
 
-    # 确认收货
-    public function action_api()
+    # 取消
+    public function cancel_api()
     {
         $order_id = Dever::input('order_id');
 
-        Dever::load('mshop/lib/buy')->set(2,1)->finish($this->id, $order_id);
+        Dever::load('mshop/lib/out')->set(2,1)->cancel($this->id, $order_id);
 
         return 'reload';
     }
+
+    # 获取商品列表
+    public function getGoods_api()
+    {
+        $store_id = $this->id;
+        return Dever::outDiy(Dever::load('store/lib/goods')->getSkuList($store_id));
+    }
+
+    # 设置生产能力
+    public function add_api()
+    {
+        $data = array();
+        $data['store_id'] = $this->id;
+        $data['host'] = Dever::url('admin/out.add', 'store');
+        $data['url'] = Dever::url('admin/out.getGoods', 'store');
+        $data['submit'] = Dever::url('admin/out.action_cmmmit?json=1', 'store');
+        $data['out_type'] = $this->getType(2);
+        $data['user'] = $this->user['name'];
+        return Dever::render('setGoods', $data);
+    }
+
+    # 得到商品和总价
+    private function goods()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+
+        $this->data['price'] = 0;
+        $this->data['num'] = 0;
+        $this->data['name'] = array();
+        $store_id = $this->id;
+        # 计算总价格
+        foreach ($goods as $k => $v) {
+            if (strstr($v['id'], '-')) {
+                $t = explode('-', $v['id']);
+                $v['id'] = $t[0];
+                $s = $t[1];
+            } else {
+                $s = -1;
+            }
+            $n = $v['num'];
+
+            $this->data['list'][$k] = Dever::load('goods/lib/info')->getPayInfo($v['id'], $s, $n);
+            $this->data['list'][$k]['num'] = $n;
+
+            # 2是库存不足
+            $this->data['list'][$k]['ku_state'] = 1;
+
+            # 验证是否有货
+            $total = Dever::load('store/lib/goods')->checkTotal($n, $v['id'], $store_id, $s);
+
+            if ($total <= 0) {
+                $this->data['list'][$k]['ku_state'] = 2;
+                $this->data['list'][$k]['buy_num'] = 0;
+            }
+
+            if ($this->data['list'][$k]['ku_state'] == 1) {
+                $this->data['list'][$k]['buy_num'] = $n;
+                $this->data['num'] += $n;
+                $this->data['price'] += $this->data['list'][$k]['price'] * $n;
+                $this->data['name'][] = $this->data['list'][$k]['name'];
+            }
+        }
+
+        $this->data['name'] = implode(',', $this->data['name']);
+    }
+
+    # 生成出库单
+    public function action_cmmmit_api()
+    {
+        $info = Dever::input('info');
+
+        $out_type = Dever::input('out_type', 1);
+
+        $this->goods();
+
+        Dever::load('mshop/lib/out')->set(2,1)->action($this->id, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $this->user['id'], $out_type, $info, 1);
+
+        return Dever::url('out', 'store');
+    }
 }

+ 1 - 1
app/store/assets/pc/html/goods.html

@@ -23,7 +23,7 @@
 
           <div class="layui-form layui-card-header layuiadmin-card-header-auto">
             <div class="layui-form-item">
-              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="name" id="name" autocomplete="off" placeholder="商品名称"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="total" id="total"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="out()" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">打印清单</button></div></div></div></div>
+              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="name" id="name" autocomplete="off" placeholder="商品名称"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="total" id="total"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out()" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">打印清单</button></div></div></div></div>
             </div>
           </div>
         </div>

+ 2 - 2
app/store/assets/pc/html/order.html

@@ -23,7 +23,7 @@
 
           <div class="layui-form layui-card-header layuiadmin-card-header-auto">
             <div class="layui-form-item">
-              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button></div></div></div></div>
+              <div id="search"><div style="margin-top:0px;"><div><div class="layui-inline"><div class="layui-input-inline"><input type="text" class="autoload_text layui-input update_value form-control layui-input " value="" name="order_num" id="order_num" autocomplete="off" placeholder="订单编号"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder=">=订货时间" name="start" id="start" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><input type="text" value="" placeholder="<=订货时间" name="end" id="end" class="manage_date update_value form-control layui-input " autocomplete="off"></div></div><div class="layui-inline"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="status" id="status"><option value="0" selected="">状态</option><option parent="" value="1">待支付</option><option parent="" value="2">待审核</option><option parent="" value="3">待发货</option><option parent="" value="4">待收货确认</option><option parent="" value="5">已完成</option><option parent="" value="6">已完成(有退款)</option><option parent="" value="7">已取消</option><option parent="" value="8">已退款</option><option parent="" value="11">已过期</option></select></div></div><div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel" autocomplete="off"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">批量打印备货单</button></div></div></div></div>
             </div>
           </div>
         </div>
@@ -44,7 +44,7 @@
           <tbody id="list-tbody"><tr><td><input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="1"/></td><td>河北仓库1(18710001234)</td><td>测试仓库(15810090845)</td><td>F202111095151925058966182</td><td>38</td><td>2</td><td>待收货确认</td><td><a href="javascript:;" onclick="fastEdit($(this), 'http://zsmatest.nongxiaohe.com/package/manage/?l=project/database/list&amp;project=shop&amp;search_option_type=2&amp;page_type=2&amp;table=buy_order_goods&amp;project=shop&amp;order_id=1&amp;page_type=1&amp;menu=shop&amp;menu_id=99&amp;search_option_state=1', '查看详情', '', 1, 1)"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看详情</button></a>&nbsp;&nbsp;</td></tr></tbody>
       </table>
 
-      <div id="mul"><button class="btn btn-danger layui-btn layui-btn-danger" onclick="out($(this))" type="button" style="height: 38px;margin-left:10px;">批量打印备货单</button></div>
+      <div id="mul"></div>
       <div id="page"></div>
       <div class="dever_desc" id="desc" style="display:none;"></div>
         </div>

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 25 - 0
app/store/assets/pc/html/out.html


+ 139 - 0
app/store/assets/pc/html/out_view.html

@@ -0,0 +1,139 @@
+
+
+<!DOCTYPE html>
+<html>
+<head>
+  <script class="include" system="" path="inc/" file="head">include()</script>
+  <style id="addstyle">#dever_modal_body img
+                {
+                    max-width:300px;
+                }</style>
+<style>
+.layui-table-cell .layui-select,.layui-table-cell .layui-input
+{
+    height: 25px;
+}
+.layui-table-cell {
+    height: auto;
+}
+
+.table th,.table td {
+  min-width: 70px;
+}
+#table_2,#table_1 {
+  overflow: auto;
+}
+.layui-btn-xs
+{
+  margin-top:1px;
+}
+.dever-emoji img {
+  width:16px;
+}
+.layui-tab-title {
+  height: 100%;
+  white-space: inherit;
+}
+.layui-form-item .layui-input-inline {
+    display: block;
+    float: none;
+    left: -3px;
+    margin: 0px 0px 0px 0px;
+}
+.chart {
+  width: 100%;
+  height:300px;
+}
+</style>
+</head>
+<body>
+<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">[基本信息]:<table class="layui-table"><thead><tr><th style="width:20%">项目</th><th style="width:80%">详情</th></tr> </thead><tbody><tr>
+          <td>订单号</td>
+          <td>F202111094567206555170114&nbsp;&nbsp;&nbsp;&nbsp;</td>
+
+        </tr><tr>
+              <td>仓库信息</td>
+              <td>仓库名称:猪肉仓库&nbsp;&nbsp;&nbsp;&nbsp;联系人:猪肉&nbsp;&nbsp;&nbsp;&nbsp;联系电话:158100090845&nbsp;&nbsp;&nbsp;&nbsp;</td>
+
+            </tr><tr>
+                  <td>供应商信息</td>
+                  <td>仓库名称:第二个仓库&nbsp;&nbsp;&nbsp;&nbsp;联系人:第二个&nbsp;&nbsp;&nbsp;&nbsp;联系电话:2323&nbsp;&nbsp;&nbsp;&nbsp;</td>
+
+                </tr><tr>
+              <td>订单备注</td>
+              <td>12&nbsp;&nbsp;&nbsp;&nbsp;</td>
+
+            </tr><tr>
+              <td>订单信息</td>
+              <td><table class="layui-table"><thead><tr><th>金额</th><th>数量</th><th>订单状态</th><th></th></tr></thead><tbody><tr><td>30</td><td>2</td><td>待收货确认</td><td></td></tr></tbody></table></td>
+            </tr></tbody></table>[配送信息]:<table class="layui-table"><thead><tr><th>名称</th><th>单号</th><th>费用</th><th>数量</th><th>重量</th><th>体积</th><th>配货员</th><th>打包员</th><th>状态</th></tr></thead><tbody><tr><td>测试服务商</td><td>12321</td><td>312313</td><td>0</td><td>3123</td><td>12312</td><td>3213</td><td>12321</td><td>待处理</td></tr></tbody></table>[商品清单]:<table class="layui-table"><thead><tr><th>名称</th><th>属性</th><th>价格</th><th>数量</th><th>状态</th></tr></thead><tbody><tr><td>多组商品</td><td>2人份;高质量</td><td>123</td><td>1</td><td>正常</td></tr><tr><td>组合商品</td><td>无</td><td>3</td><td>1</td><td>正常</td></tr></tbody></table></div>
+
+<script>
+function audit(id, process, url)
+{
+    var index = layer.confirm('确定进行此项操作吗?', function()
+    {
+        $.getJSON(url, {id:id,process:process}, function(t)
+        {
+            msg(t);
+        })
+    })
+}
+
+function tui(goods_id, order_id, source_id, status, url)
+{
+    var index = layer.confirm('确定进行此项操作吗?', function()
+    {
+        $.getJSON(url, {order_goods_id:goods_id,order_id:order_id,type_id:source_id,type:13,status:status,desc:'厂家上报'}, function(t)
+        {
+            msg(t);
+        })
+    })
+}
+
+function cancel(order_id, source_id, url)
+{
+    var index = layer.confirm('确定进行此项操作吗?', function()
+    {
+        $.getJSON(url, {order_id:order_id,type_id:source_id,type:13,desc:'厂家上报'}, function(t)
+        {
+            msg(t);
+        })
+    })
+}
+
+function print(order_id)
+{
+    layer.alert('开发中');
+}
+</script></div>
+
+<script class="include" system="" path="inc/" file="script">include()</script>
+  <script>
+    layui.config({
+        base: '../script/lib/layui/admin/' //静态资源所在路径
+    }).extend({
+    formSelects: 'plugin/formselects/formselects',
+    index: 'lib/index' //主入口模块
+  }).use(['index', 'contlist', 'table', 'form', 'formSelects'], function(){
+    var table = layui.table;
+    var form = layui.form; 
+    var formSelects = layui.formSelects;
+    init();
+  });
+
+  function out() {
+      layer.alert('开发中');
+
+      return;
+      var index = layer.confirm('确定进行此项操作吗?', function()
+      {
+
+      })
+  }
+</script>
+</body>
+</html>
+

+ 65 - 55
app/store/assets/pc/html/setGoods.html

@@ -34,26 +34,13 @@
         </div>
         <div class="main_right layui-col-xs12 layui-col-md9">
             <div class="layui-row">
-                <div class="top">
-                    <label>选择仓库:</label>
-                    <div class="layui-input-inline">
-
-                        <div><select xm-select="store_id" xm-select-skin="normal" xm-select-search="<{$search}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="store_id" id="store_id"  ></select></div>
-
-                    </div>
-                    <div class="layui-input-inline">
-                        <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="setstore()">确认选择</button>
-                    </div>
-                </div>
                 <div class="goods_list" style="height:645px;">
                     <table class="layui-table">
                         <thead>
                             <tr>
                                 <th lay-data="{field:'id'}">商品编码</th>
                                 <th lay-data="{field:'name'}">商品名称</th>
-                                <th lay-data="{field:'price', edit: 'text'}">销售价(元)</th>
-                                <th lay-data="{field:'p_price', edit: 'text'}">出厂价(元)</th>
-                                <!--<th lay-data="{field:'number', edit: 'text'}">数量</th>-->
+                                <th lay-data="{field:'number', edit: 'text'}">数量</th>
                                 <th lay-data="{field:'operation'}">操作</th>
                             </tr>
                         </thead>
@@ -63,10 +50,45 @@
                     </table>
                 </div>
                 <div class="total ft16">
-                    合计:【<span> 总金额:<i class="totalMoney">0.00</i> </span>】【<span> 总数量:<i class="totalQuantity">0</i> </span>】
+                    合计:【<span> 总数量:<i class="totalQuantity">0</i> </span>】
                 </div>
+                <table class="reading layui-table" lay-even="">
+                    <tbody>
+                        <tr>
+                            <td>出库单类型:</td>
+                            <td colspan="3">
+                                <div class="layui-input-inline">
+                                    <select class="update_value form-control layui-input layui-select" name="out_type" id="out_type"  ><{$out_type}></select>
+                                </div>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td>订单备注:</td>
+                            <td><textarea class="layui-textarea" name="info" id="info" rows="" cols="" maxlength="200" placeholder="请输入订单备注"></textarea></td>
+                        </tr>
+                        
+                        <tr>
+                            <td>操作人:</td>
+                            <td><{$user}></td>
+                        </tr>
+                        <!--
+                        <tr>
+                            <td>会员级别:</td>
+                            <td></td>
+                            <td>有效期:</td>
+                            <td></td>
+                        </tr>
+                        <tr>
+                            <td>可用积分:</td>
+                            <td></td>
+                            <td>可用储值:</td>
+                            <td></td>
+                        </tr>
+                        -->
+                    </tbody>
+                </table>
                 <div class="towbtn">
-                    <input type="button" id="settlement" value="确认设置">
+                    <input type="button" id="settlement" value="确认出库">
                 </div>
             </div>
         </div>
@@ -95,17 +117,18 @@
     {
         $("#settlement").click(function(){
             var url = '<{$submit}>';
-            var store_id = '<{$store_id}>';
 
-            layui.layer.confirm('确定进行此项设置吗?', function() {
+            layui.layer.confirm('确定进行此项操作吗?', function() {
                 var goods_string = JSON.stringify(goods);
 
                 var data = {};
-                data = {store_id:store_id, goods:goods_string};
+                var info = $('#info').val();
+                var out_type = $('#out_type').val();
+                data = {info:info, out_type:out_type,goods:goods_string};
                 $.post(url, data, function(t) {
                     t = JSON.parse(t);
                     if (t.status == 1) {
-                        layui.layer.alert('商品设置成功', function(index){
+                        layui.layer.alert('添加出库单成功', function(index){
                           location.href = t.data;
                           layer.close(index);
                         });
@@ -129,10 +152,20 @@
         });
         */
 
-        $("#goods").on("keyup", ".goods_set_price", function() {
+        $("#goods").on("keyup", ".goods_num", function() {
             var num = parseInt($(this).val());
+            if (!num || num <= 0) {
+                num = 1;
+                $(this).val(1);
+            }
             var id = $(this).parent().attr('value');
-            goods[id].p_price = num;
+            goods[id].num = num;
+            if (goods[id].num >= goods[id].total) {
+                goods[id].num = goods[id].total;
+                layer.msg('库存不足');
+            }
+            $(this).val(goods[id].num);
+            
             setTotal();
         })
     })
@@ -183,12 +216,10 @@
 
     function setGoods(node)
     {
-        if (node.id) {
+        if (node.id && node.end) {
             var key = node.id;
             if (!goods[key]) {
                 goods[key] = node;
-                goods[key].price = parseFloat(goods[key].price);
-                goods[key].p_price = parseFloat(goods[key].p_price);
                 goods[key].num = 1;
                 create(node);
                 setTotal();
@@ -209,9 +240,7 @@
             var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
             addtr += '<td class="goods_id">'+node.id+'</td>';
             addtr += '<td class="goods_name">'+node.name+'</td>';     
-            addtr += '<td class="goods_price">'+node.price+'</td>';              
-            addtr += '<td class="goods_p_price" value='+node.id+'><input type="tel" class="layui-input goods_set_price" value="'+node.p_price+'" /></td>';
-            //addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';                 
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';                 
             addtr += '<td><button class="delete_btn" onclick="del(\''+node.id+'\')">删除</button></td>';                      
             addtr += '</tr>';
             $("#goods").append(addtr);
@@ -220,7 +249,13 @@
 
     function add(id)
     {
-        goods[id].num += 1;
+        if (goods[id].num >= goods[id].total) {
+            goods[id].num = goods[id].total;
+            layer.msg('库存不足');
+        } else {
+            goods[id].num += 1;
+        }
+        
         get(id).find('.goods_num').val(goods[id].num);
         setTotal();
     }
@@ -242,18 +277,6 @@
         get(id).remove();
         setTotal();
     }
-
-
-    /*
-    //点击 - 单价 - 可编辑
-    $("#goods").on("click","td.danjia",function(){
-        if(!$(this).is('.bj')){   
-            var currentPrice = $(this).html();
-            $(this).focus();
-            $(this).addClass('bj').html('<input type="tel" class="layui-input" value="'+$(this).text()+'" />').find('input').focus().blur();    
-        } 
-    })
-    */
     
     function setTotal()
     {
@@ -261,22 +284,9 @@
         var num = 0;
         for (var i in goods) {
             num += goods[i].num;
-            cash += goods[i].p_price * goods[i].num;
         }
         $(".totalQuantity").html(num);
-        $(".totalMoney").html(cash.toFixed(2)); 
-    }
-
-    function setstore()
-    {
-        var store_id = $('.xm-select-parent[fs_id="store_id"] span[fsw="xm-select"]').attr('value');
-        if (!store_id) {
-            layui.layer.alert('请选择仓库');
-            return;
-        }
-        layui.layer.confirm('确定切换仓库吗?切换后现在选择的商品都将清空', function() {
-            location.href = '<{$host}>&id=' + store_id;
-        });
+        //$(".totalMoney").html(cash.toFixed(2)); 
     }
 </script>
 </body>

+ 265 - 0
app/store/assets/pc/html/setGoodsNum.html

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

+ 1 - 0
app/store/database/info.php

@@ -334,6 +334,7 @@ return array
     (
         'list_button' => array
         (
+            'location' => array('批量设置商品', Dever::url('lib/set.home', 'store')),
             //'add' => array('设置库存清单', '"info&where_id={id}&col=goods&oper_save_jump=info&oper_table=info&oper_parent=info"'),
 
             'list3' => array('商品列表', '"goods&search_option_store_id={id}&oper_table=info"'),

+ 1 - 0
app/store/database/member.php

@@ -16,6 +16,7 @@ return array
     'lang' => '账号管理',
     'menu' => false,
     'check' => 'mobile',
+    'role' => $role,
     # 数据结构
     'struct' => array
     (

+ 108 - 1
app/store/lib/Goods.php

@@ -53,7 +53,7 @@ class Goods
         return $state;
     }
 
-    # 获取店铺的商品SKU列表
+    # 获取店铺的商品列表
     public function getGoodsSku($store)
     {
         $table = 'store/goods_sku';
@@ -80,4 +80,111 @@ class Goods
 
         return $data;
     }
+
+    # 获取店铺的商品SKU列表
+    public function getSkuList($store)
+    {
+        $table = 'store/goods_sku';
+        $where['store_id'] = isset($store['id']) ? $store['id'] : $store;
+        $method = 'getDataPage';
+        
+        $name = Dever::input('name');
+        if ($name) {
+            $where['name'] = $name;
+        }
+        
+        $data = Dever::db($table)->$method($where);
+
+        $result = array();
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $data[$k] = Dever::load('goods/lib/info')->getPayInfo($v, $v['sku_id']);
+                $data[$k]['total'] = $data[$k]['total'] ? $data[$k]['total'] : 0;
+                if ($data[$k]['total'] <= 0) {
+                    continue;
+                }
+                if (!isset($result[$v['id']])) {
+                    $result[$v['id']]['id'] = $v['id'];
+                    $result[$v['id']]['name'] = $v['name'];
+                    $result[$v['id']]['total'] = $data[$k]['total'];
+                    $result[$v['id']]['children'] = array();
+                }
+                if (isset($data[$k]['attr']) && $data[$k]['attr']) {
+                    $result[$v['id']]['children'][] = array
+                    (
+                        'id' => $v['id'] . '-' . $data[$k]['sku_id'],
+                        'name' => $v['name'] . '-' . $data[$k]['sku_name'] . '[剩余'.$data[$k]['total'].'个]',
+                        'total' => $data[$k]['total'],
+                        'end' => true,
+                    );
+                }
+
+                if (!$result[$v['id']]['children']) {
+                    $result[$v['id']]['name'] = $v['name'] . '[剩余'.$data[$k]['total'].'个]';
+                    $result[$v['id']]['end'] = true;
+                }
+            }
+        }
+
+        return array_values($result);
+    }
+
+    # 获取库存
+    public function getInfo($store_id, $info, $sku_id = false, $attr = true)
+    {
+        $where['store_id'] = $store_id;
+        $where['goods_id'] = isset($info['goods_id']) ? $info['goods_id'] : $info;
+        $other = Dever::db('store/goods_sku')->getData($where);
+        $data = Dever::load('goods/lib/info')->getInfo($info, $attr, array($other, array('total')));
+
+        if($data) {
+
+            $sku_id = $sku_id ? $sku_id : $data['sku_id'];
+            $data['total'] = 0;
+            if ($data['price_type'] == 4) {
+                if (isset($data['goods']) && is_array($data['goods'])) {
+                    foreach ($data['goods'] as $k => $v) {
+                        $data['goods'][$k]['total'] = $this->getTotal($other, -1);
+
+                        if ($data['total'] > $data['goods'][$k]['total']) {
+                            $data['total'] = $data['goods'][$k]['total'];
+                        }
+                    }
+                }
+            } else {
+                $data['total'] = $this->getTotal($other, $sku_id);
+            }
+        }
+
+        return $data;
+    }
+
+    # 验证库存
+    public function checkTotal(&$num, $goods_id, $store_id, $sku_id, $state = 1)
+    {
+        $info = $this->getInfo($store_id, $goods_id, $sku_id, false);
+        if (!$info) {
+            Dever::alert('商品不存在');
+        }
+        $total = $info['total'];
+
+        if ($num > $total) {
+            if ($state == 2) {
+                Dever::alert('库存不足');
+            }
+            $num = $total;
+        }
+
+        return $total;
+    }
+
+    # 获取库存
+    public function getTotal($other, $sku_id)
+    {
+        if (isset($other[$sku_id])) {
+            return $other[$sku_id]['total'];
+        } else {
+            return 0;
+        }
+    }
 }

+ 97 - 0
app/store/lib/Set.php

@@ -0,0 +1,97 @@
+<?php
+
+namespace Store\Lib;
+
+use Dever;
+
+# 批量设置商品
+class Set
+{
+    # 导出订单
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取门店
+    public function search_api()
+    {
+        return Dever::search('store/info');
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $store_id = Dever::input('store_id', 1);
+        return Dever::outDiy(Dever::load('goods/lib/set')->getGoodsList($store_id, 'store_id', 'store/goods_sku'));
+    }
+
+    # 设置生产能力
+    public function home_api()
+    {
+        $data = array();
+        $data['store_id'] = Dever::input('id', 1);
+        $data['host'] = Dever::url('lib/set.home', 'store');
+        $data['url'] = Dever::url('lib/set.goods?store_id=' . $data['store_id'], 'store');
+        $data['search'] = Dever::url('lib/set.search?yes='.$data['store_id'].'&json=1', 'store');
+        $data['submit'] = Dever::url('lib/set.action_cmmmit?json=1', 'store');
+
+        return Dever::render('setGoodsNum', $data);
+    }
+
+    # 设置生产能力
+    public function action_cmmmit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $store_id = Dever::input('store_id');
+
+        foreach ($goods as $k => $v) {
+            $temp = explode('-', $k);
+            $goods_id = $temp[0];
+            if (isset($temp[1])) {
+                $sku_id = $temp[1];
+            } else {
+                $sku_id = -1;
+            }
+            if ($v['num'] < 1) {
+            	continue;
+            }
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w['store_id'] = $store_id;
+            $info = Dever::db('store/goods')->one($w);
+
+            $w['total_num'] = $v['num'];
+            if (!$info) {
+                Dever::db('store/goods')->insert($w);
+            } else {
+            	$w['total_num'] += $info['total_num'];
+                $w['where_id'] = $info['id'];
+                $w['state'] = 1;
+                Dever::db('store/goods')->update($w);
+            }
+
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w['store_id'] = $store_id;
+            $w['sku_id'] = $sku_id;
+            $info = Dever::db('store/goods_sku')->one($w);
+
+            $w['total_num'] = $v['num'];
+            if (!$info) {
+                Dever::db('store/goods_sku')->insert($w);
+            } else {
+            	$w['total_num'] += $info['total_num'];
+                $w['where_id'] = $info['id'];
+                $w['state'] = 1;
+                Dever::db('store/goods_sku')->update($w);
+            }
+        }
+
+        return Dever::url('project/database/list&project=store&&table=info&menu=store&search_option_state=1', 'manage');
+    }
+}

+ 26 - 0
app/store/template/pc/out.php

@@ -0,0 +1,26 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| home
+|--------------------------------------------------------------------------
+*/
+$view
+
+# 定义名称
+->fetch('#content_2@test', '1')  
+->fetch('#status', 'store/admin/out.getStatus') 
+->fetch('#out_type', 'store/admin/out.getType')
+->fetch('#form1@action', 'store/admin/out.getConfig#search') 
+->fetch('#list-add@href', 'store/admin/out.getConfig#add')
+
+->fetch('#list-tbody', 'store/admin/out.getList') 
+
+
+->fetch('#order_num@value', '<{Dever::input("order_num")}>') 
+->fetch('#start@value', '<{Dever::input("start")}>') 
+->fetch('#end@value', '<{Dever::input("end")}>')  
+
+->fetch('#page','<{Dever::page("current")}>') 
+
+# display
+->display();

+ 5 - 0
app/store/template/pc/out_view.php

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

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác