cqpCow 2 years ago
parent
commit
1f26447844
2 changed files with 20 additions and 9 deletions
  1. 7 4
      app/Service/FyyOrderService.php
  2. 13 5
      app/Service/FyySqlServerService.php

+ 7 - 4
app/Service/FyyOrderService.php

@@ -326,23 +326,24 @@ class FyyOrderService extends Service
     }
     }
 
 
     public function getShipmentOrder($data){
     public function getShipmentOrder($data){
-        if(empty($data['order_no'])) return ['false', '销售订单号不能为空!'];
+        if(empty($data['time'][0]) || empty($data['time'][1])) return ['false', '时间范围不能为空!'];
 
 
         $sqlServerModel = new FyySqlServerService();
         $sqlServerModel = new FyySqlServerService();
         if($sqlServerModel->error) return [false,$sqlServerModel->error];
         if($sqlServerModel->error) return [false,$sqlServerModel->error];
 
 
-        $result = $sqlServerModel->getDataFromDispatchList($data['order_no']);
+        $result = $sqlServerModel->getDataFromDispatchList($data);
         $return = [];
         $return = [];
         if(! empty($result)){
         if(! empty($result)){
             foreach ($result as $value){
             foreach ($result as $value){
                 $cfree1 = $value['cfree1'] ?? '';
                 $cfree1 = $value['cfree1'] ?? '';
                 $cfree2 = $value['cfree2'] ?? '';
                 $cfree2 = $value['cfree2'] ?? '';
-                $tmp_key = $value['cinvcode'] . $cfree1 . $cfree2;
+                $tmp_key = $value['cdlcode'] . $value['cinvcode'] . $cfree1 . $cfree2;
                 $n = $value['iquantity'] - ($value['out_quantity'] ?? 0);
                 $n = $value['iquantity'] - ($value['out_quantity'] ?? 0);
                 if(isset($return[$tmp_key])){
                 if(isset($return[$tmp_key])){
                     $return[$tmp_key]['num'] += $n;
                     $return[$tmp_key]['num'] += $n;
                 }else{
                 }else{
                     $return[$tmp_key] = [
                     $return[$tmp_key] = [
+                        'cdlcode' => $value['cdlcode'],
                         'product_no' => $value['cinvcode'],
                         'product_no' => $value['cinvcode'],
                         'product_title' => $value['product_title'],
                         'product_title' => $value['product_title'],
                         'technology_name' => $cfree1,
                         'technology_name' => $cfree1,
@@ -353,6 +354,8 @@ class FyyOrderService extends Service
             }
             }
         }
         }
 
 
-        return [true,['show'=>array_values($return),'post'=>$result]];
+        $shipment_code = array_values(array_unique(array_column($result,'cdlcode')));
+
+        return [true,['shipment_code'=>$shipment_code ,'show'=>array_values($return), 'post'=>$result]];
     }
     }
 }
 }

+ 13 - 5
app/Service/FyySqlServerService.php

@@ -529,14 +529,22 @@ class FyySqlServerService extends Service
     }
     }
 
 
     //获取发货单数据 还没发的
     //获取发货单数据 还没发的
-    public function getDataFromDispatchList($order_number){
-        $message = $this->db->table('DispatchList as a')
+    public function getDataFromDispatchList($data){
+        $model = $this->db->table('DispatchList as a')
             ->leftJoin('DispatchLists as b','b.DLID','a.DLID')
             ->leftJoin('DispatchLists as b','b.DLID','a.DLID')
-            ->where('a.cSOcode',$order_number)
             ->whereNotNull('a.cVerifier')
             ->whereNotNull('a.cVerifier')
-            ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
-            ->select('a.DLID as id','a.cDefine10 as customer_name','a.cSOCode','a.cDepCode as cdepcode','a.cCusCode as cuscode','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','b.iUnitPrice as iunitcost','b.iMoney as imoney')
+            ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity');
+
+        //检索条件
+        if(! empty($data['time'][0]) && ! empty($data['time'][1])) {
+            $model->where('a.dDate','>=',$data['time'][0]);
+            $model->where('a.dDate','<=',$data['time'][1]);
+        }
+        if(! empty($data['order_no'])) $model->where('a.cSOcode',$data['order_no']);
+
+        $message = $model->select('a.cDLCode as cdlcode','a.DLID as id','a.cDefine10 as customer_name','a.cSOCode','a.cDepCode as cdepcode','a.cCusCode as cuscode','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','b.iUnitPrice as iunitcost','b.iMoney as imoney')
             ->get()->toArray();
             ->get()->toArray();
+
         if(! empty($message)){
         if(! empty($message)){
             foreach ($message as $key => $value){
             foreach ($message as $key => $value){
 //                $message[$key]->iquantity = $value->iquantity - $value->out_quantity;
 //                $message[$key]->iquantity = $value->iquantity - $value->out_quantity;