Commit f72f14c2 by 杨树贤

语法问题

parent ae12bf26
......@@ -41,8 +41,9 @@ class RefreshHistoryPurchaseUser extends Command
$this->info('========================================');
// 调用服务方法
$result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num, function ($progress) {
$this->outputProgress($progress);
$self = $this;
$result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num, function ($progress) use ($self) {
$self->outputProgress($progress);
});
// 输出最终结果
......@@ -60,11 +61,14 @@ class RefreshHistoryPurchaseUser extends Command
$this->info('');
$this->warn('失败/跳过详情:');
foreach ($result['debug_info'] as $info) {
$failReason = isset($info['fail_reason']) ? $info['fail_reason'] : '';
$skipReason = isset($info['skip_reason']) ? $info['skip_reason'] : '';
$supplierName = isset($info['supplier_name']) ? $info['supplier_name'] : '';
$this->warn(sprintf(
' [ID:%d] %s - %s',
$info['supplier_id'],
$info['supplier_name'] ?? '',
$info['fail_reason'] ?? $info['skip_reason'] ?? ''
$supplierName,
$failReason ? $failReason : $skipReason
));
}
}
......@@ -78,19 +82,27 @@ class RefreshHistoryPurchaseUser extends Command
private function outputProgress($progress)
{
$supplierId = $progress['supplier_id'];
$supplierName = $progress['supplier_name'];
$action = $progress['action'] ?? '';
$status = $progress['status'] ?? '';
$supplierName = isset($progress['supplier_name']) ? $progress['supplier_name'] : '';
$action = isset($progress['action']) ? $progress['action'] : '';
$status = isset($progress['status']) ? $progress['status'] : '';
$statusIcon = $status === 'success' ? '✓' : ($status === 'skip' ? '-' : '✗');
$statusIcon = $status === 'success' ? 'OK' : ($status === 'skip' ? '--' : 'XX');
$statusColor = $status === 'success' ? 'info' : ($status === 'skip' ? 'comment' : 'error');
$this->$statusColor(sprintf(
$message = sprintf(
' [%s] ID:%d %s - %s',
$statusIcon,
$supplierId,
$supplierName,
$action
));
);
if ($statusColor === 'info') {
$this->info($message);
} elseif ($statusColor === 'comment') {
$this->comment($message);
} else {
$this->error($message);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment