Преглед на файлове

Merge branch 'zengjun' of ssh://was.baoshi56.com:10022/var/git/bswas

LD преди 5 години
родител
ревизия
e2458d7e4f
променени са 2 файла, в които са добавени 10 реда и са изтрити 3 реда
  1. 5 2
      app/Http/Controllers/TestController.php
  2. 5 1
      database/migrations/2020_12_23_174008_add_column_logistic_id_to_order_trackings.php

+ 5 - 2
app/Http/Controllers/TestController.php

@@ -1394,11 +1394,13 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         $minId= $orderTracking_min->id;
         $logistic = \App\Logistic::query()->where('name','新杰物流')->first();
         $logistic_zt = \App\Logistic::query()->where('name','自提')->first();
+
         for ($i=$minId;$i<= $maxId;$i+=100){
             $orderTrackings = \App\OrderTracking::query()
                 ->where('id','>=',$i)
                 ->where('id','<=',$i+100)
                 ->where('logistic_id','=',0)
+                ->where('created_at','!=','0000-00-00 00:00:00')
                 ->get();
             if($orderTrackings->count() ==0) continue;
             $update_params = [['id','logistic_id']];
@@ -1414,8 +1416,9 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
                     ];
                 }
             });
-//            dd($update_params);
-            $service->batchUpdate($update_params);
+            if(count($update_params) > 1){
+                $service->batchUpdate($update_params);
+            }
         }
     }
 

+ 5 - 1
database/migrations/2020_12_23_174008_add_column_logistic_id_to_order_trackings.php

@@ -43,11 +43,13 @@ class AddColumnLogisticIdToOrderTrackings extends Migration
         $minId= $orderTracking_min->id;
         $logistic = \App\Logistic::query()->where('name','新杰物流')->first();
         $logistic_zt = \App\Logistic::query()->where('name','自提')->first();
+
         for ($i=$minId;$i<= $maxId;$i+=100){
             $orderTrackings = \App\OrderTracking::query()
                 ->where('id','>=',$i)
                 ->where('id','<=',$i+100)
                 ->where('logistic_id','=',0)
+                ->where('created_at','!=','0000-00-00 00:00:00')
                 ->get();
             if($orderTrackings->count() ==0) continue;
             $update_params = [['id','logistic_id']];
@@ -63,7 +65,9 @@ class AddColumnLogisticIdToOrderTrackings extends Migration
                     ];
                 }
             });
-            $service->batchUpdate($update_params);
+            if(count($update_params) > 1){
+                $service->batchUpdate($update_params);
+            }
         }
     }
 }