TikTokUserCharge.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. if( date('Y-m-d',strtotime( $this->time )) != date('Y-m-d')){
  46. return ;
  47. }
  48. $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
  49. $url = 'https://newtrackapi.zhuishuyun.com/api/user/tiktokUserChargePush';
  50. $response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
  51. myLog('tiktok_push_charge')->info($response);
  52. $result = json_decode($response);
  53. if ($result) {
  54. if ($result->code != 0) {
  55. myLog('tiktok_push_charge')->info($response);
  56. }
  57. }
  58. }
  59. }