cqpCow преди 2 години
родител
ревизия
a1ff93e925
променени са 4 файла, в които са добавени 93 реда и са изтрити 11 реда
  1. 23 0
      app/Http/Controllers/Api/FyyOrderController.php
  2. 62 7
      app/Service/FyyOrderService.php
  3. 4 4
      app/Service/FyySqlServerService.php
  4. 4 0
      routes/api.php

+ 23 - 0
app/Http/Controllers/Api/FyyOrderController.php

@@ -119,4 +119,27 @@ class FyyOrderController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function orderMobileList(Request $request)
+    {
+        $service = new FyyOrderService();
+        list($status,$data) = $service->orderMobileList($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function getShipmentOrder(Request $request){
+        $service = new FyyOrderService();
+        list($status,$data) = $service->getShipmentOrder($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 62 - 7
app/Service/FyyOrderService.php

@@ -102,7 +102,7 @@ class FyyOrderService extends Service
 
     public function orderList($data){
         $model = SaleOrdersProduct::where('del_time',0)
-            ->select('id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity','box_num','finished_num')
+            ->select('id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity','box_num','finished_num','shipment_num')
             ->orderBy('id','desc');
 
         if(! empty($data['order_no'])) $model->where('order_no', 'LIKE', '%'.$data['order_no'].'%');
@@ -249,14 +249,25 @@ class FyyOrderService extends Service
         return [true,''];
     }
 
-    public function orderOutRule($data){
+    public function orderOutRule($data){//todo
         if(empty($data['order_no'])) return [false,'包装单号不能为空!'];
 
-        $box = Box::where('order_no',$data['order_no'])->where('del_time',0)->first();
-        if(! $box) return [false,'包装单不存在或已经被删除!'];
-        $box = $box->toArray();
-        if($box['state'] == 1) return [false,'包装单正在出库队列中!'];
-        if($box['state'] > 1) return [false, '包装单已出库!'];
+        $boxList = Box::whereIn('order_no',$data['order_no'])->get()->toArray();
+        if(empty($boxList)) return [false,'包装单不存在!'];
+
+        $box_detail_list = [];
+        foreach ($boxList as $value){
+            if($value['del_time'] > 0) return [false,'包装单:' . $value['order_no'] . '已删除'];
+            if($value['state'] == 1) return [false,'包装单:' . $value['order_no'] . '已操作出库!'];
+            if($value['state'] > 1) return [false,'包装单:' . $value['order_no'] . '已出库!'];
+
+            $box_detail = new BoxDetail(['channel' => $value['order_no']]);
+            $box_detail_list = $box_detail->where('del_time',0)
+                ->where('order_no',$data['order_no'])
+                ->select('order_no','out_order_no','top_id as sale_orders_product_id','ext_1 as customer_no','ext_2 as customer_name','ext_3 as product_no','num')
+                ->get()->toArray();
+        }
+
 
         $box_detail = new BoxDetail(['channel'=>$box['order_no']]);
         $box_detail_list = $box_detail->where('order_no',$data['order_no'])
@@ -276,4 +287,48 @@ class FyyOrderService extends Service
 
         return [true, $box_detail_list];
     }
+
+    public function orderMobileList($data){
+        $list = SaleOrdersProduct::where('del_time',0)
+            ->select('out_order_no')
+            ->where('box_num', '>', 0)
+            ->whereColumn('order_quantity', '>', 'shipment_num')
+            ->groupBy('order_no')
+            ->orderBy('id','desc')
+            ->get()->toArray();
+        $order = array_column($list,'out_order_no');
+
+        return [true, $order];
+    }
+
+    public function getShipmentOrder($data){
+        if(empty($data['order_no'])) return ['false', '销售订单号不能为空!'];
+
+        $sqlServerModel = new FyySqlServerService();
+        if($sqlServerModel->error) return [false,$sqlServerModel->error];
+
+        $result = $sqlServerModel->getDataFromDispatchList($data['order_no']);
+        $return = [];
+        if(! empty($result)){
+            foreach ($result as $value){
+                $cfree1 = $value['cfree1'] ?? '';
+                $cfree2 = $value['cfree2'] ?? '';
+                $tmp_key = $value['cinvcode'] . $cfree1 . $cfree2;
+                $n = $value['iquantity'] - ($value['out_quantity'] ?? 0);
+                if(isset($return[$tmp_key])){
+                    $return[$tmp_key]['num'] += $n;
+                }else{
+                    $return[$tmp_key] = [
+                        'product_no' => $value['cinvcode'],
+                        'product_title' => $value['product_title'],
+                        'technology_name' => $cfree1,
+                        'wood_name' => $cfree2,
+                        'num' => $n,
+                    ];
+                }
+            }
+        }
+
+        return [true,['show'=>array_values($return),'post'=>$result]];
+    }
 }

+ 4 - 4
app/Service/FyySqlServerService.php

@@ -538,13 +538,13 @@ class FyySqlServerService extends Service
         return $boxData;
     }
 
-    //获取发货单数据
+    //获取发货单数据 还没发的
     public function getDataFromDispatchList($order_number){
         $message = $this->db->table('DispatchList as a')
             ->leftJoin('DispatchLists as b','b.DLID','a.DLID')
-            ->whereIn('a.cSOcode',$order_number)
-//            ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
-            ->select('a.cDefine10 as customer_name','a.cSOCode','b.iDLsID as idlsid','b.cInvCode as cinvcode','b.cFree1 as cfree1','b.cFree2 as cfree2','b.cPosition as cposition','b.cBatch as cbatch','b.iQuantity as iquantity','b.iNum as inum','b.iInvExchRate as iinvexchrate','b.fOutQuantity as out_quantity')
+            ->where('a.cSOcode',$order_number)
+            ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
+            ->select('a.cDefine10 as customer_name','a.cSOCode','a.cDepCode','b.iDLsID as idlsid','b.cWhCode as cwhcode','b.cInvCode as cinvcode','b.cInvName as product_title','b.cFree1 as cfree1','b.cFree2 as cfree2','b.cPosition as cposition','b.cBatch as cbatch','b.iQuantity as iquantity','b.iNum as inum','b.iInvExchRate as iinvexchrate','b.fOutQuantity as out_quantity')
             ->get()->toArray();
         if(! empty($message)){
             foreach ($message as $key => $value){

+ 4 - 0
routes/api.php

@@ -129,6 +129,10 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('fyyDel', 'Api\FyyOrderController@del');
     $route->any('fyyList', 'Api\FyyOrderController@orderList');
     $route->any('fyyRefreshOnHandQuantity', 'Api\FyyOrderController@fyyRefreshOnHandQuantity');
+    $route->any('fyyMobileList', 'Api\FyyOrderController@orderMobileList');
+
+    //获取发货单
+    $route->any('getShipmentOrder', 'Api\FyyOrderController@getShipmentOrder');
 
     //生产订单
     $route->any('productionAdd', 'Api\ProductionOrderController@add');