Browse Source

异步队列

tgz 2 years ago
parent
commit
ed25af3d63
2 changed files with 53 additions and 1 deletions
  1. 48 0
      app/Jobs/QappOrder.php
  2. 5 1
      app/Modules/Trade/Pay/OrderPaySuccess.php

+ 48 - 0
app/Jobs/QappOrder.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Consts\SysConsts;
+use GuzzleHttp\Client;
+use Illuminate\Bus\Queueable;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+
+/**
+ * 快应用订单-异步任务处理-统计书籍在某个公司下的付费相关情况
+ * 1.统计任务
+ */
+class QappOrder implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    private $ip;
+    private $ua;
+    private $channel_id;
+    private $uid;
+    private $register_time;
+
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct(string $order_on)
+    {
+        $this->order_on = $order_on;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        
+    }
+
+    
+}

+ 5 - 1
app/Modules/Trade/Pay/OrderPaySuccess.php

@@ -5,7 +5,7 @@ namespace App\Modules\Trade\Pay;
 use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Subscribe\Models\Order;
 use DB;
-
+use App\Jobs\QappOrder;
 /**
  * 
  */
@@ -47,6 +47,10 @@ class OrderPaySuccess
                 ]);
             }
             self::freeBookStats($order->from_bid,$order->price,$order->uid);
+
+            //添加异步任务队列
+            $job = new QappOrder($tikTokRegisterRequest);
+            dispatch($job->onConnection('redis')->onQueue('qapp_order_pay_success'));
             return $status;
         } else {
             return false;