| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Http\Controllers\AdminApi;
- use App\Http\Controllers\ApiController;
- use App\Models\Member;
- use App\Servers\ESign\comm\EsignLogHelper;
- 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']);
- //更新用户授权数据
- Member::where('authFlowId',$authFlowId)->update(['authorizeUserInfo'=>1,'realnameStatus'=>1,'psnId'=>$psnId,'orgId'=>$orgId,'authorizedInfo'=>$authorizedInfo]);
- if($orgId){
- //检查该企业是否认证授权
- ESignFirmServer::creatServer()->setSignFirm($data);
- }
- }elseif ($data['action'] == 'AUTHORIZE_CHANGE'){
- //授权变更通知
- }elseif ($data['action'] == 'SIGN_FLOW_COMPLETE'){
- //合同签署
- ContractServer::creatServer()->signEnd($data['signFlowStatus'],$data['signFlowId']);
- }elseif ($data['action'] == 'SIGN_MISSON_COMPLETE'){
- //合同签署
- if(!empty($data['organization']) && !empty($data['signFlowId']))ContractServer::creatServer()->signFirmEnd($data['signResult'],$data['signFlowId'],$data['organization']);
- }elseif ($data['action']=='SEAL_AUTH_SIGN'){
- // SealServer::creatServer()->sealNotify($data['authStatus'],$data['sealAuthBizId']);
- }
- return json_encode(['code'=>'200','msg'=>'success']);
- }
- }
|