fix pargar bugs 3
This commit is contained in:
@@ -276,25 +276,27 @@ class PargarController extends Controller
|
|||||||
$appliedDocs = (int) ($result['documents']['applied'] ?? 0);
|
$appliedDocs = (int) ($result['documents']['applied'] ?? 0);
|
||||||
$appliedMande = (bool) ($result['mande']['applied'] ?? false);
|
$appliedMande = (bool) ($result['mande']['applied'] ?? false);
|
||||||
$mandeMessage = (string) ($result['mande']['message'] ?? '');
|
$mandeMessage = (string) ($result['mande']['message'] ?? '');
|
||||||
|
$ok = $appliedDocs > 0 || $appliedMande;
|
||||||
|
|
||||||
$messages = [];
|
if ($appliedDocs > 0 && $appliedMande) {
|
||||||
if ($appliedDocs > 0) {
|
$message = "{$appliedDocs} سند و ماندهٔ پرگار روی کیف اعمال شد";
|
||||||
$messages[] = "{$appliedDocs} سند از پرگار اعمال شد";
|
} elseif ($appliedDocs > 0) {
|
||||||
}
|
$message = "{$appliedDocs} سند از پرگار روی کیف اعمال شد";
|
||||||
if ($appliedMande) {
|
} elseif ($appliedMande) {
|
||||||
$messages[] = 'ماندهٔ پرگار روی کیف اعمال شد';
|
$message = 'ماندهٔ پرگار روی کیف اعمال شد';
|
||||||
}
|
} else {
|
||||||
if ($mandeMessage !== '' && ! $appliedMande) {
|
// فقط وقتی هیچچیز اعمال نشده، پیام رد/بدوناختلاف مانده را نشان بده
|
||||||
$messages[] = $mandeMessage;
|
$message = $mandeMessage !== ''
|
||||||
|
? $mandeMessage
|
||||||
|
: 'سند قابلاعمالی یافت نشد';
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'ok' => $appliedDocs > 0 || $appliedMande,
|
'ok' => $ok,
|
||||||
'message' => $messages !== []
|
'message' => $message,
|
||||||
? implode(' — ', $messages)
|
|
||||||
: 'سند قابلاعمالی یافت نشد',
|
|
||||||
'result' => $result,
|
'result' => $result,
|
||||||
], $appliedDocs > 0 || $appliedMande ? 200 : 422);
|
]);
|
||||||
|
// همیشه ۲۰۰ — «قبلاً اعمال شده / بدون اختلاف» خطا نیست؛ فرانت خودش info میزند
|
||||||
}
|
}
|
||||||
|
|
||||||
private function uniqueReferralId(): string
|
private function uniqueReferralId(): string
|
||||||
|
|||||||
Reference in New Issue
Block a user