Skip to content

Commit

Permalink
refactor:完善类型声明
Browse files Browse the repository at this point in the history
  • Loading branch information
你过得可好 committed Oct 11, 2024
1 parent b5580b4 commit 6676ec2
Show file tree
Hide file tree
Showing 15 changed files with 932 additions and 826 deletions.
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.1"
},
"php": ">=7.1",
"ext-json": "*",
"ext-openssl": "*",
"ext-curl": "*",
"ext-mbstring": "*",
"ext-bcmath": "*"
},
"authors": [
{
"name": "caihong",
Expand Down
117 changes: 63 additions & 54 deletions src/AlipayBillService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Alipay;

use Exception;

/**
* 支付宝账单服务类
* @see https://opendocs.alipay.com/open/01inem
Expand All @@ -13,15 +15,16 @@ public function __construct($config)
parent::__construct($config);
}

/**
* 账户卖出交易查询
* @param $start_time 创建时间的起始
* @param $end_time 创建时间的结束
* @param $page_no 分页号,从1开始
* @param $page_size 分页大小1000-2000,默认2000
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
*/
public function sellQuery($start_time, $end_time, $page_no = 1, $page_size = 2000)
/**
* 账户卖出交易查询
* @param string $start_time 创建时间的起始
* @param string $end_time 创建时间的结束
* @param int $page_no 分页号,从1开始
* @param int $page_size 分页大小1000-2000,默认2000
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
* @throws Exception
*/
public function sellQuery(string $start_time, string $end_time, int $page_no = 1, int $page_size = 2000)
{
$apiName = 'alipay.data.bill.sell.query';
$bizContent = [
Expand All @@ -33,15 +36,16 @@ public function sellQuery($start_time, $end_time, $page_no = 1, $page_size = 200
return $this->aopExecute($apiName, $bizContent);
}

/**
* 账户买入交易查询
* @param $start_time 创建时间的起始
* @param $end_time 创建时间的结束
* @param $page_no 分页号,从1开始
* @param $page_size 分页大小1000-2000,默认2000
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
*/
public function buyQuery($start_time, $end_time, $page_no = 1, $page_size = 2000)
/**
* 账户买入交易查询
* @param string $start_time 创建时间的起始
* @param string $end_time 创建时间的结束
* @param int $page_no 分页号,从1开始
* @param int $page_size 分页大小1000-2000,默认2000
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
* @throws Exception
*/
public function buyQuery(string $start_time, string $end_time, int $page_no = 1, int $page_size = 2000)
{
$apiName = 'alipay.data.bill.buy.query';
$bizContent = [
Expand All @@ -53,16 +57,17 @@ public function buyQuery($start_time, $end_time, $page_no = 1, $page_size = 2000
return $this->aopExecute($apiName, $bizContent);
}

/**
* 账户账务明细查询
* @param $start_time 创建时间的起始
* @param $end_time 创建时间的结束
* @param $page_no 分页号,从1开始
* @param $page_size 分页大小1000-2000,默认2000
* @param $bill_user_id 指定用户做账单查询
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
*/
public function accountlogQuery($start_time, $end_time, $page_no = 1, $page_size = 2000, $bill_user_id = null)
/**
* 账户账务明细查询
* @param string $start_time 创建时间的起始
* @param string $end_time 创建时间的结束
* @param int $page_no 分页号,从1开始
* @param int $page_size 分页大小1000-2000,默认2000
* @param null $bill_user_id 指定用户做账单查询
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
* @throws Exception
*/
public function accountlogQuery(string $start_time, string $end_time, int $page_no = 1, int $page_size = 2000, $bill_user_id = null)
{
$apiName = 'alipay.data.bill.buy.query';
$bizContent = [
Expand All @@ -75,15 +80,16 @@ public function accountlogQuery($start_time, $end_time, $page_no = 1, $page_size
return $this->aopExecute($apiName, $bizContent);
}

/**
* 账户充值,转账,提现查询
* @param $start_time 创建时间的起始
* @param $end_time 创建时间的结束
* @param $page_no 分页号,从1开始
* @param $page_size 分页大小1000-2000,默认2000
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
*/
public function transferQuery($start_time, $end_time, $page_no = 1, $page_size = 2000)
/**
* 账户充值,转账,提现查询
* @param string $start_time 创建时间的起始
* @param string $end_time 创建时间的结束
* @param int $page_no 分页号,从1开始
* @param int $page_size 分页大小1000-2000,默认2000
* @return mixed {"page_no":"1","page_size":"2000","total_size":"10000","detail_list":[]}
* @throws Exception
*/
public function transferQuery(string $start_time, string $end_time, int $page_no = 1, int $page_size = 2000)
{
$apiName = 'alipay.data.bill.transfer.query';
$bizContent = [
Expand All @@ -95,23 +101,25 @@ public function transferQuery($start_time, $end_time, $page_no = 1, $page_size =
return $this->aopExecute($apiName, $bizContent);
}

/**
* 账户当前余额查询
* @return mixed {"total_amount":"支付宝账户余额","available_amount":"账户可用余额","freeze_amount":"冻结金额","settle_amount":"待结算金额"}
*/
/**
* 账户当前余额查询
* @return mixed {"total_amount":"支付宝账户余额","available_amount":"账户可用余额","freeze_amount":"冻结金额","settle_amount":"待结算金额"}
* @throws Exception
*/
public function balanceQuery()
{
$apiName = 'alipay.data.bill.balance.query';
return $this->aopExecute($apiName);
}

/**
* 申请电子回单
* @param $type 申请的类型
* @param $key 根据不同业务类型,传入不同参数
* @return mixed {"file_id":"文件申请号"}
*/
public function ereceiptApply($type, $key)
/**
* 申请电子回单
* @param string $type 申请的类型
* @param string $key 根据不同业务类型,传入不同参数
* @return mixed {"file_id":"文件申请号"}
* @throws Exception
*/
public function ereceiptApply(string $type, string $key)
{
$apiName = 'alipay.data.bill.ereceipt.apply';
$bizContent = [
Expand All @@ -121,12 +129,13 @@ public function ereceiptApply($type, $key)
return $this->aopExecute($apiName, $bizContent);
}

/**
* 查询电子回单状态
* @param $file_id 文件申请号
* @return mixed {"status":"处理状态","download_url":"下载链接","error_message":"失败原因"}
*/
public function ereceiptQuery($file_id)
/**
* 查询电子回单状态
* @param string $file_id 文件申请号
* @return mixed {"status":"处理状态","download_url":"下载链接","error_message":"失败原因"}
* @throws Exception
*/
public function ereceiptQuery(string $file_id)
{
$apiName = 'alipay.data.bill.ereceipt.query';
$bizContent = [
Expand Down
59 changes: 32 additions & 27 deletions src/AlipayCertdocService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@

namespace Alipay;

use Exception;

/**
* 支付宝实名证件信息比对验证服务类
* @see https://opendocs.alipay.com/open/01bny6
*/
class AlipayCertdocService extends AlipayService
{
/**
* @param $config 支付宝配置信息
* @param array $config 支付宝配置信息
*/
public function __construct($config)
public function __construct(array $config)
{
parent::__construct($config);
}

/**
* 实名证件信息比对验证预咨询
* @param $cert_name 真实姓名
* @param $cert_no 证件号码
* @return mixed {"code":"10000","msg":"Success","verify_id":"申请验证ID"}
*/
public function preconsult($cert_name, $cert_no)
/**
* 实名证件信息比对验证预咨询
* @param string $cert_name 真实姓名
* @param string $cert_no 证件号码
* @return mixed {"code":"10000","msg":"Success","verify_id":"申请验证ID"}
* @throws Exception
*/
public function preconsult(string $cert_name, string $cert_no)
{
$apiName = 'alipay.user.certdoc.certverify.preconsult';
$bizContent = array(
Expand All @@ -33,13 +36,14 @@ public function preconsult($cert_name, $cert_no)
return $this->aopExecute($apiName, $bizContent);
}

/**
* 实名证件信息比对验证咨询
* @param $verify_id 申请验证ID
* @param $auth_token 用户授权令牌
* @return mixed {"code":"10000","msg":"Success","passed":"F","fail_reason":"姓名不一致","fail_params":"[\\\"user_name\\\"]"}
*/
public function consult($verify_id, $auth_token)
/**
* 实名证件信息比对验证咨询
* @param string $verify_id 申请验证ID
* @param string $auth_token 用户授权令牌
* @return mixed {"code":"10000","msg":"Success","passed":"F","fail_reason":"姓名不一致","fail_params":"[\\\"user_name\\\"]"}
* @throws Exception
*/
public function consult(string $verify_id, string $auth_token)
{
$apiName = 'alipay.user.certdoc.certverify.consult';
$bizContent = array(
Expand All @@ -53,13 +57,13 @@ public function consult($verify_id, $auth_token)

/**
* 跳转支付宝授权页面
* @param $redirect_uri 回调地址
* @param $verify_id 申请验证ID
* @param string $redirect_uri 回调地址
* @param string $verify_id 申请验证ID
* @param $state
* @param $is_get_url 是否只返回url
* @param bool $is_get_url 是否只返回url
* @return void|string
*/
public function oauth($redirect_uri, $verify_id, $state = null, $is_get_url = false)
public function oauth(string $redirect_uri, string $verify_id, $state = null, bool $is_get_url = false)
{
$param = [
'app_id' => $this->appId,
Expand All @@ -79,13 +83,14 @@ public function oauth($redirect_uri, $verify_id, $state = null, $is_get_url = fa
exit();
}

/**
* 换取授权访问令牌
* @param $code 授权码或刷新令牌
* @param $grant_type 授权方式(authorization_code,refresh_token)
* @return mixed {"user_id":"支付宝用户的唯一标识","open_id":"支付宝用户的唯一标识","access_token":"访问令牌","expires_in":"3600","refresh_token":"刷新令牌","re_expires_in":"3600"}
*/
public function getToken($code, $grant_type = 'authorization_code')
/**
* 换取授权访问令牌
* @param string $code 授权码或刷新令牌
* @param string $grant_type 授权方式(authorization_code,refresh_token)
* @return mixed {"user_id":"支付宝用户的唯一标识","open_id":"支付宝用户的唯一标识","access_token":"访问令牌","expires_in":"3600","refresh_token":"刷新令牌","re_expires_in":"3600"}
* @throws Exception
*/
public function getToken(string $code, string $grant_type = 'authorization_code')
{
$apiName = 'alipay.system.oauth.token';
$params = [];
Expand Down
57 changes: 31 additions & 26 deletions src/AlipayCertifyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Alipay;

use Exception;

/**
* 支付宝身份认证服务类
* @see https://opendocs.alipay.com/open/repo-013ubq
Expand All @@ -12,26 +14,27 @@ class AlipayCertifyService extends AlipayService
private $return_url;

/**
* @param $config 支付宝配置信息
* @param array $config 支付宝配置信息
*/
public function __construct($config)
public function __construct(array $config)
{
parent::__construct($config);
$this->return_url = $config['return_url'];
}

/**
* 身份认证初始化服务
* @param $outer_order_no 商户请求的唯一标识
* @param $cert_name 真实姓名
* @param $cert_no 证件号码
* @param $cert_type 证件类型
* @param $biz_code 认证场景码(FACE、SMART_FACE)
* @return mixed {"code":"10000","msg":"Success","certify_id":"本次申请操作的唯一标识"}
*
* @see https://opendocs.alipay.com/open/02ahjy
*/
public function initialize($outer_order_no, $cert_name, $cert_no, $cert_type = 'IDENTITY_CARD', $biz_code = 'SMART_FACE')
/**
* 身份认证初始化服务
* @param string $outer_order_no 商户请求的唯一标识
* @param string $cert_name 真实姓名
* @param string $cert_no 证件号码
* @param string $cert_type 证件类型
* @param string $biz_code 认证场景码(FACE、SMART_FACE)
* @return mixed {"code":"10000","msg":"Success","certify_id":"本次申请操作的唯一标识"}
*
* @throws Exception
* @see https://opendocs.alipay.com/open/02ahjy
*/
public function initialize(string $outer_order_no, string $cert_name, string $cert_no, string $cert_type = 'IDENTITY_CARD', string $biz_code = 'SMART_FACE')
{
$apiName = 'alipay.user.certify.open.initialize';
$bizContent = [
Expand All @@ -48,12 +51,13 @@ public function initialize($outer_order_no, $cert_name, $cert_no, $cert_type = '
return $this->aopExecute($apiName, $bizContent);
}

/**
* 身份认证开始认证
* @param $certify_id 本次申请操作的唯一标识
* @return string html表单
*/
public function certify($certify_id)
/**
* 身份认证开始认证
* @param string $certify_id 本次申请操作的唯一标识
* @return string html表单
* @throws Exception
*/
public function certify(string $certify_id): string
{
$apiName = 'alipay.user.certify.open.certify';
$bizContent = array(
Expand All @@ -62,12 +66,13 @@ public function certify($certify_id)
return $this->aopPageExecute($apiName, $bizContent);
}

/**
* 身份认证记录查询
* @param $certify_id 本次申请操作的唯一标识
* @return mixed {"code":"10000","msg":"Success","passed":"T"}
*/
public function query($certify_id)
/**
* 身份认证记录查询
* @param string $certify_id 本次申请操作的唯一标识
* @return mixed {"code":"10000","msg":"Success","passed":"T"}
* @throws Exception
*/
public function query(string $certify_id)
{
$apiName = 'alipay.user.certify.open.query';
$bizContent = array(
Expand Down
Loading

0 comments on commit 6676ec2

Please sign in to comment.