onlinetest 5 tahun lalu
induk
melakukan
49b25b89fe
2 mengubah file dengan 87 tambahan dan 32 penghapusan
  1. 85 0
      app/Jobs/NewTikTokUserCharge.php
  2. 2 32
      app/Jobs/QappTikTokUserCharge.php

+ 85 - 0
app/Jobs/NewTikTokUserCharge.php

@@ -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);
+            }
+        }
+    }
+}

+ 2 - 32
app/Jobs/QappTikTokUserCharge.php

@@ -2,40 +2,10 @@
 
 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 QappTikTokUserCharge implements ShouldQueue
+class QappTikTokUserCharge extends NewTikTokUserCharge
 {
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    /**
-     * 只有当天注册当天充值用户才上传
-     */
-    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 = self::CURRENT_DAY_REGISTER, int $molecule = 1, int $denominator = 1)
-    {
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-    }
+    protected $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/charge';
 }