推广
This commit is contained in:
116
alipay/AliverifyPublic.php
Normal file
116
alipay/AliverifyPublic.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace alipay;
|
||||
|
||||
require_once APP_PATH . 'alipay/aop/AopCertClient.php';
|
||||
require_once APP_PATH . 'alipay/aop/AopCertification.php';
|
||||
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenInitializeRequest.php';
|
||||
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenCertifyRequest.php';
|
||||
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenQueryRequest.php';
|
||||
|
||||
/**
|
||||
* 证书类型AopClient功能方法使用测试
|
||||
* 1、execute 调用示例
|
||||
* 2、sdkExecute 调用示例
|
||||
* 3、pageExecute 调用示例
|
||||
*/
|
||||
|
||||
class AliverifyPublic
|
||||
{
|
||||
|
||||
public static function initVerify($temp)
|
||||
{
|
||||
global $config;
|
||||
$aop = new \AopCertClient();
|
||||
$res = [];
|
||||
$res['name'] = $temp['name'];
|
||||
$res['id_code'] = $temp['id_code'];
|
||||
|
||||
$appCertPath = $config['alipay']['app_crt'];
|
||||
$alipayCertPath = $config['alipay']['public_crt'];
|
||||
$rootCertPath = $config['alipay']['root_crt'];
|
||||
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = $config['alipay']['app_id'];
|
||||
$aop->rsaPrivateKey = $config['alipay']['private_key'];
|
||||
$aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥
|
||||
$aop->apiVersion = '1.0';
|
||||
$aop->signType = 'RSA2';
|
||||
$aop->postCharset='utf-8';
|
||||
$aop->format='json';
|
||||
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
|
||||
$aop->appCertSN = $aop->getCertSN($appCertPath);//调用getCertSN获取证书序列号
|
||||
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
|
||||
|
||||
$request = new \AlipayUserCertifyOpenInitializeRequest();
|
||||
//$request = new AlipayUserCertifyOpenInitializeRequest (); //TODO 官方这个地方写错了,应该用下面的代码才能实现
|
||||
|
||||
$newsigndata=array();
|
||||
$newsigndata['outer_order_no']=md5(time());
|
||||
$newsigndata['biz_code']="FACE";
|
||||
$newsigndata['identity_param']['identity_type']="CERT_INFO";
|
||||
$newsigndata['identity_param']['cert_type']="IDENTITY_CARD";
|
||||
$newsigndata['identity_param']['cert_name']=$res['name'];
|
||||
$newsigndata['identity_param']['cert_no']= $res['id_code'];
|
||||
$newsigndata['face_contrast_picture']="xydasf==";
|
||||
$tosign=json_encode($newsigndata);
|
||||
$request->setBizContent($tosign);
|
||||
|
||||
$result = $aop->execute ( $request);
|
||||
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
$certify_id = $result->$responseNode->certify_id;
|
||||
if(!empty($resultCode)&&$resultCode == 10000){
|
||||
$request = new \AlipayUserCertifyOpenCertifyRequest ();
|
||||
$data['certify_id'] = $certify_id;
|
||||
$tosign=json_encode($data);
|
||||
$request->setBizContent($tosign);
|
||||
$result = $aop->pageExecute($request,"GET");
|
||||
|
||||
$res['certifyId'] = $certify_id;
|
||||
$res['url'] = $result;
|
||||
return $res;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getResult($certify_id)
|
||||
{
|
||||
global $config;
|
||||
$aop = new \AopCertClient();
|
||||
|
||||
$appCertPath = $config['alipay']['app_crt'];
|
||||
$alipayCertPath = $config['alipay']['public_crt'];
|
||||
$rootCertPath = $config['alipay']['root_crt'];
|
||||
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = $config['alipay']['app_id'];
|
||||
$aop->rsaPrivateKey = $config['alipay']['private_key'];
|
||||
$aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥
|
||||
$aop->apiVersion = '1.0';
|
||||
$aop->signType = 'RSA2';
|
||||
$aop->postCharset='utf-8';
|
||||
$aop->format='json';
|
||||
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
|
||||
$aop->appCertSN = $aop->getCertSN($appCertPath);//调用getCertSN获取证书序列号
|
||||
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
|
||||
|
||||
$request = new \AlipayUserCertifyOpenQueryRequest ();
|
||||
$data['certify_id'] = $certify_id;
|
||||
$tosign=json_encode($data);
|
||||
$request->setBizContent($tosign);
|
||||
$result = $aop->execute ( $request);
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->passed;
|
||||
if($resultCode == 'T'){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -14,13 +14,14 @@ class Account extends Controller
|
||||
{
|
||||
$get_data = $_GET;
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
$agent_phone = $this->userinfo['phone'];
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$where = [];
|
||||
$where_str = '';
|
||||
$where['agent_id'] = $agent_id;
|
||||
$where['UserCode'] = $agent_phone;
|
||||
|
||||
//处理筛选
|
||||
if($get_data['UserId'] != 0){
|
||||
@@ -65,6 +66,7 @@ class Account extends Controller
|
||||
$day = ceil(($endtime - time())/86400);
|
||||
$info['RestTime'] = $day.'天';
|
||||
}
|
||||
$info['UserCode'] = $info['UserPhone']?$info['UserPhone']:$info['UserCode'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace app\agent\controller;
|
||||
use fastphp\base\Jwt;
|
||||
use app\agent\model\AgentUser;
|
||||
use app\agent\model\User as UserModel;
|
||||
use alipay\AliverifyPublic as Aliverify;
|
||||
|
||||
class Index
|
||||
{
|
||||
@@ -21,6 +22,7 @@ class Index
|
||||
$payload = [
|
||||
'LoginName' => $userinfo['realname'],
|
||||
'RoleName' => '',
|
||||
'phone' => $userinfo['phone'],
|
||||
'OperaterID' => $userinfo['id'],
|
||||
'TenantId' => 1157,
|
||||
'iat' => time(),
|
||||
@@ -81,10 +83,10 @@ class Index
|
||||
$data['DeleteTag'] = 0;
|
||||
$data['UseTestCount'] = 0;
|
||||
$data['Sex'] = 0;
|
||||
$data['Wx'] = $data['Wx'];
|
||||
$data['QQ'] = $data['QQ'];
|
||||
$data['Wx'] = '';
|
||||
$data['QQ'] = '';
|
||||
$data['LastLoginDate'] = date('Y-m-d H:i:s',time());
|
||||
$data['Password'] = empty($data['Password'])?cToMd5('1234'):cToMd5(trim($data['Password']));
|
||||
$data['Password'] = empty($data['Password'])?cToMd5('123468455'):cToMd5(trim($data['Password']));
|
||||
|
||||
$user_model = new UserModel;
|
||||
$manager_list = $user_model->getManagerList([],'ManagerId,ManagerName,count(1) as num',['ManagerId'],'num asc');
|
||||
@@ -103,14 +105,65 @@ class Index
|
||||
}
|
||||
|
||||
if ($user_model->add($data)) {
|
||||
$info = [
|
||||
'Code' => 10000,
|
||||
'Data' => '',
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($info);
|
||||
die;
|
||||
|
||||
return $this->aliverify([
|
||||
'id_code' => $data['id_code'],
|
||||
'name' => $data['Name'],
|
||||
'phone' => $data['LoginCode']
|
||||
]);
|
||||
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
public function aliverify($temp)
|
||||
{
|
||||
$info = Aliverify::initVerify($temp);
|
||||
$user = new UserModel;
|
||||
$data = [];
|
||||
if($info){
|
||||
$update_one['certify_id'] = $info['certifyId'];
|
||||
$update_one['Name'] = $temp['name'];
|
||||
if(isset($temp['phone'])){
|
||||
$update_one['Phone'] = $temp['phone'];
|
||||
}
|
||||
$update_one['id_code'] = $temp['id_code'];
|
||||
$data['certify_id'] = $info['certifyId'];
|
||||
$data['url'] = $info['url'];
|
||||
if($user->updateOne(['Id'=>$this->userinfo['UserId']],$update_one)){
|
||||
$data['Code'] = 10000;
|
||||
} else {
|
||||
$data = [
|
||||
'Code'=>-10000
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$data = [
|
||||
'Code'=>-10000
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function aliGetResult()
|
||||
{
|
||||
$user = new UserModel;
|
||||
$user_one_info = $user->getOne(['Id'=>$this->userinfo['UserId']]);
|
||||
$info = Aliverify::getResult($user_one_info['certify_id']);
|
||||
$data = [];
|
||||
if($info){
|
||||
$user_data['is_verify'] = 1;
|
||||
if($user->updateOne(['Id'=>$this->userinfo['UserId']],$user_data)){
|
||||
$data = [
|
||||
'Code'=>10000
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$data = [
|
||||
'Code'=>-10000
|
||||
];
|
||||
}
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,13 +14,14 @@ class Order extends Controller
|
||||
{
|
||||
$get_data = $_GET;
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
$agent_phone = $this->userinfo['phone'];
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$where = [];
|
||||
$where_str = '';
|
||||
$where['agent_id'] = $agent_id;
|
||||
$where['UserName'] = $agent_phone;
|
||||
|
||||
if(!empty($get_data['ProductIds'])){
|
||||
$where['ProductId'] = $get_data['ProductIds'];
|
||||
|
||||
Reference in New Issue
Block a user