统一退款不一致(refund_inconsistent)口径:引入 amounts.tolerance 并对齐模型与筛选
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user