|
|
|
@ -15,9 +15,10 @@ class VerifyQccEnterprisePackInfo extends Command
|
|
|
|
protected $signature = 'qcc:verify-pack-info
|
|
|
|
protected $signature = 'qcc:verify-pack-info
|
|
|
|
{company_id : 候选、已占额或待人工确认企业的本地企业 ID}
|
|
|
|
{company_id : 候选、已占额或待人工确认企业的本地企业 ID}
|
|
|
|
{--timeout=60 : 请求超时时间(秒,正整数)}
|
|
|
|
{--timeout=60 : 请求超时时间(秒,正整数)}
|
|
|
|
|
|
|
|
{--request : 额外输出本次请求地址、请求头和请求体(不含 authKey)}
|
|
|
|
{--raw : 兼容旧用法,默认即输出完整响应}';
|
|
|
|
{--raw : 兼容旧用法,默认即输出完整响应}';
|
|
|
|
|
|
|
|
|
|
|
|
protected $description = '诊断元禾 packInfo 接口,按 code=200 判断成功,仅输出响应,不修改企业状态';
|
|
|
|
protected $description = '诊断元禾 packInfo 接口,按 code=200 判断成功,默认仅输出响应,不修改企业状态';
|
|
|
|
|
|
|
|
|
|
|
|
public function handle(YuanheRepository $yuanheRepository): int
|
|
|
|
public function handle(YuanheRepository $yuanheRepository): int
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -51,7 +52,8 @@ class VerifyQccEnterprisePackInfo extends Command
|
|
|
|
'enterpriseName' => $company->company_name,
|
|
|
|
'enterpriseName' => $company->company_name,
|
|
|
|
], $timeout);
|
|
|
|
], $timeout);
|
|
|
|
} catch (Throwable $exception) {
|
|
|
|
} catch (Throwable $exception) {
|
|
|
|
// 非 JSON 响应保留原文;没有响应时仅输出错误,不打印签名或请求头。
|
|
|
|
$this->printRequest($yuanheRepository);
|
|
|
|
|
|
|
|
// 非 JSON 响应保留原文;没有响应时输出错误。
|
|
|
|
$result = $exception instanceof YuanhePackInfoException && $exception->rawResponse !== null
|
|
|
|
$result = $exception instanceof YuanhePackInfoException && $exception->rawResponse !== null
|
|
|
|
? $exception->rawResponse
|
|
|
|
? $exception->rawResponse
|
|
|
|
: $exception->getMessage();
|
|
|
|
: $exception->getMessage();
|
|
|
|
@ -59,6 +61,7 @@ class VerifyQccEnterprisePackInfo extends Command
|
|
|
|
return self::FAILURE;
|
|
|
|
return self::FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->printRequest($yuanheRepository);
|
|
|
|
$this->output->writeln(
|
|
|
|
$this->output->writeln(
|
|
|
|
json_encode($response, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT),
|
|
|
|
json_encode($response, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT),
|
|
|
|
OutputInterface::OUTPUT_RAW
|
|
|
|
OutputInterface::OUTPUT_RAW
|
|
|
|
@ -66,4 +69,21 @@ class VerifyQccEnterprisePackInfo extends Command
|
|
|
|
|
|
|
|
|
|
|
|
return in_array($response['code'] ?? null, [200, '200'], true) ? self::SUCCESS : self::FAILURE;
|
|
|
|
return in_array($response['code'] ?? null, [200, '200'], true) ? self::SUCCESS : self::FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function printRequest(YuanheRepository $repository): void
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!$this->option('request')) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->output->writeln('请求信息(不含 authKey):', OutputInterface::OUTPUT_RAW);
|
|
|
|
|
|
|
|
$this->output->writeln(
|
|
|
|
|
|
|
|
$repository->lastRequest
|
|
|
|
|
|
|
|
? json_encode($repository->lastRequest, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
|
|
|
|
|
|
|
|
: '未生成请求信息。',
|
|
|
|
|
|
|
|
OutputInterface::OUTPUT_RAW
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->output->writeln('返回结果:', OutputInterface::OUTPUT_RAW);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|