46 lines
1.2 KiB
PHP
46 lines
1.2 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\Models\User;
|
||
|
|
use App\Facades\WechatService;
|
||
|
|
class SendVisitNoticeTemplate implements ShouldQueue
|
||
|
|
{
|
||
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
|
|
||
|
|
public $visitor_user_id, $user_id;
|
||
|
|
/**
|
||
|
|
* Create a new job instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct($visitor_user_id, $user_id)
|
||
|
|
{
|
||
|
|
$this->visitor_user_id = $visitor_user_id;
|
||
|
|
$this->user_id = $user_id;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the job.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
$user = User::find($this->user_id);
|
||
|
|
$visitor = User::find($this->visitor_user_id);
|
||
|
|
if (!$user->visit_notice) return;
|
||
|
|
if (empty($user->wechat) || empty($user->wechat->official_openid)) return;
|
||
|
|
$param['user_id'] = $this->visitor_user_id;
|
||
|
|
$param['name'] = $visitor->nickname;
|
||
|
|
$param['date'] = date("Y-m-d H:i:s");
|
||
|
|
$param['from'] = "福恋小程序";
|
||
|
|
WechatService::visitNoticeV2($param);
|
||
|
|
}
|
||
|
|
}
|