12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace App\Jobs;
- use App\Consts\SysConsts;
- 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 NewTikTokUserChargeV2 implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- private $uid;
- private $amount;
- private $pay_time;
- private $order_no;
- protected $url = 'https://newtrackapi.zhuishuyun.com/api/user/new_charge';
- /**
- * 一般情况都上传
- */
- const COMMON = 'common';
- /**
- * 只有当天注册当天充值用户才上传
- */
- const CURRENT_DAY_REGISTER = 'current_day_register';
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(int $uid, float $amount, string $pay_time, string $order_no)
- {
- $this->uid = $uid;
- $this->amount = $amount;
- $this->pay_time = $pay_time;
- $this->order_no = $order_no;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $client = new Client();
- $params = [
- 'uid' => $this->uid,
- 'amount' => $this->amount,
- 'pay_time' => $this->pay_time,
- 'order_no' => $this->order_no,
- 'source' => 'wdy'
- ];
- $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
- $response = $client->request('post', $this->url, ['form_params' => $params])->getBody()->getContents();
- myLog('new_user_charge')->info($response);
- $result = json_decode($response);
- if ($result) {
- if ($result->code != 0) {
- myLog('new_user_charge')->info($response);
- }
- }
- }
- }
|