66 lines
1.8 KiB
PHP
66 lines
1.8 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\User;
|
|
class CheckAvatarFace implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $user_id;
|
|
protected $avatar;
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($array)
|
|
{
|
|
$this->user_id = $array['user_id'];
|
|
$this->avatar = $array['avatar'];
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
try {
|
|
//内容安全-图片
|
|
$result = \CommonUtilsService::imageContentCecurity([$this->avatar]);
|
|
if ($result && isset($result['result']) && $result['result']) {
|
|
// return $this->failure('图片'.$result['result'].',请换一张照片');
|
|
return false;
|
|
}
|
|
//人脸识别
|
|
$userService = new UserService();
|
|
$result = $userService->faceDelectBaiDu($this->avatar);
|
|
if ($result->error_code == 18) throw new \Exception("百度借口失败", 1);
|
|
if ($result->error_code == 222202) {
|
|
return true;
|
|
}
|
|
$user = User::find($this->user_id);
|
|
//修改图片
|
|
$user->photo = $this->avatar;
|
|
$user->circle_avatar = null;
|
|
$user->my_share = null;
|
|
$user->home_share = null;
|
|
$user->is_audited = 0;
|
|
$user->is_photo_audited = 0;
|
|
$user->save();
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
return true;
|
|
}
|
|
|
|
}
|
|
}
|