51 lines
1.4 KiB
PHP
51 lines
1.4 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\RecommendSingleHistory;
|
||
|
|
use App\Models\MatchingSingleHistory;
|
||
|
|
use App\Models\User;
|
||
|
|
class SendAGRecommend implements ShouldQueue
|
||
|
|
{
|
||
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
|
public $tries = 1;
|
||
|
|
protected $param;
|
||
|
|
/**
|
||
|
|
* Create a new job instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct($param)
|
||
|
|
{
|
||
|
|
$this->param = $param;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the job.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
$param = $this->param;
|
||
|
|
if (!array_key_exists('recive_user_id', $param)) return;
|
||
|
|
$recive_user = User::find($param['recive_user_id']);
|
||
|
|
//是否关注了公众号
|
||
|
|
$result = $recive_user->hasSubscribeOfficial();
|
||
|
|
if ($result) {
|
||
|
|
//推送消息
|
||
|
|
\WechatService::agRecommendNotcie($this->param);
|
||
|
|
//添加推荐记录
|
||
|
|
RecommendSingleHistory::firstOrCreate(['user_id'=>$param['recive_user_id'], 'other_user_id'=>$param['user_id']]);
|
||
|
|
//添加到匹配列表
|
||
|
|
MatchingSingleHistory::firstOrCreate(['user_id'=>$param['recive_user_id'], 'other_user_id'=>$param['user_id']]);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|