QappTikTokUserCharge.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Jobs\QappTikTok;
  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 QappTikTokUserCharge implements ShouldQueue
  14. {
  15. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  16. private $reportParams;
  17. protected $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/charge';
  18. /**
  19. * 一般情况都上传
  20. */
  21. const COMMON = 'common';
  22. /**
  23. * 只有当天注册当天充值用户才上传
  24. */
  25. const CURRENT_DAY_REGISTER = 'current_day_register';
  26. /**
  27. * 注册24小时之内充值
  28. */
  29. const REGISTER_24_CHARGE = 'register_24_charge';
  30. /**
  31. * QappTikTokUserCharge constructor.
  32. * @param QappTikTokUserChargeRequest $reportParams
  33. */
  34. public function __construct(QappTikTokUserChargeRequest $reportParams)
  35. {
  36. $this->reportParams = $reportParams;
  37. }
  38. /**
  39. * Execute the job.
  40. * @throws \GuzzleHttp\Exception\GuzzleException
  41. */
  42. public function handle()
  43. {
  44. $client = new Client();
  45. $params = [
  46. 'uid' => (int)$this->reportParams->uid,
  47. 'amount' => (float)$this->reportParams->amount,
  48. 'pay_time' => (string)$this->reportParams->pay_time,
  49. 'type' => (string)$this->reportParams->type,
  50. 'book_id' => (string)$this->reportParams->book_id,
  51. 'book_name' => (string)$this->reportParams->book_name,
  52. 'molecule' => (int)$this->reportParams->molecule,
  53. 'denominator' => (int)$this->reportParams->denominator,
  54. 'source' => 'zsy',
  55. 'send_order_id' => $this->reportParams->send_order_id,
  56. ];
  57. $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
  58. $response = $client->request('post', $this->url, ['form_params' => $params])->getBody()->getContents();
  59. myLog('qapp_user_charge')->info($response);
  60. $result = json_decode($response);
  61. if ($result) {
  62. if ($result->code != 0) {
  63. myLog('qapp_user_charge')->info($response);
  64. }
  65. }
  66. }
  67. }