From 56e949aca741359512d695ec586f4dd8fbbf23ad Mon Sep 17 00:00:00 2001 From: liaoyin <609306725@qq.com> Date: Mon, 24 Aug 2026 10:24:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/factory/impl/QueryFactory.php | 22 ++++ src/factory/impl/TradeFactory.php | 37 ++++-- src/factory/object/trade/DeviceInfo.php | 2 +- src/factory/object/trade/DivDetail.php | 2 +- src/factory/object/trade/ObjectInfo.php | 2 +- .../object/trade/WithdrawCashRequest.php | 118 ++++++++++++++++++ .../object/trade/WithdrawCashResponse.php | 33 +++++ 7 files changed, 206 insertions(+), 10 deletions(-) create mode 100644 src/factory/object/trade/WithdrawCashRequest.php create mode 100644 src/factory/object/trade/WithdrawCashResponse.php diff --git a/src/factory/impl/QueryFactory.php b/src/factory/impl/QueryFactory.php index 8256331..17bf779 100644 --- a/src/factory/impl/QueryFactory.php +++ b/src/factory/impl/QueryFactory.php @@ -211,4 +211,26 @@ class QueryFactory extends BaseFactory } return ChainBalance::make($result->getBody()); } + + + function openAccount(string $orderDate, string $orderId, string $transType) + { + +// 20260422 +// W260422150301297 +// 8 +// + $params = [ + 'order_date' => $orderDate, + 'order_id' => $orderId, + 'trans_type' => $transType + ]; + + $result = $this->post('/api/alse/qry009', $params); + + if(!$result->isSuccess()) { + return null; + } + return BindCardStatus::make($result->getBody()); + } } \ No newline at end of file diff --git a/src/factory/impl/TradeFactory.php b/src/factory/impl/TradeFactory.php index 39c1455..7d9a6c4 100644 --- a/src/factory/impl/TradeFactory.php +++ b/src/factory/impl/TradeFactory.php @@ -12,6 +12,8 @@ use Tansilu\HfPayLib\factory\object\trade\RefundInfo; use Tansilu\HfPayLib\factory\object\trade\RefundRequest; use Tansilu\HfPayLib\factory\object\trade\UnifiedOrder; use Tansilu\HfPayLib\factory\object\trade\UnifiedOrderRequest; +use Tansilu\HfPayLib\factory\object\trade\WithdrawCashRequest; +use Tansilu\HfPayLib\factory\object\trade\WithdrawCashResponse; use Tansilu\HfPayLib\http\Factory; /** @@ -35,7 +37,7 @@ class TradeFactory extends Factory $params = $request->toParams(); $result = $this->post('/api/hfpwallet/pay033', $params); - if(!$result->isSuccess()) { + if (!$result->isSuccess()) { return null; } return UnifiedOrder::make($result->getBody()); @@ -55,7 +57,7 @@ class TradeFactory extends Factory { $params = $request->toParams(); $result = $this->post('/api/hfpwallet/pay033', $params); - if(!$result->isSuccess()) { + if (!$result->isSuccess()) { return null; } return DelayDivide::make($result->getBody()); @@ -75,15 +77,15 @@ class TradeFactory extends Factory function closeOrder(string $orderId, string $orderDate, string $merPriv = ''): ?CloseOrder { $params = [ - 'order_id' => $orderId, + 'order_id' => $orderId, 'order_date' => $orderDate, ]; - if(!empty($merPriv)) { + if (!empty($merPriv)) { $params['mer_priv'] = $merPriv; } $result = $this->post('/api/hfpwallet/pay034', $params); - if(!$result->isSuccess()) { + if (!$result->isSuccess()) { return null; } return CloseOrder::make($result->getBody()); @@ -103,7 +105,7 @@ class TradeFactory extends Factory { $params = $request->toParams(); $result = $this->post('/api/hfpay/reb001', $params); - if(!$result->isSuccess()) { + if (!$result->isSuccess()) { return null; } return RefundInfo::make($result->getBody()); @@ -124,9 +126,30 @@ class TradeFactory extends Factory { $params = $request->toParams(); $result = $this->post('/api/hfpay/reb002', $params); - if(!$result->isSuccess()) { + if (!$result->isSuccess()) { return null; } return RefundGoodsResponse::make($result->getBody()); } + + /** + * 取现 + * + * @param WithdrawCashRequest $request + * + * @return WithdrawCashResponse|null + * @throws ParamsException + * + * @see https://hfpay.cloudpnr.com/customers/nft/#/transaction/withdrawCash + */ + function withdrawCash(WithdrawCashRequest $request): ?WithdrawCashResponse + { + $params = $request->toParams(); + + $result = $this->post('/api/acou/cash01', $params); + if (!$result->isSuccess()) { + return null; + } + return WithdrawCashResponse::make($result->getBody()); + } } \ No newline at end of file diff --git a/src/factory/object/trade/DeviceInfo.php b/src/factory/object/trade/DeviceInfo.php index f08b5c8..ea2ab5d 100644 --- a/src/factory/object/trade/DeviceInfo.php +++ b/src/factory/object/trade/DeviceInfo.php @@ -49,7 +49,7 @@ class DeviceInfo implements JsonSerializable return $self; } - private array $data; + private array $data = []; public function __get($name) { diff --git a/src/factory/object/trade/DivDetail.php b/src/factory/object/trade/DivDetail.php index a440b12..f66a745 100644 --- a/src/factory/object/trade/DivDetail.php +++ b/src/factory/object/trade/DivDetail.php @@ -22,7 +22,7 @@ class DivDetail implements JsonSerializable return $self; } - private array $data; + private array $data = []; public function __get($name) { diff --git a/src/factory/object/trade/ObjectInfo.php b/src/factory/object/trade/ObjectInfo.php index d709455..fc647a2 100644 --- a/src/factory/object/trade/ObjectInfo.php +++ b/src/factory/object/trade/ObjectInfo.php @@ -33,7 +33,7 @@ class ObjectInfo implements JsonSerializable return $self; } - private array $data; + private array $data = []; public function __get($name) { diff --git a/src/factory/object/trade/WithdrawCashRequest.php b/src/factory/object/trade/WithdrawCashRequest.php new file mode 100644 index 0000000..bc0eb73 --- /dev/null +++ b/src/factory/object/trade/WithdrawCashRequest.php @@ -0,0 +1,118 @@ +data['user_cust_id'])) { + throw new ParamsException('付款人汇付客户号不能为空', 'user_cust_id'); + } + $params['user_cust_id'] = $this->data['user_cust_id']; + + if(empty($this->data['order_date'])) { + throw new ParamsException('订单日期不能为空', 'order_date'); + } + $params['order_date'] = $this->data['order_date']; + + if(empty($this->data['order_id'])) { + throw new ParamsException('订单号不能为空', 'order_id'); + } + $params['order_id'] = $this->data['order_id']; + + if(empty($this->data['trans_amt'])) { + throw new ParamsException('取现金额不能为空', 'trans_amt'); + } + $params['trans_amt'] = $this->data['trans_amt']; + + if(empty($this->data['cash_type'])) { + throw new ParamsException('取现方式不能为空', 'cash_type'); + } + $params['cash_type'] = $this->data['cash_type']; + + if(empty($this->data['transaction_addr'])) { + throw new ParamsException('交易发生地不能为空', 'transaction_addr'); + } + $params['transaction_addr'] = $this->data['transaction_addr']; + + if(empty($this->data['purpose'])) { + throw new ParamsException('用途不能为空', 'purpose'); + } + $params['purpose'] = $this->data['purpose']; + + if(empty($this->data['user_ip_addr'])) { + throw new ParamsException('IP不能为空', 'user_ip_addr'); + } + $params['user_ip_addr'] = $this->data['user_ip_addr']; + + //以下为可选参数 + if(!empty($this->data['bind_card_id'])) { + $params['bind_card_id'] = $this->data['bind_card_id']; + } + if(!empty($this->data['out_acct_id'])) { + $params['out_acct_id'] = $this->data['out_acct_id']; + } + if(!empty($this->data['fee_acct_id'])) { + $params['fee_acct_id'] = $this->data['fee_acct_id']; + } + if(!empty($this->data['fee_cust_id'])) { + $params['fee_cust_id'] = $this->data['fee_cust_id']; + } + if(!empty($this->data['serv_amt'])) { + $params['serv_amt'] = $this->data['serv_amt']; + } + if(!empty($this->data['serv_cust_id'])) { + $params['serv_cust_id'] = $this->data['serv_cust_id']; + } + if(!empty($this->data['serv_acct_id'])) { + $params['serv_acct_id'] = $this->data['serv_acct_id']; + } + if(!empty($this->data['bg_ret_url'])) { + $params['bg_ret_url'] = StrFilterHelper::fileUrl($this->data['bg_ret_url']); + } + if(!empty($this->data['mer_priv'])) { + $params['mer_priv'] = $this->data['mer_priv']; + } + if(!empty($this->data['extension'])) { + $params['extension'] = $this->data['extension']; + } + if(!empty($this->data['dev_info_json'])) { + $params['dev_info_json'] = $this->data['dev_info_json']->toJSON(); + } + + return $params; + } +} \ No newline at end of file diff --git a/src/factory/object/trade/WithdrawCashResponse.php b/src/factory/object/trade/WithdrawCashResponse.php new file mode 100644 index 0000000..3249cbb --- /dev/null +++ b/src/factory/object/trade/WithdrawCashResponse.php @@ -0,0 +1,33 @@ +