Sfoglia il codice sorgente

Merge branch 'kuaiyingyong' of iqiyoo:zhuishuyun_wap into kuaiyingyong

zz 4 anni fa
parent
commit
dac154abfd
2 ha cambiato i file con 59 aggiunte e 0 eliminazioni
  1. 54 0
      app/Jobs/UserAddDeskJob.php
  2. 5 0
      app/Modules/User/Services/UserService.php

+ 54 - 0
app/Jobs/UserAddDeskJob.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Consts\SysConsts;
+use App\Modules\User\Models\QappUserAddDestop;
+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;
+
+/**
+ * 用户加桌
+ */
+class UserAddDeskJob implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $uid;
+
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct(int $uid)
+    {
+        $this->uid = $uid;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        $exists = QappUserAddDestop::where('uid', $this->uid)->exists();
+        if ($exists) {
+            return;
+        }
+        $client = new Client();
+        $params = [
+            'uid' => $this->uid,
+            'source' => 'zsy'
+        ];
+        $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
+        $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/addDesk';
+        $response =  $client->post($url, ['form_params' => $params])->getBody()->getContents();
+        myLog('new_user_rentention')->info($response);
+    }
+}

+ 5 - 0
app/Modules/User/Services/UserService.php

@@ -18,6 +18,7 @@ use App\Modules\User\Models\User;
 use App\Modules\User\Models\UserEnv;
 use DB;
 use App\Jobs\ActionTrigger;
+use App\Jobs\UserAddDeskJob;
 use App\Modules\OfficialAccount\Models\DistributionSelfDefineConfig;
 use App\Modules\Channel\Models\Channel;
 use App\Modules\Trade\Models\Order;
@@ -43,6 +44,10 @@ class UserService
     {
         $log = QappUserAddDestop::where('uid', $uid)->orderBy('id', 'desc')->first();
         if ((!$log && $status == 1) || ($log && $log->status != $status)) {
+            if ($status == 1) {
+                $job = new UserAddDeskJob($uid);
+                dispatch($job)->onConnection('rabbitmq')->onQueue('qapp_user_add_desk');
+            }
             QappUserAddDestop::create([
                 'uid' => $uid,
                 'status' => $status