Browse Source

发货申请单导出

wufeng 2 years ago
parent
commit
2a6980e1b7
3 changed files with 79 additions and 4 deletions
  1. 3 3
      app/admin/controller/Purch.php
  2. 71 0
      app/admin/controller/Sale.php
  3. 5 1
      app/admin/route/app.php

+ 3 - 3
app/admin/controller/Purch.php

@@ -694,10 +694,10 @@ class Purch extends Base
 
         $i = 1;
         $send_type = [1 => '直接发货', 2 => '延时发货'];
-        $status = [0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => ''];
+        $status = [0 => '待与供应商确认', 1 => '待入库', 2 => '部分入库', 3 => '入库完成', 4 => '已取消订单'];
         $list = Db::name("purchease_order")
             ->alias('po')
-            ->field('"" as 序号,po.addtime as 创建时间,po.cgdNo as 单据号,po.status as 单据状态,po.cgder as 采购员,s.orderCode as 确认单号,s.addtime as 确认单时间,po.spuCode as 产品编号,po.good_name as 产品名称,"" as 规格,"" as 单位,po.supplier_name as 供应商名称,po.supplierNo as 供应商编号,po.nake_fee as 裸价,po.delivery_fee as 物流费,s.send_type as 发货方式,po.good_price as 采购单价,s.remark as 确认单备注,po.good_num as 采购数量,po.total_fee as 采购货款,b.company as 购买方公司,s.arrive_time as 到货时间,po.order_type')
+            ->field('"" as 序号,po.addtime as 创建时间,po.cgdNo as 采购单编号,po.status as 采购单状态,po.cgder as 采购员,s.orderCode as 确认单号,s.addtime as 确认单时间,po.spuCode as 产品编号,po.good_name as 产品名称,"" as 规格,"" as 单位,po.supplier_name as 供应商名称,po.supplierNo as 供应商编号,po.nake_fee as 裸价,po.delivery_fee as 物流费,s.send_type as 发货方式,po.good_price as 采购单价,s.remark as 确认单备注,po.good_num as 采购数量,po.total_fee as 采购货款,b.company as 购买方公司,s.arrive_time as 到货时间,po.order_type')
             ->whereIn('po.cgdNo', $cgdNos)
             ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
             ->leftJoin('sale s', 's.orderCode=on.orderCode')
@@ -705,7 +705,7 @@ class Purch extends Base
             ->order("po.addtime desc")
             ->withAttr('序号', function () use (&$i) {
                 return $i++;
-            })->withAttr('单状态', function ($val) use ($status) {
+            })->withAttr('采购单状态', function ($val) use ($status) {
                 return isset($status[$val]) ? $status[$val] : '';
             })->withAttr('发货方式', function ($val) use ($send_type) {
                 return isset($send_type[$val]) ? $send_type[$val] : '';

+ 71 - 0
app/admin/controller/Sale.php

@@ -3450,4 +3450,75 @@ class Sale extends Base
         $order["noble_weight"] = isset($order['weight'])?$order['weight']:0;
         return app_show(0,"获取成功",$order);
     }
+
+    //发货申请单导出
+    public function exportSaleOut()
+    {
+        $outCodes = $this->request->post('outCodes', [], 'trim');
+
+        if (empty($outCodes)) return error_show(1004, '要导出的发货申请单编号不能为空');
+
+        $i = 1;
+        $send_type = [1 => '直接发货', 2 => '延时发货'];
+        $status = [0 => '待发货', 1 => '待库管发货', 2 => '已发货待收货', 3 => '已收货', 4 => '已全部退货'];
+        $list = Db::name("order_out")
+            ->alias('a')
+            ->field('"" as 序号,a.addtime as 创建时间,po.cgdNo as 采购单编号,po.status as 采购单状态,po.cgder as 采购员,b.orderCode as 确认单号,b.addtime as 确认单时间,b.good_code as 产品编号,b.good_name as 产品名称,"" as 规格,"" as 单位,wi.name as 供应商名称,s.code as 供应商编号,po.nake_fee as 裸价,a.post_fee as 物流费,b.send_type as 发货方式,po.good_price as 采购单价,b.remark as 确认单备注,po.good_num as 采购数量,po.total_fee as 采购货款,oa.contactor as 收货人,oa.mobile as 联系方式,oa.addr as 收货地址,oa.arrive_time as 到货时间,po.order_type')
+            ->whereIn('a.outCode', $outCodes)
+            ->order("a.addtime desc")
+            ->withAttr('序号', function () use (&$i) {
+                return $i++;
+            })->withAttr('采购单状态', function ($val) use ($status) {
+                return isset($status[$val]) ? $status[$val] : '';
+            })->withAttr('发货方式', function ($val) use ($send_type) {
+                return isset($send_type[$val]) ? $send_type[$val] : '';
+            })
+            ->leftJoin("sale b", "b.orderCode=a.orderCode")
+            ->leftJoin("order_addr oa", "oa.id=a.addrid AND oa.is_del=0")
+            ->leftJoin("warehouse_info wi", "wi.wsm_code=a.wsm_code AND wi.is_del=0")
+            ->leftJoin("supplier s", "s.code=wi.supplierNo AND s.is_del=0")
+            ->leftJoin('order_send os', 'os.outCode=a.outCode ')
+            ->leftJoin("purchease_order po", "po.cgdNo=os.cgdNo AND po.is_del=0")
+            ->select()
+            ->toArray();
+
+        foreach ($list as &$value) {
+
+            if ($value['order_type'] == 3 || $value['order_type'] == 4) {
+                $temp = Db::name("good_zixun")
+                    ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
+                    ->field('id,specinfo,good_unit')
+                    ->find();
+                $good_unit = isset($temp['good_unit']) ? $temp['good_unit'] : 0;
+                $specinfo = isset($temp['specinfo']) ? json_decode($temp['specinfo'], true) : [];
+
+                $speclist = [];
+                foreach ($specinfo as $val) {
+                    $speclist[] = $val['spec_name'] . ':' . $val['spec_value_name'];
+                }
+            } else {
+                $good_unit = Db::name('good_basic')
+                    ->where(['spuCode' => $value['产品编号']])
+                    ->value('good_unit', 0);
+                $spec = Db::name("good_spec")
+                    ->field('id,spec_id,spec_value_id')
+                    ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
+                    ->select()
+                    ->toArray();
+                $speclist = [];
+                if (!empty($spec)) {
+                    foreach ($spec as $val) {
+                        $speclist[] = Db::name("specs")->where(["id" => $val['spec_id']])->value('spec_name', '') . ':' . Db::name("spec_value")->where(["id" => $val['spec_value_id']])->value('spec_value', '');
+                    }
+                }
+            }
+
+            $value['规格'] = empty($speclist) ? '' : implode(',', $speclist);;
+            $value['单位'] = $good_unit ? Db::name('unit')->where(['id' => $good_unit, 'is_del' => 0])->value('unit', '') : '';
+            unset($value['order_type']);
+        }
+
+        $headerArr = array_keys($list[0]);
+        excelSave('发货申请单导出' . date('YmdHis') . '.xls', $headerArr, $list);
+    }
 }

+ 5 - 1
app/admin/route/app.php

@@ -103,6 +103,7 @@ Route::rule('saleaddr','admin/Sale/addAddr');
 Route::rule('salegetprice','admin/Sale/getPrice');
 Route::rule('goodzxinfo','admin/Sale/goodzxinfo');
 Route::rule('getgoodzxinfobynotzixun','admin/Sale/getGoodZxInfoByNotZixun');
+Route::rule('exportsaleout','admin/Sale/exportSaleOut');//发货申请单导出
 
 Route::rule('checkflist','admin/Check/flist');
 Route::rule('checklist','admin/Check/list');
@@ -477,4 +478,7 @@ Route::rule('getonlinegoodinfo','admin/OrderImport/getOnlineGoodInfoByPlatcode')
 Route::rule('getsourcedata','admin/OrderImport/getSourceDataByPlatformId');//获取销售渠道备选数据
 Route::rule('confirmimportdata','admin/OrderImport/confirmImportData');//用户确认
 Route::rule('relationstockbatch','admin/OrderImport/relationStockBatch');//用户批量关联库存
-Route::rule('delimportorder','admin/OrderImport/delImportData');//删除【待用户确认】的订单
+Route::rule('delimportorder','admin/OrderImport/delImportData');//删除【待用户确认】的订单
+
+//报表-采购日报表-咨询单总数
+Route::rule('reportzixuntotal','admin/Report/zixunTotal');