- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务 - 将短信验证码从6位改为4位,优化用户体验 - 添加聚水潭商品按时间范围同步功能,支持分页拉取 - 增强Cron任务异常处理,添加错误日志记录 - 修复系统附件服务中图片路径处理逻辑 - 更新阿里云SDK相关组件至最新版本 - 添加think-trace调试扩展,便于问题排查 - 优化跨域中间件,使用str_contains替代strpos
94 lines
3.5 KiB
PHP
94 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace app\command;
|
|
|
|
use app\haichao\HaichaoJstServices;
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\input\Argument;
|
|
use think\console\input\Option;
|
|
use think\console\Output;
|
|
|
|
class TestJstSpu extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this->setName('test_jst_spu')
|
|
->addArgument('spu', Argument::REQUIRED, 'SPU编码')
|
|
->setDescription('测试聚水潭按SPU拉取商品接口');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$spu = $input->getArgument('spu');
|
|
|
|
if (empty($spu)) {
|
|
$output->error('请提供SPU编码');
|
|
$output->info('用法: php think test_jst_spu SPU编码');
|
|
$output->info('示例: php think test_jst_spu test123');
|
|
return;
|
|
}
|
|
|
|
$output->info('正在调用聚水潭API获取商品信息...');
|
|
$output->info('SPU: ' . $spu);
|
|
$output->newLine();
|
|
|
|
try {
|
|
$startTime = microtime(true);
|
|
|
|
$haichaoJst = HaichaoJstServices::getServices();
|
|
$result = $haichaoJst->getProductListKuan($spu);
|
|
|
|
$endTime = microtime(true);
|
|
$costTime = round(($endTime - $startTime) * 1000, 2);
|
|
|
|
$output->info('✅ API调用成功! 耗时: ' . $costTime . 'ms');
|
|
$output->newLine();
|
|
|
|
if (empty($result)) {
|
|
$output->warning('⚠️ 未获取到任何数据');
|
|
return;
|
|
}
|
|
|
|
$output->info('📦 获取到的数据:');
|
|
$output->write(json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
|
$output->newLine();
|
|
|
|
if (isset($result['code'])) {
|
|
$output->info('响应码: ' . $result['code']);
|
|
}
|
|
if (isset($result['msg'])) {
|
|
$output->info('响应消息: ' . $result['msg']);
|
|
}
|
|
if (isset($result['datas'])) {
|
|
$output->info('商品数量: ' . count($result['datas']));
|
|
|
|
if (!empty($result['datas'])) {
|
|
$output->newLine();
|
|
$output->info('📋 第一个商品信息:');
|
|
$firstProduct = $result['datas'][0];
|
|
$output->writeln(' - SPU ID: ' . ($firstProduct['i_id'] ?? 'N/A'));
|
|
$output->writeln(' - 商品名称: ' . ($firstProduct['name'] ?? 'N/A'));
|
|
$output->writeln(' - 售价: ' . ($firstProduct['s_price'] ?? 'N/A'));
|
|
$output->writeln(' - 市场价: ' . ($firstProduct['market_price'] ?? 'N/A'));
|
|
$output->writeln(' - 成本价: ' . ($firstProduct['c_price'] ?? 'N/A'));
|
|
|
|
if (isset($firstProduct['skus']) && is_array($firstProduct['skus'])) {
|
|
$output->writeln(' - SKU数量: ' . count($firstProduct['skus']));
|
|
}
|
|
}
|
|
}
|
|
|
|
$output->newLine();
|
|
|
|
} catch (\Throwable $e) {
|
|
$output->error('❌ API调用失败!');
|
|
$output->error('错误信息: ' . $e->getMessage());
|
|
$output->error('错误文件: ' . $e->getFile() . ':' . $e->getLine());
|
|
$output->newLine();
|
|
$output->info('堆栈跟踪:');
|
|
$output->write($e->getTraceAsString());
|
|
}
|
|
}
|
|
}
|