dever 3 yıl önce
ebeveyn
işleme
c6756a1d9c

+ 203 - 0
app/factory/admin/Excel.php

@@ -0,0 +1,203 @@
+<?php
+namespace Factory\Admin;
+
+use Dever;
+
+class Excel extends Core
+{
+    public function out($id, $user, $data)
+    {
+        if (!$data) {
+            Dever::alert('无导出数据');
+        }
+        $info = Dever::db('factory/info')->find($id);
+        if (!$info) {
+            Dever::alert('操作失败');
+        }
+
+        $method = 'out_' . $info['out_template'];
+        $file = '发货信息表';
+        return $this->$method($file, $user, $data);
+    }
+
+    # 模板模板
+    public function out_1($file, $user, $data)
+    {
+        $this->out_2($file, $user, $data, $file);
+    }
+
+    # 九阳模板
+    public function out_2($file, $user, $data, $name = '')
+    {
+        $header = array();
+
+        $header = array('序号', '申请发货时间', '申请人', '产品名称', '数量', '订单号', '收件人姓名', '收件人电话', '收件地址', '发货时间', '发件物流', '运单编号', '备注');
+
+        $file = $name ? $name : '中食民安&九阳发货信息表';
+
+        $body = array();
+
+        $i = 1;
+        foreach ($data as $k => $v) {
+            if (!is_array($v)) {
+                continue;
+            }
+
+            Dever::load('mshop/lib/buy')->setOutStatus($v['id'], 2);
+
+            if ($v['ps_info']) {
+                $ps_date = $v['ps_info']['cdate_day'];
+            } else {
+                $ps_date = '-';
+            }
+
+            $service_name = array();
+            $service_num = array();
+            if (isset($v['ps_info']['service']) && $v['ps_info']['service']) {
+                foreach ($v['ps_info']['service'] as $k1 => $v1) {
+                    $service_name[] = $v1['service_name'];
+                    $service_num[] = $v1['order_num'];
+                }
+            }
+
+            $service_name = implode(',', $service_name);
+            $service_num = implode(',', $service_num);
+
+            if ($v['parent_type'] == 2) {
+                $parent_order = Dever::db('shop/sell_order')->find($v['parent_order_id']);
+
+                if ($parent_order && $parent_order['uid']) {
+                    if ($parent_order['address_id']) {
+                        $address = Dever::load('passport/address')->getOne($parent_order['uid'], $parent_order['address_id']);
+                        $v['type_info']['name'] = $address['contact'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = $address['address_info'];
+                    } else {
+                        $address = Dever::db('passport/user')->find($parent_order['uid']);
+                        $v['type_info']['name'] = $address['username'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = '';
+                    }
+                }
+            }
+
+            foreach ($v['goods'] as $k1 => $v1) {
+
+                $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                if (isset($goods_info['sku'])) {
+                    $sku = $goods_info['sku']['string'];
+                } else {
+                    $sku = '';
+                }
+
+                $d = array
+                (
+                    $i,
+                    $v['operdate_day'],
+                    $user['name'],
+                    $goods_info['name'] . ' ' . $sku,
+                    $v1['num'],
+                    $v['order_num'],
+
+                    $v['type_info']['name'],
+                    $v['type_info']['mobile'],
+                    $v['type_info']['address'],
+
+                    $ps_date,
+
+                    $service_name,
+                    $service_num,
+
+                    $v['info'],
+                    
+                );
+
+                $body[] = $d;
+
+                $i++;
+            }
+        }
+
+        Dever::excelExport($body, $header, $file);
+    }
+
+    # 纯米模板
+    public function out_3($file, $user, $data)
+    {
+        $header = array();
+
+        $header = array('序号', '申请人', '发货日期', '客户名称', '品名', '单位', '数量', '订单号', '收件人', '收件电话', '收件邮寄地址', '发货时间', '发件物流', '运单编号', '备注');
+
+        $file = '纯米发货信息表';
+
+        $body = array();
+
+        $i = 1;
+        foreach ($data as $k => $v) {
+            if (!is_array($v)) {
+                continue;
+            }
+
+            Dever::load('mshop/lib/buy')->setOutStatus($v['id'], 2);
+            if ($v['ps_info']) {
+                $ps_date = $v['ps_info']['cdate_day'];
+            } else {
+                $ps_date = '-';
+            }
+
+            if ($v['parent_type'] == 2) {
+                $parent_order = Dever::db('shop/sell_order')->find($v['parent_order_id']);
+
+                if ($parent_order && $parent_order['uid']) {
+                    if ($parent_order['address_id']) {
+                        $address = Dever::load('passport/address')->getOne($parent_order['uid'], $parent_order['address_id']);
+                        $v['type_info']['truename'] = $address['contact'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = $address['address_info'];
+                    } else {
+                        $address = Dever::db('passport/user')->find($parent_order['uid']);
+                        $v['type_info']['truename'] = $address['username'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = '';
+                    }
+                }
+            }
+            
+            foreach ($v['goods'] as $k1 => $v1) {
+
+                $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                if (isset($goods_info['sku'])) {
+                    $sku = $goods_info['sku']['string'];
+                } else {
+                    $sku = '';
+                }
+
+                $d = array
+                (
+                    $i,
+                    $user['name'],
+                    $ps_date,
+                    '中食民安(北京)',
+                    $goods_info['name'] . ' ' . $sku,
+                    $goods_info['unit'],
+                    $v1['num'],
+
+                    $v['order_num'],
+
+                    $v['type_info']['truename'],
+                    $v['type_info']['mobile'],
+                    $v['type_info']['address'],
+
+                    $v['info'],
+                    
+                );
+
+                $body[] = $d;
+
+                $i++;
+            }
+        }
+
+        Dever::excelExport($body, $header, $file);
+    }
+}

+ 40 - 1
app/factory/admin/Order.php

@@ -30,6 +30,13 @@ class Order extends Core
 
         $html = '';
         if ($data && $data['order']) {
+            $out_status = Dever::db('shop/buy_order')->config['out_status'];
+            $excel = Dever::input('excel', 1);
+            if ($excel == 2) {
+                Dever::load('factory/admin/excel')->out($this->id, $this->user, $data['order']);
+                die;
+                return;
+            }
         	foreach ($data['order'] as $k => $v) {
         		if ($v['ps_info']) {
         			$ps_date = $v['ps_info']['cdate'];
@@ -73,7 +80,14 @@ class Order extends Core
                     }
                 }
 
-        		$html .= '<tr><td><input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="'.$v['id'].'"/></td><td>'.$v['order_num'].'</td><td>'.$v['operdate'].'</td><td>'.$v['type_info']['name'].'</td><td>'.$ps_date.'</td><td>'.$v['p_price'].'</td><td>'.$v['status_name'].'</td><td>'.$button.'</td></tr>';
+                $v['out_status_name'] = $out_status[$v['source_out_status']];
+
+                $dao_date = '-';
+                if ($v['source_out_date']) {
+                    $dao_date = date('Y-m-d H:i', $v['source_out_date']);
+                }
+
+        		$html .= '<tr><td><input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="'.$v['id'].'"/></td><td>'.$v['order_num'].'</td><td>'.$v['operdate'].'</td><td>'.$v['type_info']['name'].'</td><td>'.$ps_date.'</td><td>'.$v['p_price'].'</td><td>'.$v['status_name'].'</td><td>'.$v['out_status_name'].'</td><td>'.$dao_date.'</td><td>'.$button.'</td></tr>';
         	}
         }
         return $html;
@@ -107,6 +121,31 @@ class Order extends Core
         return $html;
     }
 
+    # 获取列表页搜索信息
+    public function getSearchOutStatus()
+    {
+        $config = array
+        (
+            array('value' => '0', 'name' => '全部'),
+            array('value' => 1, 'name' => '未导出'),
+            array('value' => 2, 'name' => '已导出'),
+        );
+
+        $status = Dever::input('source_out_status');
+
+        $html = '';
+        foreach ($config as $k => $v) {
+            $selected = '';
+            if ((!$status && $k == 0) || $status == $v['value']) {
+                $selected = 'selected=""';
+            } 
+
+            $html .= '<option value="'.$v['value'].'" '.$selected.'>'.$v['name'].'</option>';
+        }
+
+        return $html;
+    }
+
     # 获取列表页搜索信息
     public function getService()
     {

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

@@ -23,7 +23,11 @@
 
           <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>&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;display:none;">批量打印备货单</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"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="source_out_status" id="source_out_status"><option value="0" selected="">导出状态</option><option parent="" value="1">未导出</option><option parent="" value="2">已导出</option></select></div></div>
+
+              <div class="layui-inline"><input type="hidden" value="1" 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;display:none;">批量打印备货单</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-warm" onclick="$('#excel').val(2);list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">导出</button></div></div></div></div>
             </div>
           </div>
         </div>
@@ -39,7 +43,7 @@
         <div id="table_2" style="display:"> 
           <table class="table layui-table layui-table-body" id="table">
           <thead id="list-thead">
-              <tr><th data-priority="1"><input type="checkbox" class="checkbox-checkall" name="checkall" id="checkall" value="list" lay-ignore/></th><th data-priority="1">订单号</th><th data-priority="1">订货日期</th><th data-priority="1">订单收件人</th><th data-priority="1">发货日期</th><th data-priority="1">订单金额</th><th data-priority="1">订单状态</th><th data-priority="1" class="dever-manage">管理</th></tr>
+              <tr><th data-priority="1"><input type="checkbox" class="checkbox-checkall" name="checkall" id="checkall" value="list" lay-ignore/></th><th data-priority="1">订单号</th><th data-priority="1">订货日期</th><th data-priority="1">订单收件人</th><th data-priority="1">发货日期</th><th data-priority="1">订单金额</th><th data-priority="1">订单状态</th><th data-priority="1">导出状态</th><th data-priority="1">导出时间</th><th data-priority="1" class="dever-manage">管理</th></tr>
           </thead>
           <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>

+ 32 - 1
app/factory/database/info.php

@@ -7,6 +7,13 @@ $status = array
     3 => '认证失败',
 );
 
+$out_template = array
+(
+    1 => '默认模板',
+    2 => '九阳',
+    3 => '纯米',
+);
+
 $cate = function()
 {
     $array = array();
@@ -27,6 +34,7 @@ return array
     'lang' => '工厂列表',
     # 后台菜单排序
     'order' => 99,
+    'out_template' => $out_template,
     'end' => array
     (
         'insert' => 'factory/lib/manage.infoUpdate',
@@ -132,7 +140,7 @@ return array
             'match'     => 'option',
             'search'    => 'linkage',
             'update'    => 'linkage',
-            'option'    => Dever::url('api.get?level_total=2', 'area'),
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
             'list'      => 'Dever::load("area/api.string", "{area}")',
         ),
 
@@ -156,6 +164,16 @@ return array
             //'update'  => 'text',
         ),
 
+        'county'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '县区',
+            'default'   => '',
+            'desc'      => '县区',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
         'map'       => array
         (
             'type'      => 'varchar-300',
@@ -345,6 +363,19 @@ return array
             'show'      => 'stat_type=1,2',
         ),
 
+        'out_template'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '导出模板-供应链管理中导出的表格模板',
+            'default'   => '1',
+            'desc'      => '导出模板',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $out_template,
+            'list'      => true,
+            'edit'      => true,
+        ),
+
         'reorder'       => array
         (
             'type'      => 'int-11',

+ 3 - 0
app/factory/lib/Manage.php

@@ -25,6 +25,9 @@ class Manage
             $temp = is_string($area) ? explode(',', $area) : $area;
             $update['province'] = $temp[0];
             $update['city'] = $temp[1];
+            if (isset($temp[2])) {
+                $update['county'] = $temp[2];
+            }
         }
 
         $map = Dever::param('map', $data);

+ 2 - 2
app/factory/lib/Order.php

@@ -35,7 +35,7 @@ class Order
             $this->data['list'][$k] = Dever::load('goods/lib/info')->getPayInfo($v['id'], $s);
             if (isset($this->data['list'][$k]['min']) && $this->data['list'][$k]['min'] > 0) {
                 if ($n < $this->data['list'][$k]['min']) {
-                    $n = $this->data['list'][$k]['min'];
+                    //$n = $this->data['list'][$k]['min'];
                 }
             }
             $this->data['list'][$k]['num'] = $n;
@@ -101,7 +101,7 @@ class Order
 
         Dever::load('cash/lib/order')->up($order_data, 1, 1);
 
-        return Dever::url('project/database/list&project=shop&table=buy_order&menu=shop&menu_id=77&search_option_state=1&search_option_type=2', 'manage');
+        return Dever::url('project/database/list&project=shop&table=buy_order&menu=shop&menu_id=77&search_option_state=1&search_option_type=2&search_option_source_type=3', 'manage');
     }
 
     # 生成订单号

+ 1 - 0
app/factory/template/pc/order.php

@@ -9,6 +9,7 @@ $view
 # 定义名称
 ->fetch('#content_2@test', '1')  
 ->fetch('#status', 'factory/admin/order.getSearch') 
+->fetch('#source_out_status', 'factory/admin/order.getSearchOutStatus') 
 ->fetch('#form1@action', 'factory/admin/order.getConfig#search') 
 
 ->fetch('#list-tbody', 'factory/admin/order.getList') 

+ 23 - 1
app/goods/database/info.php

@@ -284,7 +284,7 @@ $config = array
         'f_price'       => array
         (
             'type'      => 'varchar-100',
-            'name'      => '采购价',
+            'name'      => '门店采购价',
             'default'   => '',
             'desc'      => '采购价',
             'match'     => 'option',
@@ -314,6 +314,28 @@ $config = array
             //'list'      => true,
         ),
 
+        'unit'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '计量单位',
+            'default'   => '',
+            'desc'      => '计量单位',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'weight'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '重量',
+            'default'   => '',
+            'desc'      => '重量',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'list'      => true,
+        ),
+
         'goods'       => array
         (
             'type'      => 'text-1000',

+ 23 - 1
app/goods/database/info_sku.php

@@ -104,7 +104,7 @@ $config = array
         'f_price'       => array
         (
             'type'      => 'varchar-100',
-            'name'      => '采购价',
+            'name'      => '门店采购价',
             'default'   => '',
             'desc'      => '采购价',
             'match'     => 'option',
@@ -134,6 +134,28 @@ $config = array
             'list'      => true,
         ),
 
+        'unit'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '计量单位',
+            'default'   => '',
+            'desc'      => '计量单位',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'weight'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '重量',
+            'default'   => '',
+            'desc'      => '重量',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+            //'list'      => true,
+        ),
+
         'num'       => array
         (
             'type'      => 'int-11',

+ 11 - 0
app/goods/lib/Info.php

@@ -433,6 +433,15 @@ class Info
         $info = Dever::db($this->table_info)->find($id);
 
         if ($info) {
+            if (!isset($info['unit'])) {
+                $info['unit'] = '';
+            }
+            if (!isset($info['weight'])) {
+                $info['weight'] = '';
+            }
+            if (!isset($info['code'])) {
+                $info['code'] = '';
+            }
             $info['sku_name'] = '';
             if ($sku_id > 0) {
                 $sku = Dever::db($this->table_sku)->find($sku_id);
@@ -442,6 +451,8 @@ class Info
                     $info['sku'] = Dever::load('attr/api')->getInfoByJson($sku['attr']);
                     $info['code'] = $sku['code'];
                     $info['sku_name'] = $info['sku']['string'];
+                    $info['unit'] = $sku['unit'];
+                    $info['weight'] = $sku['weight'];
                 }
             }
         }

+ 3 - 1
app/goods/lib/Sku.php

@@ -11,10 +11,12 @@ class Sku
     (
         'code' => '商品条码号',
         's_price' => '市场价',
-        'f_price' => '采购价',
+        'f_price' => '门店采购价',
         'c_price' => '成本价',
         'price' => '销售价',
         'min' => '采购起订数',
+        'unit' => '计量单位',
+        'weight' => '重量',
     );
 
     # 主要价格字段

+ 53 - 7
app/mshop/lib/Buy.php

@@ -52,12 +52,27 @@ class Buy
         return $where;
     }
 
+    # 更新导出状态
+    public function setOutStatus($id, $type = 1)
+    {
+        if ($type == 1) {
+            $data['out_status'] = 2;
+            $data['out_date'] = time();
+        } else {
+            $data['source_out_status'] = 2;
+            $data['source_out_date'] = time();
+        }
+
+        $data['where_id'] = $id;
+        Dever::db('shop/buy_order')->update($data);
+    }
+
     # 获取订单列表
-    public function getList($id)
+    public function getList($id, $status = false)
     {
         $result = array();
         $where = $this->where($id);
-        $status = Dever::input('status');
+        $status = Dever::input('status', $status);
         if ($status) {
             if ($status == 'refund') {
                 $where['refund_status'] = 2;
@@ -106,6 +121,27 @@ class Buy
             }
         }
 
+        $type = Dever::input('type');
+        if ($type) {
+            $where['type'] = $type;
+        }
+        $source_type = Dever::input('source_type');
+        if ($source_type) {
+            $where['source_type'] = $source_type;
+        }
+        $parent_type = Dever::input('parent_type');
+        if ($parent_type) {
+            $where['parent_type'] = $parent_type;
+        }
+        $out_status = Dever::input('out_status');
+        if ($out_status) {
+            $where['out_status'] = $out_status;
+        }
+        $source_out_status = Dever::input('source_out_status');
+        if ($source_out_status) {
+            $where['source_out_status'] = $source_out_status;
+        }
+
         $excel = Dever::input('excel', 1);
         if ($excel == 2) {
             $result['order'] = Dever::db($this->table)->getData($where);
@@ -204,11 +240,17 @@ class Buy
             $info['source_info'] = Dever::db('factory/info')->find($info['source_id']);
         }
         
+        $info['cdate_day'] = date('Y-m-d', $info['cdate']);
         $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
+        
         if ($info['operdate']) {
+            $info['operdate_day'] = date('Y-m-d', $info['operdate']);
             $info['operdate'] = date('Y-m-d H:i', $info['operdate']);
+            
         } else {
+            $info['operdate_day'] = $info['cdate_day'];
             $info['operdate'] = $info['cdate'];
+            
         }
         $goods_status = Dever::db('shop/buy_order_goods')->config['status'];
         $goods_process = Dever::db('shop/buy_order_refund')->config['process'];
@@ -235,9 +277,13 @@ class Buy
         $info['ps_info'] = Dever::db('shop/buy_order_ps')->find(array('order_id' => $info['id']));
         if ($info['ps_info']) {
             $info['ps_info']['service'] = Dever::array_decode($info['ps_info']['service']);
+            $info['ps_info']['cdate_day'] = date('Y-m-d', $info['ps_info']['cdate']);
             $info['ps_info']['cdate'] = date('Y-m-d H:i', $info['ps_info']['cdate']);
+            
             if ($info['ps_info']['ydate']) {
+                $info['ps_info']['ydate_day'] = date('Y-m-d', $info['ps_info']['ydate']);
                 $info['ps_info']['ydate'] = date('Y-m-d H:i', $info['ps_info']['ydate']);
+                
             }
 
             $status = Dever::db('shop/buy_order_ps')->config['status'];
@@ -775,7 +821,7 @@ class Buy
                 'content' => $config['phone'],
                 'name' => '联系平台',
             );
-        } elseif ($noprice == 1) {
+        } elseif ($type != 1 && $noprice == 1) {
             $config = Dever::load('factory/admin/auth.config');
 
             $button[] = array
@@ -785,7 +831,7 @@ class Buy
                 'name' => '打印货单',
             );
 
-            if ($info['type'] == 2) {
+            if ($info['type'] == 2 && $info['source_type'] != 2 && in_array($info['status'], array(5,6,8))) {
                 $button[] = array
                 (
                     'type' => 'link',
@@ -1136,7 +1182,7 @@ class Buy
         if (isset($cash_order) && $cash_order) {
             $head = array('序号', '结算单号', '数量', '金额', '结算类型', '入账状态', '审核状态', '结算时间', '审核未通过原因', '管理');
 
-            if ($search_option_type == 3) {
+            if ($search_option_type == 3 || $noprice == 1) {
                 unset($head[3]);
             }
 
@@ -1171,7 +1217,7 @@ class Buy
                     $m,
                 );
 
-                if ($search_option_type == 3) {
+                if ($search_option_type == 3 || $noprice == 1) {
                     unset($d[3]);
                 }
                 $body[] = $d;
@@ -1914,7 +1960,7 @@ class Buy
         $pdf->font(10);
         $pdf->br();
 
-        if ($type == 2 && $info['type'] == 2) {
+        if ($type == 2 && $info['type'] == 2 && $info['source_type'] != 2) {
             $pdf->br()->left($name . ':' . $type_info['name'], 80)->left('制单人:' . $member['name'], 60)->left('制单时间:' . date('Y-m-d H:i'), 40);
 
             $pdf->hr();

+ 91 - 9
app/shop/database/buy_order.php

@@ -13,6 +13,12 @@ $status = array
     11 => '已过期',
 );
 
+$out_status = array
+(
+    1 => '未导出',
+    2 => '已导出',
+);
+
 $audit = array
 (
     //1 => '待审核',
@@ -57,6 +63,20 @@ $store = function()
     return $array;
 };
 
+$factory = function()
+{
+    $array = array();
+    $info = Dever::db('factory/info')->select();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$type = 1;
+$noprice = 2;
+
 $search_option_type = Dever::input('search_option_type', 1);
 
 if ($search_option_type == 1) {
@@ -85,17 +105,30 @@ if ($search_option_type == 1) {
     );
     $source_name = '发货工厂';
     $source_order = 4;
+    $noprice = 1;
 }
 
 $search_option_source_type = Dever::input('search_option_source_type');
 if ($search_option_source_type == 2) {
-    $source_name = '仓库名称';
-    $source_order = -1;
-    $excel = array
-    (
-        array('导出订单', '仓库发货订单', ''),
-        array('导出订单明细', '仓库发货订单明细', 'shop/excel.store_buy_order_fa'),
-    );
+    $noprice = 1;
+    if ($search_option_type == 2) {
+        $source_name = '发货仓库';
+        $search_name = '收货仓库';
+        $source_order = -1;
+        $excel = array
+        (
+            array('导出订单', '仓库调拨订单', ''),
+            array('导出订单明细', '仓库调拨订单明细', 'shop/excel.store_buy_order_diao'),
+        );
+    } else {
+        $source_name = '仓库名称';
+        $source_order = -1;
+        $excel = array
+        (
+            array('导出订单', '仓库发货订单', ''),
+            array('导出订单明细', '仓库发货订单明细', 'shop/excel.store_buy_order_fa'),
+        );
+    }
 } elseif ($search_option_source_type == 3) {
     $search_option_type = 3;
     $search_name = '收件人名称';
@@ -103,6 +136,7 @@ if ($search_option_source_type == 2) {
     $search = $search_table . '/info-like';
     $source_name = '工厂名称';
     $source_order = -1;
+    $search_option = $factory;
     $excel = array
     (
         array('导出订单', '工厂发货订单', ''),
@@ -120,6 +154,7 @@ return array
     'status' => $status,
     'refund_status' => $refund_status,
     'config_type' => $type,
+    'out_status' => $out_status,
     'end' => array
     (
         'insert' => 'shop/lib/manage.buyOrderUpdate',
@@ -167,7 +202,8 @@ return array
                 'col' => 'name',
                 'result' => 'id',
             ),
-            //'option'    => $search_option,
+            'search'    => $search_option_type == 3 ? '' : 'select',
+            'option'    => $search_option,
             //'update_search' => $search_url,
             'list'      => 'Dever::load("shop/lib/manage.buyInfo", "{type}", "{type_id}")',
             'list_order' => 2,
@@ -247,6 +283,8 @@ return array
                 'col' => 'name',
                 'result' => 'id',
             ),
+            'search'    => $search_option_type != 1 ? 'select' : false,
+            'option'    => $search_option,
             'list'      => 'Dever::load("shop/lib/manage.buyInfo", "{source_type}", "{source_id}")',
             'list_order' => $source_order,
         ),
@@ -396,6 +434,44 @@ return array
             'list_order' => 9,
         ),
 
+        'out_status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '导出状态',
+            'default'   => '1',
+            'desc'      => '导出状态',
+            'match'     => 'is_numeric',
+            'option'    => $out_status,
+        ),
+
+        'out_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '导出时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+        ),
+
+        'source_out_status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '导出状态',
+            'default'   => '1',
+            'desc'      => '导出状态',
+            'match'     => 'is_numeric',
+            'option'    => $out_status,
+        ),
+
+        'source_out_date'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '导出时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+        ),
+
         'audit'        => array
         (
             'type'      => 'tinyint-1',
@@ -501,7 +577,7 @@ return array
             //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} == 2'),
             //'delete' => array('删除', '', '{status} == 1'),
 
-            'list' => array('查看详情', '"buy_order_goods&project=shop&order_id={id}&page_type=1&types='.$search_option_type.'"'),
+            'list' => array('查看详情', '"buy_order_goods&project=shop&order_id={id}&page_type=1&type='.$type.'&noprice='.$noprice.'"'),
 
             //'oper'  => array('审核', '"mshop/lib/manage.audit?order_id={id}"', '{status} == 2'),
             'fast' => array('审核', '"buy_order&where_id={id}&col=audit,audit_desc&oper_save_jump=buy_order&oper_table=buy_order&oper_parent=buy_order"', '{status} == 2'),
@@ -534,6 +610,9 @@ return array
                 'type_id' => 'yes',
                 'source_type' => 'yes',
                 'source_id' => 'yes',
+                'parent_type' => 'yes',
+                'out_status' => 'yes',
+                'source_out_status' => 'yes',
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
                 'start_o' => array('yes-operdate', '>='),
@@ -561,6 +640,9 @@ return array
                 'type_id' => 'yes',
                 'source_type' => 'yes',
                 'source_id' => 'yes',
+                'parent_type' => 'yes',
+                'out_status' => 'yes',
+                'source_out_status' => 'yes',
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
                 'start_o' => array('yes-operdate', '>='),

+ 1 - 1
app/shop/database/goods_sku.php

@@ -234,7 +234,7 @@ $config = array
         'edit' => false,
         'delete' => false,
         'num' => false,
-        'excel' => true,
+        'excel' => array(array('导出门店库存', '门店库存', '')),
         'page_list_table' => 'sku',
 
         # 自定义快捷新增和编辑

+ 2 - 2
app/shop/database/shop_stat.php

@@ -95,7 +95,7 @@ $config = array
             'desc'      => '采购金额',
             'match'     => 'is_string',
             'search'    => 'order',
-            'list'      => true,
+            'list'      => 'round({buy_cash}, 2)',
         ),
 
         'sell_num'        => array
@@ -116,7 +116,7 @@ $config = array
             'desc'      => '销售金额',
             'match'     => 'is_string',
             'search'    => 'order',
-            'list'      => true,
+            'list'      => 'round({sell_cash}, 2)',
         ),
 
         'sl_num'        => array

+ 25 - 22
app/shop/lib/Cron.php

@@ -344,32 +344,35 @@ class Cron
         $end = Dever::maketime($end . ' 23:59:59');
         $day = intval(($end - $start)/86400);
 
-        $goods = Dever::db('goods/info')->select();
         $shop = Dever::db('shop/info')->select();
 
         foreach ($shop as $k => $v) {
             $where['shop_id'] = $v['id'];
-            foreach ($goods as $k1 => $v1) {
-                $where['goods_id'] = $v1['id'];
-                for($i=0; $i<=$day; $i++) {
-                    $where['start'] = $start + 86400*$i;
-                    $where['end'] = $start + 86400*$i + 86399;
-                    $data = array();
-                    $data['shop_id'] = $v['id'];
-                    $data['goods_id'] = $v1['id'];
-                    $data['day'] = $where['start'];
-                    $info = Dever::db('shop/goods_stat')->find($data);
-                    $cash = Dever::db('shop/sell_order_goods')->getCashNum($where);
-                    $data['cash'] = round($cash['total'], 2);
-                    $data['num'] = Dever::db('shop/sell_order_goods')->getOrderNum($where);
-
-                    $data['area'] = $v['area'];
-                    $data['category'] = $v1['category'];
-                    if (!$info) {
-                        Dever::db('shop/goods_stat')->insert($data);
-                    } else {
-                        $data['where_id'] = $info['id'];
-                        Dever::db('shop/goods_stat')->update($data);
+            $goods = Dever::db('shop/goods')->select(array('shop_id' => $v['shop_id']));
+            if ($goods) {
+                foreach ($goods as $k1 => $v1) {
+                    $where['goods_id'] = $v1['goods_id'];
+                    $goods_info = Dever::db('goods/info')->find($v1['goods_id']);
+                    for($i=0; $i<=$day; $i++) {
+                        $where['start'] = $start + 86400*$i;
+                        $where['end'] = $start + 86400*$i + 86399;
+                        $data = array();
+                        $data['shop_id'] = $v['id'];
+                        $data['goods_id'] = $v1['goods_id'];
+                        $data['day'] = $where['start'];
+                        $info = Dever::db('shop/goods_stat')->find($data);
+                        $cash = Dever::db('shop/sell_order_goods')->getCashNum($where);
+                        $data['cash'] = round($cash['total'], 2);
+                        $data['num'] = Dever::db('shop/sell_order_goods')->getOrderNum($where);
+
+                        $data['area'] = $v['area'];
+                        $data['category'] = $goods_info['category'];
+                        if (!$info) {
+                            Dever::db('shop/goods_stat')->insert($data);
+                        } else {
+                            $data['where_id'] = $info['id'];
+                            Dever::db('shop/goods_stat')->update($data);
+                        }
                     }
                 }
             }

+ 1 - 1
app/shop/lib/Goods.php

@@ -143,7 +143,7 @@ class Goods
                 Dever::db($table . '/goods')->$otherMethod($up);
             }
 
-            if (isset($order['source_type']) && $order['source_type'] == 2 && $type == 1 && $col == 1) {
+            if (isset($order['source_type']) && $order['source_type'] == 2 && $order['type'] != 2 && $type == 1 && $col == 1) {
                 # 如果是仓库发货的,要减少仓库库存
                 $sup['where_store_id'] = $order['source_id'];
                 $sup['where_goods_id'] = $v['goods_id'];

+ 1 - 1
app/shop/lib/Sell.php

@@ -1447,7 +1447,7 @@ class Sell
                     $service[] = array
                     (
                         array('名称', $info['ps_info']['service'][$k]['service_name']),
-                        array('单号', $v['order_num']),
+                        array('单号', isset($v['order_num']) ? $v['order_num'] : ''),
                     );
                 }
             }

+ 68 - 0
app/shop/src/Excel.php

@@ -388,6 +388,74 @@ class Excel
         Dever::excelExport($body, $header, $file);
     }
 
+    # 仓库调拨单
+    public function store_buy_order_diao($data)
+    {
+        if (!$data) {
+            Dever::alert('无导出数据');
+        }
+        $file = Dever::input('excel_name');
+
+
+        $header = array('发货仓库名称', '收货仓库名称', '订货单号', '订货总数量', '商品编码', '商品名称', '规格型号', '订货数量', '订货日期', '发货日期', '订货单状态', '退款状态', '已退商品数量');
+
+        $table = 'store/info';
+
+        $body = array();
+        $status = Dever::db('shop/buy_order')->config['status'];
+        //$refund_status = Dever::db('shop/buy_order')->config['refund_status'];
+
+        foreach ($data as $k => $v) {
+            if (!is_array($v)) {
+                continue;
+            }
+            $info = Dever::db($table)->find($v['type_id']);
+            $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id']));
+            $ps = Dever::db('shop/buy_order_ps')->find(array('order_id' => $v['id']));
+            $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']);
+            $fdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-';
+            $ydate = ($ps && $ps['ydate']) ? date('Y-m-d H:i', $ps['ydate']) : '-';
+            $num = Dever::load("shop/lib/manage.buyInfoRefundNum", $v['id']);
+            $refund_status = Dever::load("shop/lib/manage.buyInfoRefundStatus", $v['id']);
+            $v['refund_cash'] = $v['refund_cash'] ? $v['refund_cash'] : 0;
+
+            $source = Dever::load("shop/lib/manage.buyInfo", $v['source_type'], $v['source_id']);
+            foreach ($goods as $k1 => $v1) {
+
+                $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                if (isset($goods_info['sku'])) {
+                    $sku = $goods_info['sku']['string'];
+                } else {
+                    $sku = '';
+                }
+
+                $d = array
+                (
+                    $source,
+                    $info['name'],
+
+                    $v['order_num'],
+                    $v['num'],
+
+                    $goods_info['code'],
+                    $goods_info['name'],
+                    $sku,
+                    $v1['num'],
+
+                    $cdate,
+                    $fdate,
+                    $status[$v['status']],
+                    $refund_status,
+                    $num,
+                );
+
+                $body[] = $d;
+            }
+        }
+
+        Dever::excelExport($body, $header, $file);
+    }
+
     # 工厂发货单
     public function factory_buy_order_fa($data)
     {

+ 14 - 2
app/store/admin/Auth.php

@@ -332,8 +332,18 @@ class Auth
                 (
                     'order' => array
                     (
-                        'name' => '门店订货单',
-                        'link' => Dever::url('order', 'store'),
+                        'name' => '门店订单发货',
+                        'link' => Dever::url('order?type=1&parent_type=1', 'store'),
+                    ),
+                    'order_1' => array
+                    (
+                        'name' => '平台商城订单发货',
+                        'link' => Dever::url('order?type=1&parent_type=2', 'store'),
+                    ),
+                    'order_2' => array
+                    (
+                        'name' => '库存调拨发货',
+                        'link' => Dever::url('order?type=2&source_type=2', 'store'),
                     ),
                     'factory_order' => array
                     (
@@ -406,6 +416,8 @@ class Auth
             unset($data['set']['child']['user']);
             if (!in_array(2, $role)) {
                 unset($data['order']['child']['order']);
+                unset($data['order']['child']['order_1']);
+                unset($data['order']['child']['order_2']);
                 unset($type[1]);
             }
             if (!in_array(4, $role)) {

+ 294 - 0
app/store/admin/Excel.php

@@ -0,0 +1,294 @@
+<?php
+namespace Store\Admin;
+
+use Dever;
+
+class Excel extends Core
+{
+    public function out($id, $user, $data)
+    {
+        if (!$data) {
+            Dever::alert('无导出数据');
+        }
+        $info = Dever::db('store/info')->find($id);
+        if (!$info) {
+            Dever::alert('操作失败');
+        }
+
+        $method = 'out_' . $info['out_template'];
+        $file = '发货信息表';
+        return $this->$method($file, $user, $data);
+    }
+
+    # 模板模板
+    public function out_1($file, $user, $data)
+    {
+        $this->out_3($file, $user, $data, $file);
+    }
+
+    # 安鲜达模板
+    public function out_2($file, $user, $data, $name = '')
+    {
+        $file = $name ? $name : '安鲜达发货信息表';
+        $body_0 = $body_1 = array();
+
+        $type = Dever::input('type');
+        $parent_type = Dever::input('parent_type');
+        $source_type = Dever::input('source_type');
+
+        if ($type == 1 && $parent_type == 2) {
+            $file .= '-平台商城订单';
+            $header_0 = array('客户订单编号', '收件人姓名', '收件人手机', '收件省份(直辖市)', '收件市(州)', '收件区(县,县级市)', '收件详细地址', '收件人备注', '订单备注', '相关单号', '订单来源');
+
+            $header_1 = array('客户订单编号', '客户货品编码', '销售平台货品编码', '数量', '备注');
+
+            foreach ($data as $k => $v) {
+                if (!is_array($v)) {
+                    continue;
+                }
+
+                Dever::load('mshop/lib/buy')->setOutStatus($v['id'], 2);
+
+                if ($v['ps_info']) {
+                    $ps_date = $v['ps_info']['cdate_day'];
+                } else {
+                    $ps_date = '-';
+                }
+
+                if ($v['parent_type'] == 2) {
+                    $parent_order = Dever::db('shop/sell_order')->find($v['parent_order_id']);
+
+                    if ($parent_order && $parent_order['uid']) {
+                        if ($parent_order['address_id']) {
+                            $address = Dever::load('passport/address')->getOne($parent_order['uid'], $parent_order['address_id']);
+                            $v['type_info']['name'] = $address['contact'];
+                            $v['type_info']['mobile'] = $address['mobile'];
+                            $v['type_info']['address'] = $address['address_info'];
+                            $v['type_info']['province_name'] = $address['province_name'];
+                            $v['type_info']['city_name'] = $address['city_name'];
+                            $v['type_info']['county_name'] = $address['county_name'];
+
+                        } else {
+                            $address = Dever::db('passport/user')->find($parent_order['uid']);
+                            $v['type_info']['name'] = $address['username'];
+                            $v['type_info']['mobile'] = $address['mobile'];
+                            $v['type_info']['address'] = '';
+                            $v['type_info']['province_name'] = $v['type_info']['city_name'] = $v['type_info']['county_name'] = '';
+                        }
+                    }
+                } else {
+                    $info = Dever::db('area/province')->find($v['type_info']['province']);
+                    $v['type_info']['province_name'] = $info['name'];
+
+                    $info = Dever::db('area/city')->find($v['type_info']['city']);
+                    $v['type_info']['city_name'] = $info['name'];
+
+                    $info = Dever::db('area/county')->find($v['type_info']['county']);
+                    $v['type_info']['county_name'] = $info['name'];
+                }
+
+                $body_0[] = array
+                (
+                    $v['order_num'],
+                    $v['type_info']['name'],
+                    $v['type_info']['mobile'],
+                    $v['type_info']['province_name'],
+                    $v['type_info']['city_name'],
+                    $v['type_info']['county_name'],
+                    $v['type_info']['address'],
+                    '',
+                    $v['info'],
+                    '',
+                    '',
+                );
+
+                foreach ($v['goods'] as $k1 => $v1) {
+
+                    $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                    if (isset($goods_info['sku'])) {
+                        $sku = $goods_info['sku']['string'];
+                    } else {
+                        $sku = '';
+                    }
+
+                    $body_1[] = array
+                    (
+                        $v['order_num'],
+                        $goods_info['code'],
+                        $goods_info['name'] . ' ' . $sku,
+                        $v1['num'],
+                        '',
+                    );
+                }
+            }
+
+            $xls = Dever::excelExport($body_0, $header_0, $file, 0, '订单主信息', true);
+
+            if ($xls) {
+                Dever::excelExport($body_1, $header_1, $file, 1, '订单货品明细', false, $xls);
+            }
+        } else {
+            
+
+            $header_0 = array('客户出库单号', '业务单据类型', '预计出库时间', '备注', '门店名称', '收件人', '收件人手机', '收件人电话', '收件人省份', '收件人城市', '收件人区县', '收件人详细地址');
+
+            $header_1 = array('客户出库单号', '货品编码', '应出数量', '库存类型', '批次号');
+
+            if ($type == 2 && $source_type == 2) {
+                $file .= '-仓库调拨订单';
+                $header_0[4] = '仓库名称';
+            } else {
+                $file .= '-门店订单';
+            }
+
+            foreach ($data as $k => $v) {
+                if (!is_array($v)) {
+                    continue;
+                }
+
+                Dever::load('mshop/lib/buy')->setOutStatus($v['id'], 2);
+
+                if ($v['ps_info']) {
+                    $ps_date = $v['ps_info']['cdate_day'];
+                } else {
+                    $ps_date = '-';
+                }
+
+                $info = Dever::db('area/province')->find($v['type_info']['province']);
+                $v['type_info']['province_name'] = $info['name'];
+
+                $info = Dever::db('area/city')->find($v['type_info']['city']);
+                $v['type_info']['city_name'] = $info['name'];
+
+                if (isset($v['type_info']['county']) && $v['type_info']['county']) {
+                    $info = Dever::db('area/county')->find($v['type_info']['county']);
+                    $v['type_info']['county_name'] = $info['name'];
+                } else {
+                    $v['type_info']['county_name'] = '';
+                }
+
+                $body_0[] = array
+                (
+                    $v['order_num'],
+                    '出库单',
+                    $ps_date,
+                    $v['info'],
+                    $v['type_info']['name'],
+                    $v['type_info']['truename'],
+                    $v['type_info']['mobile'],
+                    $v['type_info']['mobile'],
+                    $v['type_info']['province_name'],
+                    $v['type_info']['city_name'],
+                    $v['type_info']['county_name'],
+                    $v['type_info']['address'],
+                );
+
+                foreach ($v['goods'] as $k1 => $v1) {
+
+                    $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                    if (isset($goods_info['sku'])) {
+                        $sku = $goods_info['sku']['string'];
+                    } else {
+                        $sku = '';
+                    }
+
+                    $body_1[] = array
+                    (
+                        $v['order_num'],
+                        $goods_info['code'],
+                        $v1['num'],
+                        '',
+                        '',
+                    );
+                }
+            }
+
+            $xls = Dever::excelExport($body_0, $header_0, $file, 0, '出库单主表', true);
+
+            if ($xls) {
+                Dever::excelExport($body_1, $header_1, $file, 1, '出库单明细', false, $xls);
+            }
+        }
+    }
+
+    # 大连模板
+    public function out_3($file, $user, $data, $name = '')
+    {
+        $header = array();
+
+        $header = array('所属客户', '所属仓库', '出库时间', '收货人编码', '包装箱数', '备注', '货位编码', '商品编码', '计量单位', '批号', '数量', '明细备注');
+
+        $file = $name ? $name : '大连仓发货信息表';
+
+        $body = array();
+
+        $i = 1;
+        foreach ($data as $k => $v) {
+            if (!is_array($v)) {
+                continue;
+            }
+
+            Dever::load('mshop/lib/buy')->setOutStatus($v['id'], 2);
+            if ($v['ps_info']) {
+                $ps_date = $v['ps_info']['cdate_day'];
+            } else {
+                $ps_date = '-';
+            }
+
+            if ($v['parent_type'] == 2) {
+                $parent_order = Dever::db('shop/sell_order')->find($v['parent_order_id']);
+
+                if ($parent_order && $parent_order['uid']) {
+                    if ($parent_order['address_id']) {
+                        $address = Dever::load('passport/address')->getOne($parent_order['uid'], $parent_order['address_id']);
+                        $v['type_info']['name'] = $address['contact'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = $address['address_info'];
+                    } else {
+                        $address = Dever::db('passport/user')->find($parent_order['uid']);
+                        $v['type_info']['name'] = $address['username'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = '';
+                    }
+                }
+            }
+
+            if (!isset($v['type_info']['sid'])) {
+                $v['type_info']['sid'] = '';
+            }
+            
+            foreach ($v['goods'] as $k1 => $v1) {
+
+                $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                if (isset($goods_info['sku'])) {
+                    $sku = $goods_info['sku']['string'];
+                } else {
+                    $sku = '';
+                }
+
+                $d = array
+                (
+                    '简单生活(中食)有限公司',
+                    $v['type_info']['name'],
+                    $ps_date,
+                    $v['type_info']['sid'],
+                    '',
+                    $v['info'],
+                    '',
+                    $goods_info['code'],
+                    $goods_info['unit'],
+                    '',
+                    $v1['num'],
+                    $goods_info['name'] . ' ' . $sku,
+                    
+                );
+
+                $body[] = $d;
+
+                $i++;
+            }
+        }
+
+        Dever::excelExport($body, $header, $file);
+    }
+}

+ 183 - 0
app/store/admin/Factory_excel.php

@@ -0,0 +1,183 @@
+<?php
+namespace Store\Admin;
+
+use Dever;
+
+class Factory_excel extends Core
+{
+    public function out($id, $user, $data)
+    {
+        if (!$data) {
+            Dever::alert('无导出数据');
+        }
+        $info = Dever::db('store/info')->find($id);
+        if (!$info) {
+            Dever::alert('操作失败');
+        }
+
+        $method = 'out_' . $info['out_template'];
+        $file = '入库信息表';
+        return $this->$method($file, $user, $data);
+    }
+
+    # 模板模板
+    public function out_1($file, $user, $data)
+    {
+        Dever::load('mshop/lib/buy')->set(2, 1)->excel($data);
+    }
+
+    # 安鲜达模板
+    public function out_2($file, $user, $data, $name = '')
+    {
+        $file = $name ? $name : '安鲜达入库信息表';
+        $body_0 = $body_1 = array();
+
+        $header_0 = array('客户入库单号', '业务单据类型', '预计入库时间', '备注', '发件人', '发件人手机', '发件人电话', '发件人省', '发件人城市', '发件人区县', '发件人详细地址');
+
+        $header_1 = array('客户入库单号', '货品编码', '应收数量', '库存类型');
+
+        foreach ($data as $k => $v) {
+            if (!is_array($v)) {
+                continue;
+            }
+
+            Dever::load('mshop/lib/buy')->setOutStatus($v['id'], 1);
+
+            if ($v['ps_info']) {
+                $ps_date = $v['ps_info']['ydate_day'];
+            } else {
+                $ps_date = '-';
+            }
+
+            $info = Dever::db('area/province')->find($v['source_info']['province']);
+            $v['source_info']['province_name'] = $info['name'];
+
+            $info = Dever::db('area/city')->find($v['source_info']['city']);
+            $v['source_info']['city_name'] = $info['name'];
+
+            if (isset($v['source_info']['county']) && $v['source_info']['county']) {
+                $info = Dever::db('area/county')->find($v['source_info']['county']);
+                $v['source_info']['county_name'] = $info['name'];
+            } else {
+                $v['source_info']['county_name'] = '';
+            }
+            
+
+            $body_0[] = array
+            (
+                $v['order_num'],
+                '入库单',
+                $ps_date,
+                $v['info'],
+                $v['source_info']['name'],
+                $v['source_info']['mobile'],
+                $v['source_info']['mobile'],
+                $v['source_info']['province_name'],
+                $v['source_info']['city_name'],
+                $v['source_info']['county_name'],
+                $v['source_info']['address'],
+            );
+
+            foreach ($v['goods'] as $k1 => $v1) {
+
+                $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                if (isset($goods_info['sku'])) {
+                    $sku = $goods_info['sku']['string'];
+                } else {
+                    $sku = '';
+                }
+
+                $body_1[] = array
+                (
+                    $v['order_num'],
+                    $goods_info['code'],
+                    $v1['num'],
+                    '正品',
+                );
+            }
+        }
+
+        $xls = Dever::excelExport($body_0, $header_0, $file, 0, '入库单主表', true);
+
+        if ($xls) {
+            Dever::excelExport($body_1, $header_1, $file, 1, '入库单明细', false, $xls);
+        }
+    }
+
+    # 大连模板
+    public function out_3($file, $user, $data, $name = '')
+    {
+        $header = array();
+
+        $header = array('所属客户', '商品编码', '数量', '商品供应商', '计量单位', '重量(kg)', '批号', '体积(m3)', '备注');
+
+        $file = $name ? $name : '大连仓入库信息表';
+
+        $body = array();
+
+        $i = 1;
+        foreach ($data as $k => $v) {
+            if (!is_array($v)) {
+                continue;
+            }
+
+            Dever::load('mshop/lib/buy')->setOutStatus($v['id'], 1);
+            if ($v['ps_info']) {
+                $ps_date = $v['ps_info']['cdate_day'];
+            } else {
+                $ps_date = '-';
+            }
+
+            if ($v['parent_type'] == 2) {
+                $parent_order = Dever::db('shop/sell_order')->find($v['parent_order_id']);
+
+                if ($parent_order && $parent_order['uid']) {
+                    if ($parent_order['address_id']) {
+                        $address = Dever::load('passport/address')->getOne($parent_order['uid'], $parent_order['address_id']);
+                        $v['type_info']['name'] = $address['contact'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = $address['address_info'];
+                    } else {
+                        $address = Dever::db('passport/user')->find($parent_order['uid']);
+                        $v['type_info']['name'] = $address['username'];
+                        $v['type_info']['mobile'] = $address['mobile'];
+                        $v['type_info']['address'] = '';
+                    }
+                }
+            }
+
+            if (!isset($v['type_info']['sid'])) {
+                $v['type_info']['sid'] = '';
+            }
+            
+            foreach ($v['goods'] as $k1 => $v1) {
+
+                $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+                if (isset($goods_info['sku'])) {
+                    $sku = $goods_info['sku']['string'];
+                } else {
+                    $sku = '';
+                }
+
+                $d = array
+                (
+                    '厨人易料',
+                    $goods_info['code'],
+                    $v1['num'],
+                    $v['source_info']['name'],
+                    $goods_info['unit'],
+                    $goods_info['weight'],
+                    '',
+                    '',
+                    $v['info'],
+                );
+
+                $body[] = $d;
+
+                $i++;
+            }
+        }
+
+        Dever::excelExport($body, $header, $file);
+    }
+}

+ 41 - 4
app/store/admin/Factory_order.php

@@ -8,13 +8,14 @@ class Factory_order extends Core
 	# 订单列表
     public function getList()
     {
-        $data = Dever::load('mshop/lib/buy')->set(2, 1)->getList($this->id);
+        $data = Dever::load('mshop/lib/buy')->set(2, 1)->getList($this->id, '4,5,6');
 
         $html = '';
+        $out_status = Dever::db('shop/buy_order')->config['out_status'];
         $excel = Dever::input('excel', 1);
         if ($data && $data['order']) {
             if ($excel == 2) {
-                Dever::load('mshop/lib/buy')->set(2, 1)->excel($data['order']);
+                Dever::load('store/admin/factory_excel')->out($this->id, $this->user, $data['order']);
                 die;
                 return;
             }
@@ -44,9 +45,20 @@ class Factory_order extends Core
                 }
 
                 $url = Dever::url('lib/buy.excel_one?type='.$v['type'].'&type_id='.$v['type_id'].'&id='.$v['id'], 'mshop');
-                $button .= '&nbsp;&nbsp;<a href="'.$url.'"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">导出</button></a>';
 
-        		$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>';
+                if ($v['status'] == 5 || $v['status'] == 6 || $v['status'] == 8) {
+                    $button .= '&nbsp;&nbsp;<a href="'.$url.'"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">导出</button></a>';
+                }
+
+                $v['out_status_name'] = $out_status[$v['out_status']];
+
+                $dao_date = '-';
+                if ($v['out_date']) {
+                    $dao_date = date('Y-m-d H:i', $v['out_date']);
+                }
+
+
+        		$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>'.$v['out_status_name'].'</td><td>'.$dao_date.'</td><td>'.$button.'</td></tr>';
         	}
         }
         return $html;
@@ -78,6 +90,31 @@ class Factory_order extends Core
         return $html;
     }
 
+    # 获取列表页搜索信息
+    public function getSearchOutStatus()
+    {
+        $config = array
+        (
+            array('value' => '0', 'name' => '全部'),
+            array('value' => 1, 'name' => '未导出'),
+            array('value' => 2, 'name' => '已导出'),
+        );
+
+        $status = Dever::input('source_out_status');
+
+        $html = '';
+        foreach ($config as $k => $v) {
+            $selected = '';
+            if ((!$status && $k == 0) || $status == $v['value']) {
+                $selected = 'selected=""';
+            } 
+
+            $html .= '<option value="'.$v['value'].'" '.$selected.'>'.$v['name'].'</option>';
+        }
+
+        return $html;
+    }
+
     # 获取列表页搜索信息
     public function getService()
     {

+ 41 - 1
app/store/admin/Order.php

@@ -39,6 +39,14 @@ class Order extends Core
 
         $html = '';
         if ($data && $data['order']) {
+            $out_status = Dever::db('shop/buy_order')->config['out_status'];
+            $excel = Dever::input('excel', 1);
+            if ($excel == 2) {
+                Dever::load('store/admin/excel')->out($this->id, $this->user, $data['order']);
+                die;
+                return;
+            }
+
         	foreach ($data['order'] as $k => $v) {
         		if ($v['ps_info']) {
         			$ps_date = $v['ps_info']['cdate'];
@@ -85,7 +93,14 @@ class Order extends Core
                     }
                 }
 
-        		$html .= '<tr><td><input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="'.$v['id'].'"/></td><td>'.$v['order_num'].'</td><td>'.$v['operdate'].'</td><td>'.$v['type_info']['name'].'</td><td>'.$ps_date.'</td><td>'.$v['num'].'</td><td>'.$v['status_name'].'</td><td>'.$button.'</td></tr>';
+                $v['out_status_name'] = $out_status[$v['source_out_status']];
+
+                $dao_date = '-';
+                if ($v['source_out_date']) {
+                    $dao_date = date('Y-m-d H:i', $v['source_out_date']);
+                }
+
+        		$html .= '<tr><td><input type="checkbox" name="mul_where_id[]" class="checkbox-checkall-list" lay-ignore value="'.$v['id'].'"/></td><td>'.$v['order_num'].'</td><td>'.$v['operdate'].'</td><td>'.$v['type_info']['name'].'</td><td>'.$ps_date.'</td><td>'.$v['num'].'</td><td>'.$v['status_name'].'</td><td>'.$v['out_status_name'].'</td><td>'.$dao_date.'</td><td>'.$button.'</td></tr>';
         	}
         }
         return $html;
@@ -119,6 +134,31 @@ class Order extends Core
         return $html;
     }
 
+    # 获取列表页搜索信息
+    public function getSearchOutStatus()
+    {
+        $config = array
+        (
+            array('value' => '0', 'name' => '全部'),
+            array('value' => 1, 'name' => '未导出'),
+            array('value' => 2, 'name' => '已导出'),
+        );
+
+        $status = Dever::input('source_out_status');
+
+        $html = '';
+        foreach ($config as $k => $v) {
+            $selected = '';
+            if ((!$status && $k == 0) || $status == $v['value']) {
+                $selected = 'selected=""';
+            } 
+
+            $html .= '<option value="'.$v['value'].'" '.$selected.'>'.$v['name'].'</option>';
+        }
+
+        return $html;
+    }
+
     # 获取列表页搜索信息
     public function getService()
     {

+ 27 - 25
app/store/assets/pc/html/cashier.html

@@ -4,7 +4,7 @@
 <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>
+<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">
@@ -35,10 +35,10 @@
 		<div class="main_right layui-col-xs12 layui-col-md9">
 			<div class="layui-row">
 				<div class="top">
-					<label>选择仓库:</label>
+					<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><select xm-select="source_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="source_id" id="source_id"  ></select></div>
 
 					</div>
 					<div class="layui-input-inline">
@@ -51,7 +51,6 @@
 							<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:'number', edit: 'text'}">数量</th>
 								<th lay-data="{field:'operation'}">操作</th>
 							</tr>
@@ -62,12 +61,12 @@
 					</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>选择收货仓库</td>
 							<td colspan="3">
 								<div class="layui-input-inline">
 									<select xm-select="store_id" xm-select-skin="normal" xm-select-search="<{$search_store}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="store_id" id="store_id"  ></select>
@@ -105,7 +104,7 @@
 					</tbody>
 				</table>
 				<div class="towbtn">
-					<input type="button" id="settlement" value="订货下单">
+					<input type="button" id="settlement" value="确定调拨">
 				</div>
 			</div>
 		</div>
@@ -192,23 +191,22 @@
 	{
 		$("#settlement").click(function(){
 			var url = '<{$submit}>';
-			var store_id = '<{$store_id}>';
+			var source_id = '<{$source_id}>';
 			var store_id = $('.xm-select-parent[fs_id="store_id"] span[fsw="xm-select"]').attr('value');
-			console.info(store_id);
 			if (!store_id) {
-				layui.layer.alert('请选择仓库');
+				layui.layer.alert('请选择收货仓库');
 				return;
 			}
 
-			layui.layer.confirm('确定订货下单吗?', function() {
+			layui.layer.confirm('确定进行仓库调拨吗?', function() {
 				var info = $('#info').val();
 				var goods_string = JSON.stringify(goods);
 
 				var data = {};
-				data = {store_id:store_id, store_id:store_id, goods:goods_string, info:info};
+				data = {source_id:source_id, store_id:store_id, goods:goods_string, info:info};
 				$.getJSON(url, data, function(t) {
 					if (t.status == 1) {
-						layui.layer.alert('订货下单成功', function(index){
+						layui.layer.alert('仓库库存调拨下单成功', function(index){
 						  location.href = t.data;
 						  layer.close(index);
 						});
@@ -230,8 +228,14 @@
 				num = 1;
 				$(this).val(1);
 			}
+
 	        var id = $(this).parent().attr('value');
-	        goods[id].num = num;
+	        if (num >= goods[id].total) {
+	        	num = goods[id].total;
+				$(this).val(num);
+			}
+
+			goods[id].num = num;
 			setTotal();
 		})
 	})
@@ -267,7 +271,6 @@
   			var key = node.id;
   			if (!goods[key]) {
   				goods[key] = node;
-  				goods[key].price = parseFloat(goods[key].price);
   				goods[key].num = 1;
   				create(node);
   				setTotal();
@@ -288,8 +291,7 @@
 		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_name">'+node.name+'</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>';
@@ -299,6 +301,9 @@
 
 	function add(id)
 	{
+		if (goods[id].num >= goods[id].total) {
+			return;
+		}
 		goods[id].num += 1;
 		get(id).find('.goods_num').val(goods[id].num);
 		setTotal();
@@ -336,25 +341,22 @@
 	
 	function setTotal()
 	{
-		var cash = 0;
 		var num = 0;
 		for (var i in goods) {
 			num += goods[i].num;
-			cash += goods[i].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('请选择仓库');
+		var source_id = $('.xm-select-parent[fs_id="source_id"] span[fsw="xm-select"]').attr('value');
+		if (!source_id) {
+			layui.layer.alert('请选择发货仓库');
 			return;
 		}
-		layui.layer.confirm('确定切换仓库吗?切换后现在选择的商品都将清空', function() {
-			location.href = '<{$host}>&store_id=' + store_id;
+		layui.layer.confirm('确定切换发货仓库吗?切换后现在选择的商品都将清空', function() {
+			location.href = '<{$host}>&source_id=' + source_id;
 		});
 	}
 </script>

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
app/store/assets/pc/html/factory_order.html


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

@@ -17,13 +17,22 @@
       <input type="hidden" name="function" id="function" value="msg">
       <input type="hidden" name="l" id="l" value="order">
       <input type="hidden" name="method" id="method" value="search">
+      <input type="hidden" name="type" id="type" value="">
+      <input type="hidden" name="source_type" id="source_type" value="">
+      <input type="hidden" name="parent_type" id="parent_type" value="">
       <div id="search_param"></div> 
       <iframe id="f1" name="f1" style="display:none;"></iframe>
         <div class="layui-card-body" id="search_content" style="">
 
           <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>&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;display:none;">批量打印备货单</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"><div class="layui-input-inline"><select lay-ignore="" xm-select-radio="" class="update_value form-control layui-input layui-select   " name="source_out_status" id="source_out_status"><option value="0" selected="">导出状态</option><option parent="" value="1">未导出</option><option parent="" value="2">已导出</option></select></div></div>
+
+
+              <div class="layui-inline"><input type="hidden" value="1" 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;display:none;">批量打印备货单</button>&nbsp;&nbsp;<button class="btn btn-primary layui-btn layuiadmin-btn-list layui-btn-warm" onclick="$('#excel').val(2);list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">导出</button></div></div></div></div>
             </div>
           </div>
         </div>
@@ -39,7 +48,7 @@
         <div id="table_2" style="display:"> 
           <table class="table layui-table layui-table-body" id="table">
           <thead id="list-thead">
-              <tr><th data-priority="1"><input type="checkbox" class="checkbox-checkall" name="checkall" id="checkall" value="list" lay-ignore/></th><th data-priority="1">订单号</th><th data-priority="1">订货日期</th><th data-priority="1">订单收件人</th><th data-priority="1">发货日期</th><th data-priority="1">数量</th><th data-priority="1">订单状态</th><th data-priority="1" class="dever-manage">管理</th></tr>
+              <tr><th data-priority="1"><input type="checkbox" class="checkbox-checkall" name="checkall" id="checkall" value="list" lay-ignore/></th><th data-priority="1">订单号</th><th data-priority="1">订货日期</th><th data-priority="1">订单收件人</th><th data-priority="1">发货日期</th><th data-priority="1">数量</th><th data-priority="1">订单状态</th><th data-priority="1">导出状态</th><th data-priority="1">导出时间</th><th data-priority="1" class="dever-manage">管理</th></tr>
           </thead>
           <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>

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

@@ -35,7 +35,7 @@
         <div class="main_right layui-col-xs12 layui-col-md9">
             <div class="layui-row">
                 <div class="top">
-                    <label>选择门店</label>
+                    <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>

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

@@ -6,6 +6,12 @@ $status = array
     2 => '认证中',
     3 => '认证失败',
 );
+$out_template = array
+(
+    1 => '默认模板',
+    2 => '安鲜达',
+    3 => '大连唯捷',
+);
 $stat_type = Dever::db('cash/shop')->config['config_type'];
 return array
 (
@@ -15,6 +21,7 @@ return array
     'lang' => '仓库列表',
     # 后台菜单排序
     'order' => 99,
+    'out_template' => $out_template,
     'end' => array
     (
         'insert' => 'store/lib/manage.infoUpdate',
@@ -105,7 +112,7 @@ return array
             'match'     => 'option',
             'search'    => 'linkage',
             'update'    => 'linkage',
-            'option'    => Dever::url('api.get?level_total=2', 'area'),
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
             'list'      => 'Dever::load("area/api.string", "{area}")',
         ),
 
@@ -129,6 +136,16 @@ return array
             //'update'  => 'text',
         ),
 
+        'county'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '县区',
+            'default'   => '',
+            'desc'      => '县区',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
         'map'       => array
         (
             'type'      => 'varchar-300',
@@ -297,6 +314,19 @@ return array
             'show'      => 'stat_type=1,2',
         ),
 
+        'out_template'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '导出模板-供应链管理中导出的表格模板',
+            'default'   => '1',
+            'desc'      => '导出模板',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $out_template,
+            'list'      => true,
+            'edit'      => true,
+        ),
+
         'reorder'       => array
         (
             'type'      => 'int-11',

+ 26 - 0
app/store/lib/Manage.php

@@ -19,6 +19,10 @@ class Manage
             $temp = is_string($area) ? explode(',', $area) : $area;
             $update['province'] = $temp[0];
             $update['city'] = $temp[1];
+            if (isset($temp[2])) {
+                $update['county'] = $temp[2];
+            }
+            
         }
 
         $map = Dever::param('map', $data);
@@ -190,4 +194,26 @@ class Manage
     {
         return Dever::search('store/info');
     }
+
+    # 获取仓库的商品列表
+    public function goods_api()
+    {
+        $source_id = Dever::input('source_id', 1);
+        return Dever::outDiy(Dever::load('store/lib/goods')->getSkuList($source_id));
+    }
+
+    # 获取收银台
+    public function cashier_api()
+    {
+        $data = array();
+        $data['source_id'] = Dever::input('source_id', 1);
+        $data['host'] = Dever::url('lib/manage.cashier', 'store');
+        $data['url'] = Dever::url('lib/manage.goods?source_id=' . $data['source_id'], 'store');
+        $data['search'] = Dever::url('lib/manage.search?yes='.$data['source_id'].'&json=1', 'store');
+        $data['search_store'] = Dever::url('lib/manage.search?json=1', 'store');
+        $data['submit'] = Dever::url('lib/order.action_commit?json=1', 'store');
+
+        
+        return Dever::render('cashier', $data);
+    }
 }

+ 135 - 0
app/store/lib/Order.php

@@ -0,0 +1,135 @@
+<?php
+
+namespace Store\Lib;
+
+use Dever;
+
+class Order
+{
+    # 得到商品和总价
+    private function goods()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+
+        $this->data['price'] = 0;
+        $this->data['p_price'] = 0;
+        $this->data['num'] = 0;
+        $this->data['name'] = array();
+        $source_id = Dever::input('source_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'];
+
+            $where['store_id'] = $source_id;
+            $where['goods_id'] = $v['id'];
+            $where['sku_id'] = $s;
+
+            $goods_sku = Dever::db('store/goods_sku')->getOne($where);
+
+            $this->data['list'][$k] = Dever::load('goods/lib/info')->getPayInfo($v['id'], $s, 2);
+            if (isset($this->data['list'][$k]['min']) && $this->data['list'][$k]['min'] > 0) {
+                if ($n < $this->data['list'][$k]['min']) {
+                    //$n = $this->data['list'][$k]['min'];
+                }
+            }
+
+            if ($goods_sku && $goods_sku['total'] < $n) {
+                $n = $goods_sku['total'];
+            }
+
+            $this->data['list'][$k]['num'] = $n;
+            $this->data['list'][$k]['buy_num'] = $n;
+            $this->data['num'] += $n;
+
+            $price = $this->data['list'][$k]['price'];
+            $this->data['price'] += $price * $n;
+            $this->data['name'][] = $this->data['list'][$k]['name'];
+        }
+
+        $this->data['name'] = implode(',', $this->data['name']);
+    }
+
+    # 下单
+    public function action_commit_api()
+    {
+        $info = Dever::input('info');
+
+        $this->goods();
+        
+        $order_data['type'] = 2;
+        $order_data['type_id'] = Dever::input('store_id');
+        $order_data['source_id'] = Dever::input('source_id');
+        if ($order_data['type_id'] == $order_data['source_id']) {
+            Dever::alert('发货仓库和收货仓库不能相同');
+        }
+        $order_data['source_type'] = 2;
+        $order_data['name'] = $this->data['name'];
+        $order_data['num'] = $this->data['num'];
+        $order_data['info'] = $info;
+        $order_data['price'] = $this->data['price'];
+        $order_data['p_price'] = 0;
+        $order_data['operdate'] = time();
+        $order_data['status'] = 3;
+
+        $order_data['order_num'] = $this->getOrderId();
+        $order_data['refund_cash'] = 0;
+        $order_data['refund_p_cash'] = 0;
+        $id = Dever::db('shop/buy_order')->insert($order_data);
+
+        if (!$id) {
+            Dever::alert('下单失败');
+        }
+
+        $order_data['id'] = $id;
+
+        $buy_order_goods = array();
+        foreach($this->data['list'] as $k => $v) {
+            $data['order_id'] = $id;
+            $data['goods_id'] = $v['id'];
+            $data['sku_id'] = $v['sku_id'];
+            $data['price'] = $v['price'];
+            $data['p_price'] = 0;
+            $data['num'] = $v['buy_num'];
+
+            $state = Dever::db('shop/buy_order_goods')->insert($data);
+
+            if ($state) {
+                $buy_order_goods[$k] = $data;
+                $buy_order_goods[$k]['id'] = $state;
+            }
+        }
+
+        Dever::load('cash/lib/order')->up($order_data, 1, 1);
+
+        # 减少发货库存
+        if ($buy_order_goods) {
+            Dever::load('store/lib/goods')->oper($order_data['source_id'], 1, 2, $buy_order_goods);
+        }
+        
+
+        return Dever::url('project/database/list&project=shop&table=buy_order&menu=shop&menu_id=77&search_option_state=1&search_option_type=2&search_option_source_type=2', 'manage');
+    }
+
+    # 生成订单号
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('C');
+        $state = Dever::db('shop/buy_order')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+}

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

@@ -9,6 +9,7 @@ $view
 # 定义名称
 ->fetch('#content_2@test', '1')  
 ->fetch('#status', 'store/admin/order.getSearch') 
+->fetch('#source_out_status', 'store/admin/order.getSearchOutStatus') 
 ->fetch('#form1@action', 'store/admin/order.getConfig#search') 
 
 ->fetch('#list-tbody', 'store/admin/order.getList') 
@@ -18,6 +19,10 @@ $view
 ->fetch('#start@value', '<{Dever::input("start")}>') 
 ->fetch('#end@value', '<{Dever::input("end")}>')  
 
+->fetch('#type@value', '<{Dever::input("type")}>')  
+->fetch('#parent_type@value', '<{Dever::input("parent_type")}>')  
+->fetch('#source_type@value', '<{Dever::input("source_type")}>')  
+
 ->fetch('#page','<{Dever::page("current")}>') 
 
 # display

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor