$claim @return array{status:string,remote_order_no:string,note:string} */ public static function resolve( array $claim, string $resolution, string $remoteOrderNo, string $note, ?int $now = null ): array { if (strtolower(trim((string) ($claim['target'] ?? ''))) !== 'gancao') { throw new DomainException('仅甘草药房不确定提交支持人工确认'); } $status = strtoupper(trim((string) ($claim['status'] ?? ''))); $expiredPending = $status === 'PENDING' && (int) ($claim['lease_expires_at'] ?? 0) > 0 && (int) $claim['lease_expires_at'] <= ($now ?? time()); if (!$expiredPending && !in_array($status, ['UNKNOWN', 'PENDING_RECONCILE'], true)) { throw new DomainException('当前提交状态无需人工确认'); } $resolution = strtoupper(trim($resolution)); if (!in_array($resolution, ['CONFIRM_SUCCESS', 'CONFIRM_NOT_CREATED'], true)) { throw new DomainException('不支持的人工确认结果'); } $note = trim($note); if ($note === '') { throw new DomainException('请填写甘草后台核对依据'); } $remoteOrderNo = trim($remoteOrderNo); if ($resolution === 'CONFIRM_SUCCESS' && $remoteOrderNo === '') { throw new DomainException('确认成功时必须填写甘草药方单号'); } return [ 'status' => $resolution === 'CONFIRM_SUCCESS' ? 'SUCCESS' : 'FAILED', 'remote_order_no' => $resolution === 'CONFIRM_SUCCESS' ? $remoteOrderNo : '', 'note' => $note, ]; } }