Forráskód Böngészése

增加发货日志

cqp 9 hónapja
szülő
commit
58c3ba2f86
2 módosított fájl, 31 hozzáadás és 8 törlés
  1. 23 8
      app/Service/Box/BoxService.php
  2. 8 0
      config/logging.php

+ 23 - 8
app/Service/Box/BoxService.php

@@ -2,21 +2,19 @@
 
 namespace App\Service\Box;
 
-
 use App\Model\Box;
 use App\Model\BoxDetail;
 use App\Model\DispatchSub;
 use App\Model\Header_ext;
 use App\Model\OrdersProduct;
-use App\Model\OrdersProductBom;
 use App\Model\OrdersProductProcess;
 use App\Model\SaleOrdersProduct;
 use App\Model\Team;
-use App\Service\DispatchService;
 use App\Service\FinishedOrderService;
 use App\Service\FyySqlServerService;
 use App\Service\Service;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 
 /**
  * 包装相关
@@ -401,6 +399,9 @@ class BoxService extends Service
 
     public function saveOutOrderRule($data,$user){
         if(empty($data['out_data'])) return [false, '未获取到发货数据,操作失败!'];
+
+        Log::channel('sendData')->info('发货:提交包装单数据', ["param" => $data]);
+
         //客户校验
         $customer_code = array_column($data['out_data'],'customer_code');
         $isAllSame = count(array_unique($customer_code)) === 1;
@@ -673,7 +674,6 @@ class BoxService extends Service
     public function boxOrderDetail($data)
     {
         list($status, $data) = self::$box_hook->boxDetail($data);
-//        var_dump($data);die;
         $sale_orders_product_ids = [];
         foreach ($data as $v){
             $sale_orders_product_ids[] = $v['top_id'];
@@ -740,7 +740,6 @@ class BoxService extends Service
         $team_key_list = Team::pluck('title','id')->toArray();
         foreach ($list as &$v){
             $detail = $sale_orders_key_product[$v['top_id']];
-//            var_dump($detail);die;
             $v['customer_name'] = $detail['customer_name'];
             $v['table_body_mark'] = $detail['table_body_mark'];
             $v['ext_4'] = $detail['product_title'];
@@ -768,10 +767,23 @@ class BoxService extends Service
             }
         }
 
-        $list = $list->select('top_order_no','order_no as box_no','crt_time','shipment_order_no')->where('del_time',0)
+        $list = $list->select('top_order_no','order_no as box_no','crt_time','shipment_order_no','out_order_no')->where('del_time',0)
             ->get()->toArray();
 
         foreach ($list as $key => $value){
+            $model = new BoxDetail(['channel'=> $value['top_order_no']]);
+            $tmp = $model->where('del_time',0)
+                ->where('order_no',$value['box_no'])
+                ->where('out_order_no',$value['out_order_no'])
+                ->select('order_no','out_order_no','orders_product_id')
+                ->first();
+            $production_no = "";
+            if(! empty($tmp)){
+                $production_no = OrdersProduct::where('id',$tmp->orders_product_id)->select('production_no')->pluck('production_no')->toArray();
+                $production_no = $production_no[0];
+            }
+
+            $list[$key]['production_no'] = $production_no;
             $list[$key]['crt_time'] = date('Y-m-d H:i:s',$value['crt_time']);
         }
 
@@ -1103,13 +1115,16 @@ class BoxService extends Service
         if(empty($data['order_nos'])) return [false, '包装单号不能为空'];
         $order_nos = $data['order_nos'];
         $order_nos = array_unique($order_nos);
+
+        Log::channel('sendData')->info('发货:扫码包装单数据', ["param" => $order_nos]);
+
         $list = Box::where('del_time',0)
             ->whereIn('order_no',$order_nos)
-            ->select('order_no','out_order_no','top_order_no','shipment_order_no as transport_no')
+            ->select('order_no','out_order_no','top_order_no','shipment_order_no as transport_no','upd_time')
             ->get()->toArray();
         $detail_list = [];
         foreach ($list as $v){
-            if(! empty($v['transport_no'])) return [false, "包装单号:" . $v['order_no'] . "已在发货单(" . $v['transport_no'] .")中发出!"];
+//            if(! empty($v['transport_no'])) return [false, "包装单号:" . $v['order_no'] . "已在发货单(" . $v['transport_no'] .")中发出!"];
             $model = new BoxDetail(['channel'=>$v['top_order_no']]);
             $detail_list = array_merge($detail_list,$model->where('order_no',$v['order_no'])->where('top_order_no',$v['top_order_no'])->get()->toArray());
         }

+ 8 - 0
config/logging.php

@@ -115,6 +115,14 @@ return [
             'level' => 'debug',
             'days' => 7,
         ],
+
+        //发货扫描日志记录
+        'sendData' => [
+            'driver' => 'daily',
+            'path' => storage_path('logs/send_data.log'),
+            'level' => 'debug',
+            'days' => 31,
+        ],
     ],
 
 ];