30 lines
782 B
PHP
30 lines
782 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\common\service\pharmacy;
|
|
|
|
use Closure;
|
|
use InvalidArgumentException;
|
|
|
|
final class EjPharmacyCallbackFailureTransition
|
|
{
|
|
/** @param callable(int,array<string,mixed>,string):bool $conditionalUpdate */
|
|
public static function apply(int $inboxId, string $error, callable $conditionalUpdate): bool
|
|
{
|
|
if ($inboxId <= 0) {
|
|
throw new InvalidArgumentException('callback inbox id is missing');
|
|
}
|
|
|
|
return (bool) Closure::fromCallable($conditionalUpdate)(
|
|
$inboxId,
|
|
[
|
|
'process_status' => 'FAILED',
|
|
'error_message' => mb_substr($error, 0, 1000),
|
|
'update_time' => time(),
|
|
],
|
|
'PROCESSED'
|
|
);
|
|
}
|
|
}
|