feat(shopro_wechat_trade): 添加重新同步物流信息命令 新增 ResyncShipping 命令,支持强制重新上传微信物流信息, 不依赖 sync 表的 failed/pending 状态,适用于修改自提配置后 需要重传的场景。 同时修改 RetryFailed 命令,在没有待重试记录时提供操作提示, 并扩展 WxShippingService 的 retryFailed 方法支持处理 failed 状态的记录。 ```
31 行
1.1 KiB
PHP
31 行
1.1 KiB
PHP
<?php
|
||
|
||
namespace addons\shopro_wechat_trade\command;
|
||
|
||
use addons\shopro_wechat_trade\library\WxShippingService;
|
||
use think\console\Command;
|
||
use think\console\Input;
|
||
use think\console\input\Option;
|
||
use think\console\Output;
|
||
|
||
class RetryFailed extends Command
|
||
{
|
||
protected function configure()
|
||
{
|
||
$this->setName('shopro_wechat_trade:retry-failed')
|
||
->addOption('limit', null, Option::VALUE_OPTIONAL, 'Max rows', 50)
|
||
->setDescription('Retry failed WeChat trade sync records');
|
||
}
|
||
|
||
protected function execute(Input $input, Output $output)
|
||
{
|
||
$limit = intval($input->getOption('limit') ?: 50);
|
||
$count = (new WxShippingService())->retryFailed($limit);
|
||
$output->writeln('Retried ' . $count . ' sync record(s).');
|
||
if ($count === 0) {
|
||
$output->writeln('若无 pending/failed 记录,已成功同步的单需:php think shopro_wechat_trade:resync-shipping --sn=订单号');
|
||
$output->writeln('从未同步且已发货:php think shopro_wechat_trade:backfill --limit=100');
|
||
}
|
||
}
|
||
}
|