eee
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace wchat\wx\V3\Libs;
|
||||||
|
|
||||||
|
use Arrayable;
|
||||||
|
|
||||||
|
readonly class TransferSceneReportInfo implements Arrayable
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public string $info_type,
|
||||||
|
public string $info_content,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"info_type" => $this->info_type,
|
||||||
|
"info_content" => $this->info_content
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace wchat\wx\V3;
|
|
||||||
|
|
||||||
use JetBrains\PhpStorm\ArrayShape;
|
|
||||||
use wchat\wx\SmallProgram;
|
|
||||||
|
|
||||||
class TransferBatches extends SmallProgram
|
|
||||||
{
|
|
||||||
use WxV3PaymentTait;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $transfer_scene_id
|
|
||||||
* @param array $transfer_scene_report_infos
|
|
||||||
* @param TransferDetail $detail
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
#[ArrayShape([])]
|
|
||||||
public function transfer(string $transfer_scene_id, array $transfer_scene_report_infos, TransferDetail $detail): array
|
|
||||||
{
|
|
||||||
$payConfig = $this->getPayConfig();
|
|
||||||
$body = [];
|
|
||||||
if ($payConfig->typeIsApp()) {
|
|
||||||
$body['appid'] = $payConfig->pay->wx->appId;
|
|
||||||
} else {
|
|
||||||
$body['appid'] = $payConfig->appId;
|
|
||||||
}
|
|
||||||
$body['out_bill_no'] = $detail->out_detail_no;
|
|
||||||
$body["transfer_scene_id"] = $transfer_scene_id;
|
|
||||||
$body['openid'] = $detail->openid;
|
|
||||||
$body["transfer_amount"] = $detail->transfer_amount;
|
|
||||||
$body["transfer_remark"] = $detail->transfer_remark;
|
|
||||||
$body["transfer_scene_report_infos"] = $transfer_scene_report_infos;
|
|
||||||
|
|
||||||
$sign = $this->signature('POST', '/v3/fund-app/mch-transfer/transfer-bills', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
|
|
||||||
|
|
||||||
$client = $this->createClient($sign, $json);
|
|
||||||
$client->post('/v3/fund-app/mch-transfer/transfer-bills');
|
|
||||||
$client->close();
|
|
||||||
|
|
||||||
$data = json_decode($client->getBody(), TRUE);
|
|
||||||
if (json_last_error() != JSON_ERROR_NONE) {
|
|
||||||
return ['code' => $client->getStatusCode(), 'message' => $client->getBody()];
|
|
||||||
} else {
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace wchat\wx\V3;
|
namespace wchat\wx\V3;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use wchat\wx\V3\Libs\TransferSceneReportInfo;
|
||||||
|
|
||||||
class TransferDetail
|
class TransferDetail
|
||||||
{
|
{
|
||||||
@@ -11,10 +12,10 @@ class TransferDetail
|
|||||||
private string $out_bill_no;
|
private string $out_bill_no;
|
||||||
private string $transfer_scene_id;
|
private string $transfer_scene_id;
|
||||||
private string $openid;
|
private string $openid;
|
||||||
private string $user_name = '';
|
private string $user_name = '';
|
||||||
private int $transfer_amount;
|
private int $transfer_amount;
|
||||||
private string $transfer_remark;
|
private string $transfer_remark;
|
||||||
private string $notify_url = '';
|
private string $notify_url = '';
|
||||||
private string $user_recv_perception = '';
|
private string $user_recv_perception = '';
|
||||||
private array $transfer_scene_report_infos;
|
private array $transfer_scene_report_infos;
|
||||||
|
|
||||||
@@ -172,7 +173,7 @@ class TransferDetail
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array<TransferSceneReportInfo>
|
||||||
*/
|
*/
|
||||||
public function getTransferSceneReportInfos(): array
|
public function getTransferSceneReportInfos(): array
|
||||||
{
|
{
|
||||||
@@ -184,7 +185,7 @@ class TransferDetail
|
|||||||
* @param array $transfer_scene_report_infos
|
* @param array $transfer_scene_report_infos
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setTransferSceneReportInfos(array $transfer_scene_report_infos): void
|
public function setTransferSceneReportInfos(TransferSceneReportInfo ...$transfer_scene_report_infos): void
|
||||||
{
|
{
|
||||||
$this->transfer_scene_report_infos = $transfer_scene_report_infos;
|
$this->transfer_scene_report_infos = $transfer_scene_report_infos;
|
||||||
}
|
}
|
||||||
@@ -196,13 +197,17 @@ class TransferDetail
|
|||||||
*/
|
*/
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
|
$transfer_scene_report_infos = [];
|
||||||
|
foreach ($this->transfer_scene_report_infos as $transfer_scene_report_info) {
|
||||||
|
$transfer_scene_report_infos[] = $transfer_scene_report_info->toArray();
|
||||||
|
}
|
||||||
$array = [
|
$array = [
|
||||||
'out_bill_no' => $this->out_bill_no,
|
'out_bill_no' => $this->out_bill_no,
|
||||||
'transfer_scene_id' => $this->transfer_scene_id,
|
'transfer_scene_id' => $this->transfer_scene_id,
|
||||||
'openid' => $this->openid,
|
'openid' => $this->openid,
|
||||||
'transfer_amount' => $this->transfer_amount,
|
'transfer_amount' => $this->transfer_amount,
|
||||||
'transfer_remark' => $this->transfer_remark,
|
'transfer_remark' => $this->transfer_remark,
|
||||||
'transfer_scene_report_infos' => $this->transfer_scene_report_infos,
|
'transfer_scene_report_infos' => $transfer_scene_report_infos,
|
||||||
];
|
];
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user