add:企业认证时增加异步回调通知标记,定时任务监听回调是否超时,超时则记录日志。
This commit is contained in:
parent
15e4f8f6fa
commit
d220c90529
@ -199,7 +199,7 @@ class CompanyController extends BaseAdminController
|
|||||||
];
|
];
|
||||||
$res = app(JunziqianController::class)->EnterpriseCertification($data);
|
$res = app(JunziqianController::class)->EnterpriseCertification($data);
|
||||||
if ($res->success == true) {
|
if ($res->success == true) {
|
||||||
$email = substr(uniqid(),2,5).$res->data;
|
$email = $res->data;
|
||||||
// 企业人脸上传
|
// 企业人脸上传
|
||||||
// $company['master_email'] = $email; // 法人邮箱
|
// $company['master_email'] = $email; // 法人邮箱
|
||||||
// $faceCreateRe = CompanyLogic::originationFaceCreate($company);
|
// $faceCreateRe = CompanyLogic::originationFaceCreate($company);
|
||||||
@ -208,6 +208,9 @@ class CompanyController extends BaseAdminController
|
|||||||
// }
|
// }
|
||||||
// 修改法人邮箱
|
// 修改法人邮箱
|
||||||
Db::name('company')->where('id', $params['id'])->update(['master_email' => $email]);
|
Db::name('company')->where('id', $params['id'])->update(['master_email' => $email]);
|
||||||
|
// 加入缓存中,is_callback用于判断是否获取到异步通知
|
||||||
|
$redis = new \Redis();
|
||||||
|
$redis->set('authentication_company_id_'.$company['id'], json_encode(['company_id'=>$company['id'],'is_callback'=>0, 'timing'=>time()]));
|
||||||
// return $this->success('认证成功',[],1, 1);
|
// return $this->success('认证成功',[],1, 1);
|
||||||
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,6 +429,14 @@ class IndexController extends BaseApiController
|
|||||||
try {
|
try {
|
||||||
if ($parmas) {
|
if ($parmas) {
|
||||||
$data=json_decode($parmas['data'],true);
|
$data=json_decode($parmas['data'],true);
|
||||||
|
// 成功回调标记
|
||||||
|
$redis = new \Redis();
|
||||||
|
$cache = $redis->get('authentication_company_id_'.$parmas['id']);
|
||||||
|
if (!empty($cache)) {
|
||||||
|
$data = json_decode($cache, true);
|
||||||
|
$data['is_callback'] = 1;
|
||||||
|
$redis->set('authentication_company_id_'.$parmas['id'], json_encode($data));
|
||||||
|
}
|
||||||
if($data['status']==1){
|
if($data['status']==1){
|
||||||
Company::where('id', $parmas['id'])->update(['is_authentication' => 1]);
|
Company::where('id', $parmas['id'])->update(['is_authentication' => 1]);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ class CompanyLogic extends BaseLogic
|
|||||||
'organization_code' => $data['organization_code'],
|
'organization_code' => $data['organization_code'],
|
||||||
'master_name' => $data['master_name'],
|
'master_name' => $data['master_name'],
|
||||||
'master_id_card' => $data['master_id_card'],
|
'master_id_card' => $data['master_id_card'],
|
||||||
'master_email' => $data['master_email'],
|
'master_email' => substr(uniqid(),3,5).$data['master_email'],
|
||||||
'master_phone' => $data['master_phone'],
|
'master_phone' => $data['master_phone'],
|
||||||
'id' => $data['id'],
|
'id' => $data['id'],
|
||||||
];
|
];
|
||||||
|
41
app/task/TaskCompanyAuthNotifyCron.php
Normal file
41
app/task/TaskCompanyAuthNotifyCron.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\task;
|
||||||
|
|
||||||
|
use app\common\model\Company;
|
||||||
|
use app\common\model\task\Task as TaskTask;
|
||||||
|
use think\facade\Log;
|
||||||
|
use yunwuxin\cron\Task;
|
||||||
|
|
||||||
|
class TaskCompanyAuthNotifyCron extends Task
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
$this->everyMinute();
|
||||||
|
// $this->everyMinute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听企业认证回调 is_callback=1 表示回调成功
|
||||||
|
*/
|
||||||
|
protected function execute()
|
||||||
|
{
|
||||||
|
$redis = new \Redis();
|
||||||
|
//...具体的任务执行
|
||||||
|
$companyIdList = $redis->keys('authentication_company_id_*');
|
||||||
|
foreach ($companyIdList as $key) {
|
||||||
|
$data = $redis->get($key);
|
||||||
|
if (!empty($data)) {
|
||||||
|
$data = json_decode($data, true);
|
||||||
|
if ($data['is_callback'] == 1) {
|
||||||
|
$redis->del($key);
|
||||||
|
} else {
|
||||||
|
if (time() - $data['timing'] > 300) {
|
||||||
|
$companyInfo = Company::find(['id' => $data['company_id']]);
|
||||||
|
Log::info($companyInfo['company_name'].'企业认证回调超时');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'tasks' => [
|
'tasks' => [
|
||||||
app\task\TaskCron::class,
|
// app\task\TaskCron::class,
|
||||||
app\task\TaskSettlementCron::class,
|
// app\task\TaskSettlementCron::class,
|
||||||
// app\task\Ceshi::class,
|
// app\task\Ceshi::class,
|
||||||
|
app\task\TaskCompanyAuthNotifyCron::class,
|
||||||
]
|
]
|
||||||
];
|
];
|
Loading…
x
Reference in New Issue
Block a user