CaiWuXiTong/app/Console/Commands/SyncDingOnlineDaifaPrice.php
limeng a9c85b2a9f 线上代发价格:接入钉钉流程(全部已完成)+ 标签 + 商品编码 + 明细展开与SQL分页
- 按流程状态=已完成同步全部记录(去掉收款人过滤)
- 明细表「收款费用明细」JSON 解码并按行展开为多行
- 新增「标签」列:收款人=宁波顾家望业家居有限公司→刘萧代发,其余→1688代发
- 「料号」列改为「商品编码」(值留空)
- 仓库改为数据库层分页 + SQL 聚合,避免大数据量拖垮页面

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-09 18:38:35 +08:00

50 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Modules\EcommerceFinance\Services\DingPayableWorkflowMirrorSynchronizer;
use Throwable;
class SyncDingOnlineDaifaPrice extends Command
{
protected $signature = 'business-mirror:sync-ding-online-daifa-price
{--full : 执行或继续首次全量同步}
{--batch= : 每批流程数量}
{--max-batches= : 本轮最多批次数,0 表示直到完成}';
protected $description = '同步钉钉线上代发业务报销流程到共享业务镜像库';
public function handle(DingPayableWorkflowMirrorSynchronizer $synchronizer): int
{
if (! (bool) config('upstream_mirrors.refresh_enabled', false) && ! $this->option('full')) {
return self::SUCCESS;
}
try {
$result = $synchronizer
->forConfigKey('ding_online_daifa_price')
->sync(
(bool) $this->option('full'),
$this->option('batch') === null ? null : (int) $this->option('batch'),
$this->option('max-batches') === null ? null : (int) $this->option('max-batches'),
);
} catch (Throwable $exception) {
Log::error('钉钉线上代发价格流程镜像同步失败。', ['exception' => $exception::class]);
$this->error('钉钉线上代发价格流程同步失败,已保留上一版共享数据。');
return self::FAILURE;
}
$this->info(sprintf(
'%s:本轮 %d 批,累计处理 %d 条明细。',
$result['status'] === 'succeeded' ? '同步完成' : '同步进行中',
$result['batches'],
$result['rows'],
));
return self::SUCCESS;
}
}