文件
xionggeshop/addons/shopro_wechat_trade/command/ProbeOrderPath.php

67 行
2.7 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace addons\shopro_wechat_trade\command;
use addons\shopro_wechat_trade\library\WxOrderPathService;
use addons\shopro_wechat_trade\library\WxTradeConfig;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
class ProbeOrderPath extends Command
{
protected function configure()
{
$this->setName('shopro_wechat_trade:probe-path')
->setDescription('Diagnose WeChat order detail path (10060035)');
}
protected function execute(Input $input, Output $output)
{
$output->writeln('=== 微信订单详情 path 诊断 ===');
$mini = Db::name('shopro_config')->where('name', 'wxMiniProgram')->value('value');
$mini = json_decode($mini, true);
$appId = $mini['app_id'] ?? '';
$output->writeln('小程序 AppID(商城配置): ' . ($appId ?: '(未配置)'));
$config = WxTradeConfig::getInstance();
$path = WxOrderPathService::normalizePath($config->getOrderDetailPath());
$output->writeln('待配置 path: ' . $path);
$pathService = new WxOrderPathService();
try {
$current = $pathService->getPath();
$output->writeln('当前已配置 path: ' . ($current['path'] ?? '(空)'));
} catch (\Exception $e) {
$output->writeln('查询当前 path 失败: ' . $e->getMessage());
}
try {
$managed = $pathService->isTradeManaged();
$output->writeln('is_trade_managed: ' . json_encode($managed, JSON_UNESCAPED_UNICODE));
} catch (\Exception $e) {
$output->writeln('is_trade_managed 失败: ' . $e->getMessage());
}
$output->writeln('');
$output->writeln('尝试 update_order_detail_path ...');
try {
$result = $pathService->updatePath($path);
$output->writeln('[OK] 配置成功: ' . json_encode($result, JSON_UNESCAPED_UNICODE));
} catch (\Exception $e) {
$output->writeln('[FAIL] ' . $e->getMessage());
$output->writeln('');
$output->writeln('10060035 常见原因(按概率):');
$output->writeln(' 1. 小程序「线上版」或「审核中版本」里没有 pages/order/detail —— 须先上传并提审/发布');
$output->writeln(' 2. 商城配置的 AppID 与当前要开通能力的小程序不一致');
$output->writeln(' 3. 可在微信后台手动填 path,不必强依赖 API');
$output->writeln('');
$output->writeln('说明:upload_shipping_info 发货同步不依赖本 path;path 仅用于「购物订单」跳转详情');
$output->writeln('建议 path: pages/order/detail?id=${商品订单号}');
}
}
}