45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\common\service\pharmacy;
|
|
|
|
use DomainException;
|
|
|
|
final class PharmacyRemoteSnapshotPolicy
|
|
{
|
|
/**
|
|
* @param array<string,mixed> $order
|
|
* @param array<string,mixed>|null $claim
|
|
*/
|
|
public static function isLocked(array $order, ?array $claim): bool
|
|
{
|
|
if (trim((string) ($order['gancao_reciperl_order_no'] ?? '')) !== '') {
|
|
return true;
|
|
}
|
|
if (trim((string) ($order['ej_pharmacy_order_no'] ?? '')) !== '') {
|
|
return true;
|
|
}
|
|
if ((int) ($order['gancao_submit_time'] ?? 0) > 0 || (int) ($order['ej_pharmacy_submit_time'] ?? 0) > 0) {
|
|
return true;
|
|
}
|
|
|
|
return is_array($claim) && in_array(
|
|
strtoupper((string) ($claim['status'] ?? '')),
|
|
['PENDING', 'UNKNOWN', 'PENDING_RECONCILE', 'SUCCESS'],
|
|
true
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param array<string,mixed> $order
|
|
* @param array<string,mixed>|null $claim
|
|
*/
|
|
public static function assertMutable(array $order, ?array $claim): void
|
|
{
|
|
if (self::isLocked($order, $claim)) {
|
|
throw new DomainException('订单已提交药房,患者、地址、处方与发货药房快照不可修改;请先完成远端取消确认,取消后创建新版本');
|
|
}
|
|
}
|
|
}
|