66 lines
2.0 KiB
PHP
66 lines
2.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Jobs;
|
||
|
|
|
||
|
|
use App\Facades\CommonUtilsService;
|
||
|
|
use App\Http\Response\ResponseJson;
|
||
|
|
use App\Models\ApproveHistory;
|
||
|
|
use App\Models\User;
|
||
|
|
use Illuminate\Bus\Queueable;
|
||
|
|
use Illuminate\Queue\SerializesModels;
|
||
|
|
use Illuminate\Queue\InteractsWithQueue;
|
||
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||
|
|
use Illuminate\Support\Facades\DB;
|
||
|
|
|
||
|
|
class SyncTencenFaceid implements ShouldQueue
|
||
|
|
{
|
||
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
|
use ResponseJson;
|
||
|
|
protected $user_id;
|
||
|
|
/**
|
||
|
|
* Create a new job instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct($user_id)
|
||
|
|
{
|
||
|
|
$this->user_id = $user_id;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the job.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$user_id = $this->user_id;
|
||
|
|
$log = ApproveHistory::where("user_id", $user_id)->whereNotNull('eid_token')->where('type', 'body')->orderBy('id', 'desc')->first();
|
||
|
|
|
||
|
|
if (empty($log)) return ;
|
||
|
|
$res = CommonUtilsService::tencentFaceidRes($log->eid_token);
|
||
|
|
if (isset($res->Text) && isset($res->Text->ErrCode) && $res->Text->ErrCode == 0) {
|
||
|
|
//认证成功 修改认证状态
|
||
|
|
DB::beginTransaction();
|
||
|
|
User::where("id", $user_id)->update(['is_approved'=>1,'is_real_approved'=>1]);
|
||
|
|
ApproveHistory::where('user_id', $user_id)->whereIn('type', ['name', 'body'])->update(['status'=>1]);
|
||
|
|
DB::commit();
|
||
|
|
//更新出生年月日
|
||
|
|
$user = User::find($user_id);
|
||
|
|
$user->cardBirthdayToProfile();
|
||
|
|
//缓存用户认证
|
||
|
|
$user->updateCacheUser('is_approved');
|
||
|
|
$user->updateCacheUser('is_real_approved');
|
||
|
|
}
|
||
|
|
return ;
|
||
|
|
} catch (\Exception $e) {
|
||
|
|
DB::rollBack();
|
||
|
|
$this->getError($e);
|
||
|
|
return ;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|