LD 5 лет назад
Родитель
Сommit
a79c4094a4
1 измененных файлов с 20 добавлено и 0 удалено
  1. 20 0
      app/Http/Controllers/TestController.php

+ 20 - 0
app/Http/Controllers/TestController.php

@@ -522,6 +522,26 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         Commodity::destroy($deleteCommodities);
     }
 
+    public function test2(){
+        $logs = Log::query()->where('created_at','>','2020-09-30 12:25:36')
+        ->where('created_at','<','2020-09-30 18:00:36')
+        ->where('operation','App\Services\common\BatchUpdateService::batchUpdateItself')
+        ->get();
+        foreach ($logs as $log){
+            $str1 = mb_strlen("批量更新失败 SQL:(");
+            $str2 = mb_strripos($log->description,") 堆栈:");
+            $str = mb_substr($log->description,$str1,$str2-$str1);
+            $str = str_replace('CASEcommodity_id',"CASE commodity_id",$str);
+            $str = str_replace('END WHERE commodity_id'," END WHERE commodity_id",$str);
+            try{
+                DB::select(DB::raw($str));
+                LogService::log(__METHOD__,"纠正商品-SQL执行BUG",$str);
+            }catch(\Exception $e){
+                LogService::log(__METHOD__,"纠正商品-SQL执行BUG-失败",$str." | 堆栈:". $e->getMessage() . $e->getTraceAsString());
+            }
+        }
+    }
+
     /*1*/
     function socket(Request $request)
     {/**/