This commit is contained in:
Your Name
2026-08-31 15:17:34 +08:00
parent ed48f8be31
commit 456dd667df
439 changed files with 5720 additions and 422 deletions
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace app\command;
use app\common\service\qywx\QywxPromotionMediaService;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class QywxRefreshPromotionMedia extends Command
{
protected function configure()
{
$this->setName('qywx:refresh-promotion-media')->setDescription('预热/刷新已保存欢迎语使用的三天临时素材');
}
protected function execute(Input $input, Output $output): int
{
$result = (new QywxPromotionMediaService())->refreshReferenced(100);
$output->writeln('QYWX_PROMOTION_MEDIA ' . json_encode($result));
return $result['failed'] > 0 ? 1 : 0;
}
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace app\command;
use app\common\service\qywx\QywxPromotionAutomationService;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class QywxRetryPromotionAutomation extends Command
{
protected function configure()
{
$this->setName('qywx:retry-promotion-automation')
->setDescription('补偿推广标签/备注/资料同步;过期欢迎语仅记过期,不补发');
}
protected function execute(Input $input, Output $output): int
{
$result = (new QywxPromotionAutomationService())->retryPending(100);
$output->writeln('QYWX_PROMOTION_RETRY ' . json_encode($result));
return $result['failed'] > 0 ? 1 : 0;
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace app\command;
use app\common\service\qywx\QywxPromotionAutomationService;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\console\input\Option;
/** Supervisor/systemd常驻:只消费欢迎语,不运行慢速客户同步或素材上传。 */
class QywxWorkPromotionAutomation extends Command
{
protected function configure()
{
$this->setName('qywx:work-promotion-automation')
->setDescription('秒级消费推广欢迎语(需常驻;欢迎码仅20秒有效)')
->addOption('once', null, Option::VALUE_NONE, '只消费一轮');
}
protected function execute(Input $input, Output $output): int
{
$running = true;
if (function_exists('pcntl_async_signals')) {
pcntl_async_signals(true);
pcntl_signal(SIGTERM, static function () use (&$running): void { $running = false; });
pcntl_signal(SIGINT, static function () use (&$running): void { $running = false; });
}
$service = new QywxPromotionAutomationService();
do {
try {
$result = $service->processWelcomes(100);
if ($result['selected'] > 0 || $input->getOption('once')) {
$output->writeln('QYWX_PROMOTION_WELCOME ' . json_encode($result));
}
} catch (\Throwable) {
// 不输出异常堆栈/SQL/请求,避免把短期凭证带进守护进程日志。
$output->writeln('QYWX_PROMOTION_WELCOME worker storage unavailable');
if ($input->getOption('once')) {
return 1;
}
}
if (!$input->getOption('once') && $running) {
usleep(250000);
}
} while (!$input->getOption('once') && $running);
return 0;
}
}