TikTokUserCharge.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Jobs;
  3. use App\Consts\SysConsts;
  4. use GuzzleHttp\Client;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Queue\SerializesModels;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. /**
  11. * 抖音用户推送数据
  12. */
  13. class TikTokUserCharge implements ShouldQueue
  14. {
  15. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  16. private $uid;
  17. private $time;
  18. private $amount;
  19. /**
  20. * Create a new job instance.
  21. * @param int $uid
  22. * @param string $type 类型
  23. * @return void
  24. */
  25. public function __construct(int $uid, float $amount, string $time)
  26. {
  27. $this->uid = $uid;
  28. $this->amount = $amount;
  29. $this->time = $time;
  30. }
  31. /**
  32. * Execute the job.
  33. *
  34. * @return void
  35. */
  36. public function handle()
  37. {
  38. $client = new Client();
  39. $params = [
  40. 'uid' => $this->uid,
  41. 'amount' => $this->amount,
  42. 'time' => $this->time,
  43. 'source' => 'wdy'
  44. ];
  45. $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
  46. $url = 'https://newtrackapi.zhuishuyun.com/api/user/tiktokUserChargePush';
  47. $response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
  48. myLog('tiktok_push_charge')->info($response);
  49. $result = json_decode($response);
  50. if ($result) {
  51. if ($result->code != 0) {
  52. myLog('tiktok_push_charge')->info($response);
  53. }
  54. }
  55. }
  56. }