123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?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;
- use App\Modules\Trade\Models\Order;
- use App\Modules\User\Models\User;
- /**
- * 抖音用户推送数据
- */
- class TikTokUserCharge implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- private $uid;
- private $time;
- private $amount;
- /**
- * Create a new job instance.
- * @param int $uid
- * @param string $type 类型
- * @return void
- */
- public function __construct(int $uid, float $amount, string $time)
- {
- $this->uid = $uid;
- $this->amount = $amount;
- $this->time = $time;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $client = new Client();
- $params = [
- 'uid' => $this->uid,
- 'amount' => $this->amount,
- 'time' => $this->time,
- 'source' => 'wdy'
- ];
-
- \Log::info('TikTokUserCharge:'.json_encode($params));
-
- // if( date('Y-m-d',strtotime( $this->time )) != date('Y-m-d')){
- // return ;
- // }
-
- $user = User::find($this->uid);
- $order = Order::where('uid', $this->uid)->where('status', 'PAID')->orderBy('id', 'desc')->first();
- $current_day_register = date('Y-m-d', strtotime($order->created_at)) == date('Y-m-d', strtotime($user->created_at));
- if ($order && $current_day_register && $order->price >= 30) {
- $count = Order::where('uid', $this->uid)->where('status', 'PAID')->where('price', '>=', '30')->count();
- if ($count == 1) {
- } else {
- return;
- }
- } else {
- return;
- }
-
- $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
- $url = 'https://newtrackapi.zhuishuyun.com/api/user/tiktokUserChargePush';
- $response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
- myLog('tiktok_push_charge')->info($response);
- $result = json_decode($response);
- if ($result) {
- if ($result->code != 0) {
- myLog('tiktok_push_charge')->info($response);
- }
- }
- }
- }
|