NotifyController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Http\Controllers\AdminApi;
  3. use App\Http\Controllers\ApiController;
  4. use App\Models\Firm;
  5. use App\Models\Member;
  6. use App\Servers\ESign\comm\EsignLogHelper;
  7. use App\Servers\System\JobServer;
  8. class NotifyController extends ApiController
  9. {
  10. /**
  11. * e签宝回调通知
  12. * @return false|string
  13. */
  14. function esignNotify()
  15. {
  16. $data = file_get_contents('php://input');
  17. EsignLogHelper::writeLog($data,3);
  18. $data = json_decode($data,true);
  19. //回调错误
  20. if (!isset($data['action'])){
  21. return json_encode(['code'=>'0','msg'=>'error']);
  22. }
  23. if ($data['action'] == 'AUTH_PASS'){//实名认证通过通知
  24. $authFlowId = $data['authFlowId'];
  25. if ($data['authType'] == 'PSN'){
  26. $psnId = $data['psnInfo']['psnId'];
  27. //更新数据
  28. $info = Member::where('authType','PSN')
  29. ->where('authFlowId',$authFlowId)
  30. ->update(['realnameStatus'=>1,'psnId'=>$psnId]);
  31. }elseif ($data['authType'] == 'ORG'){
  32. $orgId = $data['organization']['orgId'];
  33. $orgName = $data['organization']['orgName'];
  34. //更新数据
  35. $info = Firm::where('authType','ORG')
  36. ->where('firm_name',$orgName)
  37. ->where('realnameStatus',0)
  38. ->update(['realnameStatus'=>1,'orgId'=>$orgId]);
  39. }
  40. }elseif ($data['action'] == 'AUTHORIZE_FINISH'){//授权通知
  41. $authFlowId = $data['authFlowId'];
  42. $psnId = $data['psnId'];
  43. $orgId = $data['orgId'] ?? '';
  44. $authorizedInfo = json_encode($data['authorizedInfo']);
  45. if($orgId){
  46. Firm::where('authFlowId',$authFlowId)->update(['authorizeUserInfo'=>1,'realnameStatus'=>1,'orgId'=>$orgId,'authorizedInfo'=>$authorizedInfo]);
  47. //检测系统内部的企业印章信息
  48. JobServer::creatServer()->createFirmSealJob($orgId);
  49. }else{
  50. Member::where('authFlowId',$authFlowId)->update(['authorizeUserInfo'=>1,'realnameStatus'=>1,'psnId'=>$psnId,'authorizedInfo'=>$authorizedInfo]);
  51. //检测系统内部的企业印章信息
  52. JobServer::creatServer()->createMemberSealJob($psnId);
  53. }
  54. }elseif ($data['action'] == 'AUTHORIZE_CHANGE'){
  55. //授权变更通知
  56. }elseif ($data['action'] == 'SIGN_FLOW_COMPLETE'){
  57. //合同签署
  58. ContractServer::creatServer()->signEnd($data['signFlowStatus'],$data['signFlowId']);
  59. }elseif ($data['action'] == 'SIGN_MISSON_COMPLETE'){
  60. //合同签署
  61. if(!empty($data['organization']) && !empty($data['signFlowId']))ContractServer::creatServer()->signFirmEnd($data['signResult'],$data['signFlowId'],$data['organization']);
  62. }elseif ($data['action']=='SEAL_AUTH_SIGN'){
  63. // SealServer::creatServer()->sealNotify($data['authStatus'],$data['sealAuthBizId']);
  64. }
  65. return json_encode(['code'=>'200','msg'=>'success']);
  66. }
  67. }