first commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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('订单已提交药房,患者、地址、处方与发货药房快照不可修改;请先完成远端取消确认,取消后创建新版本');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user