| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace App\Http\Controllers\AdminApi;
- use App\Http\Controllers\ApiController;
- use App\Models\Firm;
- use App\Models\Member;
- use App\Models\SignContract;
- use App\Models\SignRecord;
- use App\Servers\ESign\comm\EsignLogHelper;
- use App\Servers\System\JobServer;
- class NotifyController extends ApiController
- {
- /**
- * e签宝回调通知
- * @return false|string
- */
- function esignNotify()
- {
- $data = file_get_contents('php://input');
- EsignLogHelper::writeLog($data,3);
- $data = json_decode($data,true);
- //回调错误
- if (!isset($data['action'])){
- return json_encode(['code'=>'0','msg'=>'error']);
- }
- if ($data['action'] == 'AUTH_PASS'){//实名认证通过通知
- $authFlowId = $data['authFlowId'];
- if ($data['authType'] == 'PSN'){
- $psnId = $data['psnInfo']['psnId'];
- //更新数据
- $info = Member::where('authType','PSN')
- ->where('authFlowId',$authFlowId)
- ->update(['realnameStatus'=>1,'psnId'=>$psnId]);
- }elseif ($data['authType'] == 'ORG'){
- $orgId = $data['organization']['orgId'];
- $orgName = $data['organization']['orgName'];
- //更新数据
- $info = Firm::where('authType','ORG')
- ->where('firm_name',$orgName)
- ->where('realnameStatus',0)
- ->update(['realnameStatus'=>1,'orgId'=>$orgId]);
- }
- }elseif ($data['action'] == 'AUTHORIZE_FINISH'){//授权通知
- $authFlowId = $data['authFlowId'];
- $psnId = $data['psnId'];
- $orgId = $data['orgId'] ?? '';
- $authorizedInfo = json_encode($data['authorizedInfo']);
- if($orgId){
- Firm::where('authFlowId',$authFlowId)->update(['authorizeUserInfo'=>1,'realnameStatus'=>1,'orgId'=>$orgId,'authorizedInfo'=>$authorizedInfo]);
- //检测系统内部的企业印章信息
- JobServer::creatServer()->createFirmSealJob($orgId);
- }else{
- Member::where('authFlowId',$authFlowId)->update(['authorizeUserInfo'=>1,'realnameStatus'=>1,'psnId'=>$psnId,'authorizedInfo'=>$authorizedInfo]);
- //检测系统内部的企业印章信息
- JobServer::creatServer()->createMemberSealJob($psnId);
- }
- }elseif ($data['action'] == 'AUTHORIZE_CHANGE'){
- //授权变更通知
- }elseif ($data['action'] == 'SIGN_FLOW_COMPLETE'){
- //合同签署
- $signFlowStatus = $data['signFlowStatus'];
- $signFlowId = $data['signFlowId'];
- SignContract::where('flow_id',$signFlowId)->update(['status'=>$signFlowStatus]);
- }elseif ($data['action'] == 'SIGN_MISSON_COMPLETE'){
- //合同签署
- $signFlowStatus = $data['signResult'];
- $signFlowId = $data['signFlowId'];
- $organization = $data['organization'];
- $operator = $data['operator'];
- if (!empty($signFlowId)){
- $sign = SignContract::where('flow_id',$signFlowId)->first();
- $sign_id = $sign->{'id'};
- if (!empty($operator)){
- $psnId = $operator['psnId'];
- SignRecord::where('sign_id',$sign_id)->where('authType','PSN')->where('id_no',$psnId)->update(['status'=>$signFlowStatus]);
- }
- if (!empty($organization)){
- $orgId = $organization['orgId'];
- SignRecord::where('sign_id',$sign_id)->where('authType','ORG')->where('id_no',$orgId)->update(['status'=>$signFlowStatus]);
- }
- }
- }elseif ($data['action']=='SEAL_AUTH_SIGN'){
- // SealServer::creatServer()->sealNotify($data['authStatus'],$data['sealAuthBizId']);
- }
- return json_encode(['code'=>'200','msg'=>'success']);
- }
- }
|