diff --git a/app/adminapi/controller/CompanyController.php b/app/adminapi/controller/CompanyController.php index 390009a4d..7a7917689 100644 --- a/app/adminapi/controller/CompanyController.php +++ b/app/adminapi/controller/CompanyController.php @@ -199,7 +199,7 @@ class CompanyController extends BaseAdminController ]; $res = app(JunziqianController::class)->EnterpriseCertification($data); if ($res->success == true) { - $email = substr(uniqid(),2,5).$res->data; + $email = $res->data; // 企业人脸上传 // $company['master_email'] = $email; // 法人邮箱 // $faceCreateRe = CompanyLogic::originationFaceCreate($company); @@ -208,6 +208,9 @@ class CompanyController extends BaseAdminController // } // 修改法人邮箱 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('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1); } else { diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 175601280..1dc9ad41b 100755 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -429,6 +429,14 @@ class IndexController extends BaseApiController try { if ($parmas) { $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){ Company::where('id', $parmas['id'])->update(['is_authentication' => 1]); } diff --git a/app/common/logic/CompanyLogic.php b/app/common/logic/CompanyLogic.php index 00680cd6e..47f544480 100644 --- a/app/common/logic/CompanyLogic.php +++ b/app/common/logic/CompanyLogic.php @@ -151,7 +151,7 @@ class CompanyLogic extends BaseLogic 'organization_code' => $data['organization_code'], 'master_name' => $data['master_name'], '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'], 'id' => $data['id'], ]; diff --git a/app/task/TaskCompanyAuthNotifyCron.php b/app/task/TaskCompanyAuthNotifyCron.php new file mode 100644 index 000000000..5b1237f03 --- /dev/null +++ b/app/task/TaskCompanyAuthNotifyCron.php @@ -0,0 +1,41 @@ +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'].'企业认证回调超时'); + } + } + } + } + } +} \ No newline at end of file diff --git a/config/cron.php b/config/cron.php index b5d298e2a..7df552a6d 100644 --- a/config/cron.php +++ b/config/cron.php @@ -4,8 +4,9 @@ return [ 'tasks' => [ - app\task\TaskCron::class, - app\task\TaskSettlementCron::class, +// app\task\TaskCron::class, +// app\task\TaskSettlementCron::class, // app\task\Ceshi::class, + app\task\TaskCompanyAuthNotifyCron::class, ] ]; \ No newline at end of file