Zhouzhendong 5 лет назад
Родитель
Сommit
d6bc25a619

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

@@ -167,10 +167,20 @@ class TestController extends Controller
 
     public function test()
     {
-        $month = "2021-02";
-        dd(Carbon::parse($month)->lastOfMonth()->format("d"));
+        $error = [];
+        try{
+            $d = 0/0;
+            $this->a(null);
+        }catch (\Error|\Exception $e){
+            $error[] = "错了".$e->getMessage();
+        }
+        throw new \Exception(json_encode($error));
         return view("test");
     }
+    public function a(int $c)
+    {
+        return $c;
+    }
     public function restoreResetInstantBill()
     {
         ini_set('max_execution_time', 2500);

+ 1 - 1
app/Jobs/OrderCreateInstantBill.php

@@ -41,7 +41,7 @@ class OrderCreateInstantBill implements ShouldQueue
                 try{
                     if (!$service->createInstantBill($order))
                         LogService::log(__METHOD__,"ERROR-订单生成即时账单",$order->toJson());
-                }catch (\Exception $e){
+                }catch (\Error|\Exception $e){
                     LogService::log(__METHOD__,"ERROR-订单生成即时账单",$order->toJson()." | ".$e->getMessage());
                     $errors = ["order_".$order->id.":".$e->getMessage()];
                 }

+ 3 - 4
app/Jobs/StoreCreateInstantBill.php

@@ -4,13 +4,11 @@ namespace App\Jobs;
 
 use App\Services\LogService;
 use App\Services\StoreService;
-use App\Store;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
 
 class StoreCreateInstantBill implements ShouldQueue
 {
@@ -38,13 +36,14 @@ class StoreCreateInstantBill implements ShouldQueue
      */
     public function handle(StoreService $service)
     {
+        if (!$this->stores)return;
         $errors = [];
         foreach ($this->stores as $store){
             try{
                 $service->createInstantBill($store);
-            }catch (\Exception $e){
+            }catch (\Error|\Exception $e){
                 LogService::log(__METHOD__,"ERROR-入库生成即时账单",$store->toJson()." | ".$e->getMessage());
-                $errors = ["order_".$store->id.":".$e->getMessage()];
+                $errors = ["store_".$store->id.":".$e->getMessage()];
             }
         }
         if ($errors)throw new \Exception(json_encode($errors));