统一退款不一致(refund_inconsistent)口径:引入 amounts.tolerance 并对齐模型与筛选

This commit is contained in:
萝卜
2026-03-13 15:51:26 +00:00
parent b0ee9b6290
commit 6f1b894b45
10 changed files with 128 additions and 30 deletions

View File

@@ -48,19 +48,24 @@ class PlatformOrder extends Model
public function isRefundInconsistent(): bool
{
// 口径与平台订单列表 refund_inconsistent 保持一致:按分取整 + 0.01 容差
// 口径与平台订单列表 refund_inconsistent 保持一致:按分取整 + 容差config('saasshop.amounts.tolerance')
$refundTotal = (float) $this->refundTotal();
$paidAmount = (float) ($this->paid_amount ?? 0);
$refundCents = (int) round($refundTotal * 100);
$paidCents = (int) round($paidAmount * 100);
$tol = (float) config('saasshop.amounts.tolerance', 0.01);
$tolCents = (int) round($tol * 100);
$tolCents = max(1, $tolCents);
if ((string) $this->payment_status === 'refunded') {
// 允许 0.01 容差refund_total + 0.01 < paid
return ($refundCents + 1) < $paidCents;
// 已退款但退款总额不足refund_total + tol < paid
return ($refundCents + $tolCents) < $paidCents;
}
return $paidCents > 0 && $refundCents >= $paidCents;
// 非已退款但退款总额已达到/超过已付refund_total >= paid + tol
return $paidCents > 0 && $refundCents >= ($paidCents + $tolCents);
}
public function isReconcileMismatch(): bool