You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
214 lines
6.1 KiB
214 lines
6.1 KiB
<?php
|
|
|
|
namespace Tansilu\HfPayLib\factory\impl;
|
|
|
|
use Tansilu\HfPayLib\exception\ParamsException;
|
|
use Tansilu\HfPayLib\factory\BaseFactory;
|
|
use Tansilu\HfPayLib\factory\object\query\BalanceInfo;
|
|
use Tansilu\HfPayLib\factory\object\query\BindCardStatus;
|
|
use Tansilu\HfPayLib\factory\object\query\ChainBalance;
|
|
use Tansilu\HfPayLib\factory\object\query\OpenStatus;
|
|
use Tansilu\HfPayLib\factory\object\query\RecordLog;
|
|
use Tansilu\HfPayLib\factory\object\query\TransStatus;
|
|
use Tansilu\HfPayLib\factory\object\query\WalletStatus;
|
|
|
|
class QueryFactory extends BaseFactory
|
|
{
|
|
/**
|
|
* 开户状态查询
|
|
*
|
|
* @param string $orderId
|
|
* @param string $orderDate
|
|
* @param string $transType
|
|
*
|
|
* @return ?OpenStatus
|
|
*
|
|
* @ses https://hfpay.cloudpnr.com/customers/nft/#/query/openAccountQuery
|
|
*/
|
|
function openStatus(string $orderId, string $orderDate, string $transType): ?OpenStatus
|
|
{
|
|
$result = $this->post('/api/alse/qry009', [
|
|
'order_id' => $orderId,
|
|
'order_date' => $orderDate,
|
|
'trans_type' => $transType
|
|
]);
|
|
if(!$result->isSuccess()) {
|
|
return null;
|
|
}
|
|
return OpenStatus::make($result->getBody());
|
|
}
|
|
|
|
/**
|
|
* 钱包状态
|
|
*
|
|
* @param string $customId 用户客户号
|
|
*
|
|
* @return WalletStatus|null
|
|
*
|
|
* @see https://hfpay.cloudpnr.com/customers/nft/#/query/walletStateQuery
|
|
*/
|
|
function wallet(string $customId): ?WalletStatus
|
|
{
|
|
$result = $this->post('/api/alse/qry016', [
|
|
'user_cust_id' => $customId
|
|
]);
|
|
if(!$result->isSuccess()) {
|
|
return null;
|
|
}
|
|
return WalletStatus::make($result->getBody());
|
|
}
|
|
|
|
/**
|
|
* 查询交易状态
|
|
*
|
|
* @param string $orderID
|
|
* @param string $orderDate
|
|
* @param string $transType
|
|
* @param string $attach
|
|
* @param string $extension
|
|
*
|
|
* @return TransStatus|null
|
|
*
|
|
* @see https://hfpay.cloudpnr.com/customers/nft/#/query/transactionStateQuery
|
|
*/
|
|
function trans(string $orderID, string $orderDate, string $transType, string $attach = '', string $extension = ''): ?TransStatus
|
|
{
|
|
$params = [
|
|
'order_id' => $orderID,
|
|
'order_date' => $orderDate,
|
|
'trans_type' => $transType
|
|
];
|
|
if(!empty($attach)) {
|
|
$params['mer_priv'] = $attach;
|
|
}
|
|
if(!empty($extension)) {
|
|
$params['extension'] = $extension;
|
|
}
|
|
$result = $this->post('/api/alse/qry008', $params);
|
|
if(!$result->isSuccess()) {
|
|
return null;
|
|
}
|
|
return TransStatus::make($result->getBody());
|
|
}
|
|
|
|
/**
|
|
* 查询用户绑卡信息
|
|
*
|
|
* @param string $userId
|
|
* @param string $cardId
|
|
*
|
|
* @return BindCardStatus|null
|
|
*
|
|
* @see https://hfpay.cloudpnr.com/customers/nft/#/query/bindCardInfoQuery
|
|
*/
|
|
function bindCard(string $userId, string $cardId = ''): ?BindCardStatus
|
|
{
|
|
$params = [
|
|
'user_cust_id' => $userId
|
|
];
|
|
if(!empty($cardId)) {
|
|
$params['bind_card_id'] = $cardId;
|
|
}
|
|
$result = $this->post('/api/alse/qry004', $params);
|
|
|
|
if(!$result->isSuccess()) {
|
|
return null;
|
|
}
|
|
return BindCardStatus::make($result->getBody());
|
|
}
|
|
|
|
/**
|
|
* 余额查询
|
|
*
|
|
* @param string $customId
|
|
* @param string $accountId
|
|
* @param string $isGuarantee
|
|
*
|
|
* @return BalanceInfo|null
|
|
* @throws ParamsException
|
|
*
|
|
* @see https://hfpay.cloudpnr.com/customers/nft/#/query/balanceQuery
|
|
*/
|
|
function balance(string $customId, string $accountId = '', string $isGuarantee = ''): ?BalanceInfo
|
|
{
|
|
$params = [
|
|
'user_cust_id' => $customId
|
|
];
|
|
if($isGuarantee != '1') {
|
|
if(empty($accountId)) {
|
|
throw new ParamsException('账户号不能为空', 'PARAMS_ACCOUNT_ID_IS_EMPTY');
|
|
}
|
|
$params['acct_id'] = $accountId;
|
|
}
|
|
if(!empty($isGuarantee)) {
|
|
$params['is_query_guarantee'] = $isGuarantee;
|
|
}
|
|
$result = $this->post('/api/alse/qry001', $params);
|
|
if(!$result->isSuccess()) {
|
|
return null;
|
|
}
|
|
return BalanceInfo::make($result->getBody());
|
|
}
|
|
|
|
/**
|
|
* 流水记录查询
|
|
*
|
|
* @param string $customId
|
|
* @param string $accountId
|
|
* @param string $startDate
|
|
* @param string $endDate
|
|
* @param int $pageSize
|
|
* @param int $pageNum
|
|
* @param string $productId
|
|
* @param string $productSeqId
|
|
*
|
|
* @return RecordLog|null
|
|
*
|
|
* @see https://hfpay.cloudpnr.com/customers/nft/#/query/accountRecordQuery
|
|
*/
|
|
function record(string $customId, string $accountId, string $startDate, string $endDate, int $pageSize, int $pageNum, string $productId = '', string $productSeqId = ''): ?RecordLog
|
|
{
|
|
$params = [
|
|
'user_cust_id' => $customId,
|
|
'acct_id' => $accountId,
|
|
'trans_start_date' => $startDate,
|
|
'trans_end_date' => $endDate,
|
|
'page_size' => $pageSize,
|
|
'page_num' => $pageNum,
|
|
];
|
|
if(!empty($productId)) {
|
|
$params['product_id'] = $productId;
|
|
}
|
|
if(!empty($productSeqId)) {
|
|
$params['product_req_seq_id'] = $productSeqId;
|
|
}
|
|
|
|
$result = $this->post('/api/alse/qry005', $params);
|
|
if(!$result->isSuccess()) {
|
|
return null;
|
|
}
|
|
return RecordLog::make($result->getBody());
|
|
}
|
|
|
|
/**
|
|
* 链上余额查询
|
|
*
|
|
* @param string $customId
|
|
*
|
|
* @return ChainBalance|null
|
|
*
|
|
* @see https://hfpay.cloudpnr.com/customers/nft/#/query/chainBalanceQuery
|
|
*/
|
|
function chainBalance(string $customId): ?ChainBalance
|
|
{
|
|
$params = [
|
|
'user_cust_id' => $customId,
|
|
];
|
|
|
|
$result = $this->post('/api/alse/qry022', $params);
|
|
if(!$result->isSuccess()) {
|
|
return null;
|
|
}
|
|
return ChainBalance::make($result->getBody());
|
|
}
|
|
} |