53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace wchat\wx\V3;
|
|
|
|
use JetBrains\PhpStorm\ArrayShape;
|
|
|
|
class TransferDetail
|
|
{
|
|
|
|
|
|
/**
|
|
* @param string $out_detail_no
|
|
* @param int|float $transfer_amount
|
|
* @param string $transfer_remark
|
|
* @param string $openid
|
|
* @param string $user_name
|
|
*/
|
|
public function __construct(
|
|
readonly public string $out_detail_no,
|
|
readonly public int|float $transfer_amount,
|
|
readonly public string $transfer_remark,
|
|
readonly public string $openid,
|
|
readonly public string $user_name = ''
|
|
)
|
|
{
|
|
}
|
|
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
#[ArrayShape(['out_detail_no' => "string", 'transfer_amount' => "float|int", 'transfer_remark' => "string", 'openid' => "string", 'user_name' => "string"])]
|
|
public function toArray(): array
|
|
{
|
|
if (empty($this->user_name)) {
|
|
return [
|
|
'out_detail_no' => $this->out_detail_no,
|
|
'transfer_amount' => $this->transfer_amount,
|
|
'transfer_remark' => $this->transfer_remark,
|
|
'openid' => $this->openid,
|
|
];
|
|
}
|
|
return [
|
|
'out_detail_no' => $this->out_detail_no,
|
|
'transfer_amount' => $this->transfer_amount,
|
|
'transfer_remark' => $this->transfer_remark,
|
|
'openid' => $this->openid,
|
|
'user_name' => $this->user_name,
|
|
];
|
|
}
|
|
|
|
}
|