UserAddDeskJob.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Jobs;
  3. use App\Consts\SysConsts;
  4. use App\Modules\User\Models\QappUserAddDestop;
  5. use GuzzleHttp\Client;
  6. use Illuminate\Bus\Queueable;
  7. use Illuminate\Queue\SerializesModels;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. use Illuminate\Contracts\Queue\ShouldQueue;
  10. use Illuminate\Foundation\Bus\Dispatchable;
  11. /**
  12. * 用户加桌
  13. */
  14. class UserAddDeskJob implements ShouldQueue
  15. {
  16. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  17. protected $uid;
  18. /**
  19. * Create a new job instance.
  20. *
  21. * @return void
  22. */
  23. public function __construct(int $uid)
  24. {
  25. $this->uid = $uid;
  26. }
  27. /**
  28. * Execute the job.
  29. *
  30. * @return void
  31. */
  32. public function handle()
  33. {
  34. $exists = QappUserAddDestop::where('uid', $this->uid)->exists();
  35. if ($exists) {
  36. return;
  37. }
  38. $client = new Client();
  39. $params = [
  40. 'uid' => $this->uid,
  41. 'source' => 'wdy'
  42. ];
  43. $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
  44. $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/addDesk';
  45. $response = $client->post($url, ['form_params' => $params])->getBody()->getContents();
  46. myLog('user_add_desk')->info($response);
  47. }
  48. }