weizong song 5 months ago
parent 9ea2faef21
commit 978b7699c1

@ -59,7 +59,7 @@ class FixOrderItemsPaidAt extends Command
if ($isDryRun) { if ($isDryRun) {
$this->warn("=== 试运行模式:将只显示预览信息,不会执行实际修复 ==="); $this->warn("=== 试运行模式:将只显示预览信息,不会执行实际修复 ===");
$this->newLine(); $this->line('');
} }
$this->info("开始" . ($isDryRun ? "预览" : "修复") . " {$serviceDateStr} 的订单项..."); $this->info("开始" . ($isDryRun ? "预览" : "修复") . " {$serviceDateStr} 的订单项...");
@ -92,9 +92,9 @@ class FixOrderItemsPaidAt extends Command
$bar = $this->output->createProgressBar($totalCount); $bar = $this->output->createProgressBar($totalCount);
$bar->start(); $bar->start();
} else { } else {
$this->newLine(); $this->line('');
$this->info("预览将要修复的记录:"); $this->info("预览将要修复的记录:");
$this->newLine(); $this->line('');
} }
foreach ($items as $item) { foreach ($items as $item) {
@ -104,7 +104,7 @@ class FixOrderItemsPaidAt extends Command
if (!$customerId) { if (!$customerId) {
if (!$isDryRun) { if (!$isDryRun) {
$this->newLine(); $this->line('');
$this->warn("订单项 {$item->id} 没有关联的客户,跳过"); $this->warn("订单项 {$item->id} 没有关联的客户,跳过");
$bar->advance(); $bar->advance();
} }
@ -157,7 +157,7 @@ class FixOrderItemsPaidAt extends Command
'created_at' => $serviceDateEnd 'created_at' => $serviceDateEnd
]); ]);
} else { } else {
$this->newLine(); $this->line('');
$this->warn("订单项 {$item->id} 没有找到关联的 balance 记录"); $this->warn("订单项 {$item->id} 没有找到关联的 balance 记录");
} }
@ -168,7 +168,7 @@ class FixOrderItemsPaidAt extends Command
} catch (\Exception $e) { } catch (\Exception $e) {
DB::rollBack(); DB::rollBack();
$errorCount++; $errorCount++;
$this->newLine(); $this->line('');
$this->error("修复订单项 {$item->id} 失败:" . $e->getMessage()); $this->error("修复订单项 {$item->id} 失败:" . $e->getMessage());
Log::error("修复订单项 {$item->id} 失败:" . $e->getMessage()); Log::error("修复订单项 {$item->id} 失败:" . $e->getMessage());
} }
@ -195,7 +195,7 @@ class FixOrderItemsPaidAt extends Command
} catch (\Exception $e) { } catch (\Exception $e) {
$errorCount++; $errorCount++;
if (!$isDryRun) { if (!$isDryRun) {
$this->newLine(); $this->line('');
$this->error("处理订单项 {$item->id} 时出错:" . $e->getMessage()); $this->error("处理订单项 {$item->id} 时出错:" . $e->getMessage());
} }
Log::error("处理订单项 {$item->id} 时出错:" . $e->getMessage()); Log::error("处理订单项 {$item->id} 时出错:" . $e->getMessage());
@ -209,12 +209,13 @@ class FixOrderItemsPaidAt extends Command
if (!$isDryRun) { if (!$isDryRun) {
$bar->finish(); $bar->finish();
} }
$this->newLine(2); $this->line('');
$this->line('');
// 试运行模式:显示详细预览信息 // 试运行模式:显示详细预览信息
if ($isDryRun && !empty($previewData)) { if ($isDryRun && !empty($previewData)) {
$this->info("=== 预览详情 ==="); $this->info("=== 预览详情 ===");
$this->newLine(); $this->line('');
// 显示满足条件的记录 // 显示满足条件的记录
$willFix = array_filter($previewData, function($item) { $willFix = array_filter($previewData, function($item) {
@ -223,7 +224,7 @@ class FixOrderItemsPaidAt extends Command
if (!empty($willFix)) { if (!empty($willFix)) {
$this->info("满足条件将修复的记录(" . count($willFix) . " 条):"); $this->info("满足条件将修复的记录(" . count($willFix) . " 条):");
$this->newLine(); $this->line('');
$this->table( $this->table(
['订单项ID', '订单ID', '客户ID', '服务日期', '金额', '当时余额', '原paid_at', '新paid_at', '有balance记录'], ['订单项ID', '订单ID', '客户ID', '服务日期', '金额', '当时余额', '原paid_at', '新paid_at', '有balance记录'],
array_map(function($item) { array_map(function($item) {
@ -240,7 +241,7 @@ class FixOrderItemsPaidAt extends Command
]; ];
}, $willFix) }, $willFix)
); );
$this->newLine(); $this->line('');
} }
// 显示跳过的记录 // 显示跳过的记录
@ -250,7 +251,7 @@ class FixOrderItemsPaidAt extends Command
if (!empty($willSkip)) { if (!empty($willSkip)) {
$this->warn("不满足条件将跳过的记录(" . count($willSkip) . " 条):"); $this->warn("不满足条件将跳过的记录(" . count($willSkip) . " 条):");
$this->newLine(); $this->line('');
$this->table( $this->table(
['订单项ID', '订单ID', '客户ID', '服务日期', '金额', '当时余额', '原paid_at', '跳过原因'], ['订单项ID', '订单ID', '客户ID', '服务日期', '金额', '当时余额', '原paid_at', '跳过原因'],
array_map(function($item) { array_map(function($item) {
@ -266,7 +267,7 @@ class FixOrderItemsPaidAt extends Command
]; ];
}, $willSkip) }, $willSkip)
); );
$this->newLine(); $this->line('');
} }
} }
@ -283,7 +284,7 @@ class FixOrderItemsPaidAt extends Command
); );
if ($isDryRun) { if ($isDryRun) {
$this->newLine(); $this->line('');
$this->comment("提示:这是试运行模式,没有执行实际修复。"); $this->comment("提示:这是试运行模式,没有执行实际修复。");
$this->comment("要执行实际修复,请运行命令时不加 --dry-run 参数。"); $this->comment("要执行实际修复,请运行命令时不加 --dry-run 参数。");
} }

Loading…
Cancel
Save