Commit f72f14c2 by 杨树贤

语法问题

parent ae12bf26
...@@ -41,8 +41,9 @@ class RefreshHistoryPurchaseUser extends Command ...@@ -41,8 +41,9 @@ class RefreshHistoryPurchaseUser extends Command
$this->info('========================================'); $this->info('========================================');
// 调用服务方法 // 调用服务方法
$result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num, function ($progress) { $self = $this;
$this->outputProgress($progress); $result = SupplierService::refreshHistoryPurchaseUserWithProgress($mode, $num, function ($progress) use ($self) {
$self->outputProgress($progress);
}); });
// 输出最终结果 // 输出最终结果
...@@ -60,11 +61,14 @@ class RefreshHistoryPurchaseUser extends Command ...@@ -60,11 +61,14 @@ class RefreshHistoryPurchaseUser extends Command
$this->info(''); $this->info('');
$this->warn('失败/跳过详情:'); $this->warn('失败/跳过详情:');
foreach ($result['debug_info'] as $info) { 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( $this->warn(sprintf(
' [ID:%d] %s - %s', ' [ID:%d] %s - %s',
$info['supplier_id'], $info['supplier_id'],
$info['supplier_name'] ?? '', $supplierName,
$info['fail_reason'] ?? $info['skip_reason'] ?? '' $failReason ? $failReason : $skipReason
)); ));
} }
} }
...@@ -78,19 +82,27 @@ class RefreshHistoryPurchaseUser extends Command ...@@ -78,19 +82,27 @@ class RefreshHistoryPurchaseUser extends Command
private function outputProgress($progress) private function outputProgress($progress)
{ {
$supplierId = $progress['supplier_id']; $supplierId = $progress['supplier_id'];
$supplierName = $progress['supplier_name']; $supplierName = isset($progress['supplier_name']) ? $progress['supplier_name'] : '';
$action = $progress['action'] ?? ''; $action = isset($progress['action']) ? $progress['action'] : '';
$status = $progress['status'] ?? ''; $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'); $statusColor = $status === 'success' ? 'info' : ($status === 'skip' ? 'comment' : 'error');
$this->$statusColor(sprintf( $message = sprintf(
' [%s] ID:%d %s - %s', ' [%s] ID:%d %s - %s',
$statusIcon, $statusIcon,
$supplierId, $supplierId,
$supplierName, $supplierName,
$action $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