eee
This commit is contained in:
@@ -26,15 +26,12 @@ class TransferBatches extends SmallProgram
|
|||||||
} else {
|
} else {
|
||||||
$body['appid'] = $payConfig->appId;
|
$body['appid'] = $payConfig->appId;
|
||||||
}
|
}
|
||||||
$body['out_batch_no'] = $detail->out_detail_no;
|
$body['out_bill_no'] = $detail->out_detail_no;
|
||||||
$body["batch_name"] = $payConfig->getBody();
|
|
||||||
$body["body"] = $payConfig->getBody();
|
|
||||||
$body["batch_remark"] = $payConfig->getBody();
|
|
||||||
$body["total_amount"] = $detail->transfer_amount;
|
|
||||||
$body["total_num"] = 1;
|
|
||||||
$body["transfer_scene_id"] = $transfer_scene_id;
|
$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;
|
$body["transfer_scene_report_infos"] = $transfer_scene_report_infos;
|
||||||
$body["transfer_detail_list"] = [$detail->toArray()];
|
|
||||||
|
|
||||||
$sign = $this->signature('POST', '/v3/fund-app/mch-transfer/transfer-bills', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
|
$sign = $this->signature('POST', '/v3/fund-app/mch-transfer/transfer-bills', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
|||||||
+197
-25
@@ -2,51 +2,223 @@
|
|||||||
|
|
||||||
namespace wchat\wx\V3;
|
namespace wchat\wx\V3;
|
||||||
|
|
||||||
use JetBrains\PhpStorm\ArrayShape;
|
use Exception;
|
||||||
|
|
||||||
class TransferDetail
|
class TransferDetail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
private string $out_bill_no;
|
||||||
|
private string $transfer_scene_id;
|
||||||
|
private string $openid;
|
||||||
|
private string $user_name = '';
|
||||||
|
private int $transfer_amount;
|
||||||
|
private string $transfer_remark;
|
||||||
|
private string $notify_url = '';
|
||||||
|
private string $user_recv_perception = '';
|
||||||
|
private array $transfer_scene_report_infos;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $out_detail_no
|
* @return string
|
||||||
* @param int|float $transfer_amount
|
|
||||||
* @param string $transfer_remark
|
|
||||||
* @param string $openid
|
|
||||||
* @param string $user_name
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function getOutBillNo(): string
|
||||||
public string $out_detail_no,
|
|
||||||
public int|float $transfer_amount,
|
|
||||||
public string $transfer_remark,
|
|
||||||
public string $openid,
|
|
||||||
public string $user_name = ''
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return $this->out_bill_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $out_bill_no
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setOutBillNo(string $out_bill_no): void
|
||||||
|
{
|
||||||
|
$this->out_bill_no = $out_bill_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTransferSceneId(): string
|
||||||
|
{
|
||||||
|
return $this->transfer_scene_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $transfer_scene_id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setTransferSceneId(string $transfer_scene_id): void
|
||||||
|
{
|
||||||
|
$this->transfer_scene_id = $transfer_scene_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOpenid(): string
|
||||||
|
{
|
||||||
|
return $this->openid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $openid
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setOpenid(string $openid): void
|
||||||
|
{
|
||||||
|
$this->openid = $openid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserName(): string
|
||||||
|
{
|
||||||
|
return $this->user_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $user_name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setUserName(string $user_name): void
|
||||||
|
{
|
||||||
|
$this->user_name = $user_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getTransferAmount(): int
|
||||||
|
{
|
||||||
|
return $this->transfer_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $transfer_amount
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setTransferAmount(int $transfer_amount): void
|
||||||
|
{
|
||||||
|
$this->transfer_amount = $transfer_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTransferRemark(): string
|
||||||
|
{
|
||||||
|
return $this->transfer_remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $transfer_remark
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setTransferRemark(string $transfer_remark): void
|
||||||
|
{
|
||||||
|
$this->transfer_remark = $transfer_remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNotifyUrl(): string
|
||||||
|
{
|
||||||
|
return $this->notify_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $notify_url
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setNotifyUrl(string $notify_url): void
|
||||||
|
{
|
||||||
|
$this->notify_url = $notify_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRecvPerception(): string
|
||||||
|
{
|
||||||
|
return $this->user_recv_perception;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $user_recv_perception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setUserRecvPerception(string $user_recv_perception): void
|
||||||
|
{
|
||||||
|
$this->user_recv_perception = $user_recv_perception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
#[ArrayShape(['out_detail_no' => "string", 'transfer_amount' => "float|int", 'transfer_remark' => "string", 'openid' => "string", 'user_name' => "string"])]
|
public function getTransferSceneReportInfos(): array
|
||||||
|
{
|
||||||
|
return $this->transfer_scene_report_infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $transfer_scene_report_infos
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setTransferSceneReportInfos(array $transfer_scene_report_infos): void
|
||||||
|
{
|
||||||
|
$this->transfer_scene_report_infos = $transfer_scene_report_infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
if (empty($this->user_name)) {
|
$array = [
|
||||||
return [
|
'out_bill_no' => $this->out_bill_no,
|
||||||
'out_detail_no' => $this->out_detail_no,
|
'transfer_scene_id' => $this->transfer_scene_id,
|
||||||
|
'openid' => $this->openid,
|
||||||
'transfer_amount' => $this->transfer_amount,
|
'transfer_amount' => $this->transfer_amount,
|
||||||
'transfer_remark' => $this->transfer_remark,
|
'transfer_remark' => $this->transfer_remark,
|
||||||
'openid' => $this->openid,
|
'transfer_scene_report_infos' => $this->transfer_scene_report_infos,
|
||||||
];
|
];
|
||||||
|
foreach ($array as $key => $value) {
|
||||||
|
if (empty($value)) {
|
||||||
|
throw new Exception('必填项' . $key . '不能为空.');
|
||||||
}
|
}
|
||||||
return [
|
}
|
||||||
'out_detail_no' => $this->out_detail_no,
|
if (!empty($this->user_name)) {
|
||||||
'transfer_amount' => $this->transfer_amount,
|
$array['user_name'] = $this->user_name;
|
||||||
'transfer_remark' => $this->transfer_remark,
|
}
|
||||||
'openid' => $this->openid,
|
if (!empty($this->notify_url)) {
|
||||||
'user_name' => $this->user_name,
|
$array['notify_url'] = $this->notify_url;
|
||||||
];
|
}
|
||||||
|
if (!empty($this->user_recv_perception)) {
|
||||||
|
$array['user_recv_perception'] = $this->user_recv_perception;
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace wchat\wx\V3;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use JetBrains\PhpStorm\ArrayShape;
|
||||||
|
use Kiri;
|
||||||
|
use wchat\wx\SmallProgram;
|
||||||
|
|
||||||
|
class WxV3Transfer extends SmallProgram
|
||||||
|
{
|
||||||
|
use WxV3PaymentTait;
|
||||||
|
|
||||||
|
private ?string $appid;
|
||||||
|
private ?string $out_bill_no;
|
||||||
|
private ?string $transfer_scene_id;
|
||||||
|
private ?string $openid;
|
||||||
|
private ?int $transfer_amount;
|
||||||
|
private ?string $user_name;
|
||||||
|
private ?string $transfer_remark;
|
||||||
|
private ?string $notify_url;
|
||||||
|
private ?string $user_recv_perception;
|
||||||
|
private ?array $transfer_scene_report_infos;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransferDetail $detail
|
||||||
|
* @return array<'out_bill_no', 'transfer_bill_no', 'create_time', 'state'>
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
#[ArrayShape([])]
|
||||||
|
public function transfer(TransferDetail $detail): array
|
||||||
|
{
|
||||||
|
$payConfig = $this->getPayConfig();
|
||||||
|
$body = $detail->toArray();
|
||||||
|
if ($payConfig->typeIsApp()) {
|
||||||
|
$body['appid'] = $payConfig->pay->wx->appId;
|
||||||
|
} else {
|
||||||
|
$body['appid'] = $payConfig->appId;
|
||||||
|
}
|
||||||
|
$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();
|
||||||
|
|
||||||
|
if ($client->getStatusCode() == 200) {
|
||||||
|
return json_decode($client->getBody(), TRUE);
|
||||||
|
}
|
||||||
|
throw new Exception('转账申请发起失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user