代码初始化
This commit is contained in:
146
extend/AliPayV2/AliPay.php
Normal file
146
extend/AliPayV2/AliPay.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
use think\Loader;
|
||||
|
||||
/**
|
||||
* 支付宝插件 使用方法请查看同文件夹下的demo
|
||||
* 目前已经支持电脑网站支付,手机APP支付,支付回调校验,用户提现等功能,如需拓展请联系作者
|
||||
* @author Jack_YanTC <627495692@qq.com>
|
||||
*/
|
||||
class AliPay
|
||||
{
|
||||
private $appId;
|
||||
private $rsaPrivateKey;
|
||||
private $notifyUrl;
|
||||
private $alipayPublicKey;
|
||||
private $appCertPath;
|
||||
private $alipayCertPath;
|
||||
private $rootCertPath;
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->appCertPath = ADDON_PATH . 'epay/certs/appCertPublicKey_2021005162648430.crt';
|
||||
$this->alipayCertPath = ADDON_PATH . 'epay/certs/alipayCertPublicKey_RSA2.crt';
|
||||
$this->rootCertPath = ADDON_PATH . 'epay/certs/alipayRootCert.crt';
|
||||
|
||||
$configs = get_system_config();
|
||||
$this->appId = $configs['alipay_app_id'];
|
||||
$this->rsaPrivateKey = $configs['alipay_private_key'];
|
||||
$this->alipayPublicKey = $configs['alipay_public_key'];
|
||||
$this->notifyUrl = $configs['web_site']."/api/Payment/notify_ali";
|
||||
|
||||
$aliPayPath = EXTEND_PATH.'/AliPayV2/alipay-sdk/aopV2/';
|
||||
require_once $aliPayPath . 'AopCertClient.php';
|
||||
require_once $aliPayPath . 'AopClient.php';
|
||||
require_once $aliPayPath . 'AopCertification.php';
|
||||
require_once $aliPayPath . 'AlipayConfig.php';
|
||||
require_once $aliPayPath . 'request/AlipaySystemOauthTokenRequest.php';
|
||||
require_once $aliPayPath . 'request/AlipayUserInfoShareRequest.php';
|
||||
require_once $aliPayPath . 'request/AlipayTradeAppPayRequest.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝手机网站支付
|
||||
* @param string $orderid 订单号
|
||||
* @param string $money 金额
|
||||
* @param string $subject 标题
|
||||
* @return string
|
||||
*/
|
||||
public function aliAppPays($orderid, $money, $subject)
|
||||
{
|
||||
$aop = new AopCertClient ();
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = $this->appId;
|
||||
$aop->rsaPrivateKey = $this->rsaPrivateKey;
|
||||
$aop->alipayrsaPublicKey = $aop->getPublicKey($this->alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥
|
||||
$aop->apiVersion = '1.0';
|
||||
$aop->signType = 'RSA2';
|
||||
$aop->postCharset = 'utf-8';
|
||||
$aop->format = 'json';
|
||||
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
|
||||
$aop->appCertSN = $aop->getCertSN($this->appCertPath);//调用getCertSN获取证书序列号
|
||||
$aop->alipayRootCertSN = $aop->getRootCertSN($this->rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
|
||||
|
||||
$request = new AlipayTradeAppPayRequest ();
|
||||
|
||||
$bizcontent = json_encode([
|
||||
'subject' => $subject,
|
||||
'out_trade_no' => $orderid,//此订单号为商户唯一订单号
|
||||
'total_amount' => $money//保留两位小数
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$request->setNotifyUrl($this->notifyUrl);
|
||||
$request->setBizContent($bizcontent);
|
||||
|
||||
$result = $aop->sdkExecute($request);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function verify($post)
|
||||
{
|
||||
$aop = new AopCertClient ();
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = $this->appId;
|
||||
$aop->rsaPrivateKey = $this->rsaPrivateKey;
|
||||
$aop->alipayrsaPublicKey = $aop->getPublicKey($this->alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥
|
||||
$aop->apiVersion = '1.0';
|
||||
$aop->signType = 'RSA2';
|
||||
$aop->postCharset = 'utf-8';
|
||||
$aop->format = 'json';
|
||||
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
|
||||
$aop->appCertSN = $aop->getCertSN($this->appCertPath);//调用getCertSN获取证书序列号
|
||||
$aop->alipayRootCertSN = $aop->getRootCertSN($this->rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
|
||||
|
||||
return $aop->rsaCheckV1($post, NULL, "RSA2");
|
||||
}
|
||||
|
||||
|
||||
//支付宝换取访问令牌
|
||||
public function login($auth_code)
|
||||
{
|
||||
$aop = new AopCertClient ();
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = $this->appId;
|
||||
$aop->rsaPrivateKey = $this->rsaPrivateKey;
|
||||
$aop->alipayrsaPublicKey = $aop->getPublicKey($this->alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥
|
||||
$aop->apiVersion = '1.0';
|
||||
$aop->signType = 'RSA2';
|
||||
$aop->postCharset = 'utf-8';
|
||||
$aop->format = 'json';
|
||||
$aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
|
||||
$aop->appCertSN = $aop->getCertSN($this->appCertPath);//调用getCertSN获取证书序列号
|
||||
$aop->alipayRootCertSN = $aop->getRootCertSN($this->rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
|
||||
|
||||
|
||||
// 创建请求对象
|
||||
$request = new AlipaySystemOauthTokenRequest();//AlipaySystemOauthTokenRequest
|
||||
$request->setGrantType("authorization_code");
|
||||
$request->setCode( $auth_code);
|
||||
|
||||
// 执行请求,获取access_token
|
||||
$result = $aop->execute($request);
|
||||
|
||||
if (isset( $result->alipay_system_oauth_token_response->access_token)) {
|
||||
// 获取用户信息
|
||||
$userinfo_request = new AlipayUserInfoShareRequest();
|
||||
$userinfo_result = $aop->execute( $userinfo_request, $result->alipay_system_oauth_token_response->access_token);
|
||||
if ($userinfo_result->alipay_user_info_share_response->code == '10000') {
|
||||
// 处理用户信息,例如保存到数据库
|
||||
$user_info = $userinfo_result->alipay_user_info_share_response;
|
||||
return ['code'=>'1','msg'=>'success','data'=>$user_info];
|
||||
} else {
|
||||
// 处理错误
|
||||
return ['code'=>$result->error_response->code,'msg'=>$result->error_response->msg.'/'.$result->error_response->sub_code,'data'=>$result->error_response->sub_msg];
|
||||
}
|
||||
} else {
|
||||
// 处理错误
|
||||
return ['code'=>$result->error_response->code,'msg'=>$result->error_response->msg.'/'.$result->error_response->sub_code,'data'=>$result->error_response->sub_msg];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
197
extend/AliPayV2/alipay-sdk/aopV2/AlipayConfig.php
Normal file
197
extend/AliPayV2/alipay-sdk/aopV2/AlipayConfig.php
Normal file
@@ -0,0 +1,197 @@
|
||||
|
||||
<?php
|
||||
class AlipayConfig {
|
||||
/**
|
||||
* 网关地址
|
||||
* 线上:https://openapi.alipay.com/gateway.do
|
||||
* 沙箱:https://openapi.alipaydev.com/gateway.do
|
||||
*/
|
||||
private $serverUrl;
|
||||
|
||||
/**
|
||||
* 开放平台上创建的应用的ID
|
||||
*/
|
||||
private $appId;
|
||||
|
||||
/**
|
||||
* 报文格式,推荐:json
|
||||
*/
|
||||
private $format = "json";
|
||||
|
||||
/**
|
||||
* 字符串编码,推荐:utf-8
|
||||
*/
|
||||
private $charset = "utf-8";
|
||||
|
||||
/**
|
||||
* 签名算法类型,推荐:RSA2
|
||||
*/
|
||||
private $signType = "RSA2";
|
||||
|
||||
/**
|
||||
* 商户私钥
|
||||
*/
|
||||
private $privateKey;
|
||||
|
||||
/**
|
||||
* 支付宝公钥字符串(公钥模式下设置,证书模式下无需设置)
|
||||
*/
|
||||
private $alipayPublicKey;
|
||||
|
||||
/**
|
||||
* 商户应用公钥证书路径(证书模式下设置,公钥模式下无需设置)
|
||||
*/
|
||||
private $appCertPath;
|
||||
|
||||
/**
|
||||
* 支付宝公钥证书路径(证书模式下设置,公钥模式下无需设置)
|
||||
*/
|
||||
private $alipayPublicCertPath;
|
||||
|
||||
/**
|
||||
* 支付宝根证书路径(证书模式下设置,公钥模式下无需设置)
|
||||
*/
|
||||
private $rootCertPath;
|
||||
|
||||
/**
|
||||
* 指定商户公钥应用证书内容字符串,该字段与appCertPath只需指定一个,优先以该字段的值为准(证书模式下设置,公钥模式下无需设置)
|
||||
*/
|
||||
private $appCertContent;
|
||||
|
||||
/**
|
||||
* 指定支付宝公钥证书内容字符串,该字段与alipayPublicCertPath只需指定一个,优先以该字段的值为准(证书模式下设置,公钥模式下无需设置)
|
||||
*/
|
||||
private $alipayPublicCertContent;
|
||||
|
||||
/**
|
||||
* 指定根证书内容字符串,该字段与rootCertPath只需指定一个,优先以该字段的值为准(证书模式下设置,公钥模式下无需设置)
|
||||
*/
|
||||
private $rootCertContent;
|
||||
|
||||
/**
|
||||
* 敏感信息对称加密算法类型,推荐:AES
|
||||
*/
|
||||
private $encryptType = "AES";
|
||||
|
||||
/**
|
||||
* 敏感信息对称加密算法密钥
|
||||
*/
|
||||
private $encryptKey;
|
||||
|
||||
/**
|
||||
* 跳过加验签(小程序云免鉴权)
|
||||
*/
|
||||
private $skipSign = false;
|
||||
|
||||
|
||||
public function getServerUrl() {
|
||||
return $this->serverUrl;
|
||||
}
|
||||
|
||||
public function setServerUrl($serverUrl) {
|
||||
$this->serverUrl = $serverUrl;
|
||||
}
|
||||
public function getAppId(){
|
||||
return $this->appId;
|
||||
}
|
||||
public function setAppId($appId){
|
||||
$this->appId = $appId;
|
||||
}
|
||||
public function getFormat(){
|
||||
return $this->format;
|
||||
}
|
||||
public function setFormat($format){
|
||||
$this->format = $format;
|
||||
}
|
||||
public function getCharset() {
|
||||
return $this->charset;
|
||||
}
|
||||
|
||||
public function setCharset($charset) {
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
public function getSignType() {
|
||||
return $this->signType;
|
||||
}
|
||||
|
||||
public function setSignType($signType) {
|
||||
$this->signType = $signType;
|
||||
}
|
||||
public function getEncryptKey() {
|
||||
return $this->encryptKey;
|
||||
}
|
||||
|
||||
public function setEncryptKey($encryptKey) {
|
||||
$this->encryptKey = $encryptKey;
|
||||
}
|
||||
public function getEncryptType() {
|
||||
return $this->encryptType;
|
||||
}
|
||||
public function setEncryptType($encryptType) {
|
||||
$this->encryptType = $encryptType;
|
||||
}
|
||||
public function getPrivateKey() {
|
||||
return $this->privateKey;
|
||||
}
|
||||
|
||||
public function setPrivateKey($privateKey) {
|
||||
$this->privateKey = $privateKey;
|
||||
}
|
||||
public function getAlipayPublicKey() {
|
||||
return $this->alipayPublicKey;
|
||||
}
|
||||
public function setAlipayPublicKey($alipayPublicKey) {
|
||||
$this->alipayPublicKey = $alipayPublicKey;
|
||||
}
|
||||
public function getAppCertPath() {
|
||||
return $this->appCertPath;
|
||||
}
|
||||
|
||||
public function setAppCertPath($appCertPath) {
|
||||
$this->appCertPath = $appCertPath;
|
||||
}
|
||||
|
||||
public function getAlipayPublicCertPath() {
|
||||
return $this->alipayPublicCertPath;
|
||||
}
|
||||
public function setAlipayPublicCertPath($alipayPublicCertPath) {
|
||||
$this->alipayPublicCertPath = $alipayPublicCertPath;
|
||||
}
|
||||
|
||||
public function getRootCertPath() {
|
||||
return $this->rootCertPath;
|
||||
}
|
||||
public function setRootCertPath($rootCertPath) {
|
||||
$this->rootCertPath = $rootCertPath;
|
||||
}
|
||||
public function getAppCertContent() {
|
||||
return $this->appCertContent;
|
||||
}
|
||||
public function setAppCertContent($appCertContent) {
|
||||
$this->appCertContent = $appCertContent;
|
||||
}
|
||||
public function getAlipayPublicCertContent() {
|
||||
return $this->alipayPublicCertContent;
|
||||
}
|
||||
public function setAlipayPublicCertContent($alipayPublicCertContent) {
|
||||
$this->alipayPublicCertContent = $alipayPublicCertContent;
|
||||
}
|
||||
public function getRootCertContent() {
|
||||
return $this->rootCertContent;
|
||||
}
|
||||
|
||||
public function setRootCertContent($rootCertContent) {
|
||||
$this->rootCertContent = $rootCertContent;
|
||||
}
|
||||
|
||||
public function isSkipSign()
|
||||
{
|
||||
return $this->skipSign;
|
||||
}
|
||||
|
||||
public function setSkipSign(bool $skipSign)
|
||||
{
|
||||
$this->skipSign = $skipSign;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 多媒体文件客户端
|
||||
* @author yikai.hu
|
||||
* @version $Id: AlipayMobilePublicMultiMediaClient.php, v 0.1 Aug 15, 2014 10:19:01 AM yikai.hu Exp $
|
||||
*/
|
||||
|
||||
include("AlipayMobilePublicMultiMediaExecute.php");
|
||||
|
||||
class AlipayMobilePublicMultiMediaClient
|
||||
{
|
||||
private $DEFAULT_CHARSET = 'UTF-8';
|
||||
private $METHOD_POST = "POST";
|
||||
private $METHOD_GET = "GET";
|
||||
private $SIGN = 'sign'; //get name
|
||||
|
||||
private $timeout = 10;// 超时时间
|
||||
private $serverUrl;
|
||||
private $appId;
|
||||
private $privateKey;
|
||||
private $prodCode;
|
||||
private $format = 'json'; //todo
|
||||
private $sign_type = 'RSA'; //todo
|
||||
|
||||
private $charset;
|
||||
private $apiVersion = "1.0";
|
||||
private $apiMethodName = "alipay.mobile.public.multimedia.download";
|
||||
private $media_id = "L21pZnMvVDFQV3hYWGJKWFhYYUNucHJYP3Q9YW13ZiZ4c2lnPTU0MzRhYjg1ZTZjNWJmZTMxZGJiNjIzNDdjMzFkNzkw575";
|
||||
//此处写死的,实际开发中,请传入
|
||||
|
||||
private $connectTimeout = 3000;
|
||||
private $readTimeout = 15000;
|
||||
|
||||
function __construct($serverUrl = '', $appId = '', $partner_private_key = '', $format = '', $charset = 'GBK')
|
||||
{
|
||||
$this->serverUrl = $serverUrl;
|
||||
$this->appId = $appId;
|
||||
$this->privateKey = $partner_private_key;
|
||||
$this->format = $format;
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* getContents 获取网址内容
|
||||
* @param $request
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
$datas = array(
|
||||
"app_id" => $this->appId,
|
||||
"method" => $this->METHOD_POST,
|
||||
"sign_type" => $this->sign_type,
|
||||
"version" => $this->apiVersion,
|
||||
"timestamp" => date('Y-m-d H:i:s'),//yyyy-MM-dd HH:mm:ss
|
||||
"biz_content" => '{"mediaId":"' . $this->media_id . '"}',
|
||||
"charset" => $this->charset
|
||||
);
|
||||
|
||||
//要提交的数据
|
||||
$data_sign = $this->buildGetUrl($datas);
|
||||
|
||||
$post_data = $data_sign;
|
||||
//初始化 curl
|
||||
$ch = curl_init();
|
||||
//设置目标服务器
|
||||
curl_setopt($ch, CURLOPT_URL, $this->serverUrl);
|
||||
curl_setopt($ch, CURLOPT_HEADER, TRUE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
//超时时间
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
|
||||
|
||||
if ($this->METHOD_POST == 'POST') {
|
||||
// post数据
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
// post的变量
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||||
}
|
||||
|
||||
|
||||
$output = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
echo $output;
|
||||
|
||||
$datas = explode("\r\n\r\n", $output, 2);
|
||||
$header = $datas[0];
|
||||
|
||||
if ($httpCode == '200') {
|
||||
$body = $datas[1];
|
||||
} else {
|
||||
$body = '';
|
||||
|
||||
}
|
||||
|
||||
return $this->execute($header, $body, $httpCode);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $request
|
||||
* @return text | bin
|
||||
*/
|
||||
public function execute($header = '', $body = '', $httpCode = '')
|
||||
{
|
||||
$exe = new AlipayMobilePublicMultiMediaExecute($header, $body, $httpCode);
|
||||
return $exe;
|
||||
}
|
||||
|
||||
public function buildGetUrl($query = array())
|
||||
{
|
||||
if (!is_array($query)) {
|
||||
//exit;
|
||||
}
|
||||
//排序参数,
|
||||
$data = $this->buildQuery($query);
|
||||
|
||||
// 私钥密码
|
||||
$passphrase = '';
|
||||
$key_width = 64;
|
||||
|
||||
//私钥
|
||||
$privateKey = $this->privateKey;
|
||||
$p_key = array();
|
||||
//如果私钥是 1行
|
||||
if (!stripos($privateKey, "\n")) {
|
||||
$i = 0;
|
||||
while ($key_str = substr($privateKey, $i * $key_width, $key_width)) {
|
||||
$p_key[] = $key_str;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
//echo '一行?';
|
||||
}
|
||||
$privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . implode("\n", $p_key);
|
||||
$privateKey = $privateKey . "\n-----END RSA PRIVATE KEY-----";
|
||||
|
||||
//私钥
|
||||
$private_id = openssl_pkey_get_private($privateKey, $passphrase);
|
||||
|
||||
// 签名
|
||||
$signature = '';
|
||||
|
||||
if ("RSA2" == $this->sign_type) {
|
||||
|
||||
openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA256);
|
||||
} else {
|
||||
|
||||
openssl_sign($data, $signature, $private_id, OPENSSL_ALGO_SHA1);
|
||||
}
|
||||
|
||||
openssl_free_key($private_id);
|
||||
|
||||
//加密后的内容通常含有特殊字符,需要编码转换下
|
||||
$signature = base64_encode($signature);
|
||||
|
||||
$signature = urlencode($signature);
|
||||
|
||||
//$signature = 'XjUN6YM1Mc9HXebKMv7GTLy7gmyhktyOgKk2/Jf+cz4DtP6udkzTdpkjW2j/Z4ZSD7xD6CNYI1Spz4yS93HPT0a5X9LgFWYY8SaADqe+ArXg+FBSiTwUz49SE//Xd9+LEiIRsSFkbpkuiGoO6mqJmB7vXjlD5lx6qCM3nb41wb8=';
|
||||
|
||||
$out = $data . '&' . $this->SIGN . '=' . $signature;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询参数排序 a-z
|
||||
* */
|
||||
public function buildQuery($query)
|
||||
{
|
||||
if (!$query) {
|
||||
return null;
|
||||
}
|
||||
//将要 参数 排序
|
||||
ksort($query);
|
||||
|
||||
//重新组装参数
|
||||
$params = array();
|
||||
foreach ($query as $key => $value) {
|
||||
$params[] = $key . '=' . $value;
|
||||
}
|
||||
$data = implode('&', $params);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 多媒体文件客户端
|
||||
* @author yuanwai.wang
|
||||
* @version $Id: AlipayMobilePublicMultiMediaExecute.php, v 0.1 Aug 15, 2014 10:19:01 AM yuanwai.wang Exp $
|
||||
*/
|
||||
|
||||
//namespace alipay\api ;
|
||||
|
||||
|
||||
class AlipayMobilePublicMultiMediaExecute
|
||||
{
|
||||
|
||||
private $code = 200;
|
||||
private $msg = '';
|
||||
private $body = '';
|
||||
private $params = '';
|
||||
|
||||
private $fileSuffix = array(
|
||||
"image/jpeg" => 'jpg', //+
|
||||
"text/plain" => 'text'
|
||||
);
|
||||
|
||||
/*
|
||||
* @$header : 头部
|
||||
* */
|
||||
function __construct($header, $body, $httpCode)
|
||||
{
|
||||
$this->code = $httpCode;
|
||||
$this->msg = '';
|
||||
$this->params = $header;
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getMsg()
|
||||
{
|
||||
return $this->msg;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
$subject = $this->params;
|
||||
$pattern = '/Content\-Type:([^;]+)/';
|
||||
preg_match($pattern, $subject, $matches);
|
||||
if ($matches) {
|
||||
$type = $matches[1];
|
||||
} else {
|
||||
$type = 'application/download';
|
||||
}
|
||||
|
||||
return str_replace(' ', '', $type);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getContentLength()
|
||||
{
|
||||
$subject = $this->params;
|
||||
$pattern = '/Content-Length:\s*([^\n]+)/';
|
||||
preg_match($pattern, $subject, $matches);
|
||||
return (int)(isset($matches[1]) ? $matches[1] : '');
|
||||
}
|
||||
|
||||
|
||||
public function getFileSuffix($fileType)
|
||||
{
|
||||
$type = isset($this->fileSuffix[$fileType]) ? $this->fileSuffix[$fileType] : 'text/plain';
|
||||
if (!$type) {
|
||||
$type = 'json';
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
//header('Content-type: image/jpeg');
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数
|
||||
* @return text | bin
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1303
extend/AliPayV2/alipay-sdk/aopV2/AopCertClient.php
Normal file
1303
extend/AliPayV2/alipay-sdk/aopV2/AopCertClient.php
Normal file
File diff suppressed because it is too large
Load Diff
527
extend/AliPayV2/alipay-sdk/aopV2/AopCertification.php
Normal file
527
extend/AliPayV2/alipay-sdk/aopV2/AopCertification.php
Normal file
@@ -0,0 +1,527 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 验证支付宝公钥证书是否可信
|
||||
* @param $alipayCert 支付宝公钥证书
|
||||
* @param $rootCert 支付宝根证书
|
||||
*/
|
||||
function isTrusted($alipayCert, $rootCert)
|
||||
{
|
||||
$alipayCerts = readPemCertChain($alipayCert);
|
||||
$rootCerts = readPemCertChain($rootCert);
|
||||
if (verifyCertChain($alipayCerts, $rootCerts)) {
|
||||
return verifySignature($alipayCert, $rootCert);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function verifySignature($alipayCert, $rootCert)
|
||||
{
|
||||
$alipayCertArray = explode("-----END CERTIFICATE-----", $alipayCert);
|
||||
$rootCertArray = explode("-----END CERTIFICATE-----", $rootCert);
|
||||
$length = count($rootCertArray) - 1;
|
||||
$checkSign = isCertSigner($alipayCertArray[0] . "-----END CERTIFICATE-----", $alipayCertArray[1] . "-----END CERTIFICATE-----");
|
||||
if (!$checkSign) {
|
||||
$checkSign = isCertSigner($alipayCertArray[1] . "-----END CERTIFICATE-----", $alipayCertArray[0] . "-----END CERTIFICATE-----");
|
||||
if ($checkSign) {
|
||||
$issuer = openssl_x509_parse($alipayCertArray[0] . "-----END CERTIFICATE-----")['issuer'];
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$subject = openssl_x509_parse($rootCertArray[$i] . "-----END CERTIFICATE-----")['subject'];
|
||||
if ($issuer == $subject) {
|
||||
isCertSigner($alipayCertArray[0] . "-----END CERTIFICATE-----", $rootCertArray[$i] . $rootCertArray);
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $checkSign;
|
||||
}
|
||||
} else {
|
||||
$issuer = openssl_x509_parse($alipayCertArray[1] . "-----END CERTIFICATE-----")['issuer'];
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$subject = openssl_x509_parse($rootCertArray[$i] . "-----END CERTIFICATE-----")['subject'];
|
||||
if ($issuer == $subject) {
|
||||
$checkSign = isCertSigner($alipayCertArray[1] . "-----END CERTIFICATE-----", $rootCertArray[$i] . "-----END CERTIFICATE-----");
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
return $checkSign;
|
||||
}
|
||||
}
|
||||
|
||||
function readPemCertChain($cert)
|
||||
{
|
||||
$array = explode("-----END CERTIFICATE-----", $cert);
|
||||
$certs[] = null;
|
||||
for ($i = 0; $i < count($array) - 1; $i++) {
|
||||
$certs[$i] = openssl_x509_parse($array[$i] . "-----END CERTIFICATE-----");
|
||||
}
|
||||
return $certs;
|
||||
}
|
||||
|
||||
function verifyCert($prev, $rootCerts)
|
||||
{
|
||||
$nowTime = time();
|
||||
if ($nowTime < $prev['validFrom_time_t']) {
|
||||
echo "证书未激活";
|
||||
return false;
|
||||
}
|
||||
if ($nowTime > $prev['validTo_time_t']) {
|
||||
echo "证书已经过期";
|
||||
return false;
|
||||
}
|
||||
$subjectMap = null;
|
||||
for ($i = 0; $i < count($rootCerts); $i++) {
|
||||
$subjectDN = array2string($rootCerts[$i]['subject']);
|
||||
$subjectMap[$subjectDN] = $rootCerts[$i];
|
||||
}
|
||||
$issuerDN = array2string(($prev['issuer']));
|
||||
if (!array_key_exists($issuerDN, $subjectMap)) {
|
||||
echo "证书链验证失败";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证证书链是否是信任证书库中证书签发的
|
||||
* @param $alipayCerts 目标验证证书列表
|
||||
* @param $rootCerts 可信根证书列表
|
||||
*/
|
||||
function verifyCertChain($alipayCerts, $rootCerts)
|
||||
{
|
||||
$sorted = sortByDn($alipayCerts);
|
||||
if (!$sorted) {
|
||||
echo "证书链验证失败:不是完整的证书链";
|
||||
return false;
|
||||
}
|
||||
//先验证第一个证书是不是信任库中证书签发的
|
||||
$prev = $alipayCerts[0];
|
||||
$firstOK = verifyCert($prev, $rootCerts);
|
||||
$length = count($alipayCerts);
|
||||
if (!$firstOK || $length == 1) {
|
||||
return $firstOK;
|
||||
}
|
||||
|
||||
$nowTime = time();
|
||||
//验证证书链
|
||||
for ($i = 1; $i < $length; $i++) {
|
||||
$cert = $alipayCerts[$i];
|
||||
if ($nowTime < $cert['validFrom_time_t']) {
|
||||
echo "证书未激活";
|
||||
return false;
|
||||
}
|
||||
if ($nowTime > $cert['validTo_time_t']) {
|
||||
echo "证书已经过期";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将证书链按照完整的签发顺序进行排序,排序后证书链为:[issuerA, subjectA]-[issuerA, subjectB]-[issuerB, subjectC]-[issuerC, subjectD]...
|
||||
* @param $certs 证书链
|
||||
*/
|
||||
function sortByDn(&$certs)
|
||||
{
|
||||
//是否包含自签名证书
|
||||
$hasSelfSignedCert = false;
|
||||
$subjectMap = null;
|
||||
$issuerMap = null;
|
||||
for ($i = 0; $i < count($certs); $i++) {
|
||||
if (isSelfSigned($certs[$i])) {
|
||||
if ($hasSelfSignedCert) {
|
||||
return false;
|
||||
}
|
||||
$hasSelfSignedCert = true;
|
||||
}
|
||||
$subjectDN = array2string($certs[$i]['subject']);
|
||||
$issuerDN = array2string(($certs[$i]['issuer']));
|
||||
$subjectMap[$subjectDN] = $certs[$i];
|
||||
$issuerMap[$issuerDN] = $certs[$i];
|
||||
}
|
||||
$certChain = null;
|
||||
addressingUp($subjectMap, $certChain, $certs[0]);
|
||||
addressingDown($issuerMap, $certChain, $certs[0]);
|
||||
|
||||
//说明证书链不完整
|
||||
if (count($certs) != count($certChain)) {
|
||||
return false;
|
||||
}
|
||||
//将证书链复制到原先的数据
|
||||
for ($i = 0; $i < count($certs); $i++) {
|
||||
$certs[$i] = $certChain[count($certs) - $i - 1];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证证书是否是自签发的
|
||||
* @param $cert 目标证书
|
||||
*/
|
||||
function isSelfSigned($cert)
|
||||
{
|
||||
$subjectDN = array2string($cert['subject']);
|
||||
$issuerDN = array2string($cert['issuer']);
|
||||
return ($subjectDN == $issuerDN);
|
||||
}
|
||||
|
||||
|
||||
function array2string($array)
|
||||
{
|
||||
$string = [];
|
||||
if ($array && is_array($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
$string[] = $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
return implode(',', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向上构造证书链
|
||||
* @param $subjectMap 主题和证书的映射
|
||||
* @param $certChain 证书链
|
||||
* @param $current 当前需要插入证书链的证书,include
|
||||
*/
|
||||
function addressingUp($subjectMap, &$certChain, $current)
|
||||
{
|
||||
$certChain[] = $current;
|
||||
if (isSelfSigned($current)) {
|
||||
return;
|
||||
}
|
||||
$issuerDN = array2string($current['issuer']);
|
||||
|
||||
if (!array_key_exists($issuerDN, $subjectMap)) {
|
||||
return;
|
||||
}
|
||||
addressingUp($subjectMap, $certChain, $subjectMap[$issuerDN]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向下构造证书链
|
||||
* @param $issuerMap 签发者和证书的映射
|
||||
* @param $certChain 证书链
|
||||
* @param $current 当前需要插入证书链的证书,exclude
|
||||
*/
|
||||
function addressingDown($issuerMap, &$certChain, $current)
|
||||
{
|
||||
$subjectDN = array2string($current['subject']);
|
||||
if (!array_key_exists($subjectDN, $issuerMap)) {
|
||||
return $certChain;
|
||||
}
|
||||
$certChain[] = $issuerMap[$subjectDN];
|
||||
addressingDown($issuerMap, $certChain, $issuerMap[$subjectDN]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract signature from der encoded cert.
|
||||
* Expects x509 der encoded certificate consisting of a section container
|
||||
* containing 2 sections and a bitstream. The bitstream contains the
|
||||
* original encrypted signature, encrypted by the public key of the issuing
|
||||
* signer.
|
||||
* @param string $der
|
||||
* @return string on success
|
||||
* @return bool false on failures
|
||||
*/
|
||||
function extractSignature($der = false)
|
||||
{
|
||||
if (strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
// skip container sequence
|
||||
$der = substr($der, 4);
|
||||
// now burn through two sequences and the return the final bitstream
|
||||
while (strlen($der) > 1) {
|
||||
$class = ord($der[0]);
|
||||
$classHex = dechex($class);
|
||||
switch ($class) {
|
||||
// BITSTREAM
|
||||
case 0x03:
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
return substr($der, 3 + $bytes, $len);
|
||||
break;
|
||||
// SEQUENCE
|
||||
case 0x30:
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$contents = substr($der, 2 + $bytes, $len);
|
||||
$der = substr($der, 2 + $bytes + $len);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get signature algorithm oid from der encoded signature data.
|
||||
* Expects decrypted signature data from a certificate in der format.
|
||||
* This ASN1 data should contain the following structure:
|
||||
* SEQUENCE
|
||||
* SEQUENCE
|
||||
* OID (signature algorithm)
|
||||
* NULL
|
||||
* OCTET STRING (signature hash)
|
||||
* @return bool false on failures
|
||||
* @return string oid
|
||||
*/
|
||||
function getSignatureAlgorithmOid($der = null)
|
||||
{
|
||||
// Validate this is the der we need...
|
||||
if (!is_string($der) or strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
$bit_seq1 = 0;
|
||||
$bit_seq2 = 2;
|
||||
$bit_oid = 4;
|
||||
if (ord($der[$bit_seq1]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid()');
|
||||
}
|
||||
if (ord($der[$bit_seq2]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid()');
|
||||
}
|
||||
if (ord($der[$bit_oid]) !== 0x06) {
|
||||
die('Invalid DER passed to getSignatureAlgorithmOid');
|
||||
}
|
||||
// strip out what we don't need and get the oid
|
||||
$der = substr($der, $bit_oid);
|
||||
// Get the oid
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$oid_data = substr($der, 2 + $bytes, $len);
|
||||
// Unpack the OID
|
||||
$oid = floor(ord($oid_data[0]) / 40);
|
||||
$oid .= '.' . ord($oid_data[0]) % 40;
|
||||
$value = 0;
|
||||
$i = 1;
|
||||
while ($i < strlen($oid_data)) {
|
||||
$value = $value << 7;
|
||||
$value = $value | (ord($oid_data[$i]) & 0x7f);
|
||||
if (!(ord($oid_data[$i]) & 0x80)) {
|
||||
$oid .= '.' . $value;
|
||||
$value = 0;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $oid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get signature hash from der encoded signature data.
|
||||
* Expects decrypted signature data from a certificate in der format.
|
||||
* This ASN1 data should contain the following structure:
|
||||
* SEQUENCE
|
||||
* SEQUENCE
|
||||
* OID (signature algorithm)
|
||||
* NULL
|
||||
* OCTET STRING (signature hash)
|
||||
* @return bool false on failures
|
||||
* @return string hash
|
||||
*/
|
||||
function getSignatureHash($der = null)
|
||||
{
|
||||
// Validate this is the der we need...
|
||||
if (!is_string($der) or strlen($der) < 5) {
|
||||
return false;
|
||||
}
|
||||
if (ord($der[0]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
// strip out the container sequence
|
||||
$der = substr($der, 2);
|
||||
if (ord($der[0]) !== 0x30) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
// Get the length of the first sequence so we can strip it out.
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
$der = substr($der, 2 + $bytes + $len);
|
||||
// Now we should have an octet string
|
||||
if (ord($der[0]) !== 0x04) {
|
||||
die('Invalid DER passed to getSignatureHash()');
|
||||
}
|
||||
$len = ord($der[1]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$i + 2]);
|
||||
}
|
||||
}
|
||||
return bin2hex(substr($der, 2 + $bytes, $len));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if one cert was used to sign another
|
||||
* Note that more than one CA cert can give a positive result, some certs
|
||||
* re-issue signing certs after having only changed the expiration dates.
|
||||
* @param string $cert - PEM encoded cert
|
||||
* @param string $caCert - PEM encoded cert that possibly signed $cert
|
||||
* @return bool
|
||||
*/
|
||||
function isCertSigner($certPem = null, $caCertPem = null)
|
||||
{
|
||||
if (!function_exists('openssl_pkey_get_public')) {
|
||||
die('Need the openssl_pkey_get_public() function.');
|
||||
}
|
||||
if (!function_exists('openssl_public_decrypt')) {
|
||||
die('Need the openssl_public_decrypt() function.');
|
||||
}
|
||||
if (!function_exists('hash')) {
|
||||
die('Need the php hash() function.');
|
||||
}
|
||||
if (empty($certPem) or empty($caCertPem)) {
|
||||
return false;
|
||||
}
|
||||
// Convert the cert to der for feeding to extractSignature.
|
||||
$certDer = pemToDer($certPem);
|
||||
if (!is_string($certDer)) {
|
||||
die('invalid certPem');
|
||||
}
|
||||
// Grab the encrypted signature from the der encoded cert.
|
||||
$encryptedSig = extractSignature($certDer);
|
||||
if (!is_string($encryptedSig)) {
|
||||
die('Failed to extract encrypted signature from certPem.');
|
||||
}
|
||||
// Extract the public key from the ca cert, which is what has
|
||||
// been used to encrypt the signature in the cert.
|
||||
$pubKey = openssl_pkey_get_public($caCertPem);
|
||||
if ($pubKey === false) {
|
||||
die('Failed to extract the public key from the ca cert.');
|
||||
}
|
||||
// Attempt to decrypt the encrypted signature using the CA's public
|
||||
// key, returning the decrypted signature in $decryptedSig. If
|
||||
// it can't be decrypted, this ca was not used to sign it for sure...
|
||||
$rc = openssl_public_decrypt($encryptedSig, $decryptedSig, $pubKey);
|
||||
if ($rc === false) {
|
||||
return false;
|
||||
}
|
||||
// We now have the decrypted signature, which is der encoded
|
||||
// asn1 data containing the signature algorithm and signature hash.
|
||||
// Now we need what was originally hashed by the issuer, which is
|
||||
// the original DER encoded certificate without the issuer and
|
||||
// signature information.
|
||||
$origCert = stripSignerAsn($certDer);
|
||||
if ($origCert === false) {
|
||||
die('Failed to extract unsigned cert.');
|
||||
}
|
||||
// Get the oid of the signature hash algorithm, which is required
|
||||
// to generate our own hash of the original cert. This hash is
|
||||
// what will be compared to the issuers hash.
|
||||
$oid = getSignatureAlgorithmOid($decryptedSig);
|
||||
if ($oid === false) {
|
||||
die('Failed to determine the signature algorithm.');
|
||||
}
|
||||
switch ($oid) {
|
||||
case '1.2.840.113549.2.2':
|
||||
$algo = 'md2';
|
||||
break;
|
||||
case '1.2.840.113549.2.4':
|
||||
$algo = 'md4';
|
||||
break;
|
||||
case '1.2.840.113549.2.5':
|
||||
$algo = 'md5';
|
||||
break;
|
||||
case '1.3.14.3.2.18':
|
||||
$algo = 'sha';
|
||||
break;
|
||||
case '1.3.14.3.2.26':
|
||||
$algo = 'sha1';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.1':
|
||||
$algo = 'sha256';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.2':
|
||||
$algo = 'sha384';
|
||||
break;
|
||||
case '2.16.840.1.101.3.4.2.3':
|
||||
$algo = 'sha512';
|
||||
break;
|
||||
default:
|
||||
die('Unknown signature hash algorithm oid: ' . $oid);
|
||||
break;
|
||||
}
|
||||
// Get the issuer generated hash from the decrypted signature.
|
||||
$decryptedHash = getSignatureHash($decryptedSig);
|
||||
// Ok, hash the original unsigned cert with the same algorithm
|
||||
// and if it matches $decryptedHash we have a winner.
|
||||
$certHash = hash($algo, $origCert);
|
||||
return ($decryptedHash === $certHash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pem encoded certificate to DER encoding
|
||||
* @return string $derEncoded on success
|
||||
* @return bool false on failures
|
||||
*/
|
||||
function pemToDer($pem = null)
|
||||
{
|
||||
if (!is_string($pem)) {
|
||||
return false;
|
||||
}
|
||||
$cert_split = preg_split('/(-----((BEGIN)|(END)) CERTIFICATE-----)/', $pem);
|
||||
if (!isset($cert_split[1])) {
|
||||
return false;
|
||||
}
|
||||
return base64_decode($cert_split[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain der cert with issuer and signature sections stripped.
|
||||
* @param string $der - der encoded certificate
|
||||
* @return string $der on success
|
||||
* @return bool false on failures.
|
||||
*/
|
||||
function stripSignerAsn($der = null)
|
||||
{
|
||||
if (!is_string($der) or strlen($der) < 8) {
|
||||
return false;
|
||||
}
|
||||
$bit = 4;
|
||||
$len = ord($der[($bit + 1)]);
|
||||
$bytes = 0;
|
||||
if ($len & 0x80) {
|
||||
$bytes = $len & 0x0f;
|
||||
$len = 0;
|
||||
for ($i = 0; $i < $bytes; $i++) {
|
||||
$len = ($len << 8) | ord($der[$bit + $i + 2]);
|
||||
}
|
||||
}
|
||||
return substr($der, 4, $len + 4);
|
||||
}
|
||||
1334
extend/AliPayV2/alipay-sdk/aopV2/AopClient.php
Normal file
1334
extend/AliPayV2/alipay-sdk/aopV2/AopClient.php
Normal file
File diff suppressed because it is too large
Load Diff
78
extend/AliPayV2/alipay-sdk/aopV2/AopEncrypt.php
Normal file
78
extend/AliPayV2/alipay-sdk/aopV2/AopEncrypt.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* 加密工具类
|
||||
*
|
||||
* User: jiehua
|
||||
* Date: 16/3/30
|
||||
* Time: 下午3:25
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 加密方法
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function encrypt($str, $screct_key)
|
||||
{
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$screct_key = base64_decode($screct_key);
|
||||
$str = trim($str);
|
||||
$str = addPKCS7Padding($str);
|
||||
|
||||
//设置全0的IV
|
||||
|
||||
$iv = str_repeat("\0", 16);
|
||||
$encrypt_str = openssl_encrypt($str, 'aes-128-cbc', $screct_key, OPENSSL_NO_PADDING, $iv);
|
||||
return base64_encode($encrypt_str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密方法
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function decrypt($str, $screct_key)
|
||||
{
|
||||
//AES, 128 模式加密数据 CBC
|
||||
$str = base64_decode($str);
|
||||
$screct_key = base64_decode($screct_key);
|
||||
|
||||
//设置全0的IV
|
||||
$iv = str_repeat("\0", 16);
|
||||
$decrypt_str = openssl_decrypt($str, 'aes-128-cbc', $screct_key, OPENSSL_NO_PADDING, $iv);
|
||||
$decrypt_str = stripPKSC7Padding($decrypt_str);
|
||||
return $decrypt_str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充算法
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
function addPKCS7Padding($source)
|
||||
{
|
||||
$source = trim($source);
|
||||
$block = 16;
|
||||
|
||||
$pad = $block - (strlen($source) % $block);
|
||||
if ($pad <= $block) {
|
||||
$char = chr($pad);
|
||||
$source .= str_repeat($char, $pad);
|
||||
}
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移去填充算法
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
function stripPKSC7Padding($source)
|
||||
{
|
||||
$char = substr($source, -1);
|
||||
$num = ord($char);
|
||||
if ($num == 62) return $source;
|
||||
$source = substr($source, 0, -$num);
|
||||
return $source;
|
||||
}
|
||||
18
extend/AliPayV2/alipay-sdk/aopV2/EncryptParseItem.php
Normal file
18
extend/AliPayV2/alipay-sdk/aopV2/EncryptParseItem.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* TODO 补充说明
|
||||
*
|
||||
* User: jiehua
|
||||
* Date: 16/3/30
|
||||
* Time: 下午8:55
|
||||
*/
|
||||
|
||||
class EncryptParseItem
|
||||
{
|
||||
public $startIndex;
|
||||
|
||||
public $endIndex;
|
||||
|
||||
public $encryptContent;
|
||||
|
||||
}
|
||||
16
extend/AliPayV2/alipay-sdk/aopV2/EncryptResponseData.php
Normal file
16
extend/AliPayV2/alipay-sdk/aopV2/EncryptResponseData.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* TODO 补充说明
|
||||
*
|
||||
* User: jiehua
|
||||
* Date: 16/3/30
|
||||
* Time: 下午8:51
|
||||
*/
|
||||
|
||||
class EncryptResponseData
|
||||
{
|
||||
public $realContent;
|
||||
|
||||
public $returnContent;
|
||||
|
||||
}
|
||||
15
extend/AliPayV2/alipay-sdk/aopV2/SignData.php
Normal file
15
extend/AliPayV2/alipay-sdk/aopV2/SignData.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jiehua
|
||||
* Date: 15/5/2
|
||||
* Time: 下午6:21
|
||||
*/
|
||||
|
||||
class SignData
|
||||
{
|
||||
public $signSourceData = null;
|
||||
|
||||
public $sign = null;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.system.oauth.token request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2024-03-01 16:28:47
|
||||
*/
|
||||
class AlipaySystemOauthTokenRequest
|
||||
{
|
||||
/**
|
||||
* 授权码,用户对应用授权后得到。本参数在 grant_type 为 authorization_code 时必填;为 refresh_token 时不填。
|
||||
**/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* 授权方式
|
||||
**/
|
||||
private $grantType;
|
||||
|
||||
/**
|
||||
* 刷新令牌,上次换取访问令牌时得到。本参数在 grant_type 为 authorization_code 时不填;为 refresh_token 时必填,且该值来源于此接口的返回值 app_refresh_token(即至少需要通过 grant_type=authorization_code 调用此接口一次才能获取)。
|
||||
**/
|
||||
private $refreshToken;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->apiParas["code"] = $code;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setGrantType($grantType)
|
||||
{
|
||||
$this->grantType = $grantType;
|
||||
$this->apiParas["grant_type"] = $grantType;
|
||||
}
|
||||
|
||||
public function getGrantType()
|
||||
{
|
||||
return $this->grantType;
|
||||
}
|
||||
|
||||
public function setRefreshToken($refreshToken)
|
||||
{
|
||||
$this->refreshToken = $refreshToken;
|
||||
$this->apiParas["refresh_token"] = $refreshToken;
|
||||
}
|
||||
|
||||
public function getRefreshToken()
|
||||
{
|
||||
return $this->refreshToken;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.system.oauth.token";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.app.pay request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2024-12-11 16:02:21
|
||||
*/
|
||||
class AlipayTradeAppPayRequest
|
||||
{
|
||||
/**
|
||||
* app支付接口2.0
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.app.pay";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.trade.query request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2024-12-25 16:17:22
|
||||
*/
|
||||
class AlipayTradeQueryRequest
|
||||
{
|
||||
/**
|
||||
* 统一收单线下交易查询
|
||||
修改路由策略到R
|
||||
**/
|
||||
private $bizContent;
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function setBizContent($bizContent)
|
||||
{
|
||||
$this->bizContent = $bizContent;
|
||||
$this->apiParas["biz_content"] = $bizContent;
|
||||
}
|
||||
|
||||
public function getBizContent()
|
||||
{
|
||||
return $this->bizContent;
|
||||
}
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.trade.query";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* ALIPAY API: alipay.user.info.share request
|
||||
*
|
||||
* @author auto create
|
||||
* @since 1.0, 2025-02-13 15:12:20
|
||||
*/
|
||||
class AlipayUserInfoShareRequest
|
||||
{
|
||||
|
||||
private $apiParas = array();
|
||||
private $terminalType;
|
||||
private $terminalInfo;
|
||||
private $prodCode;
|
||||
private $apiVersion="1.0";
|
||||
private $notifyUrl;
|
||||
private $returnUrl;
|
||||
private $needEncrypt=false;
|
||||
|
||||
|
||||
public function getApiMethodName()
|
||||
{
|
||||
return "alipay.user.info.share";
|
||||
}
|
||||
|
||||
public function setNotifyUrl($notifyUrl)
|
||||
{
|
||||
$this->notifyUrl=$notifyUrl;
|
||||
}
|
||||
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->notifyUrl;
|
||||
}
|
||||
|
||||
public function setReturnUrl($returnUrl)
|
||||
{
|
||||
$this->returnUrl=$returnUrl;
|
||||
}
|
||||
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
public function getApiParas()
|
||||
{
|
||||
return $this->apiParas;
|
||||
}
|
||||
|
||||
public function getTerminalType()
|
||||
{
|
||||
return $this->terminalType;
|
||||
}
|
||||
|
||||
public function setTerminalType($terminalType)
|
||||
{
|
||||
$this->terminalType = $terminalType;
|
||||
}
|
||||
|
||||
public function getTerminalInfo()
|
||||
{
|
||||
return $this->terminalInfo;
|
||||
}
|
||||
|
||||
public function setTerminalInfo($terminalInfo)
|
||||
{
|
||||
$this->terminalInfo = $terminalInfo;
|
||||
}
|
||||
|
||||
public function getProdCode()
|
||||
{
|
||||
return $this->prodCode;
|
||||
}
|
||||
|
||||
public function setProdCode($prodCode)
|
||||
{
|
||||
$this->prodCode = $prodCode;
|
||||
}
|
||||
|
||||
public function setApiVersion($apiVersion)
|
||||
{
|
||||
$this->apiVersion=$apiVersion;
|
||||
}
|
||||
|
||||
public function getApiVersion()
|
||||
{
|
||||
return $this->apiVersion;
|
||||
}
|
||||
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
|
||||
$this->needEncrypt=$needEncrypt;
|
||||
|
||||
}
|
||||
|
||||
public function getNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
}
|
||||
114
extend/AliPayV2/alipay-sdk/aopV2/schema/AttributeRule.php
Normal file
114
extend/AliPayV2/alipay-sdk/aopV2/schema/AttributeRule.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class AttributeRule
|
||||
{
|
||||
private $type;
|
||||
private $name;
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $type
|
||||
* @param $value
|
||||
*/
|
||||
public function __construct($type = null, $name = null, $value = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function checkRuleType($ruleType)
|
||||
{
|
||||
$ruleTypeArr = array(
|
||||
"required" => "是否必填,true/false",
|
||||
"maxLength" => "字符串要求最大长度",
|
||||
"minLength" => "字符串要求最小长度",
|
||||
"exclusiveMaximum" => "最大值,包含最大值,<=",
|
||||
"exclusiveMinimum" => "最小值,包含最小值,>=",
|
||||
"maximum" => "最大值,不包含最大值,<",
|
||||
"minimum" => "最小值,不包含最小值,>",
|
||||
"maxSize" => "最大个数",
|
||||
"minSize" => "最大个数",
|
||||
"precision" => "精度",
|
||||
"pattern" => "正则表达式",
|
||||
"valueType" => "值类型",
|
||||
"devTip" => "输入提示",
|
||||
"height" => "高度",
|
||||
"width" => "长度",
|
||||
"urlSchema" => "url格式"
|
||||
);
|
||||
if (empty($ruleType)) return false;
|
||||
if (array_key_exists($ruleType, $ruleTypeArr)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function toElement($dom, $parent, $attributeId)
|
||||
{
|
||||
if (empty($this->name) && $this->name != '0') {
|
||||
throw new \Exception("id=[" . $attributeId . "] AttrRule格式错误!AttrRule缺少name!");
|
||||
}
|
||||
if (!$this->checkRuleType($this->type)) {
|
||||
throw new \Exception("id=[" . $attributeId . "] AttrRule类型type不合法!");
|
||||
}
|
||||
if (empty($this->value) && $this->value != '0') {
|
||||
throw new \Exception("id=[" . $attributeId . "] AttrRule格式错误!AttrRule缺少value!");
|
||||
}
|
||||
$rule = $dom->createElement("rule");
|
||||
$rule->setAttribute("name", $this->name);
|
||||
$rule->setAttribute("type", $this->type);
|
||||
$rule->setAttribute("value", $this->value);
|
||||
$parent->appendChild($rule);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
66
extend/AliPayV2/alipay-sdk/aopV2/schema/Option.php
Normal file
66
extend/AliPayV2/alipay-sdk/aopV2/schema/Option.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
class Option
|
||||
{
|
||||
private $displayName;
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param $displayName
|
||||
* @param $value
|
||||
*/
|
||||
public function __construct($displayName = null, $value = null)
|
||||
{
|
||||
$this->displayName = $displayName;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function toElement($dom, $parent, $attributeId)
|
||||
{
|
||||
if (empty($this->displayName) && $this->displayName != '0') {
|
||||
throw new \Exception("id=[" . $attributeId . "] Option格式错误!Option名称displayName不能为空!");
|
||||
}
|
||||
if (empty($this->value) && $this->value != '0') {
|
||||
throw new \Exception("id=[" . $attributeId . "] Option格式错误!Option的值value不能为空!");
|
||||
}
|
||||
$option = $dom->createElement("option");
|
||||
$option->setAttribute("displayName", $this->displayName);
|
||||
$option->setAttribute("value", $this->value);
|
||||
$parent->appendChild($option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDisplayName()
|
||||
{
|
||||
return $this->displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $displayName
|
||||
*/
|
||||
public function setDisplayName($displayName)
|
||||
{
|
||||
$this->displayName = $displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once 'XMLAttribute.php';
|
||||
require_once 'AttributeRule.php';
|
||||
require_once 'Option.php';
|
||||
|
||||
class ServiceSchemaFactory
|
||||
{
|
||||
public static function createAttribute($id = null, $name = null, $type = null, $valueType = null)
|
||||
{
|
||||
$attribute = new XMLAttribute();
|
||||
$attribute->setId($id);
|
||||
$attribute->setName($name);
|
||||
$attribute->setType($type);
|
||||
$attribute->setValueType($valueType);
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
public static function createRule($type = null, $name = null, $value = null)
|
||||
{
|
||||
return new AttributeRule($type, $name, $value);
|
||||
}
|
||||
|
||||
public static function createOption($displayName = null, $value = null)
|
||||
{
|
||||
return new Option($displayName, $value);
|
||||
}
|
||||
}
|
||||
256
extend/AliPayV2/alipay-sdk/aopV2/schema/ServiceSchemaReader.php
Normal file
256
extend/AliPayV2/alipay-sdk/aopV2/schema/ServiceSchemaReader.php
Normal file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
require_once 'XMLAttribute.php';
|
||||
require_once 'AttributeRule.php';
|
||||
require_once 'Option.php';
|
||||
require_once 'ServiceSchemaFactory.php';
|
||||
|
||||
class ServiceSchemaReader
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function readXmlForArrayByFile($filePath)
|
||||
{
|
||||
set_error_handler('ServiceSchemaReader::errorHandler');
|
||||
$dom = new DOMDocument('1.0', 'utf-8');
|
||||
try {
|
||||
$dom->load($filePath);
|
||||
} catch (Exception $e) {
|
||||
throw new \Exception("XML格式错误,无法正常解析!");
|
||||
}
|
||||
return self::readXmlForList($dom->documentElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function readXmlForArrayByString($xmlString)
|
||||
{
|
||||
set_error_handler('ServiceSchemaReader::errorHandler');
|
||||
$dom = new DOMDocument('1.0', 'utf-8');
|
||||
try {
|
||||
$dom->loadXML($xmlString);
|
||||
} catch (Exception $e) {
|
||||
throw new \Exception("XML格式错误,无法正常解析!");
|
||||
}
|
||||
return self::readXmlForList($dom->documentElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function readXmlForList(DOMElement $rootEle)
|
||||
{
|
||||
$attributeArr = array();
|
||||
foreach ($rootEle->getElementsByTagName('attribute') as $item) {
|
||||
if ($item->parentNode === $rootEle) {
|
||||
$attribute = self::elementToAttribute($item);
|
||||
$attributeArr[$attribute->getId()] = $attribute;
|
||||
}
|
||||
}
|
||||
return $attributeArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function elementToAttribute($attributeElm)
|
||||
{
|
||||
$attributeId = $attributeElm->getAttribute("id");
|
||||
if (self::checkEmpty($attributeId)) {
|
||||
throw new \Exception("Attribute属性缺少id! 节点路径 [" . $attributeElm->getNodePath() . "]");
|
||||
}
|
||||
$attributeName = $attributeElm->getAttribute("name");
|
||||
$attributeType = $attributeElm->getAttribute("type");
|
||||
if (self::checkEmpty($attributeType)) {
|
||||
throw new \Exception("Attribute属性缺少type! 节点路径 [" . $attributeElm->getNodePath() . "].attributeId=" . $attributeId);
|
||||
}
|
||||
|
||||
$valueType = $attributeElm->getAttribute("valueType");
|
||||
$attribute = ServiceSchemaFactory::createAttribute($attributeId, $attributeName, $attributeType, $valueType);
|
||||
if (!$attribute->checkAttributeValueType($valueType)) {
|
||||
throw new \Exception("Attribute属性valueType不正确! 节点路径 [" . $attributeElm->getNodePath() . "].attributeId=" . $attributeId);
|
||||
}
|
||||
|
||||
if ("single" === $attributeType) {
|
||||
ServiceSchemaReader::elementToSingleAttribute($attributeElm, $attribute);
|
||||
} elseif ("multi" === $attributeType) {
|
||||
ServiceSchemaReader::elementToMultiAttribute($attributeElm, $attribute);
|
||||
} elseif ("complex" === $attributeType) {
|
||||
ServiceSchemaReader::elementToComplexAttribute($attributeElm, $attribute);
|
||||
} elseif ("multiComplex" === $attributeType) {
|
||||
ServiceSchemaReader::elementToMultiComplexAttribute($attributeElm, $attribute);
|
||||
} else {
|
||||
throw new \Exception("Attribute属性type类型不正确! 节点路径 [" . $attributeElm->getNodePath() . "].attributeId=" . $attributeId);
|
||||
}
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function elementToSingleAttribute($attributeElm, $attribute)
|
||||
{
|
||||
self::elementToRule($attributeElm, $attribute);
|
||||
self::elementToOption($attributeElm, $attribute);
|
||||
foreach ($attributeElm->getElementsByTagName('value') as $value) {
|
||||
if ($value->parentNode === $attributeElm) {
|
||||
$attribute->setValues($value->nodeValue);
|
||||
//只取第一个<value>标签
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function elementToMultiAttribute($attributeElm, $attribute)
|
||||
{
|
||||
self::elementToRule($attributeElm, $attribute);
|
||||
self::elementToOption($attributeElm, $attribute);
|
||||
foreach ($attributeElm->getElementsByTagName('values') as $values) {
|
||||
if ($values->parentNode === $attributeElm) {
|
||||
$valueArr = array();
|
||||
foreach ($values->getElementsByTagName('value') as $value) {
|
||||
if ($value->parentNode === $values) {
|
||||
$valueArr[] = $value->nodeValue;
|
||||
}
|
||||
}
|
||||
$attribute->setValues($valueArr);
|
||||
//只取第一个<values>标签
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function elementToComplexAttribute($attributeElm, $attribute)
|
||||
{
|
||||
self::elementToRule($attributeElm, $attribute);
|
||||
foreach ($attributeElm->getElementsByTagName('attributes') as $attributes) {
|
||||
if ($attributes->parentNode === $attributeElm) {
|
||||
$attributeArr = array();
|
||||
foreach ($attributes->getElementsByTagName('attribute') as $item) {
|
||||
if ($item->parentNode === $attributes) {
|
||||
$attributeType = $item->getAttribute("type");
|
||||
if ("single" === $attributeType || "multi" === $attributeType) {
|
||||
$attributeArr[] = self::elementToAttribute($item);
|
||||
}
|
||||
} else {
|
||||
throw new \Exception("Attribute属性type类型不正确! 节点路径 [" . $item->getNodePath() . "]");
|
||||
}
|
||||
}
|
||||
$attribute->setValues($attributeArr);
|
||||
//只取第一个<attributes>标签
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function elementToMultiComplexAttribute($attributeElm, $attribute)
|
||||
{
|
||||
$attributeArr = array();
|
||||
foreach ($attributeElm->getElementsByTagName('attributes') as $attributes) {
|
||||
if ($attributes->parentNode === $attributeElm) {
|
||||
$complexAttr = new XMLAttribute();//每一个$complexAttr都是一个ComplexAttribute对象
|
||||
$valuesArr = array();
|
||||
foreach ($attributes->getElementsByTagName('attribute') as $item) {
|
||||
if ($item->parentNode === $attributes) {
|
||||
$attributeType = $item->getAttribute("type");
|
||||
if ("single" === $attributeType || "multi" === $attributeType) {
|
||||
$valuesArr[] = self::elementToAttribute($item);
|
||||
}
|
||||
} else {
|
||||
throw new \Exception("Attribute属性type类型不正确! 节点路径 [" . $item->getNodePath() . "]");
|
||||
}
|
||||
}
|
||||
$complexAttr->setValues($valuesArr);
|
||||
$attributeArr[] = $complexAttr;
|
||||
}
|
||||
}
|
||||
$attribute->setValues($attributeArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function elementToRule($attributeElm, $attribute)
|
||||
{
|
||||
foreach ($attributeElm->getElementsByTagName('rules') as $rules) {
|
||||
if ($rules->parentNode === $attributeElm) {
|
||||
$ruleArr = array();
|
||||
foreach ($rules->getElementsByTagName('rule') as $rule) {
|
||||
if ($rule->parentNode === $rules) {
|
||||
$ruleType = $rule->getAttribute("type");
|
||||
$ruleName = $rule->getAttribute("name");
|
||||
$ruleValue = $rule->getAttribute("value");
|
||||
if (self::checkEmpty($ruleValue)) {
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] AttrRule格式错误!AttrRule缺少value!");
|
||||
}
|
||||
$ruleObj = ServiceSchemaFactory::createRule($ruleType, $ruleName, $ruleValue);
|
||||
if (!$ruleObj->checkRuleType($ruleType)) {
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] AttrRule类型type不合法!");
|
||||
}
|
||||
$ruleArr[] = $ruleObj;
|
||||
}
|
||||
}
|
||||
$attribute->setRules($ruleArr);
|
||||
//只取第一个<rules>标签
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function elementToOption($attributeElm, $attribute)
|
||||
{
|
||||
foreach ($attributeElm->getElementsByTagName('options') as $options) {
|
||||
if ($options->parentNode === $attributeElm) {
|
||||
$optionsArr = array();
|
||||
foreach ($options->getElementsByTagName('option') as $option) {
|
||||
if ($option->parentNode === $options) {
|
||||
$displayName = $option->getAttribute("displayName");
|
||||
if (self::checkEmpty($displayName)) {
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] Option格式错误!Option名称displayName不能为空!");
|
||||
}
|
||||
$value = $option->getAttribute("value");
|
||||
if (self::checkEmpty($value)) {
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] Option格式错误!Option的值value不能为空!");
|
||||
}
|
||||
$optionObj = ServiceSchemaFactory::createOption($displayName, $value);
|
||||
$optionsArr[] = $optionObj;
|
||||
}
|
||||
}
|
||||
$attribute->setOptions($optionsArr);
|
||||
//只取第一个<options>标签
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function checkEmpty($value)
|
||||
{
|
||||
if (is_null($value))
|
||||
return true;
|
||||
if (trim($value) == "")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
static function errorHandler($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
throw new \Exception($errstr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class ServiceSchemaWriter
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function writeSchemaXmlString(array $attributesArr)
|
||||
{
|
||||
$dom = new DOMDocument('1.0', 'utf-8');
|
||||
$root = $dom->createElement("serviceSchema");
|
||||
foreach ($attributesArr as $attribute) {
|
||||
if ($attribute instanceof XMLAttribute) {
|
||||
$attribute->toValueElement($dom, $root);
|
||||
}
|
||||
}
|
||||
$dom->appendChild($root);
|
||||
return $dom->saveXML($dom->documentElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function writeFullchemaXmlString(array $attributesArr)
|
||||
{
|
||||
$dom = new DOMDocument('1.0', 'utf-8');
|
||||
$root = $dom->createElement("serviceSchema");
|
||||
foreach ($attributesArr as $attribute) {
|
||||
if ($attribute instanceof XMLAttribute) {
|
||||
$attribute->toElement($dom, $root);
|
||||
}
|
||||
}
|
||||
$dom->appendChild($root);
|
||||
return $dom->saveXML($dom->documentElement);
|
||||
}
|
||||
}
|
||||
342
extend/AliPayV2/alipay-sdk/aopV2/schema/XMLAttribute.php
Normal file
342
extend/AliPayV2/alipay-sdk/aopV2/schema/XMLAttribute.php
Normal file
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
|
||||
class XMLAttribute
|
||||
{
|
||||
private $id;
|
||||
private $name;
|
||||
private $type;
|
||||
private $valueType;
|
||||
private $rules;
|
||||
private $options;
|
||||
private $values;
|
||||
|
||||
public function checkAttributeValueType($attributeValueType)
|
||||
{
|
||||
$valueTypeArr = array(
|
||||
"text" => "文本类型",
|
||||
"boolean" => "boolean类型",
|
||||
"numeric" => "数据类型",
|
||||
"enum" => "枚举型",
|
||||
"object" => "对象型"
|
||||
);
|
||||
if (empty($attributeValueType)) return false;
|
||||
// foreach ($valueTypeArr as $key => $value){
|
||||
// if($attributeValueType === $key) return true;
|
||||
// }
|
||||
if (array_key_exists($attributeValueType, $valueTypeArr)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function toElement($dom, $parent)
|
||||
{
|
||||
$this->checkAttribute();
|
||||
if ("single" === $this->type || "multi" === $this->type) {
|
||||
$attributeElm = $this->appendAttributeValues($dom, $parent, $this);
|
||||
$this->appendRulesElement($dom, $attributeElm, $this->rules, $this->id);
|
||||
$this->appendOptionsElement($dom, $attributeElm, $this->options, $this->id);
|
||||
} elseif ("complex" === $this->type) {
|
||||
$attributeElm = $dom->createElement("attribute");
|
||||
$attributeElm->setAttribute("id", $this->id);
|
||||
$attributeElm->setAttribute("type", $this->type);
|
||||
if ($this->name != "" && !is_null($this->name)) {
|
||||
$attributeElm->setAttribute("name", $this->name);
|
||||
}
|
||||
if ($this->checkAttributeValueType($this->valueType)) {
|
||||
$attributeElm->setAttribute("valueType", $this->valueType);
|
||||
}
|
||||
|
||||
$attributesElm = $dom->createElement("attributes");
|
||||
if (is_array($this->values)) {
|
||||
foreach ($this->values as $attribute) {
|
||||
if ($attribute instanceof XMLAttribute) {
|
||||
$attributeElmTmp = $this->appendAttributeValues($dom, $attributesElm, $attribute);
|
||||
$this->appendRulesElement($dom, $attributeElmTmp, $attribute->rules, $attribute->id);
|
||||
$this->appendOptionsElement($dom, $attributeElmTmp, $attribute->options, $attribute->id);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($this->values)) {//complex类型的values必须是数组 或 空
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$attributeElm->appendChild($attributesElm);
|
||||
$this->appendRulesElement($dom, $attributeElm, $this->rules, $this->id);
|
||||
$parent->appendChild($attributeElm);
|
||||
} elseif ("multiComplex" === $this->type) {
|
||||
$attributeElm = $dom->createElement("attribute");
|
||||
$attributeElm->setAttribute("id", $this->id);
|
||||
if ($this->name != "" && !is_null($this->name)) {
|
||||
$attributeElm->setAttribute("name", $this->name);
|
||||
}
|
||||
$attributeElm->setAttribute("type", $this->type);
|
||||
$attributeElm->setAttribute("valueType", "object");
|
||||
|
||||
if (is_array($this->values)) {
|
||||
foreach ($this->values as $complexAttribute) {
|
||||
if ($complexAttribute instanceof XMLAttribute) {
|
||||
$attributesElm = $dom->createElement("attributes");
|
||||
if (is_array($complexAttribute->getValues())) {
|
||||
foreach ($complexAttribute->getValues() as $attribute) {
|
||||
if ($attribute instanceof XMLAttribute) {
|
||||
if (!$this->checkAttributeValueType($attribute->getValueType())) {
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] XMLAttribute属性valueType不正确!");
|
||||
}
|
||||
$attributeElmTmp = $this->appendAttributeValues($dom, $attributesElm, $attribute);
|
||||
$this->appendRulesElement($dom, $attributeElmTmp, $attribute->rules, $attribute->id);
|
||||
$this->appendOptionsElement($dom, $attributeElmTmp, $attribute->options, $attribute->id);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($complexAttribute->getValues())) {//complex类型的values必须是数组 或 空
|
||||
throw new \Exception("id=[" . $complexAttribute->getId() . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$attributeElm->appendChild($attributesElm);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($this->values)) {//multiComplex类型的values必须是数组 或 空
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$parent->appendChild($attributeElm);
|
||||
} else {
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性type类型不正确!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function toValueElement($dom, $parent)
|
||||
{
|
||||
$this->checkAttribute();
|
||||
if ("single" === $this->type || "multi" === $this->type) {
|
||||
$this->appendAttributeValues($dom, $parent, $this);
|
||||
} elseif ("complex" === $this->type) {
|
||||
$attributeElm = $dom->createElement("attribute");
|
||||
$attributeElm->setAttribute("id", $this->id);
|
||||
$attributeElm->setAttribute("type", $this->type);
|
||||
if ($this->name != "" && !is_null($this->name)) {
|
||||
$attributeElm->setAttribute("name", $this->name);
|
||||
}
|
||||
if ($this->checkAttributeValueType($this->valueType)) {
|
||||
$attributeElm->setAttribute("valueType", $this->valueType);
|
||||
}
|
||||
|
||||
$attributesElm = $dom->createElement("attributes");
|
||||
if (is_array($this->values)) {
|
||||
foreach ($this->values as $attribute) {
|
||||
if ($attribute instanceof XMLAttribute) {
|
||||
$this->appendAttributeValues($dom, $attributesElm, $attribute);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($this->values)) {//complex类型的values必须是数组 或 空
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$attributeElm->appendChild($attributesElm);
|
||||
$parent->appendChild($attributeElm);
|
||||
} elseif ("multiComplex" === $this->type) {
|
||||
$attributeElm = $dom->createElement("attribute");
|
||||
$attributeElm->setAttribute("id", $this->id);
|
||||
if ($this->name != "" && !is_null($this->name)) {
|
||||
$attributeElm->setAttribute("name", $this->name);
|
||||
}
|
||||
$attributeElm->setAttribute("type", $this->type);
|
||||
$attributeElm->setAttribute("valueType", "object");
|
||||
|
||||
if (is_array($this->values)) {
|
||||
foreach ($this->values as $complexAttribute) {
|
||||
if ($complexAttribute instanceof XMLAttribute) {
|
||||
$attributesElm = $dom->createElement("attributes");
|
||||
if (is_array($complexAttribute->getValues())) {
|
||||
foreach ($complexAttribute->getValues() as $attribute) {
|
||||
if ($attribute instanceof XMLAttribute) {
|
||||
if (!$this->checkAttributeValueType($attribute->getValueType())) {
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] XMLAttribute属性valueType不正确!");
|
||||
}
|
||||
$this->appendAttributeValues($dom, $attributesElm, $attribute);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($complexAttribute->getValues())) {//complex类型的values必须是数组 或 空
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$attributeElm->appendChild($attributesElm);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($this->values)) {//multiComplex类型的values必须是数组 或 空
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$parent->appendChild($attributeElm);
|
||||
} else {
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性type类型不正确!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function appendAttributeValues($dom, $parent, $attribute)
|
||||
{
|
||||
$attributeElm = $dom->createElement("attribute");
|
||||
if ($attribute->getId() != "" && !is_null($attribute->getId())) {
|
||||
$attributeElm->setAttribute("id", $attribute->getId());
|
||||
}
|
||||
if ($attribute->getName() != "" && !is_null($attribute->getName())) {
|
||||
$attributeElm->setAttribute("name", $attribute->getName());
|
||||
}
|
||||
if ($attribute->getType() != "" && !is_null($attribute->getType())) {
|
||||
$attributeElm->setAttribute("type", $attribute->getType());
|
||||
}
|
||||
if ($this->checkAttributeValueType($attribute->getValueType())) {
|
||||
$attributeElm->setAttribute("valueType", $attribute->getValueType());
|
||||
}
|
||||
$values = $attribute->getValues();
|
||||
|
||||
if ("single" === $attribute->getType()) {
|
||||
$valueElm = $dom->createElement("value");
|
||||
if (is_string($values)) {
|
||||
$text = $dom->createTextNode($values);
|
||||
$valueElm->appendChild($text);
|
||||
} elseif (!is_null($values)) {//single类型的values必须是字符串 或 空
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$attributeElm->appendChild($valueElm);
|
||||
$parent->appendChild($attributeElm);
|
||||
} elseif ("multi" === $attribute->getType()) {
|
||||
$valuesElm = $dom->createElement("values");
|
||||
if (is_array($values)) {
|
||||
foreach ($values as $value) {
|
||||
if (is_string($value) || is_null($value)) {
|
||||
$valueElm = $dom->createElement("value", $value);
|
||||
$valuesElm->appendChild($valueElm);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($values)) {//multi类型的values必须是数组 或 空
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] XMLAttribute属性values不合法!");
|
||||
}
|
||||
$attributeElm->appendChild($valuesElm);
|
||||
$parent->appendChild($attributeElm);
|
||||
} else {
|
||||
throw new \Exception("id=[" . $attribute->getId() . "] XMLAttribute属性type类型不正确!");
|
||||
}
|
||||
return $attributeElm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function appendRulesElement($dom, $parent, $rules, $attributeId)
|
||||
{
|
||||
if (empty($rules)) return;
|
||||
if (!is_array($rules)) {
|
||||
throw new \Exception("id=[" . $attributeId . "] XMLAttribute属性rules不合法!");
|
||||
}
|
||||
$rulesElm = $dom->createElement("rules");
|
||||
foreach ($rules as $rule) {
|
||||
if ($rule instanceof AttributeRule) {
|
||||
$rule->toElement($dom, $rulesElm, $attributeId);
|
||||
}
|
||||
}
|
||||
$parent->appendChild($rulesElm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function appendOptionsElement($dom, $parent, $options, $attributeId)
|
||||
{
|
||||
if (empty($options)) return;
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception("id=[" . $attributeId . "] XMLAttribute属性options不合法!");
|
||||
}
|
||||
$optionsElm = $dom->createElement("options");
|
||||
foreach ($options as $option) {
|
||||
if ($option instanceof Option) {
|
||||
$option->toElement($dom, $optionsElm, $attributeId);
|
||||
}
|
||||
}
|
||||
$parent->appendChild($optionsElm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function checkAttribute()
|
||||
{
|
||||
if (empty($this->id) && $this->id != '0') {
|
||||
throw new \Exception("XMLAttribute属性缺少id!");
|
||||
}
|
||||
if (empty($this->type) && $this->type != '0') {
|
||||
throw new \Exception("id=[" . $this->id . "] XMLAttribute属性缺少type!");
|
||||
}
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getValueType()
|
||||
{
|
||||
return $this->valueType;
|
||||
}
|
||||
|
||||
public function setValueType($valueType)
|
||||
{
|
||||
$this->valueType = $valueType;
|
||||
}
|
||||
|
||||
public function getRules()
|
||||
{
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
public function setRules($rules)
|
||||
{
|
||||
$this->rules = $rules;
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function setOptions($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function getValues()
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
public function setValues($values)
|
||||
{
|
||||
$this->values = $values;
|
||||
}
|
||||
}
|
||||
31
extend/Mqtt/Mqtt.php
Normal file
31
extend/Mqtt/Mqtt.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use think\Env;
|
||||
|
||||
require_once 'phpMQTT.php';
|
||||
class Mqtt {
|
||||
public $mqtt;
|
||||
|
||||
public function __construct() {
|
||||
$this->server = Env::get('mqtt.mqtt_server'); // change if necessary
|
||||
$this->port = Env::get('mqtt.mqtt_port'); // change if necessary
|
||||
$this->username = Env::get('mqtt.mqtt_username'); // set your username
|
||||
$this->password = Env::get('mqtt.mqtt_password'); // set your password
|
||||
}
|
||||
|
||||
public function publishs($topic, $content) {
|
||||
$client_id = 'php-' . uniqid();
|
||||
|
||||
$this->mqtt = new phpMQTT($this->server, $this->port, $client_id);
|
||||
|
||||
if($this->mqtt->connect()) {
|
||||
$this->mqtt->publish($topic, $content, 0);
|
||||
}else{
|
||||
\Think\Log::write('MQTT连接失败: ' . var_export($this->mqtt->connect(), true), 'INFO');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
671
extend/Mqtt/phpMQTT.php
Normal file
671
extend/Mqtt/phpMQTT.php
Normal file
@@ -0,0 +1,671 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
/*
|
||||
phpMQTT
|
||||
A simple php class to connect/publish/subscribe to an MQTT broker
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Licence
|
||||
|
||||
Copyright (c) 2010 Blue Rhinos Consulting | Andrew Milsted
|
||||
andrew@bluerhinos.co.uk | http://www.bluerhinos.co.uk
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
/* phpMQTT */
|
||||
|
||||
class phpMQTT
|
||||
{
|
||||
protected $socket; /* holds the socket */
|
||||
protected $msgid = 1; /* counter for message id */
|
||||
public $keepalive = 10; /* default keepalive timmer */
|
||||
public $timesinceping; /* host unix time, used to detect disconects */
|
||||
public $topics = []; /* used to store currently subscribed topics */
|
||||
public $debug = false; /* should output debug messages */
|
||||
public $address; /* broker address */
|
||||
public $port; /* broker port */
|
||||
public $clientid; /* client id sent to brocker */
|
||||
public $will; /* stores the will of the client */
|
||||
protected $username; /* stores username */
|
||||
protected $password; /* stores password */
|
||||
|
||||
public $cafile;
|
||||
protected static $known_commands = [
|
||||
1 => 'CONNECT',
|
||||
2 => 'CONNACK',
|
||||
3 => 'PUBLISH',
|
||||
4 => 'PUBACK',
|
||||
5 => 'PUBREC',
|
||||
6 => 'PUBREL',
|
||||
7 => 'PUBCOMP',
|
||||
8 => 'SUBSCRIBE',
|
||||
9 => 'SUBACK',
|
||||
10 => 'UNSUBSCRIBE',
|
||||
11 => 'UNSUBACK',
|
||||
12 => 'PINGREQ',
|
||||
13 => 'PINGRESP',
|
||||
14 => 'DISCONNECT'
|
||||
];
|
||||
|
||||
/**
|
||||
* phpMQTT constructor.
|
||||
*
|
||||
* @param $address
|
||||
* @param $port
|
||||
* @param $clientid
|
||||
* @param null $cafile
|
||||
*/
|
||||
public function __construct($address, $port, $clientid, $cafile = null)
|
||||
{
|
||||
$this->broker($address, $port, $clientid, $cafile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the broker details
|
||||
*
|
||||
* @param $address
|
||||
* @param $port
|
||||
* @param $clientid
|
||||
* @param null $cafile
|
||||
*/
|
||||
public function broker($address, $port, $clientid, $cafile = null): void
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->port = $port;
|
||||
$this->clientid = $clientid;
|
||||
$this->cafile = $cafile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will try and connect, if fails it will sleep 10s and try again, this will enable the script to recover from a network outage
|
||||
*
|
||||
* @param bool $clean - should the client send a clean session flag
|
||||
* @param null $will
|
||||
* @param null $username
|
||||
* @param null $password
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function connect_auto($clean = true, $will = null, $username = null, $password = null): bool
|
||||
{
|
||||
while ($this->connect($clean, $will, $username, $password) === false) {
|
||||
sleep(10);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $clean - should the client send a clean session flag
|
||||
* @param null $will
|
||||
* @param null $username
|
||||
* @param null $password
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function connect($clean = true, $will = null, $username = null, $password = null): bool
|
||||
{
|
||||
if ($will) {
|
||||
$this->will = $will;
|
||||
}
|
||||
if ($username) {
|
||||
$this->username = $username;
|
||||
}
|
||||
if ($password) {
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
if ($this->cafile) {
|
||||
$socketContext = stream_context_create(
|
||||
[
|
||||
'ssl' => [
|
||||
'verify_peer_name' => true,
|
||||
'cafile' => $this->cafile
|
||||
]
|
||||
]
|
||||
);
|
||||
$this->socket = stream_socket_client('tls://' . $this->address . ':' . $this->port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $socketContext);
|
||||
} else {
|
||||
$this->socket = stream_socket_client('tcp://' . $this->address . ':' . $this->port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT);
|
||||
}
|
||||
|
||||
if (!$this->socket) {
|
||||
$this->_errorMessage("stream_socket_create() $errno, $errstr");
|
||||
return false;
|
||||
}
|
||||
|
||||
stream_set_timeout($this->socket, 5);
|
||||
stream_set_blocking($this->socket, 0);
|
||||
|
||||
$i = 0;
|
||||
$buffer = '';
|
||||
|
||||
$buffer .= chr(0x00);
|
||||
$i++; // Length MSB
|
||||
$buffer .= chr(0x04);
|
||||
$i++; // Length LSB
|
||||
$buffer .= chr(0x4d);
|
||||
$i++; // M
|
||||
$buffer .= chr(0x51);
|
||||
$i++; // Q
|
||||
$buffer .= chr(0x54);
|
||||
$i++; // T
|
||||
$buffer .= chr(0x54);
|
||||
$i++; // T
|
||||
$buffer .= chr(0x04);
|
||||
$i++; // // Protocol Level
|
||||
|
||||
//No Will
|
||||
$var = 0;
|
||||
if ($clean) {
|
||||
$var += 2;
|
||||
}
|
||||
|
||||
//Add will info to header
|
||||
if ($this->will !== null) {
|
||||
$var += 4; // Set will flag
|
||||
$var += ($this->will['qos'] << 3); //Set will qos
|
||||
if ($this->will['retain']) {
|
||||
$var += 32;
|
||||
} //Set will retain
|
||||
}
|
||||
|
||||
if ($this->username !== null) {
|
||||
$var += 128;
|
||||
} //Add username to header
|
||||
if ($this->password !== null) {
|
||||
$var += 64;
|
||||
} //Add password to header
|
||||
|
||||
$buffer .= chr($var);
|
||||
$i++;
|
||||
|
||||
//Keep alive
|
||||
$buffer .= chr($this->keepalive >> 8);
|
||||
$i++;
|
||||
$buffer .= chr($this->keepalive & 0xff);
|
||||
$i++;
|
||||
|
||||
$buffer .= $this->strwritestring($this->clientid, $i);
|
||||
|
||||
//Adding will to payload
|
||||
if ($this->will !== null) {
|
||||
$buffer .= $this->strwritestring($this->will['topic'], $i);
|
||||
$buffer .= $this->strwritestring($this->will['content'], $i);
|
||||
}
|
||||
|
||||
if ($this->username !== null) {
|
||||
$buffer .= $this->strwritestring($this->username, $i);
|
||||
}
|
||||
if ($this->password !== null) {
|
||||
$buffer .= $this->strwritestring($this->password, $i);
|
||||
}
|
||||
|
||||
$head = chr(0x10);
|
||||
|
||||
while ($i > 0) {
|
||||
$encodedByte = $i % 128;
|
||||
$i /= 128;
|
||||
$i = (int)$i;
|
||||
if ($i > 0) {
|
||||
$encodedByte |= 128;
|
||||
}
|
||||
$head .= chr($encodedByte);
|
||||
}
|
||||
|
||||
fwrite($this->socket, $head, 2);
|
||||
fwrite($this->socket, $buffer);
|
||||
|
||||
$string = $this->read(4);
|
||||
|
||||
if (ord($string[0]) >> 4 === 2 && $string[3] === chr(0)) {
|
||||
$this->_debugMessage('Connected to Broker');
|
||||
} else {
|
||||
$this->_errorMessage(
|
||||
sprintf(
|
||||
"Connection failed! (Error: 0x%02x 0x%02x)\n",
|
||||
ord($string[0]),
|
||||
ord($string[3])
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->timesinceping = time();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads in so many bytes
|
||||
*
|
||||
* @param int $int
|
||||
* @param bool $nb
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
public function read($int = 8192, $nb = false)
|
||||
{
|
||||
$string = '';
|
||||
$togo = $int;
|
||||
|
||||
if ($nb) {
|
||||
return fread($this->socket, $togo);
|
||||
}
|
||||
|
||||
while (!feof($this->socket) && $togo > 0) {
|
||||
$fread = fread($this->socket, $togo);
|
||||
$string .= $fread;
|
||||
$togo = $int - strlen($string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to a topic, wait for message and return it
|
||||
*
|
||||
* @param $topic
|
||||
* @param $qos
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subscribeAndWaitForMessage($topic, $qos): string
|
||||
{
|
||||
$this->subscribe(
|
||||
[
|
||||
$topic => [
|
||||
'qos' => $qos,
|
||||
'function' => '__direct_return_message__'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
do {
|
||||
$return = $this->proc();
|
||||
} while ($return === true);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* subscribes to topics
|
||||
*
|
||||
* @param $topics
|
||||
* @param int $qos
|
||||
*/
|
||||
public function subscribe($topics, $qos = 0): void
|
||||
{
|
||||
$i = 0;
|
||||
$buffer = '';
|
||||
$id = $this->msgid;
|
||||
$buffer .= chr($id >> 8);
|
||||
$i++;
|
||||
$buffer .= chr($id % 256);
|
||||
$i++;
|
||||
|
||||
foreach ($topics as $key => $topic) {
|
||||
$buffer .= $this->strwritestring($key, $i);
|
||||
$buffer .= chr($topic['qos']);
|
||||
$i++;
|
||||
$this->topics[$key] = $topic;
|
||||
}
|
||||
|
||||
$cmd = 0x82;
|
||||
//$qos
|
||||
$cmd += ($qos << 1);
|
||||
|
||||
$head = chr($cmd);
|
||||
$head .= $this->setmsglength($i);
|
||||
fwrite($this->socket, $head, strlen($head));
|
||||
|
||||
$this->_fwrite($buffer);
|
||||
$string = $this->read(2);
|
||||
|
||||
$bytes = ord(substr($string, 1, 1));
|
||||
$this->read($bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a keep alive ping
|
||||
*/
|
||||
public function ping(): void
|
||||
{
|
||||
$head = chr(0xc0);
|
||||
$head .= chr(0x00);
|
||||
fwrite($this->socket, $head, 2);
|
||||
$this->timesinceping = time();
|
||||
$this->_debugMessage('ping sent');
|
||||
}
|
||||
|
||||
/**
|
||||
* sends a proper disconnect cmd
|
||||
*/
|
||||
public function disconnect(): void
|
||||
{
|
||||
$head = ' ';
|
||||
$head[0] = chr(0xe0);
|
||||
$head[1] = chr(0x00);
|
||||
fwrite($this->socket, $head, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a proper disconnect, then closes the socket
|
||||
*/
|
||||
public function close(): void
|
||||
{
|
||||
$this->disconnect();
|
||||
stream_socket_shutdown($this->socket, STREAM_SHUT_WR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes $content on a $topic
|
||||
*
|
||||
* @param $topic
|
||||
* @param $content
|
||||
* @param int $qos
|
||||
* @param bool $retain
|
||||
*/
|
||||
public function publish($topic, $content, $qos = 0, $retain = false): void
|
||||
{
|
||||
$i = 0;
|
||||
$buffer = '';
|
||||
|
||||
$buffer .= $this->strwritestring($topic, $i);
|
||||
|
||||
if ($qos) {
|
||||
$id = $this->msgid++;
|
||||
$buffer .= chr($id >> 8);
|
||||
$i++;
|
||||
$buffer .= chr($id % 256);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$buffer .= $content;
|
||||
$i += strlen($content);
|
||||
|
||||
$head = ' ';
|
||||
$cmd = 0x30;
|
||||
if ($qos) {
|
||||
$cmd += $qos << 1;
|
||||
}
|
||||
if (empty($retain) === false) {
|
||||
++$cmd;
|
||||
}
|
||||
|
||||
$head[0] = chr($cmd);
|
||||
$head .= $this->setmsglength($i);
|
||||
|
||||
fwrite($this->socket, $head, strlen($head));
|
||||
$this->_fwrite($buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string to the socket
|
||||
*
|
||||
* @param $buffer
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
protected function _fwrite($buffer)
|
||||
{
|
||||
$buffer_length = strlen($buffer);
|
||||
for ($written = 0; $written < $buffer_length; $written += $fwrite) {
|
||||
$fwrite = fwrite($this->socket, substr($buffer, $written));
|
||||
if ($fwrite === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $buffer_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a received topic
|
||||
*
|
||||
* @param $msg
|
||||
*
|
||||
* @retrun bool|string
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
$tlen = (ord($msg[0]) << 8) + ord($msg[1]);
|
||||
$topic = substr($msg, 2, $tlen);
|
||||
$msg = substr($msg, ($tlen + 2));
|
||||
$found = false;
|
||||
foreach ($this->topics as $key => $top) {
|
||||
if (preg_match(
|
||||
'/^' . str_replace(
|
||||
'#',
|
||||
'.*',
|
||||
str_replace(
|
||||
'+',
|
||||
"[^\/]*",
|
||||
str_replace(
|
||||
'/',
|
||||
"\/",
|
||||
str_replace(
|
||||
'$',
|
||||
'\$',
|
||||
$key
|
||||
)
|
||||
)
|
||||
)
|
||||
) . '$/',
|
||||
$topic
|
||||
)) {
|
||||
$found = true;
|
||||
|
||||
if ($top['function'] === '__direct_return_message__') {
|
||||
return $msg;
|
||||
}
|
||||
|
||||
if (is_callable($top['function'])) {
|
||||
call_user_func($top['function'], $topic, $msg);
|
||||
} else {
|
||||
$this->_errorMessage('Message received on topic ' . $topic . ' but function is not callable.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($found === false) {
|
||||
$this->_debugMessage('msg received but no match in subscriptions');
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
/**
|
||||
* The processing loop for an "always on" client
|
||||
* set true when you are doing other stuff in the loop good for
|
||||
* watching something else at the same time
|
||||
*
|
||||
* @param bool $loop
|
||||
*
|
||||
* @return bool | string
|
||||
*/
|
||||
public function proc(bool $loop = true)
|
||||
{
|
||||
if (feof($this->socket)) {
|
||||
$this->_debugMessage('eof receive going to reconnect for good measure');
|
||||
fclose($this->socket);
|
||||
$this->connect_auto(false);
|
||||
if (count($this->topics)) {
|
||||
$this->subscribe($this->topics);
|
||||
}
|
||||
}
|
||||
|
||||
$byte = $this->read(1, true);
|
||||
|
||||
if ((string)$byte === '') {
|
||||
if ($loop === true) {
|
||||
usleep(100000);
|
||||
}
|
||||
} else {
|
||||
$cmd = (int)(ord($byte) / 16);
|
||||
$this->_debugMessage(
|
||||
sprintf(
|
||||
'Received CMD: %d (%s)',
|
||||
$cmd,
|
||||
isset(static::$known_commands[$cmd]) === true ? static::$known_commands[$cmd] : 'Unknown'
|
||||
)
|
||||
);
|
||||
|
||||
$multiplier = 1;
|
||||
$value = 0;
|
||||
do {
|
||||
$digit = ord($this->read(1));
|
||||
$value += ($digit & 127) * $multiplier;
|
||||
$multiplier *= 128;
|
||||
} while (($digit & 128) !== 0);
|
||||
|
||||
$this->_debugMessage('Fetching: ' . $value . ' bytes');
|
||||
|
||||
$string = $value > 0 ? $this->read($value) : '';
|
||||
|
||||
if ($cmd) {
|
||||
switch ($cmd) {
|
||||
case 3: //Publish MSG
|
||||
$return = $this->message($string);
|
||||
if (is_bool($return) === false) {
|
||||
return $return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->timesinceping < (time() - $this->keepalive)) {
|
||||
$this->_debugMessage('not had something in a while so ping');
|
||||
$this->ping();
|
||||
}
|
||||
|
||||
if ($this->timesinceping < (time() - ($this->keepalive * 2))) {
|
||||
$this->_debugMessage('not seen a packet in a while, disconnecting/reconnecting');
|
||||
fclose($this->socket);
|
||||
$this->connect_auto(false);
|
||||
if (count($this->topics)) {
|
||||
$this->subscribe($this->topics);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of a msg, (and increments $i)
|
||||
*
|
||||
* @param $msg
|
||||
* @param $i
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
protected function getmsglength(&$msg, &$i)
|
||||
{
|
||||
$multiplier = 1;
|
||||
$value = 0;
|
||||
do {
|
||||
$digit = ord($msg[$i]);
|
||||
$value += ($digit & 127) * $multiplier;
|
||||
$multiplier *= 128;
|
||||
$i++;
|
||||
} while (($digit & 128) !== 0);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $len
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function setmsglength($len): string
|
||||
{
|
||||
$string = '';
|
||||
do {
|
||||
$digit = $len % 128;
|
||||
$len >>= 7;
|
||||
// if there are more digits to encode, set the top bit of this digit
|
||||
if ($len > 0) {
|
||||
$digit |= 0x80;
|
||||
}
|
||||
$string .= chr($digit);
|
||||
} while ($len > 0);
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @param $i
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function strwritestring($str, &$i): string
|
||||
{
|
||||
$len = strlen($str);
|
||||
$msb = $len >> 8;
|
||||
$lsb = $len % 256;
|
||||
$ret = chr($msb);
|
||||
$ret .= chr($lsb);
|
||||
$ret .= $str;
|
||||
$i += ($len + 2);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a sting out character by character
|
||||
*
|
||||
* @param $string
|
||||
*/
|
||||
public function printstr($string): void
|
||||
{
|
||||
$strlen = strlen($string);
|
||||
for ($j = 0; $j < $strlen; $j++) {
|
||||
$num = ord($string[$j]);
|
||||
if ($num > 31) {
|
||||
$chr = $string[$j];
|
||||
} else {
|
||||
$chr = ' ';
|
||||
}
|
||||
printf("%4d: %08b : 0x%02x : %s \n", $j, $num, $num, $chr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
protected function _debugMessage(string $message): void
|
||||
{
|
||||
if ($this->debug === true) {
|
||||
echo date('r: ') . $message . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
protected function _errorMessage(string $message): void
|
||||
{
|
||||
error_log('Error:' . $message);
|
||||
}
|
||||
}
|
||||
85
extend/TongLian/TongLian.php
Normal file
85
extend/TongLian/TongLian.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
|
||||
use think\Env;
|
||||
|
||||
class TongLian
|
||||
{
|
||||
/**
|
||||
* 通联支付
|
||||
*/
|
||||
public function TongLianPay($date, $type) {
|
||||
$data['appid'] = Env::get('AllinPay.appId');//平台分配的APPID
|
||||
$data['body'] = $date['remarke'];//订单标题(不能有空格)
|
||||
$data['cusid'] = Env::get('AllinPay.cusid');//平台分配的商户号
|
||||
$data['notify_url'] = get_system_config_value("web_site")."/api/Payment/allinpayNotify";//服务器异步通知页面路径
|
||||
if($type == 4){//4通联支付宝 5通联微信
|
||||
$data['paytype'] = 'A02';//支付方式 支付宝A02
|
||||
}elseif($type == 5){
|
||||
$data['paytype'] = 'W06';//支付方式 微信小程序固定W06
|
||||
}
|
||||
$data['randomstr'] = uniqid();//商户自行生成的随机字符串
|
||||
$data['remark'] = $type;//订单备注信息
|
||||
$data['reqsn'] = $date['order_sn'];//商户订单号
|
||||
$data['version'] = '12';//版本号 默认为12
|
||||
$data['trxamt'] = strval($date['money']*100);//付款金额 单位为分
|
||||
$data['signtype'] = 'RSA';//签名类型 RSA/RSA2/SM2
|
||||
$data['sign'] = $this->Sign($data);//签名
|
||||
|
||||
ksort($data);
|
||||
// var_dump($data);die;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
//RSA签名
|
||||
public function Sign(array $array){
|
||||
ksort($array);
|
||||
$bufSignSrc = $this->ToUrlParams($array);
|
||||
//用商户的RSA私钥进行签名
|
||||
$private_key = Env::get('AllinPay.cusRsaPrivateKey');
|
||||
$private_key = chunk_split($private_key , 64, "\n");
|
||||
$key = "-----BEGIN RSA PRIVATE KEY-----\n".$private_key."-----END RSA PRIVATE KEY-----";
|
||||
|
||||
if(!openssl_sign($bufSignSrc, $signature, $key)) {
|
||||
echo 'sign fail';
|
||||
}
|
||||
//加密后的内容通常含有特殊字符,需要编码转换下,在网络间通过url传输时要注意base64编码是否是url安全的
|
||||
return base64_encode($signature);
|
||||
}
|
||||
|
||||
//生成键值对字符串
|
||||
public function ToUrlParams(array $array)
|
||||
{
|
||||
$buff = "";
|
||||
foreach ($array as $k => $v)
|
||||
{
|
||||
if($v != "" && !is_array($v)){
|
||||
$buff .= $k . "=" . $v . "&";
|
||||
}
|
||||
}
|
||||
|
||||
$buff = trim($buff, "&");
|
||||
return $buff;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验签名
|
||||
* @param array 参数
|
||||
* @param unknown_type appkey
|
||||
*/
|
||||
public function ValidSign(array $array){
|
||||
$sign =$array['sign'];
|
||||
unset($array['sign']);
|
||||
ksort($array);
|
||||
|
||||
$bufSignSrc = $this->ToUrlParams($array);
|
||||
//通联的公钥进行验签
|
||||
$public_key = Env::get('AllinPay.allpayrsaPublicKey');
|
||||
$public_key = chunk_split($public_key , 64, "\n");
|
||||
$key = "-----BEGIN PUBLIC KEY-----\n".$public_key."-----END PUBLIC KEY-----\n";
|
||||
$result= openssl_verify($bufSignSrc,base64_decode($sign),$key);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
479
extend/WxPay/WxPay.php
Normal file
479
extend/WxPay/WxPay.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?php
|
||||
|
||||
|
||||
class WxPay
|
||||
{
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*
|
||||
* @param array $options
|
||||
* @param $options ['app_id'] APPID:绑定支付的APPID(必须配置,开户邮件中可查看)
|
||||
* @param $options ['mch_id'] MCHID:商户号(必须配置,开户邮件中可查看)
|
||||
* @param $options ['key'] KEY:商户支付密钥,参考开户邮件设置(必须配置,登录商户平台自行设置)
|
||||
* @param $options ['appsecret'] 公众帐号secert(仅JSAPI支付的时候需要配置),
|
||||
* @param $options ['notify_url'] 支付宝回调地址
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->config = get_system_config();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付App
|
||||
* @param string $data 业务参数 body out_trade_no total_fee
|
||||
* @param string $data ['out_trade_no'] 订单号 必填
|
||||
* @param string $data ['total_fee'] 订单金额 必填
|
||||
* @param string $data ['body'] 订单详情 必填
|
||||
* @return $response 返回app所需字符串
|
||||
*/
|
||||
public function WxPayApp($d) {
|
||||
$total_fee = abs(floatval($d['money'])) * 100;// 微信支付 单位为分
|
||||
|
||||
$ip = $this->get_client_ip();
|
||||
if ($ip == '::1')
|
||||
$ip = '1.1.1.1';
|
||||
|
||||
$data ["appid"] = \think\Env::get('wechatpay.appid');
|
||||
$data ["mch_id"] = \think\Env::get('wechatpay.mch_id');
|
||||
$data ["nonce_str"] = $this->getRandChar(32);
|
||||
$data ["body"] = $d['remarke'];
|
||||
// $data['attach'] = $d['attach'];
|
||||
$data ["out_trade_no"] = $d['order_sn'];
|
||||
$data ["total_fee"] = $total_fee;
|
||||
$data ["spbill_create_ip"] = $ip;
|
||||
$data ["notify_url"] = get_system_config_value("web_site")."/api/Payment/notify_wx";
|
||||
$data ["trade_type"] = "APP";
|
||||
|
||||
$s = $this->getSign($data);
|
||||
$data ["sign"] = $s;
|
||||
|
||||
$xml = $this->arrayToXml($data);
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
|
||||
$response = $this->postXmlCurl($xml, $url);
|
||||
$re = $this->xmlstr_to_array($response);
|
||||
|
||||
if ($re ['return_code'] == 'FAIL') {
|
||||
return array(-1, '订单创建失败!'.\think\Env::get('wechatpay.api_v3_key'), $re['return_msg']);
|
||||
}
|
||||
// 二次签名
|
||||
$reapp = $this->getOrder($re['prepay_id']);
|
||||
return $reapp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
* @param string $data 业务参数 body out_trade_no total_fee
|
||||
* @param string $data ['out_trade_no'] 订单号 必填
|
||||
* @param string $data ['total_fee'] 订单金额 必填
|
||||
* @param string $data ['body'] 订单详情 必填
|
||||
* @return $response 返回app所需字符串
|
||||
*/
|
||||
public function WxPayH5($d) {
|
||||
$host = I('server.REQUEST_SCHEME') . '://' . I('server.SERVER_NAME');
|
||||
$wxConfig = $this->config;
|
||||
$out_trade_no = $d['out_trade_no'];
|
||||
$total_fee = abs(floatval($d['total_fee'])) * 100;// 微信支付 单位为分
|
||||
$nonce_str = $this->getRandChar(32);
|
||||
$ip = $this->get_client_ip();
|
||||
if ($ip == '::1')
|
||||
$ip = '1.1.1.1';
|
||||
$data ["appid"] = $wxConfig["app_id"];
|
||||
$data ["body"] = $d['body'];
|
||||
$data['attach'] = $d['attach'];
|
||||
$data ["mch_id"] = $wxConfig['mch_id'];
|
||||
$data ["nonce_str"] = $nonce_str;
|
||||
$data ["notify_url"] = C('BASE_URL').'api/payment/wxH5Notify';
|
||||
$data ["out_trade_no"] = $out_trade_no;
|
||||
$data ["spbill_create_ip"] = $ip;
|
||||
$data ["total_fee"] = $total_fee;
|
||||
$data ["trade_type"] = "MWEB";
|
||||
$data ["time_expire"] = $d['time_expire'];
|
||||
$s = $this->getSign($data);
|
||||
$data ["sign"] = $s;
|
||||
|
||||
$xml = $this->arrayToXml($data);
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
|
||||
$response = $this->postXmlCurl($xml, $url);
|
||||
$re = $this->xmlstr_to_array($response);
|
||||
|
||||
if ($re ['return_code'] == 'FAIL') {
|
||||
return array(-1, '订单创建失败!', $re['return_msg']);
|
||||
}
|
||||
return $re;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝web支付 需要签约 电脑网站支付
|
||||
* @param string $data 业务参数
|
||||
* @param string $data ['out_trade_no'] 订单号 必填
|
||||
* @param string $data ['total_fee'] 订单金额 必填
|
||||
* @param string $data ['body'] 订单详情 必填
|
||||
* @return string 支付二维码图片地址
|
||||
*/
|
||||
public function WxPayWeb($d) {
|
||||
$wxConfig = $this->config;
|
||||
$out_trade_no = $d['out_trade_no'];
|
||||
$total_fee = abs(floatval($d['total_fee'])) * 100;// 微信支付 单位为分
|
||||
$nonce_str = $this->getRandChar(32);
|
||||
$ip = $this->get_client_ip();
|
||||
if ($ip == '::1')
|
||||
$ip = '1.1.1.1';
|
||||
$data ["appid"] = $wxConfig["app_id"];
|
||||
$data ["body"] = $d['body'];
|
||||
$data ["mch_id"] = $wxConfig['mch_id'];
|
||||
$data ["nonce_str"] = $nonce_str;
|
||||
$data ["notify_url"] = $wxConfig["notify_url"];
|
||||
$data ["out_trade_no"] = $out_trade_no;
|
||||
$data ["spbill_create_ip"] = $ip;
|
||||
$data ["total_fee"] = $total_fee;
|
||||
$data ["trade_type"] = "NATIVE";
|
||||
$s = $this->getSign($data);
|
||||
$data ["sign"] = $s;
|
||||
$xml = $this->arrayToXml($data);
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
|
||||
$response = $this->postXmlCurl($xml, $url);
|
||||
$re = $this->xmlstr_to_array($response);
|
||||
if ($re ['return_code'] == 'FAIL') {
|
||||
jsonReturn(-1, '订单创建失败!', $re['return_msg']);
|
||||
}
|
||||
$url2 = $re["code_url"];
|
||||
$imgUrl = '/Plugins/WxPay/qrcode.php?data=' . urlencode($url2);
|
||||
return $imgUrl;
|
||||
//return '<img alt="模式二扫码支付" src="/Plugins/WxPay/phpqrcode.php?data=' . urlencode($url2).'"/>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信退款
|
||||
* @param $d
|
||||
*/
|
||||
public function wxRefund($d){
|
||||
$wxConfig = $this->config;
|
||||
$str = $this->getRandChar(32);
|
||||
$total_fee = abs(floatval($d['total_fee']))*100;
|
||||
$refund_fee = abs(floatval($d['refund_fee']))*100;
|
||||
$data ["appid"] = $wxConfig["app_id"];
|
||||
$data ["mch_id"] = $wxConfig['mch_id'];
|
||||
$data['nonce_str'] = $str;
|
||||
$data['out_trade_no'] = $d['out_trade_no']; //支付是返回的订单编号
|
||||
$data['out_refund_no'] = $d['out_refund_no']; //退单编号-重新生成的
|
||||
$data['total_fee'] = $total_fee; //订单总金额
|
||||
$data['refund_fee'] = $refund_fee; //需要退还金额
|
||||
$data['refund_desc'] = $d['refund_desc']; //退款描述
|
||||
$s = $this->getSign($data);
|
||||
$data ["sign"] = $s;
|
||||
$url = "https://api.mch.weixin.qq.com/secapi/pay/refund";
|
||||
$xml=$this->arrayToXml($data);
|
||||
$result = $this->url($xml,$url);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信退款详情
|
||||
* @param $d
|
||||
*/
|
||||
public function wxRefundDetail($d){
|
||||
$wxConfig = $this->config;
|
||||
$str = $this->getRandChar(32);
|
||||
$data ["appid"] = $wxConfig["app_id"];
|
||||
$data ["mch_id"] = $wxConfig['mch_id'];
|
||||
$data['nonce_str'] = $str;
|
||||
$data['out_trade_no'] = $d['out_trade_no']; //订单号,不用订单号可以添加其他的
|
||||
$s = $this->getSign($data);
|
||||
$data ["sign"] = $s;
|
||||
$url = "https://api.mch.weixin.qq.com/pay/refundquery";
|
||||
$xml=$this->arrayToXml($data);
|
||||
$response = $this->postXmlCurl($xml, $url);
|
||||
$re = $this->xmlstr_to_array($response);
|
||||
return $re;
|
||||
}
|
||||
/**
|
||||
* 微信提现
|
||||
* @param $d
|
||||
*/
|
||||
public function wxWithdraw($d){
|
||||
$wxConfig = $this->config;
|
||||
$str = $this->getRandChar(32);
|
||||
$data['mch_appid'] = $wxConfig["app_id"];
|
||||
$data['mchid'] = $wxConfig['mch_id'];
|
||||
$data['openid'] = $d['openid']; //提现用户授权id openid
|
||||
$data['nonce_str'] = $str;
|
||||
$data['partner_trade_no'] = $d['partner_trade_no']; //订单号
|
||||
$data['check_name']='NO_CHECK';
|
||||
$data['amount'] = $d['amount']*100; //提现金额
|
||||
$data['desc'] = '平台提现';
|
||||
$data['spbill_create_ip'] = $_SERVER['SERVER_ADDR'];
|
||||
$s = $this->getSign($data);
|
||||
$data ["sign"] = $s;
|
||||
$url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";
|
||||
$xml=$this->arrayToXml($data);
|
||||
$result = $this->url($xml,$url);
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* curl
|
||||
*/
|
||||
function url($xml,$url ,$second=30){
|
||||
$ch=curl_init();
|
||||
curl_setopt($ch,CURLOPT_URL,$url);
|
||||
curl_setopt($ch,CURLOPT_HEADER,FALSE);
|
||||
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
|
||||
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TURE);//证书检查
|
||||
curl_setopt($ch,CURLOPT_SSLCERTTYPE,'pem');
|
||||
curl_setopt($ch,CURLOPT_SSLCERT,getcwd().'/Plugins/WxPay/cert/apiclient_cert.pem');
|
||||
curl_setopt($ch,CURLOPT_SSLCERTTYPE,'pem');
|
||||
curl_setopt($ch,CURLOPT_SSLKEY,getcwd().'/Plugins/WxPay/cert/apiclient_key.pem');
|
||||
curl_setopt($ch,CURLOPT_SSLCERTTYPE,'pem');
|
||||
curl_setopt($ch,CURLOPT_CAINFO,getcwd().'/Plugins/WxPay/cert/rootca.pem');
|
||||
curl_setopt($ch,CURLOPT_POST,TRUE);
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS,$xml);
|
||||
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
// 要求结果为字符串且输出到屏幕上
|
||||
|
||||
$data=curl_exec($ch);
|
||||
if($data){
|
||||
curl_close($ch);
|
||||
$re = $this->xmlstr_to_array($data);
|
||||
return $re;
|
||||
}else{
|
||||
$error=curl_errno($ch);
|
||||
echo "curl出错,错误代码:$error"."<br/>";
|
||||
echo "<a href='http://curl.haxx.se/libcurl/c/libcurs.html'>;错误原因查询</a><br/>";
|
||||
curl_close($ch);
|
||||
echo false;
|
||||
}
|
||||
|
||||
// 初始化curl
|
||||
$ch = curl_init();
|
||||
// 超时时间
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
|
||||
// 这里设置代理,如果有的话
|
||||
// curl_setopt($ch,CURLOPT_PROXY, '8.8.8.8');
|
||||
// curl_setopt($ch,CURLOPT_PROXYPORT, 8080);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
// 设置header
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
// 要求结果为字符串且输出到屏幕上
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
// post提交方式
|
||||
curl_setopt($ch, CURLOPT_POST, TRUE);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
|
||||
// 运行curl
|
||||
$data = curl_exec($ch);
|
||||
// 返回结果
|
||||
if ($data) {
|
||||
curl_close($ch);
|
||||
return $data;
|
||||
} else {
|
||||
$error = curl_errno($ch);
|
||||
echo "curl出错,错误码:$error" . "<br>";
|
||||
echo "<a href='http://curl.haxx.se/libcurl/c/libcurl-errors.html'>错误原因查询</a></br>";
|
||||
curl_close($ch);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 微信签名验证
|
||||
* @param string $data 业务参数
|
||||
* @return array
|
||||
*/
|
||||
public function WxPayNotifyCheck() {
|
||||
$postStr = file_get_contents('php://input');
|
||||
|
||||
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
|
||||
if ($postObj === false) {
|
||||
|
||||
}
|
||||
if ($postObj->return_code != 'SUCCESS') {
|
||||
;
|
||||
}
|
||||
$arr = (array)$postObj;
|
||||
unset($arr['sign']);
|
||||
if ($this->getSign($arr) == $postObj->sign) {
|
||||
return array('status' => true, 'data' => $arr);
|
||||
} else
|
||||
return array('status' => false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以下为微信所需相关方法,请勿修改
|
||||
*/
|
||||
|
||||
|
||||
// 执行第二次签名,才能返回给客户端使用
|
||||
public function getOrder($prepayId) {
|
||||
$data ["appid"] = \think\Env::get('wechatpay.appid');
|
||||
$data ["noncestr"] = $this->getRandChar(32);;
|
||||
$data ["package"] = "Sign=WXPay";
|
||||
$data ["partnerid"] = \think\Env::get('wechatpay.mch_id');
|
||||
$data ["prepayid"] = $prepayId;
|
||||
$data ["timestamp"] = time();
|
||||
$s = $this->getSign($data);
|
||||
$data ["sign"] = $s;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
//生成签名
|
||||
function getSign($Obj) {
|
||||
foreach ($Obj as $k => $v) {
|
||||
$Parameters [strtolower($k)] = $v;
|
||||
}
|
||||
// 签名步骤一:按字典序排序参数
|
||||
ksort($Parameters);
|
||||
$String = $this->formatBizQueryParaMap($Parameters, false);
|
||||
// echo "【string】 =".$String."</br>";
|
||||
// 签名步骤二:在string后加入KEY
|
||||
$String = $String . "&key=" . \think\Env::get('wechatpay.api_v3_key');
|
||||
// echo "<textarea style='width: 50%; height: 150px;'>$String</textarea> <br />";
|
||||
// 签名步骤三:MD5加密
|
||||
$result_ = strtoupper(md5($String));
|
||||
return $result_;
|
||||
}
|
||||
|
||||
// 获取指定长度的随机字符串
|
||||
function getRandChar($length) {
|
||||
$str = null;
|
||||
$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
$max = strlen($strPol) - 1;
|
||||
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$str .= $strPol [rand(0, $max)]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// 数组转xml
|
||||
function arrayToXml($arr) {
|
||||
$xml = "<xml>";
|
||||
foreach ($arr as $key => $val) {
|
||||
if (is_numeric($val)) {
|
||||
$xml .= "<" . $key . ">" . $val . "</" . $key . ">";
|
||||
} else
|
||||
$xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">";
|
||||
}
|
||||
$xml .= "</xml>";
|
||||
return $xml;
|
||||
}
|
||||
|
||||
// post https请求,CURLOPT_POSTFIELDS xml格式
|
||||
function postXmlCurl($xml, $url, $second = 30) {
|
||||
// 初始化curl
|
||||
$ch = curl_init();
|
||||
// 超时时间
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
|
||||
// 这里设置代理,如果有的话
|
||||
// curl_setopt($ch,CURLOPT_PROXY, '8.8.8.8');
|
||||
// curl_setopt($ch,CURLOPT_PROXYPORT, 8080);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
// 设置header
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
// 要求结果为字符串且输出到屏幕上
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
// post提交方式
|
||||
curl_setopt($ch, CURLOPT_POST, TRUE);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
|
||||
// 运行curl
|
||||
$data = curl_exec($ch);
|
||||
// 返回结果
|
||||
if ($data) {
|
||||
curl_close($ch);
|
||||
return $data;
|
||||
} else {
|
||||
$error = curl_errno($ch);
|
||||
echo "curl出错,错误码:$error" . "<br>";
|
||||
echo "<a href='http://curl.haxx.se/libcurl/c/libcurl-errors.html'>错误原因查询</a></br>";
|
||||
curl_close($ch);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//获取当前服务器的IP
|
||||
function get_client_ip() {
|
||||
if ($_SERVER ['REMOTE_ADDR']) {
|
||||
$cip = $_SERVER ['REMOTE_ADDR'];
|
||||
} elseif (getenv("REMOTE_ADDR")) {
|
||||
$cip = getenv("REMOTE_ADDR");
|
||||
} elseif (getenv("HTTP_CLIENT_IP")) {
|
||||
$cip = getenv("HTTP_CLIENT_IP");
|
||||
} else {
|
||||
$cip = "unknown";
|
||||
}
|
||||
return $cip;
|
||||
}
|
||||
|
||||
// 将数组转成uri字符串
|
||||
function formatBizQueryParaMap($paraMap, $urlencode) {
|
||||
$buff = "";
|
||||
ksort($paraMap);
|
||||
foreach ($paraMap as $k => $v) {
|
||||
if ($urlencode) {
|
||||
$v = urlencode($v);
|
||||
}
|
||||
$buff .= strtolower($k) . "=" . $v . "&";
|
||||
}
|
||||
|
||||
if (strlen($buff) > 0) {
|
||||
$reqPar = substr($buff, 0, strlen($buff) - 1);
|
||||
}
|
||||
return $reqPar;
|
||||
}
|
||||
|
||||
//xml转成数组
|
||||
function xmlstr_to_array($xmlstr) {
|
||||
$doc = new \DOMDocument ();
|
||||
$doc->loadXML($xmlstr);
|
||||
return $this->domnode_to_array($doc->documentElement);
|
||||
}
|
||||
|
||||
//dom转成数组
|
||||
function domnode_to_array($node) {
|
||||
$output = array();
|
||||
switch ($node->nodeType) {
|
||||
case XML_CDATA_SECTION_NODE :
|
||||
case XML_TEXT_NODE :
|
||||
$output = trim($node->textContent);
|
||||
break;
|
||||
case XML_ELEMENT_NODE :
|
||||
for ($i = 0, $m = $node->childNodes->length; $i < $m; $i++) {
|
||||
$child = $node->childNodes->item($i);
|
||||
$v = $this->domnode_to_array($child);
|
||||
if (isset ($child->tagName)) {
|
||||
$t = $child->tagName;
|
||||
if (!isset ($output [$t])) {
|
||||
$output [$t] = array();
|
||||
}
|
||||
$output [$t] [] = $v;
|
||||
} elseif ($v) {
|
||||
$output = ( string )$v;
|
||||
}
|
||||
}
|
||||
if (is_array($output)) {
|
||||
if ($node->attributes->length) {
|
||||
$a = array();
|
||||
foreach ($node->attributes as $attrName => $attrNode) {
|
||||
$a [$attrName] = ( string )$attrNode->value;
|
||||
}
|
||||
$output ['@attributes'] = $a;
|
||||
}
|
||||
foreach ($output as $t => $v) {
|
||||
if (is_array($v) && count($v) == 1 && $t != '@attributes') {
|
||||
$output [$t] = $v [0];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
95
extend/Yzh/ApiUserSignServiceClient.php
Normal file
95
extend/Yzh/ApiUserSignServiceClient.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\Apiusersign\ApiUseSignContractRequest;
|
||||
use Yzh\Model\Apiusersign\ApiUseSignContractResponse;
|
||||
use Yzh\Model\Apiusersign\ApiUserSignContractRequest;
|
||||
use Yzh\Model\Apiusersign\ApiUserSignContractResponse;
|
||||
use Yzh\Model\Apiusersign\ApiUserSignRequest;
|
||||
use Yzh\Model\Apiusersign\ApiUserSignResponse;
|
||||
use Yzh\Model\Apiusersign\GetApiUserSignStatusRequest;
|
||||
use Yzh\Model\Apiusersign\GetApiUserSignStatusResponse;
|
||||
use Yzh\Model\Apiusersign\ApiUserSignReleaseRequest;
|
||||
use Yzh\Model\Apiusersign\ApiUserSignReleaseResponse;
|
||||
|
||||
/**
|
||||
* API 签约
|
||||
* Class ApiUserSignServiceClient
|
||||
*/
|
||||
class ApiUserSignServiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'apiusersignservice';
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL
|
||||
* @param ApiUseSignContractRequest $request
|
||||
* @param null $option
|
||||
* @return ApiUseSignContractResponse
|
||||
*/
|
||||
public function apiUseSignContract($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ApiUseSignContractRequest) {
|
||||
throw new ConfigException("Apiusersign->apiUseSignContract request 必须是 Yzh\\Model\\Apiusersign\\ApiUseSignContractRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/sign/v1/user/contract', $request, "Yzh\\Model\\Apiusersign\\ApiUseSignContractResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL V2
|
||||
* @param ApiUserSignContractRequest $request
|
||||
* @param null $option
|
||||
* @return ApiUserSignContractResponse
|
||||
*/
|
||||
public function apiUserSignContract($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ApiUserSignContractRequest) {
|
||||
throw new ConfigException("Apiusersign->apiUserSignContract request 必须是 Yzh\\Model\\Apiusersign\\ApiUserSignContractRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/sign/v1/user/contract', $request, "Yzh\\Model\\Apiusersign\\ApiUserSignContractResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户签约
|
||||
* @param ApiUserSignRequest $request
|
||||
* @param null $option
|
||||
* @return ApiUserSignResponse
|
||||
*/
|
||||
public function apiUserSign($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ApiUserSignRequest) {
|
||||
throw new ConfigException("Apiusersign->apiUserSign request 必须是 Yzh\\Model\\Apiusersign\\ApiUserSignRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/sign/v1/user/sign', $request, "Yzh\\Model\\Apiusersign\\ApiUserSignResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户签约状态
|
||||
* @param GetApiUserSignStatusRequest $request
|
||||
* @param null $option
|
||||
* @return GetApiUserSignStatusResponse
|
||||
*/
|
||||
public function getApiUserSignStatus($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetApiUserSignStatusRequest) {
|
||||
throw new ConfigException("Apiusersign->getApiUserSignStatus request 必须是 Yzh\\Model\\Apiusersign\\GetApiUserSignStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/sign/v1/user/status', $request, "Yzh\\Model\\Apiusersign\\GetApiUserSignStatusResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户解约(测试账号专用接口)
|
||||
* @param ApiUserSignReleaseRequest $request
|
||||
* @param null $option
|
||||
* @return ApiUserSignReleaseResponse
|
||||
*/
|
||||
public function apiUserSignRelease($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ApiUserSignReleaseRequest) {
|
||||
throw new ConfigException("Apiusersign->apiUserSignRelease request 必须是 Yzh\\Model\\Apiusersign\\ApiUserSignReleaseRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/sign/v1/user/release', $request, "Yzh\\Model\\Apiusersign\\ApiUserSignReleaseResponse", $option);
|
||||
}
|
||||
}
|
||||
143
extend/Yzh/AuthenticationClient.php
Normal file
143
extend/Yzh/AuthenticationClient.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\Authentication\BankCardFourAuthVerifyRequest;
|
||||
use Yzh\Model\Authentication\BankCardFourAuthVerifyResponse;
|
||||
use Yzh\Model\Authentication\BankCardFourAuthConfirmRequest;
|
||||
use Yzh\Model\Authentication\BankCardFourAuthConfirmResponse;
|
||||
use Yzh\Model\Authentication\BankCardFourVerifyRequest;
|
||||
use Yzh\Model\Authentication\BankCardFourVerifyResponse;
|
||||
use Yzh\Model\Authentication\BankCardThreeVerifyRequest;
|
||||
use Yzh\Model\Authentication\BankCardThreeVerifyResponse;
|
||||
use Yzh\Model\Authentication\IDCardVerifyRequest;
|
||||
use Yzh\Model\Authentication\IDCardVerifyResponse;
|
||||
use Yzh\Model\Authentication\UserExemptedInfoRequest;
|
||||
use Yzh\Model\Authentication\UserExemptedInfoResponse;
|
||||
use Yzh\Model\Authentication\UserWhiteCheckRequest;
|
||||
use Yzh\Model\Authentication\UserWhiteCheckResponse;
|
||||
use Yzh\Model\Authentication\GetBankCardInfoRequest;
|
||||
use Yzh\Model\Authentication\GetBankCardInfoResponse;
|
||||
|
||||
/**
|
||||
* 用户信息验证
|
||||
* Class AuthenticationClient
|
||||
*/
|
||||
class AuthenticationClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'authentication';
|
||||
|
||||
/**
|
||||
* 银行卡四要素鉴权请求(下发短信验证码)
|
||||
* @param BankCardFourAuthVerifyRequest $request
|
||||
* @param null $option
|
||||
* @return BankCardFourAuthVerifyResponse
|
||||
*/
|
||||
public function bankCardFourAuthVerify($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof BankCardFourAuthVerifyRequest) {
|
||||
throw new ConfigException("Authentication->bankCardFourAuthVerify request 必须是 Yzh\\Model\\Authentication\\BankCardFourAuthVerifyRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/authentication/verify-request', $request, "Yzh\\Model\\Authentication\\BankCardFourAuthVerifyResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行卡四要素确认请求(上传短信验证码)
|
||||
* @param BankCardFourAuthConfirmRequest $request
|
||||
* @param null $option
|
||||
* @return BankCardFourAuthConfirmResponse
|
||||
*/
|
||||
public function bankCardFourAuthConfirm($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof BankCardFourAuthConfirmRequest) {
|
||||
throw new ConfigException("Authentication->bankCardFourAuthConfirm request 必须是 Yzh\\Model\\Authentication\\BankCardFourAuthConfirmRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/authentication/verify-confirm', $request, "Yzh\\Model\\Authentication\\BankCardFourAuthConfirmResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行卡四要素验证
|
||||
* @param BankCardFourVerifyRequest $request
|
||||
* @param null $option
|
||||
* @return BankCardFourVerifyResponse
|
||||
*/
|
||||
public function bankCardFourVerify($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof BankCardFourVerifyRequest) {
|
||||
throw new ConfigException("Authentication->bankCardFourVerify request 必须是 Yzh\\Model\\Authentication\\BankCardFourVerifyRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/authentication/verify-bankcard-four-factor', $request, "Yzh\\Model\\Authentication\\BankCardFourVerifyResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行卡三要素验证
|
||||
* @param BankCardThreeVerifyRequest $request
|
||||
* @param null $option
|
||||
* @return BankCardThreeVerifyResponse
|
||||
*/
|
||||
public function bankCardThreeVerify($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof BankCardThreeVerifyRequest) {
|
||||
throw new ConfigException("Authentication->bankCardThreeVerify request 必须是 Yzh\\Model\\Authentication\\BankCardThreeVerifyRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/authentication/verify-bankcard-three-factor', $request, "Yzh\\Model\\Authentication\\BankCardThreeVerifyResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证实名验证
|
||||
* @param IDCardVerifyRequest $request
|
||||
* @param null $option
|
||||
* @return IDCardVerifyResponse
|
||||
*/
|
||||
public function iDCardVerify($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof IDCardVerifyRequest) {
|
||||
throw new ConfigException("Authentication->iDCardVerify request 必须是 Yzh\\Model\\Authentication\\IDCardVerifyRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/authentication/verify-id', $request, "Yzh\\Model\\Authentication\\IDCardVerifyResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传非居民身份证验证名单信息
|
||||
* @param UserExemptedInfoRequest $request
|
||||
* @param null $option
|
||||
* @return UserExemptedInfoResponse
|
||||
*/
|
||||
public function userExemptedInfo($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof UserExemptedInfoRequest) {
|
||||
throw new ConfigException("Authentication->userExemptedInfo request 必须是 Yzh\\Model\\Authentication\\UserExemptedInfoRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/payment/v1/user/exempted/info', $request, "Yzh\\Model\\Authentication\\UserExemptedInfoResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看用户是否在非居民身份证验证名单中
|
||||
* @param UserWhiteCheckRequest $request
|
||||
* @param null $option
|
||||
* @return UserWhiteCheckResponse
|
||||
*/
|
||||
public function userWhiteCheck($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof UserWhiteCheckRequest) {
|
||||
throw new ConfigException("Authentication->userWhiteCheck request 必须是 Yzh\\Model\\Authentication\\UserWhiteCheckRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/payment/v1/user/white/check', $request, "Yzh\\Model\\Authentication\\UserWhiteCheckResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行卡信息查询接口
|
||||
* @param GetBankCardInfoRequest $request
|
||||
* @param null $option
|
||||
* @return GetBankCardInfoResponse
|
||||
*/
|
||||
public function getBankCardInfo($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetBankCardInfoRequest) {
|
||||
throw new ConfigException("Authentication->getBankCardInfo request 必须是 Yzh\\Model\\Authentication\\GetBankCardInfoRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/payment/v1/card', $request, "Yzh\\Model\\Authentication\\GetBankCardInfoResponse", $option);
|
||||
}
|
||||
}
|
||||
254
extend/Yzh/BaseClient.php
Normal file
254
extend/Yzh/BaseClient.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Exception\HttpException;
|
||||
use Yzh\Config;
|
||||
use Yzh\Utils\Rsa;
|
||||
use Yzh\Utils\Des;
|
||||
use Yzh\Utils\Hmac;
|
||||
use Yzh\Utils\MessString;
|
||||
use Yzh\Model\BaseResponse;
|
||||
|
||||
defined("JSON_UNESCAPED_UNICODE") or define("JSON_UNESCAPED_UNICODE", 256);
|
||||
|
||||
class BaseClient
|
||||
{
|
||||
const SDK_NAME = "yunzhanghu-sdk-php";
|
||||
const SDK_VERSION = "2.0.15";
|
||||
const ENV_PROD = "yzh_env_prod";
|
||||
const ENV_SANDBOX = "yzh_env_sandbox";
|
||||
|
||||
protected $env;
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
protected $config;
|
||||
protected static $service_name;
|
||||
|
||||
protected static $env_service_host_map = array(
|
||||
self::ENV_PROD => array( // 正式环境
|
||||
'payment' => 'https://api-service.yunzhanghu.com', // 实时支付服务接口域名
|
||||
'tax' => 'https://api-service.yunzhanghu.com',
|
||||
'authentication' => 'https://api-service.yunzhanghu.com',
|
||||
'invoice' => 'https://api-service.yunzhanghu.com',
|
||||
'dataservice' => 'https://api-service.yunzhanghu.com', // 数据服务接口域名
|
||||
'apiusersignservice' => 'https://api-service.yunzhanghu.com', // API 用户签约接口域名
|
||||
'h5usersignservice' => 'https://api-service.yunzhanghu.com', // H5 用户签约接口域名
|
||||
'uploadusersignservice' => 'https://api-service.yunzhanghu.com', // 用户签约信息上传接口域名
|
||||
'bizlicgxv2h5apiservice' => 'https://api-aic.yunzhanghu.com', // 个体工商户注册服务(共享大额 H5+API)接口域名
|
||||
'bizlicgxv2h5service' => 'https://api-aic.yunzhanghu.com', // 个体工商户注册服务(共享大额 H5)接口域名
|
||||
'bizlicxjjh5apiservice' => 'https://api-aic.yunzhanghu.com', // 个体工商户注册服务 (云账户新经济 H5+API)接口域名
|
||||
'bizlicxjjh5service' => 'https://api-aic.yunzhanghu.com', // 个体工商户注册服务(云账户新经济 H5)接口域名
|
||||
'ins' => 'https://api-ins.yunzhanghu.com', // 保险服务接口域名
|
||||
'task' => 'https://api-task.yunzhanghu.com', // 任务库服务接口域名
|
||||
|
||||
),
|
||||
self::ENV_SANDBOX => array( // 沙箱环境
|
||||
'payment' => 'https://api-service.yunzhanghu.com/sandbox', // 实时支付服务接口域名
|
||||
'authentication' => 'https://api-service.yunzhanghu.com/sandbox', // 用户信息验证接口域名
|
||||
'apiusersignservice' => 'https://api-service.yunzhanghu.com/sandbox', // API 签约接口域名
|
||||
'h5usersignservice' => 'https://api-service.yunzhanghu.com/sandbox', // H5 签约接口域名
|
||||
'ins' => '', // 保险服务接口域名
|
||||
'aic' => '', // 个体工商户注册服务接口域名
|
||||
'task' => '', // 任务库服务接口域名
|
||||
'dataservice' => '', // 数据服务接口域名
|
||||
),
|
||||
);
|
||||
|
||||
protected $rsa;
|
||||
protected $hmac;
|
||||
protected $des;
|
||||
protected $app_key;
|
||||
protected $sign_type;
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
if (!$config instanceof Config) {
|
||||
throw new ConfigException('config 参数必须是 Yzh\\Config 实例', ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
$this->config = $config;
|
||||
$this->setEnv($config->env);
|
||||
|
||||
if ($this->config->sign_type == Config::SIGN_TYPE_RSA) {
|
||||
$this->rsa = new Rsa($this->config->app_private_key, $this->config->yzh_public_key);
|
||||
$this->sign_type = Config::SIGN_TYPE_RSA;
|
||||
} else if ($this->config->sign_type == Config::SIGN_TYPE_HMAC) {
|
||||
$this->hmac = new Hmac($this->config->app_key);
|
||||
$this->sign_type = Config::SIGN_TYPE_HMAC;
|
||||
} else {
|
||||
throw new ConfigException("签名方式配置错误", ExceptionCode::CONFIG_ERROR_WRONG_SIGN_TYPE);
|
||||
}
|
||||
|
||||
$this->app_key = $this->config->app_key;
|
||||
$this->des = new Des($this->config->app_des3_key);
|
||||
}
|
||||
|
||||
public function setEnv($envName)
|
||||
{
|
||||
if (!in_array($envName, array(self::ENV_PROD, self::ENV_SANDBOX), true)) {
|
||||
throw new ConfigException("请选择正确的服务环境", ExceptionCode::CONFIG_ERROR_WRONG_ENV);
|
||||
}
|
||||
$this->env = $envName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function get($url, $data, $header, $option)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $url . '?' . http_build_query($data),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => $option->getConnectTimeout(),
|
||||
CURLOPT_TIMEOUT => $option->getTimeout(),
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => $header,
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if ($response == false) {
|
||||
$errMsg = curl_error($curl);
|
||||
curl_close($curl);
|
||||
throw new HttpException("请求失败,response:" . $errMsg, 0);
|
||||
}
|
||||
|
||||
$curlInfo = curl_getinfo($curl);
|
||||
curl_close($curl);
|
||||
|
||||
if ($curlInfo['http_code'] != 200) {
|
||||
throw new HttpException("请求失败,response:" . $response, $curlInfo['http_code']);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Option $option
|
||||
*/
|
||||
protected function post($url, $data, $header, $option)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => $option->getConnectTimeout(),
|
||||
CURLOPT_TIMEOUT => $option->getTimeout(),
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => http_build_query($data),
|
||||
CURLOPT_HTTPHEADER => $header,
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if ($response == false) {
|
||||
$errMsg = curl_error($curl);
|
||||
curl_close($curl);
|
||||
throw new HttpException("请求失败,response:" . $errMsg, 0);
|
||||
}
|
||||
|
||||
$curlInfo = curl_getinfo($curl);
|
||||
curl_close($curl);
|
||||
|
||||
if ($curlInfo['http_code'] != 200) {
|
||||
throw new HttpException("请求失败,response:" . $response, $curlInfo['http_code']);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function send($method, $path, $request, $responseDataClass, $option = null)
|
||||
{
|
||||
if (!is_null($option) && !$option instanceof Option) {
|
||||
throw new ConfigException("参数 option 必须为 Yzh\\Request\\Option 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
|
||||
if (is_null($option)) {
|
||||
$option = new Option(array('timeout' => $this->config->timeout));
|
||||
}
|
||||
|
||||
// 获取接口请求参数
|
||||
$requestData = $this->getRequestData($request);
|
||||
$responseDecoder = property_exists($request, 'data_type') && $request->data_type == 'encryption' ? $this->des : null;
|
||||
|
||||
// 获取 url 的 path 部分, 将 path 部分拼接到传入的 path 上
|
||||
$baseUrl = self::$env_service_host_map[$this->env][$this::$service_name];
|
||||
if (empty($baseUrl)) {
|
||||
throw new ConfigException('该环境不支持该请求,环境为:' . $this::$service_name, ExceptionCode::CONFIG_ERROR_UNSUPPORT_URL_IN_CURRENT_ENV);
|
||||
}
|
||||
|
||||
$header = array(
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'dealer-id: ' . $this->config->app_dealer_id,
|
||||
'request-id: ' . $request->getRequestId(),
|
||||
'User-Agent: ' . $this->generateUserAgent()
|
||||
);
|
||||
|
||||
$url = $baseUrl . $path;
|
||||
if ($method == "GET") {
|
||||
$body = $this->get($url, $requestData, $header, $option);
|
||||
} else {
|
||||
$body = $this->post($url, $requestData, $header, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var BaseResponse $resp
|
||||
*/
|
||||
$resp = new $responseDataClass();
|
||||
$respData = json_decode($body, true);
|
||||
if (isset($respData['code'])) {
|
||||
$resp->setCode($respData['code']);
|
||||
}
|
||||
|
||||
if (isset($respData['message'])) {
|
||||
$resp->setMessage($respData['message']);
|
||||
}
|
||||
|
||||
$requestID = "";
|
||||
if (isset($respData['request_id'])) {
|
||||
$requestID = $respData['request_id'];
|
||||
} elseif (isset($respData['requestID'])) {
|
||||
$requestID = $respData['requestID'];
|
||||
}
|
||||
$resp->setRequestID($requestID);
|
||||
|
||||
if (!isset($respData['data']) || !class_exists($responseDataClass)) {
|
||||
return $resp;
|
||||
}
|
||||
|
||||
if (is_string($respData['data']) && !is_null($responseDecoder)) {
|
||||
$data = json_decode($responseDecoder->decrypt($respData['data']), true);
|
||||
} else {
|
||||
$data = $respData['data'];
|
||||
}
|
||||
$resp->setData($data);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
private function generateUserAgent()
|
||||
{
|
||||
return self::SDK_NAME . "/" . self::SDK_VERSION . "/" . PHP_VERSION;
|
||||
}
|
||||
|
||||
private function getRequestData($request)
|
||||
{
|
||||
$encryptedBody = $this->des->encrypt(json_encode($request->getRequestData(), JSON_UNESCAPED_UNICODE));
|
||||
$mess = MessString::rand(16);
|
||||
$nowts = time();
|
||||
if ($this->sign_type == Config::SIGN_TYPE_RSA) {
|
||||
$sign = $this->rsa->sign(sprintf("data=%s&mess=%s×tamp=%d&key=%s", $encryptedBody, $mess, $nowts, $this->config->app_key));
|
||||
} else {
|
||||
$sign = $this->hmac->sign(sprintf("data=%s&mess=%s×tamp=%d&key=%s", $encryptedBody, $mess, $nowts, $this->config->app_key));
|
||||
}
|
||||
return array(
|
||||
'data' => $encryptedBody,
|
||||
'mess' => $mess,
|
||||
'timestamp' => $nowts,
|
||||
'sign' => $sign,
|
||||
'sign_type' => $this->sign_type,
|
||||
);
|
||||
}
|
||||
}
|
||||
63
extend/Yzh/BizlicGxV2H5APIServiceClient.php
Normal file
63
extend/Yzh/BizlicGxV2H5APIServiceClient.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\Bizlicgxv2h5api\GxV2H5APIPreCollectBizlicMsgRequest;
|
||||
use Yzh\Model\Bizlicgxv2h5api\GxV2H5APIPreCollectBizlicMsgResponse;
|
||||
use Yzh\Model\Bizlicgxv2h5api\GxV2H5APIGetStartUrlRequest;
|
||||
use Yzh\Model\Bizlicgxv2h5api\GxV2H5APIGetStartUrlResponse;
|
||||
use Yzh\Model\Bizlicgxv2h5api\GxV2H5APIGetAicStatusRequest;
|
||||
use Yzh\Model\Bizlicgxv2h5api\GxV2H5APIGetAicStatusResponse;
|
||||
|
||||
/**
|
||||
* 云账户共享大额 H5+API
|
||||
* Class BizlicGxV2H5APIServiceClient
|
||||
*/
|
||||
class BizlicGxV2H5APIServiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'bizlicgxv2h5apiservice';
|
||||
|
||||
/**
|
||||
* 工商实名信息录入
|
||||
* @param GxV2H5APIPreCollectBizlicMsgRequest $request
|
||||
* @param null $option
|
||||
* @return GxV2H5APIPreCollectBizlicMsgResponse
|
||||
*/
|
||||
public function gxV2H5APIPreCollectBizlicMsg($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GxV2H5APIPreCollectBizlicMsgRequest) {
|
||||
throw new ConfigException("Bizlicgxv2h5api->gxV2H5APIPreCollectBizlicMsg request 必须是 Yzh\\Model\\Bizlicgxv2h5api\\GxV2H5APIPreCollectBizlicMsgRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/aic/sharing-economy/api-h5/v1/collect', $request, "Yzh\\Model\\Bizlicgxv2h5api\\GxV2H5APIPreCollectBizlicMsgResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预启动
|
||||
* @param GxV2H5APIGetStartUrlRequest $request
|
||||
* @param null $option
|
||||
* @return GxV2H5APIGetStartUrlResponse
|
||||
*/
|
||||
public function gxV2H5APIGetStartUrl($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GxV2H5APIGetStartUrlRequest) {
|
||||
throw new ConfigException("Bizlicgxv2h5api->gxV2H5APIGetStartUrl request 必须是 Yzh\\Model\\Bizlicgxv2h5api\\GxV2H5APIGetStartUrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/sharing-economy/api-h5/v1/h5url', $request, "Yzh\\Model\\Bizlicgxv2h5api\\GxV2H5APIGetStartUrlResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态
|
||||
* @param GxV2H5APIGetAicStatusRequest $request
|
||||
* @param null $option
|
||||
* @return GxV2H5APIGetAicStatusResponse
|
||||
*/
|
||||
public function gxV2H5APIGetAicStatus($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GxV2H5APIGetAicStatusRequest) {
|
||||
throw new ConfigException("Bizlicgxv2h5api->gxV2H5APIGetAicStatus request 必须是 Yzh\\Model\\Bizlicgxv2h5api\\GxV2H5APIGetAicStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/sharing-economy/api-h5/v1/status', $request, "Yzh\\Model\\Bizlicgxv2h5api\\GxV2H5APIGetAicStatusResponse", $option);
|
||||
}
|
||||
}
|
||||
47
extend/Yzh/BizlicGxV2H5ServiceClient.php
Normal file
47
extend/Yzh/BizlicGxV2H5ServiceClient.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\Bizlicgxv2h5\GxV2H5GetStartUrlRequest;
|
||||
use Yzh\Model\Bizlicgxv2h5\GxV2H5GetStartUrlResponse;
|
||||
use Yzh\Model\Bizlicgxv2h5\GxV2H5GetAicStatusRequest;
|
||||
use Yzh\Model\Bizlicgxv2h5\GxV2H5GetAicStatusResponse;
|
||||
|
||||
/**
|
||||
* 云账户共享大额 H5
|
||||
* Class BizlicGxV2H5ServiceClient
|
||||
*/
|
||||
class BizlicGxV2H5ServiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'bizlicgxv2h5service';
|
||||
|
||||
/**
|
||||
* 预启动
|
||||
* @param GxV2H5GetStartUrlRequest $request
|
||||
* @param null $option
|
||||
* @return GxV2H5GetStartUrlResponse
|
||||
*/
|
||||
public function gxV2H5GetStartUrl($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GxV2H5GetStartUrlRequest) {
|
||||
throw new ConfigException("Bizlicgxv2h5->gxV2H5GetStartUrl request 必须是 Yzh\\Model\\Bizlicgxv2h5\\GxV2H5GetStartUrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/sharing-economy/h5/v1/h5url', $request, "Yzh\\Model\\Bizlicgxv2h5\\GxV2H5GetStartUrlResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态
|
||||
* @param GxV2H5GetAicStatusRequest $request
|
||||
* @param null $option
|
||||
* @return GxV2H5GetAicStatusResponse
|
||||
*/
|
||||
public function gxV2H5GetAicStatus($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GxV2H5GetAicStatusRequest) {
|
||||
throw new ConfigException("Bizlicgxv2h5->gxV2H5GetAicStatus request 必须是 Yzh\\Model\\Bizlicgxv2h5\\GxV2H5GetAicStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/sharing-economy/h5/v1/status', $request, "Yzh\\Model\\Bizlicgxv2h5\\GxV2H5GetAicStatusResponse", $option);
|
||||
}
|
||||
}
|
||||
63
extend/Yzh/BizlicXjjH5APIServiceClient.php
Normal file
63
extend/Yzh/BizlicXjjH5APIServiceClient.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\Bizlicxjjh5api\H5PreCollectBizlicMsgRequest;
|
||||
use Yzh\Model\Bizlicxjjh5api\H5PreCollectBizlicMsgResponse;
|
||||
use Yzh\Model\Bizlicxjjh5api\H5APIGetStartUrlRequest;
|
||||
use Yzh\Model\Bizlicxjjh5api\H5APIGetStartUrlResponse;
|
||||
use Yzh\Model\Bizlicxjjh5api\H5APIEcoCityAicStatusRequest;
|
||||
use Yzh\Model\Bizlicxjjh5api\H5APIEcoCityAicStatusResponse;
|
||||
|
||||
/**
|
||||
* 云账户新经济 H5+API
|
||||
* Class BizlicXjjH5APIServiceClient
|
||||
*/
|
||||
class BizlicXjjH5APIServiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'bizlicxjjh5apiservice';
|
||||
|
||||
/**
|
||||
* 工商实名信息录入
|
||||
* @param H5PreCollectBizlicMsgRequest $request
|
||||
* @param null $option
|
||||
* @return H5PreCollectBizlicMsgResponse
|
||||
*/
|
||||
public function h5PreCollectBizlicMsg($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5PreCollectBizlicMsgRequest) {
|
||||
throw new ConfigException("Bizlicxjjh5api->h5PreCollectBizlicMsg request 必须是 Yzh\\Model\\Bizlicxjjh5api\\H5PreCollectBizlicMsgRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/aic/new-economy/api-h5/v1/collect', $request, "Yzh\\Model\\Bizlicxjjh5api\\H5PreCollectBizlicMsgResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预启动
|
||||
* @param H5APIGetStartUrlRequest $request
|
||||
* @param null $option
|
||||
* @return H5APIGetStartUrlResponse
|
||||
*/
|
||||
public function h5APIGetStartUrl($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5APIGetStartUrlRequest) {
|
||||
throw new ConfigException("Bizlicxjjh5api->h5APIGetStartUrl request 必须是 Yzh\\Model\\Bizlicxjjh5api\\H5APIGetStartUrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/new-economy/api-h5/v1/h5url', $request, "Yzh\\Model\\Bizlicxjjh5api\\H5APIGetStartUrlResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态
|
||||
* @param H5APIEcoCityAicStatusRequest $request
|
||||
* @param null $option
|
||||
* @return H5APIEcoCityAicStatusResponse
|
||||
*/
|
||||
public function h5APIEcoCityAicStatus($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5APIEcoCityAicStatusRequest) {
|
||||
throw new ConfigException("Bizlicxjjh5api->h5APIEcoCityAicStatus request 必须是 Yzh\\Model\\Bizlicxjjh5api\\H5APIEcoCityAicStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/new-economy/api-h5/v1/status', $request, "Yzh\\Model\\Bizlicxjjh5api\\H5APIEcoCityAicStatusResponse", $option);
|
||||
}
|
||||
}
|
||||
47
extend/Yzh/BizlicXjjH5ServiceClient.php
Normal file
47
extend/Yzh/BizlicXjjH5ServiceClient.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\Bizlicxjjh5\H5GetStartUrlRequest;
|
||||
use Yzh\Model\Bizlicxjjh5\H5GetStartUrlResponse;
|
||||
use Yzh\Model\Bizlicxjjh5\H5EcoCityAicStatusRequest;
|
||||
use Yzh\Model\Bizlicxjjh5\H5EcoCityAicStatusResponse;
|
||||
|
||||
/**
|
||||
* 云账户新经济 H5
|
||||
* Class BizlicXjjH5ServiceClient
|
||||
*/
|
||||
class BizlicXjjH5ServiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'bizlicxjjh5service';
|
||||
|
||||
/**
|
||||
* 预启动
|
||||
* @param H5GetStartUrlRequest $request
|
||||
* @param null $option
|
||||
* @return H5GetStartUrlResponse
|
||||
*/
|
||||
public function h5GetStartUrl($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5GetStartUrlRequest) {
|
||||
throw new ConfigException("Bizlicxjjh5->h5GetStartUrl request 必须是 Yzh\\Model\\Bizlicxjjh5\\H5GetStartUrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/new-economy/h5/v1/h5url', $request, "Yzh\\Model\\Bizlicxjjh5\\H5GetStartUrlResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态
|
||||
* @param H5EcoCityAicStatusRequest $request
|
||||
* @param null $option
|
||||
* @return H5EcoCityAicStatusResponse
|
||||
*/
|
||||
public function h5EcoCityAicStatus($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5EcoCityAicStatusRequest) {
|
||||
throw new ConfigException("Bizlicxjjh5->h5EcoCityAicStatus request 必须是 Yzh\\Model\\Bizlicxjjh5\\H5EcoCityAicStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/aic/new-economy/h5/v1/status', $request, "Yzh\\Model\\Bizlicxjjh5\\H5EcoCityAicStatusResponse", $option);
|
||||
}
|
||||
}
|
||||
95
extend/Yzh/Config.php
Normal file
95
extend/Yzh/Config.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
|
||||
class Config
|
||||
{
|
||||
public $app_dealer_id;
|
||||
public $app_broker_id;
|
||||
public $app_key;
|
||||
public $sign_type;
|
||||
public $app_private_key;
|
||||
public $yzh_public_key;
|
||||
public $app_des3_key;
|
||||
public $timeout;
|
||||
public $env;
|
||||
public $service_name;
|
||||
|
||||
const SIGN_TYPE_RSA = 'rsa';
|
||||
const SIGN_TYPE_HMAC = 'sha256';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function newFromArray($params = array())
|
||||
{
|
||||
$config = new Config();
|
||||
|
||||
if (isset($params['app_dealer_id']) && !empty($params['app_dealer_id'])) {
|
||||
$config->app_dealer_id = $params['app_dealer_id'];
|
||||
} else {
|
||||
throw new ConfigException("缺少 app_dealer_id", ExceptionCode::CONFIG_ERROR_LOST_KEY);
|
||||
}
|
||||
|
||||
if (isset($params['app_broker_id']) && !empty($params['app_broker_id'])) {
|
||||
$config->app_broker_id = $params['app_broker_id'];
|
||||
} else {
|
||||
throw new ConfigException("缺少 app_broker_id", ExceptionCode::CONFIG_ERROR_LOST_KEY);
|
||||
}
|
||||
|
||||
if (isset($params['app_key']) && !empty($params['app_key'])) {
|
||||
$config->app_key = $params['app_key'];
|
||||
} else {
|
||||
throw new ConfigException("缺少 app_key", ExceptionCode::CONFIG_ERROR_LOST_KEY);
|
||||
}
|
||||
|
||||
if (isset($params['app_des3_key']) && !empty($params['app_des3_key'])) {
|
||||
$config->app_des3_key = $params['app_des3_key'];
|
||||
} else {
|
||||
throw new ConfigException("缺少 app_des3_key", ExceptionCode::CONFIG_ERROR_LOST_KEY);
|
||||
}
|
||||
|
||||
if (isset($params['sign_type']) && !empty($params['sign_type'])) {
|
||||
$config->sign_type = $params['sign_type'];
|
||||
} else {
|
||||
$config->sign_type = self::SIGN_TYPE_RSA; // 默认是 RSA 签名
|
||||
}
|
||||
|
||||
if (!in_array($config->sign_type, array(self::SIGN_TYPE_RSA, self::SIGN_TYPE_HMAC))) {
|
||||
throw new ConfigException("缺少 app_private_key", ExceptionCode::CONFIG_ERROR_WRONG_SIGN_TYPE);
|
||||
}
|
||||
|
||||
if ($config->sign_type == self::SIGN_TYPE_RSA) {
|
||||
if (isset($params['app_private_key']) && !empty($params['app_private_key'])) {
|
||||
$config->app_private_key = $params['app_private_key'];
|
||||
} else {
|
||||
throw new ConfigException("缺少 app_private_key", ExceptionCode::CONFIG_ERROR_LOST_KEY);
|
||||
}
|
||||
|
||||
if (isset($params['yzh_public_key']) && !empty($params['yzh_public_key'])) {
|
||||
$config->yzh_public_key = $params['yzh_public_key'];
|
||||
} else {
|
||||
throw new ConfigException("缺少 yzh_public_key", ExceptionCode::CONFIG_ERROR_LOST_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['timeout']) && intval($params['timeout']) > 0) {
|
||||
$config->timeout = intval($params['timeout']);
|
||||
}
|
||||
|
||||
if (isset($params['env']) && !empty($params['env'])) {
|
||||
$config->env = $params['env'];
|
||||
} else {
|
||||
$config->env = BaseClient::ENV_PROD;
|
||||
}
|
||||
|
||||
if (isset($params["service_name"]) && !empty($params["service_name"])) {
|
||||
$config->service_name = $params["service_name"];
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
49
extend/Yzh/CustomClient.php
Normal file
49
extend/Yzh/CustomClient.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Exception\RunTimeException;
|
||||
use Yzh\Model\Custom\CustomRequest;
|
||||
use Yzh\Model\Custom\CustomResponse;
|
||||
use Yzh\Model\Custom\CustomResponseData;
|
||||
|
||||
/**
|
||||
* 通用请求函数
|
||||
*/
|
||||
class CustomClient extends BaseClient {
|
||||
const METHOD_GET = "GET";
|
||||
const METHOD_POST = "POST";
|
||||
|
||||
/**
|
||||
* 发起请求
|
||||
* @param string $method 请求方式 GET/POST
|
||||
* @param string $url 请求地址
|
||||
* @param Object $request 请求参数
|
||||
* @param Object $response 响应参数
|
||||
* @param null $option
|
||||
* @throws ConfigException
|
||||
* @throws RunTimeException
|
||||
*/
|
||||
public function doRequest($method, $url, $request, $response, $option = null)
|
||||
{
|
||||
if (empty($this->config->service_name)) {
|
||||
throw new ConfigException("config service_name 必须设置", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
self::$service_name= $this->config->service_name;
|
||||
if (!$request instanceof CustomRequest) {
|
||||
throw new ConfigException("request 必须是 Yzh\Model\CustomerRequest 的子类", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
if (!$response instanceof CustomResponseData) {
|
||||
throw new ConfigException("response 必须是 Yzh\Model\CustomerResponseData 的子类", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
$method = strtoupper($method);
|
||||
$res = $this->send($method, $url, $request, "Yzh\\Model\\Custom\\CustomResponse", $option);
|
||||
if (!$res instanceof CustomResponse) {
|
||||
throw new RunTimeException("系统错误");
|
||||
}
|
||||
$res->setCustomerData($response);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
177
extend/Yzh/DataServiceClient.php
Normal file
177
extend/Yzh/DataServiceClient.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
|
||||
|
||||
use Yzh\Model\Dataservice\ListDailyOrderRequest;
|
||||
use Yzh\Model\Dataservice\ListDailyOrderResponse;
|
||||
use Yzh\Model\Dataservice\ListDailyOrderV2Request;
|
||||
use Yzh\Model\Dataservice\ListDailyOrderV2Response;
|
||||
use Yzh\Model\Dataservice\GetDailyOrderFileRequest;
|
||||
use Yzh\Model\Dataservice\GetDailyOrderFileResponse;
|
||||
use Yzh\Model\Dataservice\GetDailyOrderFileV2Request;
|
||||
use Yzh\Model\Dataservice\GetDailyOrderFileV2Response;
|
||||
use Yzh\Model\Dataservice\ListDailyBillRequest;
|
||||
use Yzh\Model\Dataservice\ListDailyBillResponse;
|
||||
use Yzh\Model\Dataservice\GetDailyBillFileV2Request;
|
||||
use Yzh\Model\Dataservice\GetDailyBillFileV2Response;
|
||||
use Yzh\Model\Dataservice\ListDealerRechargeRecordV2Request;
|
||||
use Yzh\Model\Dataservice\ListDealerRechargeRecordV2Response;
|
||||
use Yzh\Model\Dataservice\ListBalanceDailyStatementRequest;
|
||||
use Yzh\Model\Dataservice\ListBalanceDailyStatementResponse;
|
||||
use Yzh\Model\Dataservice\ListDailyOrderSummaryRequest;
|
||||
use Yzh\Model\Dataservice\ListDailyOrderSummaryResponse;
|
||||
use Yzh\Model\Dataservice\ListMonthlyOrderSummaryRequest;
|
||||
use Yzh\Model\Dataservice\ListMonthlyOrderSummaryResponse;
|
||||
|
||||
/**
|
||||
* 对账文件获取
|
||||
* Class DataServiceClient
|
||||
*/
|
||||
class DataServiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'dataservice';
|
||||
|
||||
/**
|
||||
* 查询日订单数据
|
||||
* @param ListDailyOrderRequest $request
|
||||
* @param null $option
|
||||
* @return ListDailyOrderResponse
|
||||
*/
|
||||
public function listDailyOrder($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ListDailyOrderRequest) {
|
||||
throw new ConfigException("Dataservice->listDailyOrder request 必须是 Yzh\\Model\\Dataservice\\ListDailyOrderRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v1/orders', $request, "Yzh\\Model\\Dataservice\\ListDailyOrderResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日订单数据(支付和退款订单)
|
||||
* @param ListDailyOrderV2Request $request
|
||||
* @param null $option
|
||||
* @return ListDailyOrderV2Response
|
||||
*/
|
||||
public function listDailyOrderV2($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ListDailyOrderV2Request) {
|
||||
throw new ConfigException("Dataservice->listDailyOrderV2 request 必须是 Yzh\\Model\\Dataservice\\ListDailyOrderV2Request 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v2/orders', $request, "Yzh\\Model\\Dataservice\\ListDailyOrderV2Response", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日订单文件
|
||||
* @param GetDailyOrderFileRequest $request
|
||||
* @param null $option
|
||||
* @return GetDailyOrderFileResponse
|
||||
*/
|
||||
public function getDailyOrderFile($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetDailyOrderFileRequest) {
|
||||
throw new ConfigException("Dataservice->getDailyOrderFile request 必须是 Yzh\\Model\\Dataservice\\GetDailyOrderFileRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v1/order/downloadurl', $request, "Yzh\\Model\\Dataservice\\GetDailyOrderFileResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日订单文件(支付和退款订单)
|
||||
* @param GetDailyOrderFileV2Request $request
|
||||
* @param null $option
|
||||
* @return GetDailyOrderFileV2Response
|
||||
*/
|
||||
public function getDailyOrderFileV2($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetDailyOrderFileV2Request) {
|
||||
throw new ConfigException("Dataservice->getDailyOrderFileV2 request 必须是 Yzh\\Model\\Dataservice\\GetDailyOrderFileV2Request 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v1/order/day/url', $request, "Yzh\\Model\\Dataservice\\GetDailyOrderFileV2Response", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日流水数据
|
||||
* @param ListDailyBillRequest $request
|
||||
* @param null $option
|
||||
* @return ListDailyBillResponse
|
||||
*/
|
||||
public function listDailyBill($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ListDailyBillRequest) {
|
||||
throw new ConfigException("Dataservice->listDailyBill request 必须是 Yzh\\Model\\Dataservice\\ListDailyBillRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v1/bills', $request, "Yzh\\Model\\Dataservice\\ListDailyBillResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日流水文件
|
||||
* @param GetDailyBillFileV2Request $request
|
||||
* @param null $option
|
||||
* @return GetDailyBillFileV2Response
|
||||
*/
|
||||
public function getDailyBillFileV2($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetDailyBillFileV2Request) {
|
||||
throw new ConfigException("Dataservice->getDailyBillFileV2 request 必须是 Yzh\\Model\\Dataservice\\GetDailyBillFileV2Request 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v2/bill/downloadurl', $request, "Yzh\\Model\\Dataservice\\GetDailyBillFileV2Response", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询平台企业预付业务服务费记录
|
||||
* @param ListDealerRechargeRecordV2Request $request
|
||||
* @param null $option
|
||||
* @return ListDealerRechargeRecordV2Response
|
||||
*/
|
||||
public function listDealerRechargeRecordV2($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ListDealerRechargeRecordV2Request) {
|
||||
throw new ConfigException("Dataservice->listDealerRechargeRecordV2 request 必须是 Yzh\\Model\\Dataservice\\ListDealerRechargeRecordV2Request 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v2/recharge-record', $request, "Yzh\\Model\\Dataservice\\ListDealerRechargeRecordV2Response", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询余额日账单数据
|
||||
* @param ListBalanceDailyStatementRequest $request
|
||||
* @param null $option
|
||||
* @return ListBalanceDailyStatementResponse
|
||||
*/
|
||||
public function listBalanceDailyStatement($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ListBalanceDailyStatementRequest) {
|
||||
throw new ConfigException("Dataservice->listBalanceDailyStatement request 必须是 Yzh\\Model\\Dataservice\\ListBalanceDailyStatementRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v1/statements-daily', $request, "Yzh\\Model\\Dataservice\\ListBalanceDailyStatementResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日订单汇总数据
|
||||
* @param ListDailyOrderSummaryRequest $request
|
||||
* @param null $option
|
||||
* @return ListDailyOrderSummaryResponse
|
||||
*/
|
||||
public function listDailyOrderSummary($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ListDailyOrderSummaryRequest) {
|
||||
throw new ConfigException("Dataservice->listDailyOrderSummary request 必须是 Yzh\\Model\\Dataservice\\ListDailyOrderSummaryRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v2/order/daily-summary', $request, "Yzh\\Model\\Dataservice\\ListDailyOrderSummaryResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询月订单汇总数据
|
||||
* @param ListMonthlyOrderSummaryRequest $request
|
||||
* @param null $option
|
||||
* @return ListMonthlyOrderSummaryResponse
|
||||
*/
|
||||
public function listMonthlyOrderSummary($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ListMonthlyOrderSummaryRequest) {
|
||||
throw new ConfigException("Dataservice->listMonthlyOrderSummary request 必须是 Yzh\\Model\\Dataservice\\ListMonthlyOrderSummaryRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/dataservice/v2/order/monthly-summary', $request, "Yzh\\Model\\Dataservice\\ListMonthlyOrderSummaryResponse", $option);
|
||||
}
|
||||
}
|
||||
7
extend/Yzh/Exception/BaseException.php
Normal file
7
extend/Yzh/Exception/BaseException.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Exception;
|
||||
|
||||
class BaseException extends \Exception
|
||||
{
|
||||
}
|
||||
15
extend/Yzh/Exception/ConfigException.php
Normal file
15
extend/Yzh/Exception/ConfigException.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Exception;
|
||||
|
||||
class ConfigException extends BaseException
|
||||
{
|
||||
public function __construct($message = "", $code = 0)
|
||||
{
|
||||
$msg = ExceptionCode::getErrorMessage($code);
|
||||
if (!empty($message)) {
|
||||
$msg .= ": " . $message;
|
||||
}
|
||||
parent::__construct((string) $msg, (int) $code);
|
||||
}
|
||||
}
|
||||
36
extend/Yzh/Exception/ExceptionCode.php
Normal file
36
extend/Yzh/Exception/ExceptionCode.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Exception;
|
||||
|
||||
final class ExceptionCode
|
||||
{
|
||||
const CONFIG_ERROR_WRONG_PARAM = 10000;
|
||||
const CONFIG_ERROR_WRONG_ENV = 1001;
|
||||
const CONFIG_ERROR_LACK_PACKAGE = 10002;
|
||||
const CONFIG_ERROR_WRONG_SIGN_TYPE = 10003;
|
||||
const CONFIG_ERROR_LOST_KEY = 20000;
|
||||
const CONFIG_ERROR_RSA_KEY_INVALID = 20001;
|
||||
const CONFIG_ERROR_UNSUPPORT_URL_IN_CURRENT_ENV = 20002;
|
||||
const PRIVATE_KEY_ENCRYPT_FAIL = 20003;
|
||||
const PRIVATE_KEY_DECRYPT_FAIL = 2004;
|
||||
const PUBLIC_KEY_DECRYPT_FAIL = 20005;
|
||||
const DES_KEY_ENCRYPT_FAIL = 2006;
|
||||
const DES_KEY_DECRYPT_FAIL = 2007;
|
||||
|
||||
private static $error_message_map = array(
|
||||
self::CONFIG_ERROR_LOST_KEY => '[客户端] 缺少配置参数',
|
||||
self::CONFIG_ERROR_RSA_KEY_INVALID => '[客户端] RSA 密钥格式错误',
|
||||
);
|
||||
|
||||
public static function getErrorMessage($code)
|
||||
{
|
||||
if (!is_int($code)) {
|
||||
return 'code 必须是整型';
|
||||
}
|
||||
|
||||
if (!array_key_exists($code, self::$error_message_map)) {
|
||||
return "未知错误";
|
||||
}
|
||||
return self::$error_message_map[$code];
|
||||
}
|
||||
}
|
||||
7
extend/Yzh/Exception/HttpException.php
Normal file
7
extend/Yzh/Exception/HttpException.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Exception;
|
||||
|
||||
class HttpException extends BaseException
|
||||
{
|
||||
}
|
||||
7
extend/Yzh/Exception/RunTimeException.php
Normal file
7
extend/Yzh/Exception/RunTimeException.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Exception;
|
||||
|
||||
class RunTimeException extends BaseException
|
||||
{
|
||||
}
|
||||
79
extend/Yzh/H5UserSignServiceClient.php
Normal file
79
extend/Yzh/H5UserSignServiceClient.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\H5usersign\H5UserPresignRequest;
|
||||
use Yzh\Model\H5usersign\H5UserPresignResponse;
|
||||
use Yzh\Model\H5usersign\H5UserSignRequest;
|
||||
use Yzh\Model\H5usersign\H5UserSignResponse;
|
||||
use Yzh\Model\H5usersign\GetH5UserSignStatusRequest;
|
||||
use Yzh\Model\H5usersign\GetH5UserSignStatusResponse;
|
||||
use Yzh\Model\H5usersign\H5UserReleaseRequest;
|
||||
use Yzh\Model\H5usersign\H5UserReleaseResponse;
|
||||
|
||||
/**
|
||||
* H5 签约
|
||||
* Class H5UserSignServiceClient
|
||||
*/
|
||||
class H5UserSignServiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'h5usersignservice';
|
||||
|
||||
/**
|
||||
* 预申请签约
|
||||
* @param H5UserPresignRequest $request
|
||||
* @param null $option
|
||||
* @return H5UserPresignResponse
|
||||
*/
|
||||
public function h5UserPresign($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5UserPresignRequest) {
|
||||
throw new ConfigException("H5usersign->h5UserPresign request 必须是 Yzh\\Model\\H5usersign\\H5UserPresignRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/sdk/v1/presign', $request, "Yzh\\Model\\H5usersign\\H5UserPresignResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请签约
|
||||
* @param H5UserSignRequest $request
|
||||
* @param null $option
|
||||
* @return H5UserSignResponse
|
||||
*/
|
||||
public function h5UserSign($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5UserSignRequest) {
|
||||
throw new ConfigException("H5usersign->h5UserSign request 必须是 Yzh\\Model\\H5usersign\\H5UserSignRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/sdk/v1/sign/h5', $request, "Yzh\\Model\\H5usersign\\H5UserSignResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户签约状态
|
||||
* @param GetH5UserSignStatusRequest $request
|
||||
* @param null $option
|
||||
* @return GetH5UserSignStatusResponse
|
||||
*/
|
||||
public function getH5UserSignStatus($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetH5UserSignStatusRequest) {
|
||||
throw new ConfigException("H5usersign->getH5UserSignStatus request 必须是 Yzh\\Model\\H5usersign\\GetH5UserSignStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/sdk/v1/sign/user/status', $request, "Yzh\\Model\\H5usersign\\GetH5UserSignStatusResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户解约(测试账号专用接口)
|
||||
* @param H5UserReleaseRequest $request
|
||||
* @param null $option
|
||||
* @return H5UserReleaseResponse
|
||||
*/
|
||||
public function h5UserRelease($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof H5UserReleaseRequest) {
|
||||
throw new ConfigException("H5usersign->h5UserRelease request 必须是 Yzh\\Model\\H5usersign\\H5UserReleaseRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/sdk/v1/sign/release', $request, "Yzh\\Model\\H5usersign\\H5UserReleaseResponse", $option);
|
||||
}
|
||||
}
|
||||
127
extend/Yzh/InvoiceClient.php
Normal file
127
extend/Yzh/InvoiceClient.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh;
|
||||
|
||||
use Yzh\Exception\ConfigException;
|
||||
use Yzh\Exception\ExceptionCode;
|
||||
use Yzh\Model\Invoice\GetInvoiceStatRequest;
|
||||
use Yzh\Model\Invoice\GetInvoiceStatResponse;
|
||||
use Yzh\Model\Invoice\GetInvoiceAmountRequest;
|
||||
use Yzh\Model\Invoice\GetInvoiceAmountResponse;
|
||||
use Yzh\Model\Invoice\ApplyInvoiceRequest;
|
||||
use Yzh\Model\Invoice\ApplyInvoiceResponse;
|
||||
use Yzh\Model\Invoice\GetInvoiceStatusRequest;
|
||||
use Yzh\Model\Invoice\GetInvoiceStatusResponse;
|
||||
use Yzh\Model\Invoice\GetInvoiceInformationRequest;
|
||||
use Yzh\Model\Invoice\GetInvoiceInformationResponse;
|
||||
use Yzh\Model\Invoice\GetInvoiceFileRequest;
|
||||
use Yzh\Model\Invoice\GetInvoiceFileResponse;
|
||||
use Yzh\Model\Invoice\SendReminderEmailRequest;
|
||||
use Yzh\Model\Invoice\SendReminderEmailResponse;
|
||||
|
||||
/**
|
||||
* 发票开具
|
||||
* Class InvoiceClient
|
||||
*/
|
||||
class InvoiceClient extends BaseClient
|
||||
{
|
||||
protected static $service_name = 'invoice';
|
||||
|
||||
/**
|
||||
* 查询平台企业已开具和待开具发票金额
|
||||
* @param GetInvoiceStatRequest $request
|
||||
* @param null $option
|
||||
* @return GetInvoiceStatResponse
|
||||
*/
|
||||
public function getInvoiceStat($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetInvoiceStatRequest) {
|
||||
throw new ConfigException("Invoice->getInvoiceStat request 必须是 Yzh\\Model\\Invoice\\GetInvoiceStatRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('GET', '/api/payment/v1/invoice-stat', $request, "Yzh\\Model\\Invoice\\GetInvoiceStatResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询可开具发票额度和发票开具信息
|
||||
* @param GetInvoiceAmountRequest $request
|
||||
* @param null $option
|
||||
* @return GetInvoiceAmountResponse
|
||||
*/
|
||||
public function getInvoiceAmount($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetInvoiceAmountRequest) {
|
||||
throw new ConfigException("Invoice->getInvoiceAmount request 必须是 Yzh\\Model\\Invoice\\GetInvoiceAmountRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/invoice/v2/invoice-amount', $request, "Yzh\\Model\\Invoice\\GetInvoiceAmountResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发票开具申请
|
||||
* @param ApplyInvoiceRequest $request
|
||||
* @param null $option
|
||||
* @return ApplyInvoiceResponse
|
||||
*/
|
||||
public function applyInvoice($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof ApplyInvoiceRequest) {
|
||||
throw new ConfigException("Invoice->applyInvoice request 必须是 Yzh\\Model\\Invoice\\ApplyInvoiceRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/invoice/v2/apply', $request, "Yzh\\Model\\Invoice\\ApplyInvoiceResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询发票开具申请状态
|
||||
* @param GetInvoiceStatusRequest $request
|
||||
* @param null $option
|
||||
* @return GetInvoiceStatusResponse
|
||||
*/
|
||||
public function getInvoiceStatus($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetInvoiceStatusRequest) {
|
||||
throw new ConfigException("Invoice->getInvoiceStatus request 必须是 Yzh\\Model\\Invoice\\GetInvoiceStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/invoice/v2/invoice/invoice-status', $request, "Yzh\\Model\\Invoice\\GetInvoiceStatusResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询发票信息
|
||||
* @param GetInvoiceInformationRequest $request
|
||||
* @param null $option
|
||||
* @return GetInvoiceInformationResponse
|
||||
*/
|
||||
public function getInvoiceInformation($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetInvoiceInformationRequest) {
|
||||
throw new ConfigException("Invoice->getInvoiceInformation request 必须是 Yzh\\Model\\Invoice\\GetInvoiceInformationRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/invoice/v2/invoice-face-information', $request, "Yzh\\Model\\Invoice\\GetInvoiceInformationResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载 PDF 版发票
|
||||
* @param GetInvoiceFileRequest $request
|
||||
* @param null $option
|
||||
* @return GetInvoiceFileResponse
|
||||
*/
|
||||
public function getInvoiceFile($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof GetInvoiceFileRequest) {
|
||||
throw new ConfigException("Invoice->getInvoiceFile request 必须是 Yzh\\Model\\Invoice\\GetInvoiceFileRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/invoice/v2/invoice/invoice-pdf', $request, "Yzh\\Model\\Invoice\\GetInvoiceFileResponse", $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送发票开具成功通知邮件
|
||||
* @param SendReminderEmailRequest $request
|
||||
* @param null $option
|
||||
* @return SendReminderEmailResponse
|
||||
*/
|
||||
public function sendReminderEmail($request, $option = null)
|
||||
{
|
||||
if (!$request instanceof SendReminderEmailRequest) {
|
||||
throw new ConfigException("Invoice->sendReminderEmail request 必须是 Yzh\\Model\\Invoice\\SendReminderEmailRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||
}
|
||||
return $this->send('POST', '/api/invoice/v2/invoice/reminder/email', $request, "Yzh\\Model\\Invoice\\SendReminderEmailResponse", $option);
|
||||
}
|
||||
}
|
||||
32
extend/Yzh/Model/Apiusersign/ApiUseSignContractRequest.php
Normal file
32
extend/Yzh/Model/Apiusersign/ApiUseSignContractRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL 请求
|
||||
* Class ApiUseSignContractRequest
|
||||
*/
|
||||
class ApiUseSignContractRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Apiusersign/ApiUseSignContractResponse.php
Normal file
33
extend/Yzh/Model/Apiusersign/ApiUseSignContractResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL 返回
|
||||
* Class ApiUseSignContractResponse
|
||||
*/
|
||||
class ApiUseSignContractResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return ApiUseSignContractResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new ApiUseSignContractResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL 返回
|
||||
* Class ApiUseSignContractResponseData
|
||||
*/
|
||||
class ApiUseSignContractResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 预览跳转 URL
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
/**
|
||||
* 协议名称
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* 预览跳转 URL
|
||||
* @var string $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览跳转 URL
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 协议名称
|
||||
* @var string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 协议名称
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
}
|
||||
32
extend/Yzh/Model/Apiusersign/ApiUserSignContractRequest.php
Normal file
32
extend/Yzh/Model/Apiusersign/ApiUserSignContractRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL 请求 V2
|
||||
* Class ApiUserSignContractRequest
|
||||
*/
|
||||
class ApiUserSignContractRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Apiusersign/ApiUserSignContractResponse.php
Normal file
33
extend/Yzh/Model/Apiusersign/ApiUserSignContractResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL 返回 V2
|
||||
* Class ApiUserSignContractResponse
|
||||
*/
|
||||
class ApiUserSignContractResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return ApiUserSignContractResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new ApiUserSignContractResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 获取协议预览 URL 返回 V2
|
||||
* Class ApiUserSignContractResponseData
|
||||
*/
|
||||
class ApiUserSignContractResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 预览跳转 URL
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
/**
|
||||
* 协议名称
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* 预览跳转 URL
|
||||
* @var string $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览跳转 URL
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 协议名称
|
||||
* @var string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 协议名称
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
}
|
||||
47
extend/Yzh/Model/Apiusersign/ApiUserSignReleaseRequest.php
Normal file
47
extend/Yzh/Model/Apiusersign/ApiUserSignReleaseRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 用户解约(测试账号专用接口)请求
|
||||
* Class ApiUserSignReleaseRequest
|
||||
*/
|
||||
class ApiUserSignReleaseRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 证件号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 证件类型 idcard:身份证 passport:护照 mtphkm:港澳居民来往内地通行证 mtpt:台湾居民往来大陆通行证 rphkm:中华人民共和国港澳居民居住证 rpt:中华人民共和国台湾居民居住证 fpr:外国人永久居留身份证 ffwp:中华人民共和国外国人就业许可证书
|
||||
* @var string
|
||||
*/
|
||||
public $card_type;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Apiusersign/ApiUserSignReleaseResponse.php
Normal file
33
extend/Yzh/Model/Apiusersign/ApiUserSignReleaseResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 用户解约(测试账号专用接口)返回
|
||||
* Class ApiUserSignReleaseResponse
|
||||
*/
|
||||
class ApiUserSignReleaseResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return ApiUserSignReleaseResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new ApiUserSignReleaseResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 用户解约(测试账号专用接口)返回
|
||||
* Class ApiUserSignReleaseResponseData
|
||||
*/
|
||||
class ApiUserSignReleaseResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 是否解约成功
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* 是否解约成功
|
||||
* @var string $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否解约成功
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
47
extend/Yzh/Model/Apiusersign/ApiUserSignRequest.php
Normal file
47
extend/Yzh/Model/Apiusersign/ApiUserSignRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 用户签约请求
|
||||
* Class ApiUserSignRequest
|
||||
*/
|
||||
class ApiUserSignRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 证件号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 证件类型 idcard:身份证 passport:护照 mtphkm:港澳居民来往内地通行证 mtpt:台湾居民往来大陆通行证 rphkm:中华人民共和国港澳居民居住证 rpt:中华人民共和国台湾居民居住证 fpr:外国人永久居留身份证 ffwp:中华人民共和国外国人就业许可证书
|
||||
* @var string
|
||||
*/
|
||||
public $card_type;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Apiusersign/ApiUserSignResponse.php
Normal file
33
extend/Yzh/Model/Apiusersign/ApiUserSignResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 用户签约返回
|
||||
* Class ApiUserSignResponse
|
||||
*/
|
||||
class ApiUserSignResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return ApiUserSignResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new ApiUserSignResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
37
extend/Yzh/Model/Apiusersign/ApiUserSignResponseData.php
Normal file
37
extend/Yzh/Model/Apiusersign/ApiUserSignResponseData.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 用户签约返回
|
||||
* Class ApiUserSignResponseData
|
||||
*/
|
||||
class ApiUserSignResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 是否签约成功
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* 是否签约成功
|
||||
* @var string $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否签约成功
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
42
extend/Yzh/Model/Apiusersign/GetApiUserSignStatusRequest.php
Normal file
42
extend/Yzh/Model/Apiusersign/GetApiUserSignStatusRequest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 获取用户签约状态请求
|
||||
* Class GetApiUserSignStatusRequest
|
||||
*/
|
||||
class GetApiUserSignStatusRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 证件号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 获取用户签约状态返回
|
||||
* Class GetApiUserSignStatusResponse
|
||||
*/
|
||||
class GetApiUserSignStatusResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return GetApiUserSignStatusResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new GetApiUserSignStatusResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Apiusersign;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 获取用户签约状态返回
|
||||
* Class GetApiUserSignStatusResponseData
|
||||
*/
|
||||
class GetApiUserSignStatusResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 签约时间
|
||||
* @var string
|
||||
*/
|
||||
protected $signed_at;
|
||||
/**
|
||||
* 用户签约状态
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* 签约时间
|
||||
* @var string $signed_at
|
||||
*/
|
||||
public function setSignedAt($signed_at)
|
||||
{
|
||||
$this->signed_at = $signed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签约时间
|
||||
* @return string
|
||||
*/
|
||||
public function getSignedAt()
|
||||
{
|
||||
return $this->signed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户签约状态
|
||||
* @var string $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户签约状态
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 银行卡四要素确认请求(上传短信验证码)请求
|
||||
* Class BankCardFourAuthConfirmRequest
|
||||
*/
|
||||
class BankCardFourAuthConfirmRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 银行卡号
|
||||
* @var string
|
||||
*/
|
||||
public $card_no;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 银行预留手机号
|
||||
* @var string
|
||||
*/
|
||||
public $mobile;
|
||||
/**
|
||||
* 短信验证码
|
||||
* @var string
|
||||
*/
|
||||
public $captcha;
|
||||
/**
|
||||
* 交易凭证
|
||||
* @var string
|
||||
*/
|
||||
public $ref;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 银行卡四要素确认请求(上传短信验证码)返回
|
||||
* Class BankCardFourAuthConfirmResponse
|
||||
*/
|
||||
class BankCardFourAuthConfirmResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return BankCardFourAuthConfirmResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new BankCardFourAuthConfirmResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 银行卡四要素确认请求(上传短信验证码)返回
|
||||
* Class BankCardFourAuthConfirmResponseData
|
||||
*/
|
||||
class BankCardFourAuthConfirmResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 银行卡四要素鉴权请求(下发短信验证码)请求
|
||||
* Class BankCardFourAuthVerifyRequest
|
||||
*/
|
||||
class BankCardFourAuthVerifyRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 银行卡号
|
||||
* @var string
|
||||
*/
|
||||
public $card_no;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 银行预留手机号
|
||||
* @var string
|
||||
*/
|
||||
public $mobile;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 银行卡四要素鉴权请求(下发短信验证码)返回
|
||||
* Class BankCardFourAuthVerifyResponse
|
||||
*/
|
||||
class BankCardFourAuthVerifyResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return BankCardFourAuthVerifyResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new BankCardFourAuthVerifyResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 银行卡四要素鉴权请求(下发短信验证码)返回
|
||||
* Class BankCardFourAuthVerifyResponseData
|
||||
*/
|
||||
class BankCardFourAuthVerifyResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 交易凭证
|
||||
* @var string
|
||||
*/
|
||||
protected $ref;
|
||||
|
||||
/**
|
||||
* 交易凭证
|
||||
* @var string $ref
|
||||
*/
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易凭证
|
||||
* @return string
|
||||
*/
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 银行卡四要素验证请求
|
||||
* Class BankCardFourVerifyRequest
|
||||
*/
|
||||
class BankCardFourVerifyRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 银行卡号
|
||||
* @var string
|
||||
*/
|
||||
public $card_no;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 银行预留手机号
|
||||
* @var string
|
||||
*/
|
||||
public $mobile;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 银行卡四要素验证返回
|
||||
* Class BankCardFourVerifyResponse
|
||||
*/
|
||||
class BankCardFourVerifyResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return BankCardFourVerifyResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new BankCardFourVerifyResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 银行卡四要素验证返回
|
||||
* Class BankCardFourVerifyResponseData
|
||||
*/
|
||||
class BankCardFourVerifyResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 银行卡三要素验证请求
|
||||
* Class BankCardThreeVerifyRequest
|
||||
*/
|
||||
class BankCardThreeVerifyRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 银行卡号
|
||||
* @var string
|
||||
*/
|
||||
public $card_no;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 银行卡三要素验证返回
|
||||
* Class BankCardThreeVerifyResponse
|
||||
*/
|
||||
class BankCardThreeVerifyResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return BankCardThreeVerifyResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new BankCardThreeVerifyResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 银行卡三要素验证返回
|
||||
* Class BankCardThreeVerifyResponseData
|
||||
*/
|
||||
class BankCardThreeVerifyResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
}
|
||||
32
extend/Yzh/Model/Authentication/GetBankCardInfoRequest.php
Normal file
32
extend/Yzh/Model/Authentication/GetBankCardInfoRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 银行卡信息查询请求
|
||||
* Class GetBankCardInfoRequest
|
||||
*/
|
||||
class GetBankCardInfoRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 银行卡号
|
||||
* @var string
|
||||
*/
|
||||
public $card_no;
|
||||
/**
|
||||
* 银行名称
|
||||
* @var string
|
||||
*/
|
||||
public $bank_name;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Authentication/GetBankCardInfoResponse.php
Normal file
33
extend/Yzh/Model/Authentication/GetBankCardInfoResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 银行卡信息查询返回
|
||||
* Class GetBankCardInfoResponse
|
||||
*/
|
||||
class GetBankCardInfoResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return GetBankCardInfoResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new GetBankCardInfoResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
106
extend/Yzh/Model/Authentication/GetBankCardInfoResponseData.php
Normal file
106
extend/Yzh/Model/Authentication/GetBankCardInfoResponseData.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 银行卡信息查询返回
|
||||
* Class GetBankCardInfoResponseData
|
||||
*/
|
||||
class GetBankCardInfoResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 银行代码
|
||||
* @var string
|
||||
*/
|
||||
protected $bank_code;
|
||||
/**
|
||||
* 银行名称
|
||||
* @var string
|
||||
*/
|
||||
protected $bank_name;
|
||||
/**
|
||||
* 卡类型
|
||||
* @var string
|
||||
*/
|
||||
protected $card_type;
|
||||
/**
|
||||
* 云账户是否支持向该银行支付
|
||||
* @var bool
|
||||
*/
|
||||
protected $is_support;
|
||||
|
||||
/**
|
||||
* 银行代码
|
||||
* @var string $bank_code
|
||||
*/
|
||||
public function setBankCode($bank_code)
|
||||
{
|
||||
$this->bank_code = $bank_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行代码
|
||||
* @return string
|
||||
*/
|
||||
public function getBankCode()
|
||||
{
|
||||
return $this->bank_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行名称
|
||||
* @var string $bank_name
|
||||
*/
|
||||
public function setBankName($bank_name)
|
||||
{
|
||||
$this->bank_name = $bank_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行名称
|
||||
* @return string
|
||||
*/
|
||||
public function getBankName()
|
||||
{
|
||||
return $this->bank_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡类型
|
||||
* @var string $card_type
|
||||
*/
|
||||
public function setCardType($card_type)
|
||||
{
|
||||
$this->card_type = $card_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡类型
|
||||
* @return string
|
||||
*/
|
||||
public function getCardType()
|
||||
{
|
||||
return $this->card_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 云账户是否支持向该银行支付
|
||||
* @var bool $is_support
|
||||
*/
|
||||
public function setIsSupport($is_support)
|
||||
{
|
||||
$this->is_support = $is_support;
|
||||
}
|
||||
|
||||
/**
|
||||
* 云账户是否支持向该银行支付
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsSupport()
|
||||
{
|
||||
return $this->is_support;
|
||||
}
|
||||
}
|
||||
32
extend/Yzh/Model/Authentication/IDCardVerifyRequest.php
Normal file
32
extend/Yzh/Model/Authentication/IDCardVerifyRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 身份证实名验证请求
|
||||
* Class IDCardVerifyRequest
|
||||
*/
|
||||
class IDCardVerifyRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Authentication/IDCardVerifyResponse.php
Normal file
33
extend/Yzh/Model/Authentication/IDCardVerifyResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 身份证实名验证返回
|
||||
* Class IDCardVerifyResponse
|
||||
*/
|
||||
class IDCardVerifyResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return IDCardVerifyResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new IDCardVerifyResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
14
extend/Yzh/Model/Authentication/IDCardVerifyResponseData.php
Normal file
14
extend/Yzh/Model/Authentication/IDCardVerifyResponseData.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 身份证实名验证返回
|
||||
* Class IDCardVerifyResponseData
|
||||
*/
|
||||
class IDCardVerifyResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 非居民身份证验证名单审核结果回调通知
|
||||
* Class NotifyUserExemptedInfoRequest
|
||||
*/
|
||||
class NotifyUserExemptedInfoRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 证件号
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 审核状态
|
||||
* @var string
|
||||
*/
|
||||
public $status;
|
||||
/**
|
||||
* 流水号
|
||||
* @var string
|
||||
*/
|
||||
public $ref;
|
||||
/**
|
||||
* 审核信息
|
||||
* @var string
|
||||
*/
|
||||
public $comment;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
82
extend/Yzh/Model/Authentication/UserExemptedInfoRequest.php
Normal file
82
extend/Yzh/Model/Authentication/UserExemptedInfoRequest.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 上传非居民身份证验证名单信息请求
|
||||
* Class UserExemptedInfoRequest
|
||||
*/
|
||||
class UserExemptedInfoRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 证件类型码
|
||||
* @var string
|
||||
*/
|
||||
public $card_type;
|
||||
/**
|
||||
* 证件号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 申请备注
|
||||
* @var string
|
||||
*/
|
||||
public $comment_apply;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 人员信息图片
|
||||
* @var string[]
|
||||
*/
|
||||
public $user_images;
|
||||
/**
|
||||
* 国别(地区)代码
|
||||
* @var string
|
||||
*/
|
||||
public $country;
|
||||
/**
|
||||
* 出生日期
|
||||
* @var string
|
||||
*/
|
||||
public $birthday;
|
||||
/**
|
||||
* 性别
|
||||
* @var string
|
||||
*/
|
||||
public $gender;
|
||||
/**
|
||||
* 回调地址
|
||||
* @var string
|
||||
*/
|
||||
public $notify_url;
|
||||
/**
|
||||
* 请求流水号
|
||||
* @var string
|
||||
*/
|
||||
public $ref;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Authentication/UserExemptedInfoResponse.php
Normal file
33
extend/Yzh/Model/Authentication/UserExemptedInfoResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 上传非居民身份证验证名单信息返回
|
||||
* Class UserExemptedInfoResponse
|
||||
*/
|
||||
class UserExemptedInfoResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return UserExemptedInfoResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new UserExemptedInfoResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 上传非居民身份证验证名单信息返回
|
||||
* Class UserExemptedInfoResponseData
|
||||
*/
|
||||
class UserExemptedInfoResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 是否上传成功
|
||||
* @var string
|
||||
*/
|
||||
protected $ok;
|
||||
|
||||
/**
|
||||
* 是否上传成功
|
||||
* @var string $ok
|
||||
*/
|
||||
public function setOk($ok)
|
||||
{
|
||||
$this->ok = $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否上传成功
|
||||
* @return string
|
||||
*/
|
||||
public function getOk()
|
||||
{
|
||||
return $this->ok;
|
||||
}
|
||||
}
|
||||
32
extend/Yzh/Model/Authentication/UserWhiteCheckRequest.php
Normal file
32
extend/Yzh/Model/Authentication/UserWhiteCheckRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 查看用户是否在非居民身份证验证名单中请求
|
||||
* Class UserWhiteCheckRequest
|
||||
*/
|
||||
class UserWhiteCheckRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 证件号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Authentication/UserWhiteCheckResponse.php
Normal file
33
extend/Yzh/Model/Authentication/UserWhiteCheckResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 查看用户是否在非居民身份证验证名单中返回
|
||||
* Class UserWhiteCheckResponse
|
||||
*/
|
||||
class UserWhiteCheckResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return UserWhiteCheckResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new UserWhiteCheckResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Authentication;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 查看用户是否在非居民身份证验证名单中返回
|
||||
* Class UserWhiteCheckResponseData
|
||||
*/
|
||||
class UserWhiteCheckResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $ok;
|
||||
|
||||
/**
|
||||
* @var bool $ok
|
||||
*/
|
||||
public function setOk($ok)
|
||||
{
|
||||
$this->ok = $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getOk()
|
||||
{
|
||||
return $this->ok;
|
||||
}
|
||||
}
|
||||
30
extend/Yzh/Model/BaseModel.php
Normal file
30
extend/Yzh/Model/BaseModel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model;
|
||||
|
||||
abstract class BaseModel
|
||||
{
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$setMethodName = "set" . $this->camelCase($property);
|
||||
if (method_exists($this, $setMethodName)) {
|
||||
call_user_func(array($this, $setMethodName), $params[$property]);
|
||||
} else {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function camelCase($string, $dontStrip = [])
|
||||
{
|
||||
/*
|
||||
* This will take any dash or underscore turn it into a space, run ucwords against
|
||||
* it so it capitalizes the first letter in all words separated by a space then it
|
||||
* turns and deletes all spaces.
|
||||
*/
|
||||
return lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-z0-9' . implode('', $dontStrip) . ']+/', ' ', $string))));
|
||||
}
|
||||
}
|
||||
40
extend/Yzh/Model/BaseRequest.php
Normal file
40
extend/Yzh/Model/BaseRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model;
|
||||
|
||||
use Yzh\Utils\MessString;
|
||||
|
||||
abstract class BaseRequest
|
||||
{
|
||||
protected $_requestID;
|
||||
|
||||
public function getRequestID()
|
||||
{
|
||||
if (isset($this->_requestID) && !empty($this->_requestID)) {
|
||||
return $this->_requestID;
|
||||
}
|
||||
return MessString::rand(32);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义请求 ID
|
||||
* @param string $requestID 请求 ID
|
||||
*/
|
||||
public function setRequestID($requestID)
|
||||
{
|
||||
$this->_requestID = $requestID;
|
||||
}
|
||||
|
||||
public function getRequestData()
|
||||
{
|
||||
$requestData = array();
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if ($property == '_requestID') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$requestData[$property] = $this->{$property};
|
||||
}
|
||||
return $requestData;
|
||||
}
|
||||
}
|
||||
113
extend/Yzh/Model/BaseResponse.php
Normal file
113
extend/Yzh/Model/BaseResponse.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model;
|
||||
|
||||
use Yzh\Exception\RuntimeException;
|
||||
|
||||
abstract class BaseResponse
|
||||
{
|
||||
const CODE_SUCC = '0000';
|
||||
|
||||
/**
|
||||
* 业务状态码
|
||||
*/
|
||||
protected $code = "";
|
||||
/**
|
||||
* 业务状态描述信息
|
||||
*/
|
||||
protected $message = "";
|
||||
/**
|
||||
* 请求 ID
|
||||
*/
|
||||
protected $requestID = "";
|
||||
/**
|
||||
* 业务数据
|
||||
*/
|
||||
protected $data = [];
|
||||
/**
|
||||
* @var array
|
||||
* 原始数据
|
||||
*/
|
||||
protected $arr_data = [];
|
||||
|
||||
/**
|
||||
* 获取业务状态码
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置业务状态码
|
||||
* @return self
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return $this->code === self::CODE_SUCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务状态码描述信息
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置业务状态码描述信息
|
||||
* @return self
|
||||
*/
|
||||
public function setMessage($message)
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求 ID
|
||||
*/
|
||||
public function getRequestID()
|
||||
{
|
||||
return $this->requestID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求 ID
|
||||
* @return self
|
||||
*/
|
||||
public function setRequestID($requestID)
|
||||
{
|
||||
$this->requestID = $requestID;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return self
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
throw new RunTimeException("子类必须自行实现 setData 方法");
|
||||
}
|
||||
}
|
||||
52
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetAicStatusRequest.php
Normal file
52
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetAicStatusRequest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态请求
|
||||
* Class GxV2H5GetAicStatusRequest
|
||||
*/
|
||||
class GxV2H5GetAicStatusRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 用户唯一标识
|
||||
* @var string
|
||||
*/
|
||||
public $open_id;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 平台企业端的用户 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_user_id;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetAicStatusResponse.php
Normal file
33
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetAicStatusResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态返回
|
||||
* Class GxV2H5GetAicStatusResponse
|
||||
*/
|
||||
class GxV2H5GetAicStatusResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return GxV2H5GetAicStatusResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new GxV2H5GetAicStatusResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
221
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetAicStatusResponseData.php
Normal file
221
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetAicStatusResponseData.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态返回
|
||||
* Class GxV2H5GetAicStatusResponseData
|
||||
*/
|
||||
class GxV2H5GetAicStatusResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 用户注册状态
|
||||
* @var int32
|
||||
*/
|
||||
protected $status;
|
||||
/**
|
||||
* 注册状态描述
|
||||
* @var string
|
||||
*/
|
||||
protected $status_message;
|
||||
/**
|
||||
* 注册详情状态码
|
||||
* @var int32
|
||||
*/
|
||||
protected $status_detail;
|
||||
/**
|
||||
* 注册详情状态码描述
|
||||
* @var string
|
||||
*/
|
||||
protected $status_detail_message;
|
||||
/**
|
||||
* 注册发起时间
|
||||
* @var string
|
||||
*/
|
||||
protected $applyed_at;
|
||||
/**
|
||||
* 注册完成时间
|
||||
* @var string
|
||||
*/
|
||||
protected $registed_at;
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
* @var string
|
||||
*/
|
||||
protected $uscc;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
protected $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
protected $real_name;
|
||||
|
||||
/**
|
||||
* 用户注册状态
|
||||
* @var int32 $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册状态
|
||||
* @return int32
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册状态描述
|
||||
* @var string $status_message
|
||||
*/
|
||||
public function setStatusMessage($status_message)
|
||||
{
|
||||
$this->status_message = $status_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册状态描述
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusMessage()
|
||||
{
|
||||
return $this->status_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码
|
||||
* @var int32 $status_detail
|
||||
*/
|
||||
public function setStatusDetail($status_detail)
|
||||
{
|
||||
$this->status_detail = $status_detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码
|
||||
* @return int32
|
||||
*/
|
||||
public function getStatusDetail()
|
||||
{
|
||||
return $this->status_detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码描述
|
||||
* @var string $status_detail_message
|
||||
*/
|
||||
public function setStatusDetailMessage($status_detail_message)
|
||||
{
|
||||
$this->status_detail_message = $status_detail_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码描述
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusDetailMessage()
|
||||
{
|
||||
return $this->status_detail_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册发起时间
|
||||
* @var string $applyed_at
|
||||
*/
|
||||
public function setApplyedAt($applyed_at)
|
||||
{
|
||||
$this->applyed_at = $applyed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册发起时间
|
||||
* @return string
|
||||
*/
|
||||
public function getApplyedAt()
|
||||
{
|
||||
return $this->applyed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册完成时间
|
||||
* @var string $registed_at
|
||||
*/
|
||||
public function setRegistedAt($registed_at)
|
||||
{
|
||||
$this->registed_at = $registed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册完成时间
|
||||
* @return string
|
||||
*/
|
||||
public function getRegistedAt()
|
||||
{
|
||||
return $this->registed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
* @var string $uscc
|
||||
*/
|
||||
public function setUscc($uscc)
|
||||
{
|
||||
$this->uscc = $uscc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
* @return string
|
||||
*/
|
||||
public function getUscc()
|
||||
{
|
||||
return $this->uscc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string $id_card
|
||||
*/
|
||||
public function setIdCard($id_card)
|
||||
{
|
||||
$this->id_card = $id_card;
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
* @return string
|
||||
*/
|
||||
public function getIdCard()
|
||||
{
|
||||
return $this->id_card;
|
||||
}
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
* @var string $real_name
|
||||
*/
|
||||
public function setRealName($real_name)
|
||||
{
|
||||
$this->real_name = $real_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
* @return string
|
||||
*/
|
||||
public function getRealName()
|
||||
{
|
||||
return $this->real_name;
|
||||
}
|
||||
}
|
||||
62
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetStartUrlRequest.php
Normal file
62
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetStartUrlRequest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 预启动请求
|
||||
* Class GxV2H5GetStartUrlRequest
|
||||
*/
|
||||
class GxV2H5GetStartUrlRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 平台企业端的用户 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_user_id;
|
||||
/**
|
||||
* 客户端类型
|
||||
* @var int32
|
||||
*/
|
||||
public $client_type;
|
||||
/**
|
||||
* 异步通知 URL
|
||||
* @var string
|
||||
*/
|
||||
public $notify_url;
|
||||
/**
|
||||
* H5 页面主题颜色
|
||||
* @var string
|
||||
*/
|
||||
public $color;
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @var string
|
||||
*/
|
||||
public $return_url;
|
||||
/**
|
||||
* H5 页面 Title
|
||||
* @var int32
|
||||
*/
|
||||
public $customer_title;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetStartUrlResponse.php
Normal file
33
extend/Yzh/Model/Bizlicgxv2h5/GxV2H5GetStartUrlResponse.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 预启动返回
|
||||
* Class GxV2H5GetStartUrlResponse
|
||||
*/
|
||||
class GxV2H5GetStartUrlResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return GxV2H5GetStartUrlResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new GxV2H5GetStartUrlResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 预启动返回
|
||||
* Class GxV2H5GetStartUrlResponseData
|
||||
*/
|
||||
class GxV2H5GetStartUrlResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @var string
|
||||
*/
|
||||
protected $h5_url;
|
||||
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @var string $h5_url
|
||||
*/
|
||||
public function setH5Url($h5_url)
|
||||
{
|
||||
$this->h5_url = $h5_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @return string
|
||||
*/
|
||||
public function getH5Url()
|
||||
{
|
||||
return $this->h5_url;
|
||||
}
|
||||
}
|
||||
92
extend/Yzh/Model/Bizlicgxv2h5/NotifyGxV2H5AicRequest.php
Normal file
92
extend/Yzh/Model/Bizlicgxv2h5/NotifyGxV2H5AicRequest.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 个体工商户注册/注销结果回调通知
|
||||
* Class NotifyGxV2H5AicRequest
|
||||
*/
|
||||
class NotifyGxV2H5AicRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 用户唯一标识
|
||||
* @var string
|
||||
*/
|
||||
public $open_id;
|
||||
/**
|
||||
* 平台企业端的用户 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_user_id;
|
||||
/**
|
||||
* 注册/注销提交时间
|
||||
* @var string
|
||||
*/
|
||||
public $submit_at;
|
||||
/**
|
||||
* 注册/注销完成时间
|
||||
* @var string
|
||||
*/
|
||||
public $registed_at;
|
||||
/**
|
||||
* 用户注册/注销状态
|
||||
* @var int32
|
||||
*/
|
||||
public $status;
|
||||
/**
|
||||
* 注册/注销状态描述
|
||||
* @var string
|
||||
*/
|
||||
public $status_message;
|
||||
/**
|
||||
* 注册/注销详情状态码
|
||||
* @var int32
|
||||
*/
|
||||
public $status_detail;
|
||||
/**
|
||||
* 注册/注销详情状态码描述
|
||||
* @var string
|
||||
*/
|
||||
public $status_detail_message;
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
* @var string
|
||||
*/
|
||||
public $uscc;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 回调类型
|
||||
* @var int32
|
||||
*/
|
||||
public $type;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态请求
|
||||
* Class GxV2H5APIGetAicStatusRequest
|
||||
*/
|
||||
class GxV2H5APIGetAicStatusRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 用户唯一标识
|
||||
* @var string
|
||||
*/
|
||||
public $open_id;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 平台企业端的用户 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_user_id;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态返回
|
||||
* Class GxV2H5APIGetAicStatusResponse
|
||||
*/
|
||||
class GxV2H5APIGetAicStatusResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return GxV2H5APIGetAicStatusResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new GxV2H5APIGetAicStatusResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 查询个体工商户状态返回
|
||||
* Class GxV2H5APIGetAicStatusResponseData
|
||||
*/
|
||||
class GxV2H5APIGetAicStatusResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 用户注册状态
|
||||
* @var int32
|
||||
*/
|
||||
protected $status;
|
||||
/**
|
||||
* 注册状态描述
|
||||
* @var string
|
||||
*/
|
||||
protected $status_message;
|
||||
/**
|
||||
* 注册详情状态码
|
||||
* @var int32
|
||||
*/
|
||||
protected $status_detail;
|
||||
/**
|
||||
* 注册详情状态码描述
|
||||
* @var string
|
||||
*/
|
||||
protected $status_detail_message;
|
||||
/**
|
||||
* 注册发起时间
|
||||
* @var string
|
||||
*/
|
||||
protected $applyed_at;
|
||||
/**
|
||||
* 注册完成时间
|
||||
* @var string
|
||||
*/
|
||||
protected $registed_at;
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
* @var string
|
||||
*/
|
||||
protected $uscc;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
protected $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
protected $real_name;
|
||||
|
||||
/**
|
||||
* 用户注册状态
|
||||
* @var int32 $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册状态
|
||||
* @return int32
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册状态描述
|
||||
* @var string $status_message
|
||||
*/
|
||||
public function setStatusMessage($status_message)
|
||||
{
|
||||
$this->status_message = $status_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册状态描述
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusMessage()
|
||||
{
|
||||
return $this->status_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码
|
||||
* @var int32 $status_detail
|
||||
*/
|
||||
public function setStatusDetail($status_detail)
|
||||
{
|
||||
$this->status_detail = $status_detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码
|
||||
* @return int32
|
||||
*/
|
||||
public function getStatusDetail()
|
||||
{
|
||||
return $this->status_detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码描述
|
||||
* @var string $status_detail_message
|
||||
*/
|
||||
public function setStatusDetailMessage($status_detail_message)
|
||||
{
|
||||
$this->status_detail_message = $status_detail_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册详情状态码描述
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusDetailMessage()
|
||||
{
|
||||
return $this->status_detail_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册发起时间
|
||||
* @var string $applyed_at
|
||||
*/
|
||||
public function setApplyedAt($applyed_at)
|
||||
{
|
||||
$this->applyed_at = $applyed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册发起时间
|
||||
* @return string
|
||||
*/
|
||||
public function getApplyedAt()
|
||||
{
|
||||
return $this->applyed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册完成时间
|
||||
* @var string $registed_at
|
||||
*/
|
||||
public function setRegistedAt($registed_at)
|
||||
{
|
||||
$this->registed_at = $registed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册完成时间
|
||||
* @return string
|
||||
*/
|
||||
public function getRegistedAt()
|
||||
{
|
||||
return $this->registed_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
* @var string $uscc
|
||||
*/
|
||||
public function setUscc($uscc)
|
||||
{
|
||||
$this->uscc = $uscc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
* @return string
|
||||
*/
|
||||
public function getUscc()
|
||||
{
|
||||
return $this->uscc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string $id_card
|
||||
*/
|
||||
public function setIdCard($id_card)
|
||||
{
|
||||
$this->id_card = $id_card;
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
* @return string
|
||||
*/
|
||||
public function getIdCard()
|
||||
{
|
||||
return $this->id_card;
|
||||
}
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
* @var string $real_name
|
||||
*/
|
||||
public function setRealName($real_name)
|
||||
{
|
||||
$this->real_name = $real_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
* @return string
|
||||
*/
|
||||
public function getRealName()
|
||||
{
|
||||
return $this->real_name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 预启动请求
|
||||
* Class GxV2H5APIGetStartUrlRequest
|
||||
*/
|
||||
class GxV2H5APIGetStartUrlRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 平台企业端的用户 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_user_id;
|
||||
/**
|
||||
* 客户端类型
|
||||
* @var int32
|
||||
*/
|
||||
public $client_type;
|
||||
/**
|
||||
* 异步通知 URL
|
||||
* @var string
|
||||
*/
|
||||
public $notify_url;
|
||||
/**
|
||||
* H5 页面主题颜色
|
||||
* @var string
|
||||
*/
|
||||
public $color;
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @var string
|
||||
*/
|
||||
public $return_url;
|
||||
/**
|
||||
* H5 页面 Title
|
||||
* @var int32
|
||||
*/
|
||||
public $customer_title;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 预启动返回
|
||||
* Class GxV2H5APIGetStartUrlResponse
|
||||
*/
|
||||
class GxV2H5APIGetStartUrlResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return GxV2H5APIGetStartUrlResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new GxV2H5APIGetStartUrlResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseModel;
|
||||
use Yzh\Model\ResponseDataInterface;
|
||||
|
||||
/**
|
||||
* 预启动返回
|
||||
* Class GxV2H5APIGetStartUrlResponseData
|
||||
*/
|
||||
class GxV2H5APIGetStartUrlResponseData extends BaseModel implements ResponseDataInterface
|
||||
{
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @var string
|
||||
*/
|
||||
protected $h5_url;
|
||||
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @var string $h5_url
|
||||
*/
|
||||
public function setH5Url($h5_url)
|
||||
{
|
||||
$this->h5_url = $h5_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转 URL
|
||||
* @return string
|
||||
*/
|
||||
public function getH5Url()
|
||||
{
|
||||
return $this->h5_url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseRequest;
|
||||
|
||||
/**
|
||||
* 工商实名信息录入请求
|
||||
* Class GxV2H5APIPreCollectBizlicMsgRequest
|
||||
*/
|
||||
class GxV2H5APIPreCollectBizlicMsgRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
* 平台企业 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_id;
|
||||
/**
|
||||
* 综合服务主体 ID
|
||||
* @var string
|
||||
*/
|
||||
public $broker_id;
|
||||
/**
|
||||
* 平台企业端的用户 ID
|
||||
* @var string
|
||||
*/
|
||||
public $dealer_user_id;
|
||||
/**
|
||||
* 手机号
|
||||
* @var string
|
||||
*/
|
||||
public $phone_no;
|
||||
/**
|
||||
* 身份证号码
|
||||
* @var string
|
||||
*/
|
||||
public $id_card;
|
||||
/**
|
||||
* 姓名
|
||||
* @var string
|
||||
*/
|
||||
public $real_name;
|
||||
/**
|
||||
* 身份证住址
|
||||
* @var string
|
||||
*/
|
||||
public $id_card_address;
|
||||
/**
|
||||
* 身份证签发机关
|
||||
* @var string
|
||||
*/
|
||||
public $id_card_agency;
|
||||
/**
|
||||
* 身份证民族
|
||||
* @var string
|
||||
*/
|
||||
public $id_card_nation;
|
||||
/**
|
||||
* 身份证有效期开始时间
|
||||
* @var string
|
||||
*/
|
||||
public $id_card_validity_start;
|
||||
/**
|
||||
* 身份证有效期结束时间
|
||||
* @var string
|
||||
*/
|
||||
public $id_card_validity_end;
|
||||
|
||||
public function __construct($params = array())
|
||||
{
|
||||
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||
if (isset($params[$property])) {
|
||||
$this->{$property} = $params[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yzh\Model\Bizlicgxv2h5api;
|
||||
|
||||
use Yzh\Model\BaseResponse;
|
||||
use Yzh\Model\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 工商实名信息录入返回
|
||||
* Class GxV2H5APIPreCollectBizlicMsgResponse
|
||||
*/
|
||||
class GxV2H5APIPreCollectBizlicMsgResponse extends BaseResponse implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* 获取数据对象
|
||||
* @return GxV2H5APIPreCollectBizlicMsgResponseData
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据对象
|
||||
* @param array $data
|
||||
* @return self
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = new GxV2H5APIPreCollectBizlicMsgResponseData($data);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user