refactor: centralize receipt total logic on PlatformOrder
This commit is contained in:
@@ -1470,20 +1470,8 @@ class PlatformOrderController extends Controller
|
||||
|
||||
private function receiptTotalForOrder(PlatformOrder $order): float
|
||||
{
|
||||
// 优先读扁平字段 payment_summary.total_amount(更稳定、避免遍历 receipts)
|
||||
$total = (float) (data_get($order->meta, 'payment_summary.total_amount') ?? 0);
|
||||
if ($total > 0) {
|
||||
return $total;
|
||||
}
|
||||
|
||||
// 回退:遍历 payment_receipts[].amount
|
||||
$receipts = (array) (data_get($order->meta, 'payment_receipts', []) ?? []);
|
||||
$sum = 0.0;
|
||||
foreach ($receipts as $r) {
|
||||
$sum += (float) (data_get($r, 'amount') ?? 0);
|
||||
}
|
||||
|
||||
return $sum;
|
||||
// 口径统一:集中到模型方法,避免多处复制导致漂移
|
||||
return (float) $order->receiptTotal();
|
||||
}
|
||||
|
||||
private function refundTotalForOrder(PlatformOrder $order): float
|
||||
|
||||
Reference in New Issue
Block a user