46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Jobs;
|
||
|
|
|
||
|
|
use Illuminate\Bus\Queueable;
|
||
|
|
use Illuminate\Queue\SerializesModels;
|
||
|
|
use Illuminate\Queue\InteractsWithQueue;
|
||
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||
|
|
use App\Services\UserService;
|
||
|
|
use App\Models\Wechat;
|
||
|
|
use Illuminate\Support\Facades\Log;
|
||
|
|
|
||
|
|
class AddInviteLog implements ShouldQueue
|
||
|
|
{
|
||
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
|
protected $openid, $from_openid, $from_user_id, $user_id;
|
||
|
|
/**
|
||
|
|
* Create a new job instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct($arr)
|
||
|
|
{
|
||
|
|
$this->openid = $arr['openid']??Wechat::where('user_id', $arr['user_id'])->value('openid');
|
||
|
|
$this->from_openid = $arr['from_openid']??Wechat::where('user_id', $arr['from_user_id'])->value('openid');
|
||
|
|
$this->user_id = $arr['user_id']??Wechat::where('openid', $this->openid)->value('user_id');
|
||
|
|
$this->from_user_id = $arr['from_user_id']??Wechat::where('openid', $this->from_openid)->value('user_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the job.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
if ($this->user_id && $this->from_user_id && $this->user_id == $this->from_user_id) return true;
|
||
|
|
if ($this->openid && $this->from_openid && $this->openid == $this->from_openid ) return true;
|
||
|
|
$user_service = new UserService();
|
||
|
|
$user_service->addInviteHistory($this->user_id, $this->from_user_id, $this->openid, $this->from_openid);
|
||
|
|
return true;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|