文件
yjyf/server/application/common/library/CancelRefundSummary.php

21 行
584 B
PHP

<?php
namespace app\common\library;
class CancelRefundSummary
{
public static function summarize(array $rows)
{
$amount = 0.0;
$state = $rows ? 'success' : 'missing';
foreach ($rows as $row) {
$amount += (float)$row['refund_amount'];
if ($row['status'] === 'refund_failed') {
$state = 'failed';
} elseif ($row['status'] !== 'refunded' && $state !== 'failed') {
$state = 'processing';
}
}
return ['state' => $state, 'amount' => round($amount, 2)];
}
}