From c5f8b19a83a76b51afe662532a7fe6c9a681eada Mon Sep 17 00:00:00 2001 From: xl Date: Tue, 7 Nov 2023 16:14:59 +0800 Subject: [PATCH] Default Changelist --- wchat/wx/V3/TransferDetail.php | 54 +++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/wchat/wx/V3/TransferDetail.php b/wchat/wx/V3/TransferDetail.php index c8858b2..5c7a6d3 100644 --- a/wchat/wx/V3/TransferDetail.php +++ b/wchat/wx/V3/TransferDetail.php @@ -7,30 +7,38 @@ use JetBrains\PhpStorm\ArrayShape; class TransferDetail { - public function __construct( - public string $out_detail_no, - public int|float $transfer_amount, - public string $transfer_remark, - public string $openid, - public string $user_name - ) - { - } + public function __construct( + public string $out_detail_no, + public int|float $transfer_amount, + public string $transfer_remark, + public string $openid, + 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 - { - 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, - ]; - } + /** + * @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, + ]; + } }