123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Jobs\QappTikTok;
- 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 NewQappTikTokUserCharge implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- private $reportParams;
- protected $url;
- /**
- * QappTikTokUserCharge constructor.
- * @param QappTikTokUserChargeRequest $reportParams
- */
- public function __construct(QappTikTokUserChargeRequest $reportParams)
- {
- $this->reportParams = $reportParams;
- $this->url = env('TIKTOK_API_URL'). 'api/qappuser/new_charge';
- }
- /**
- * Execute the job.
- * @throws \GuzzleHttp\Exception\GuzzleException
- */
- public function handle()
- {
- $client = new Client();
- $params = [
- 'uid' => (int)$this->reportParams->uid,
- 'amount' => (float)$this->reportParams->amount,
- 'pay_time' => (string)$this->reportParams->pay_time,
- 'order_no' => (string)$this->reportParams->order_no,
- 'book_id' => (string)$this->reportParams->book_id,
- 'book_name' => (string)$this->reportParams->book_name,
- 'source' => 'zsy',
- ];
- // 避免签名错误
- if ($this->reportParams->send_order_id) {
- $params['send_order_id'] = $this->reportParams->send_order_id;
- }
- $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
- $response = $client->request('post', $this->url, ['form_params' => $params])->getBody()->getContents();
- myLog('qapp_user_charge')->info($response);
- $result = json_decode($response);
- if ($result) {
- if ($result->code != 0) {
- myLog('qapp_user_charge')->info($response);
- }
- }
- }
- }
|