科目映射表:导出文件名的时间戳也按平台时区(北京时间)

This commit is contained in:
yueyang 2026-09-29 18:04:31 +08:00 committed by yueyang
parent 1cd0bc8053
commit 57ea42ffb8
2 changed files with 5 additions and 5 deletions

View File

@ -343,7 +343,7 @@ class AccountMappingActions extends Controller
fputcsv($csv, $row);
}
fclose($csv);
}, '科目映射表_' . now()->format('Ymd_His') . '.csv', [
}, '科目映射表_' . $this->store->platformNow()->format('Ymd_His') . '.csv', [
'Content-Type' => 'text/csv; charset=UTF-8',
'Cache-Control' => 'private, no-store',
]);

View File

@ -362,11 +362,11 @@ class AccountMappingStore
}
/**
* 记录时间用的“现在”:固定按平台时区,不受页面请求里公司设置覆盖的影响。
* 本模块统一用的“现在”:固定按平台时区,不受页面请求里公司设置覆盖的影响。
*
* 直接用 now() 的话,页面操作写进日志的时间会差 7 小时(Europe/London)。
*/
private function logNow(): Carbon
public function platformNow(): Carbon
{
$timezone = trim((string) config('app.platform_timezone', ''));
@ -404,7 +404,7 @@ class AccountMappingStore
}
$json = json_encode(
['updated_at' => $this->logNow()->toDateTimeString(), 'rules' => array_values($rules)],
['updated_at' => $this->platformNow()->toDateTimeString(), 'rules' => array_values($rules)],
JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT
);
@ -421,7 +421,7 @@ class AccountMappingStore
$events = is_array($payload['events'] ?? null) ? $payload['events'] : [];
$events[] = array_merge([
'at' => $this->logNow()->toDateTimeString(),
'at' => $this->platformNow()->toDateTimeString(),
'action' => $action,
'id' => $id,
'before' => $before,