$order * @param array|null $claim */ public static function isLocked(array $order, ?array $claim): bool { // 远端已确认取消(洛阳药房撤单、甘草撤单/驳回)且没有在途的新版本提交:快照不再被药房使用。 if (self::isRemoteCancelled($order) && !self::isClaimInFlight($claim)) { return false; } 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 $order */ public static function isRemoteCancelled(array $order): bool { return strtoupper(trim((string) ($order['ej_pharmacy_status'] ?? ''))) === 'CANCELLED' || in_array((int) ($order['gancao_order_state'] ?? 0), [91, 92], true); } /** @param array|null $claim */ public static function isClaimInFlight(?array $claim): bool { return is_array($claim) && in_array( strtoupper((string) ($claim['status'] ?? '')), ['PENDING', 'UNKNOWN', 'PENDING_RECONCILE'], true ); } /** * @param array $order * @param array|null $claim */ public static function assertMutable(array $order, ?array $claim): void { if (self::isLocked($order, $claim)) { throw new DomainException('订单已提交药房,患者、地址、处方与发货药房快照不可修改;请先完成远端取消确认,取消后创建新版本'); } } }