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