Files
kiri-wchat/wx/V3/TransferDetail.php
T

230 lines
4.8 KiB
PHP
Raw Normal View History

2022-09-09 16:42:55 +08:00
<?php
namespace wchat\wx\V3;
2025-02-24 16:29:54 +08:00
use Exception;
2025-02-24 17:08:40 +08:00
use wchat\wx\V3\Libs\TransferSceneReportInfo;
2022-09-09 16:42:55 +08:00
class TransferDetail
{
2023-11-14 00:07:18 +08:00
2025-02-24 16:29:54 +08:00
private string $out_bill_no;
private string $transfer_scene_id;
private string $openid;
2025-02-24 17:08:40 +08:00
private string $user_name = '';
2025-02-24 16:29:54 +08:00
private int $transfer_amount;
private string $transfer_remark;
2025-02-24 17:08:40 +08:00
private string $notify_url = '';
2025-02-24 16:29:54 +08:00
private string $user_recv_perception = '';
private array $transfer_scene_report_infos;
/**
* @return string
*/
public function getOutBillNo(): string
{
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;
}
2023-11-14 00:07:18 +08:00
/**
* @param string $openid
2025-02-24 16:29:54 +08:00
* @return void
*/
public function setOpenid(string $openid): void
{
$this->openid = $openid;
}
/**
* @return string
*/
public function getUserName(): string
{
return $this->user_name;
}
/**
2023-11-14 00:07:18 +08:00
* @param string $user_name
2025-02-24 16:29:54 +08:00
* @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;
}
/**
2025-02-24 17:08:40 +08:00
* @return array<TransferSceneReportInfo>
2025-02-24 16:29:54 +08:00
*/
public function getTransferSceneReportInfos(): array
{
return $this->transfer_scene_report_infos;
}
/**
* @param array $transfer_scene_report_infos
* @return void
2023-11-14 00:07:18 +08:00
*/
2025-02-24 17:08:40 +08:00
public function setTransferSceneReportInfos(TransferSceneReportInfo ...$transfer_scene_report_infos): void
2023-11-07 16:14:59 +08:00
{
2025-02-24 16:29:54 +08:00
$this->transfer_scene_report_infos = $transfer_scene_report_infos;
2023-11-07 16:14:59 +08:00
}
2022-09-09 16:42:55 +08:00
2023-11-07 16:14:59 +08:00
/**
* @return array
2025-02-24 16:29:54 +08:00
* @throws Exception
2023-11-07 16:14:59 +08:00
*/
public function toArray(): array
{
2025-02-24 17:08:40 +08:00
$transfer_scene_report_infos = [];
foreach ($this->transfer_scene_report_infos as $transfer_scene_report_info) {
$transfer_scene_report_infos[] = $transfer_scene_report_info->toArray();
}
2025-02-24 16:29:54 +08:00
$array = [
'out_bill_no' => $this->out_bill_no,
'transfer_scene_id' => $this->transfer_scene_id,
'openid' => $this->openid,
'transfer_amount' => $this->transfer_amount,
'transfer_remark' => $this->transfer_remark,
2025-02-24 17:08:40 +08:00
'transfer_scene_report_infos' => $transfer_scene_report_infos,
2023-11-07 16:14:59 +08:00
];
2025-02-24 16:29:54 +08:00
foreach ($array as $key => $value) {
if (empty($value)) {
throw new Exception('必填项' . $key . '不能为空.');
}
}
if (!empty($this->user_name)) {
$array['user_name'] = $this->user_name;
}
if (!empty($this->notify_url)) {
$array['notify_url'] = $this->notify_url;
}
if (!empty($this->user_recv_perception)) {
$array['user_recv_perception'] = $this->user_recv_perception;
}
return $array;
2023-11-07 16:14:59 +08:00
}
2022-09-09 16:42:55 +08:00
}