fix: 兼容 Windows PowerShell 支付宝定时任务 #798

Merged
yutu merged 1 commits from hotfix/92451-alipay-task-encoding into main 2026-10-30 20:15:00 +08:00
2 changed files with 11 additions and 4 deletions

View File

@ -1,4 +1,4 @@
#Requires -Version 5.1
#Requires -Version 5.1
[CmdletBinding(SupportsShouldProcess = $true)]
param(

View File

@ -1,4 +1,4 @@
[CmdletBinding()]
[CmdletBinding()]
param(
[ValidatePattern('^\d{4}-\d{2}-\d{2}$')]
[string] $Date,
@ -32,7 +32,10 @@ function Write-Log {
if (-not (Test-Path -LiteralPath $secretFile -PathType Leaf)) {
throw '缺少 runtime/private/敏感信息.md'
}
$secret = Get-Content -LiteralPath $secretFile -Raw
$secret = [System.IO.File]::ReadAllText(
$secretFile,
[System.Text.UTF8Encoding]::new($false)
)
$account = [regex]::Match($secret, '账号:([^\r\n]+)').Groups[1].Value.Trim()
$accountShort = [regex]::Match($secret, '支付宝账户简称:([^\r\n]+)').Groups[1].Value.Trim()
if ($account -notmatch '^\d{6,30}$') {
@ -57,7 +60,11 @@ if (-not [string]::IsNullOrWhiteSpace($InputFile)) {
Write-Log ('支付宝导出失败:' + ($exportOutput.Trim() -replace "`r?`n", ' | '))
throw '支付宝账单导出失败;未写入财务台账'
}
$state = Get-Content -LiteralPath (Join-Path $outputDir 'last-export.json') -Raw | ConvertFrom-Json
$statePath = Join-Path $outputDir 'last-export.json'
$state = [System.IO.File]::ReadAllText(
$statePath,
[System.Text.UTF8Encoding]::new($false)
) | ConvertFrom-Json
if (-not $state.ok -or [int] $state.rows -le 0) {
Write-Log '支付宝账单为空;未写入财务台账'
throw '支付宝账单为空;未写入财务台账'