fix trigger bug 2

This commit is contained in:
2026-07-22 14:15:22 +03:30
parent 7d02639917
commit 8165fc37b8
6 changed files with 52 additions and 7 deletions
@@ -126,13 +126,17 @@ class ConditionalOrderController extends Controller
if (! empty($data['expires_at'])) {
try {
$expires = \Illuminate\Support\Carbon::parse($data['expires_at']);
$expires = \Illuminate\Support\Carbon::parse(
$data['expires_at'],
config('app.timezone')
)->timezone(config('app.timezone'));
} catch (\Throwable $e) {
throw new UnprocessableEntityHttpException('زمان اعتبار تاریخ معتبری نیست.');
}
if ($expires->lte(now())) {
throw new UnprocessableEntityHttpException('زمان اعتبار باید بعد از الان باشد.');
throw new UnprocessableEntityHttpException('زمان اعتبار باید بعد از تایم فعلی باشد.');
}
// Wall-clock in app TZ; column is DATETIME (not TIMESTAMP) to avoid double TZ shift.
$data['expires_at'] = $expires->format('Y-m-d H:i:s');
}
@@ -149,13 +149,17 @@ class ConditionalOrderController extends Controller
if (! empty($data['expires_at'])) {
try {
$expires = \Illuminate\Support\Carbon::parse($data['expires_at']);
$expires = \Illuminate\Support\Carbon::parse(
$data['expires_at'],
config('app.timezone')
)->timezone(config('app.timezone'));
} catch (\Throwable $e) {
throw new UnprocessableEntityHttpException('زمان اعتبار تاریخ معتبری نیست.');
}
if ($expires->lte(now())) {
throw new UnprocessableEntityHttpException('زمان اعتبار باید بعد از الان باشد.');
throw new UnprocessableEntityHttpException('زمان اعتبار باید بعد از تایم فعلی باشد.');
}
// Wall-clock in app TZ; column is DATETIME (not TIMESTAMP) to avoid double TZ shift.
$data['expires_at'] = $expires->format('Y-m-d H:i:s');
}
+3 -1
View File
@@ -205,10 +205,12 @@ class ConditionalOrderService
public function expirePendingPastDue(): int
{
$now = now()->timezone(config('app.timezone'))->format('Y-m-d H:i:s');
return ConditionalOrder::query()
->where('status', ConditionalOrder::STATUS_PENDING)
->whereNotNull('expires_at')
->where('expires_at', '<', now())
->where('expires_at', '<', $now)
->update([
'status' => ConditionalOrder::STATUS_EXPIRED,
'is_active' => false,
+5 -1
View File
@@ -16,7 +16,11 @@ class ConditionalOrderValidation
'in' => ':attribute انتخاب‌شده نامعتبر است.',
'boolean' => ':attribute باید صحیح یا غلط باشد.',
'date' => ':attribute تاریخ معتبری نیست.',
'after' => ':attribute باید بعد از الان باشد.',
'after' => 'زمان اعتبار باید بعد از تایم فعلی باشد.',
'after_or_equal' => 'زمان اعتبار باید بعد از تایم فعلی باشد.',
'expires_at.date' => 'زمان اعتبار تاریخ معتبری نیست.',
'expires_at.after' => 'زمان اعتبار باید بعد از تایم فعلی باشد.',
'expires_at.after_or_equal' => 'زمان اعتبار باید بعد از تایم فعلی باشد.',
'exists' => ':attribute انتخاب‌شده معتبر نیست.',
'string' => ':attribute باید متن باشد.',
'nullable' => '',