|
@@ -0,0 +1,85 @@
|
|
|
+<?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 NewTikTokUserCharge implements ShouldQueue
|
|
|
+{
|
|
|
+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
+
|
|
|
+ private $uid;
|
|
|
+ private $amount;
|
|
|
+ private $pay_time;
|
|
|
+ private $type;
|
|
|
+ /**
|
|
|
+ * 分子
|
|
|
+ */
|
|
|
+ private $molecule;
|
|
|
+ /**
|
|
|
+ * 分母
|
|
|
+ */
|
|
|
+ private $denominator;
|
|
|
+
|
|
|
+ protected $url = 'https://newtrackapi.zhuishuyun.com/api/user/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 $type = null, int $molecule = 1, int $denominator = 1)
|
|
|
+ {
|
|
|
+ $this->uid = $uid;
|
|
|
+ $this->amount = $amount;
|
|
|
+ $this->pay_time = $pay_time;
|
|
|
+ $this->type = $type ? $type : 'common';
|
|
|
+ $this->molecule = $molecule;
|
|
|
+ $this->denominator = $denominator;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Execute the job.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ $client = new Client();
|
|
|
+ $params = [
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'amount' => $this->amount,
|
|
|
+ 'pay_time' => $this->pay_time,
|
|
|
+ 'type' => $this->type,
|
|
|
+ 'molecule' => $this->molecule,
|
|
|
+ 'denominator' => $this->denominator,
|
|
|
+ 'source' => 'zsy'
|
|
|
+ ];
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|