|
|
@@ -6,11 +6,9 @@ namespace App\Servers\ESign;
|
|
|
|
|
|
|
|
|
use App\Models\Member;
|
|
|
-use App\Models\SignMember;
|
|
|
use App\Servers\ESign\comm\EsignHttpHelper;
|
|
|
use App\Servers\ESign\comm\EsignLogHelper;
|
|
|
use App\Servers\ESign\emun\HttpEmun;
|
|
|
-use App\Servers\Member\MemberServer;
|
|
|
use App\Servers\System\RedisDataServer;
|
|
|
use App\Servers\System\SmsServer;
|
|
|
|
|
|
@@ -60,7 +58,7 @@ class ESignServer
|
|
|
* 获取个人认证&授权页面链接
|
|
|
* @return bool
|
|
|
*/
|
|
|
- function psnauthurl($m_id,$firm_id,$phone,$psnName,$id_number,$psnId='')
|
|
|
+ function psnauthurl($m_id,$phone,$psnName,$id_number,$psnId='')
|
|
|
{
|
|
|
$authShortUrl=RedisDataServer::creatServer()->getData($m_id.'_memberUrl');
|
|
|
if($authShortUrl){
|
|
|
@@ -87,7 +85,7 @@ class ESignServer
|
|
|
"redirectConfig"=>[
|
|
|
"redirectUrl"=>'',
|
|
|
],
|
|
|
- "notifyUrl"=>route('wps.esignNotify'),
|
|
|
+ "notifyUrl"=>route('notify.esignNotify'),
|
|
|
"clientType"=>"ALL",
|
|
|
"appScheme"=>""
|
|
|
];
|
|
|
@@ -103,15 +101,14 @@ class ESignServer
|
|
|
if($authShortUrl){
|
|
|
return true;
|
|
|
}
|
|
|
- $signMember=SignMember::where('m_id',$m_id)->where('firm_id',$firm_id)->where('authType','PSN')->where([['updated_at','<=',date('Y-m-d H:i:s',time()-600),'or'],['authShortUrl','=','','or']])->first();
|
|
|
+ $signMember=Member::where('m_id',$m_id)->where('authType','PSN')->where([['updated_at','<=',date('Y-m-d H:i:s',time()-600),'or'],['authShortUrl','=','','or']])->first();
|
|
|
if($signMember){
|
|
|
$authUrl = $ret['data']['authUrl'];
|
|
|
$authShortUrl = $ret['data']['authShortUrl'];
|
|
|
RedisDataServer::creatServer()->setData($m_id.'_memberUrl',$authShortUrl,'str',600);
|
|
|
$authFlowId = $ret['data']['authFlowId'];
|
|
|
- $member=Member::where('id',$m_id)->select(['phone','promissory_name'])->first();
|
|
|
- $content='尊敬的'.$member['promissory_name'].',您有待认证信息,点击认证 '.$authShortUrl;
|
|
|
- SmsServer::creatServer()->sendContent($member['phone'],$content);
|
|
|
+ $content='尊敬的'.$signMember['name'].',您有待认证信息,点击认证 '.$authShortUrl;
|
|
|
+ SmsServer::creatServer()->sendContent($signMember['phone'],$content);
|
|
|
//存入数据库
|
|
|
$signMember->update([
|
|
|
'authUrl'=>$authUrl,
|
|
|
@@ -128,36 +125,16 @@ class ESignServer
|
|
|
|
|
|
/**
|
|
|
* 查询个人认证信息
|
|
|
- * @param $m_id //用户id
|
|
|
- * @param $firm_id //企业id
|
|
|
- * @param $firm_name //企业名称
|
|
|
* @param $phone //手机号
|
|
|
* @param $psnName //认证人姓名
|
|
|
* @param $id_number //认证人身份证号
|
|
|
* @return SignMember|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
|
|
|
*/
|
|
|
- function personsidentityinfo($m_id,$firm_id,$firm_name,$phone,$psnName,$id_number)
|
|
|
+ function personsidentityinfo($m_id,$phone,$psnName,$id_number)
|
|
|
{
|
|
|
- $info = SignMember::where('id_number',$id_number)->where('firm_id',$firm_id)->where('authType','PSN')->first();
|
|
|
- if (empty($info)){
|
|
|
- //入库
|
|
|
- SignMember::create([
|
|
|
- 'm_id' => $m_id,
|
|
|
- 'firm_id' => $firm_id,
|
|
|
- 'firm_name' => $firm_name,
|
|
|
- 'phone' => $phone,
|
|
|
- 'name' => $psnName,
|
|
|
- 'id_number' => $id_number,
|
|
|
- 'realnameStatus'=>0,
|
|
|
- 'authorizeUserInfo'=>0,
|
|
|
- 'psnId'=>'',
|
|
|
- 'authShortUrl'=>'',
|
|
|
- 'authType' => 'PSN',
|
|
|
- ]);
|
|
|
- }else{
|
|
|
- if($info->{'realnameStatus'}==1 && $info->{'psnId'}!=''){
|
|
|
- return $info->{'realnameStatus'};
|
|
|
- }
|
|
|
+ $info = Member::where('id_number',$id_number)->where('id',$m_id)->where('authType','PSN')->first();
|
|
|
+ if($info->{'realnameStatus'}==1 && $info->{'psnId'}!=''){
|
|
|
+ return $info->{'realnameStatus'};
|
|
|
}
|
|
|
|
|
|
$config=$this->config;
|
|
|
@@ -175,17 +152,14 @@ class ESignServer
|
|
|
//个人账号ID
|
|
|
$psnId = $ret['data']['psnId'];
|
|
|
//更新认证信息
|
|
|
- SignMember::where('id_number',$id_number)->where('firm_id',$firm_id)->where('authType','PSN')->update([
|
|
|
+ Member::where('id_number',$id_number)->update([
|
|
|
'realnameStatus'=>$realnameStatus,
|
|
|
'authorizeUserInfo'=>$authorizeUserInfo,
|
|
|
'psnId'=>$psnId,
|
|
|
]);
|
|
|
- if ($realnameStatus == 1){//更新用户认证状态
|
|
|
- MemberServer::creatServer()->updateMemberStatus($m_id,$firm_id);
|
|
|
- }
|
|
|
|
|
|
if (empty($realnameStatus) || empty($authorizeUserInfo)){//走个人认证授权流程
|
|
|
- $this->psnauthurl($m_id,$firm_id,$phone,$psnName,$id_number,$psnId);
|
|
|
+ $this->psnauthurl($m_id,$phone,$psnName,$id_number,$psnId);
|
|
|
}
|
|
|
//未授权也注销
|
|
|
if(empty($authorizeUserInfo))$realnameStatus=0;
|
|
|
@@ -197,7 +171,7 @@ class ESignServer
|
|
|
//个人账号ID
|
|
|
$psnId = '';
|
|
|
//走认证授权流程
|
|
|
- $this->psnauthurl($m_id,$firm_id,$phone,$psnName,$id_number);
|
|
|
+ $this->psnauthurl($m_id,$phone,$psnName,$id_number);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -205,137 +179,6 @@ class ESignServer
|
|
|
return $realnameStatus;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询企业授权详情
|
|
|
- * @param $orgId
|
|
|
- * @return \App\Servers\ESign\comm\EsignResponse
|
|
|
- */
|
|
|
- function organizationsAuthorizedInfo($orgId){
|
|
|
- $config=$this->config ;
|
|
|
- $apiaddr="/v3/organizations/".$orgId."/authorized-info";
|
|
|
- $requestType = HttpEmun::GET;
|
|
|
- $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
|
|
|
- //发起接口请求
|
|
|
- EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
|
|
|
- $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
|
|
|
- EsignLogHelper::printMsg($response->getStatus());
|
|
|
- EsignLogHelper::printMsg($response->getBody());
|
|
|
- return $response;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询企业实名状态
|
|
|
- * @param $orgName
|
|
|
- * @return mixed
|
|
|
- */
|
|
|
- function organizationsIdentityInfo($orgName){
|
|
|
- $config=$this->config;
|
|
|
- $apiaddr="/v3/organizations/identity-info?orgName=".$orgName;
|
|
|
- $requestType = HttpEmun::GET;
|
|
|
- $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
|
|
|
- //发起接口请求
|
|
|
-// EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
|
|
|
- $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
|
|
|
-// EsignLogHelper::writeLog($response->getStatus());
|
|
|
-// EsignLogHelper::printMsg($response->getBody());
|
|
|
- $ret=json_decode($response->getBody(),true);
|
|
|
- if(isset($ret['code']) && $ret['code']==0){
|
|
|
- //realnameStatus 0 - 未实名,1 - 已实名
|
|
|
- return $ret['data'];
|
|
|
- }else{
|
|
|
- return ['realnameStatus'=>-1,'orgId'=>'','authorizeUserInfo'=>false,'orgName'=>$orgName];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取机构认证&授权页面链接
|
|
|
- * @param $orgName
|
|
|
- */
|
|
|
- function orgAuthUrl($orgName){
|
|
|
- $config=$this->config;
|
|
|
- $apiaddr="/v3/org-auth-url";
|
|
|
- $requestType = HttpEmun::POST;
|
|
|
- $data=[
|
|
|
- "orgAuthConfig"=>[
|
|
|
- "orgName"=>$orgName,
|
|
|
- "orgInfo"=>[
|
|
|
- "orgIDCardNum"=>"",
|
|
|
- "orgIDCardType"=>"CRED_ORG_USCC"
|
|
|
-
|
|
|
- ],
|
|
|
- "transactorInfo"=>[
|
|
|
- "psnAccount"=>"",
|
|
|
- "psnInfo"=>[
|
|
|
- "psnIDCardNum"=>"",
|
|
|
- "psnName"=>""
|
|
|
- ]
|
|
|
- ],
|
|
|
- ],
|
|
|
- "redirectConfig"=>[
|
|
|
- "redirectUrl"=>"https://www.baidu.com/"
|
|
|
- ],
|
|
|
- "notifyUrl"=>"",
|
|
|
- "clientType"=>"ALL",
|
|
|
- "appScheme"=>""
|
|
|
- ];
|
|
|
- $paramStr = json_encode($data);
|
|
|
- //生成签名验签+json体的header
|
|
|
- $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
|
|
|
- //发起接口请求
|
|
|
-// EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
|
|
|
- $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
|
|
|
-// EsignLogHelper::printMsg($response->getStatus());
|
|
|
-// EsignLogHelper::printMsg($response->getBody());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 企业授权
|
|
|
- * @param $orgName
|
|
|
- */
|
|
|
- function orgAuthorizehUrl($orgName){
|
|
|
- $config=$this->config;
|
|
|
- $apiaddr="/v3/org-auth-url";
|
|
|
- $requestType = HttpEmun::POST;
|
|
|
- $data=[
|
|
|
- "orgAuthConfig"=>[
|
|
|
- "orgName"=>$orgName,
|
|
|
- "orgInfo"=>[
|
|
|
- "orgIDCardNum"=>"",
|
|
|
- "orgIDCardType"=>" "
|
|
|
-
|
|
|
- ],
|
|
|
- "transactorInfo"=>[
|
|
|
- "psnAccount"=>"",
|
|
|
- "psnInfo"=>[
|
|
|
- "psnIDCardNum"=>"",
|
|
|
- "psnName"=>""
|
|
|
- ]
|
|
|
- ],
|
|
|
- ],
|
|
|
- "authorizeConfig"=>[
|
|
|
- "authorizedScopes"=>[
|
|
|
- "get_org_identity_info","get_psn_identity_info","org_initiate_sign","psn_initiate_sign","manage_org_resource","manage_psn_resource","use_org_order"
|
|
|
- ]
|
|
|
- ],
|
|
|
- "redirectConfig"=>[
|
|
|
- "redirectUrl"=>"https://www.baidu.com/"
|
|
|
- ],
|
|
|
- "notifyUrl"=>"",
|
|
|
- "clientType"=>"ALL",
|
|
|
- "appScheme"=>""
|
|
|
- ];
|
|
|
- $paramStr = json_encode($data);
|
|
|
- //生成签名验签+json体的header
|
|
|
- $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
|
|
|
- //发起接口请求
|
|
|
- EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
|
|
|
- $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
|
|
|
- EsignLogHelper::printMsg($response->getStatus());
|
|
|
- EsignLogHelper::printMsg($response->getBody());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
|