feat(server): 同步虾皮完整颜色尺码并一次性匹配 (#290)

图搜采集成功并自动关联后,拉取该虾皮商品的完整颜色尺码清单合并进档案,
再触发一次匹配。此后同一虾皮商品的其它颜色 SYB 订单无需再采集、再点匹配。

- 新增 shopeespec 叶子包,凭据只从 GOAUTO_ERPGO_BASE_URL/GOAUTO_ERPGO_APIKEY
  读取;错误文本不携带 URL,避免 apikey 流进日志。
- 写入档案前经 sybspec.StripAnnotations 剥离 【...】,与 SYB 明细同源,
  否则 confirmedMappings 查不到、映射全部落空。
- 标记记录同步时对着哪个 PDD 商品(spec_sync_pdd_product_id),不是布尔值,
  重新关联时自动失效。
- 已完整同步的商品再次图搜时返回 IMAGE_SEARCH_SPEC_SYNCED。
- 迁移只加列不回填:既有档案仍是从 SYB 明细增量累积的,不能假装已同步。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NTDbDcwbDw1TSAcE6wfh2F
This commit is contained in:
QiuSW
2026-09-16 10:33:53 +08:00
co-authored by Claude Opus 5
parent a27db5f960
commit 5b3c8df3bc
10 changed files with 546 additions and 4 deletions
+36
View File
@@ -97,6 +97,31 @@ function Read-DatabaseConfig {
}
}
function Read-ErpGoConfig {
param([string]$Path)
# Optional section. Absent or incomplete means the Shopee spec sync stays
# off; the server treats that as "skip", not as an error (#290).
$values = @{}
$insideSection = $false
foreach ($line in Get-Content -LiteralPath $Path) {
if ($line -match '^\s*(#.*)?$') {
continue
}
if ($line -match '^erpgo\s*:\s*$') {
$insideSection = $true
continue
}
if ($insideSection -and $line -match '^\S') {
break
}
if ($insideSection -and $line -match '^\s+(baseUrl|apikey)\s*:\s*(.*?)\s*$') {
$values[$Matches[1]] = ConvertFrom-YamlScalar $Matches[2]
}
}
return $values
}
function Read-PortConfig {
param([string]$Path)
@@ -169,6 +194,7 @@ try {
$ConfigPath = [IO.Path]::GetFullPath($ConfigPath)
$databaseConfig = Read-DatabaseConfig $ConfigPath
$portConfig = Read-PortConfig $ConfigPath
$erpgoConfig = Read-ErpGoConfig $ConfigPath
if (-not $PSBoundParameters.ContainsKey('DatabaseHost')) {
$DatabaseHost = $databaseConfig.Host
@@ -219,6 +245,14 @@ try {
$env:GOAUTO_DB_DRIVER = "mysql"
$env:GOAUTO_DB_DSN = "${DatabaseUser}:${plainPassword}@tcp(${DatabaseHost}:${DatabasePort})/${DatabaseName}?charset=utf8mb4&parseTime=True&loc=Local&timeout=5s"
$env:GOAUTO_SERVER_PORT = [string]$portConfig.Server
# Shopee spec service. The key never reaches the repo: config.yaml is
# gitignored and the server only ever reads the environment (#290).
if ($erpgoConfig.ContainsKey('baseUrl') -and -not [string]::IsNullOrWhiteSpace([string]$erpgoConfig.baseUrl)) {
$env:GOAUTO_ERPGO_BASE_URL = [string]$erpgoConfig.baseUrl
}
if ($erpgoConfig.ContainsKey('apikey') -and -not [string]::IsNullOrWhiteSpace([string]$erpgoConfig.apikey)) {
$env:GOAUTO_ERPGO_APIKEY = [string]$erpgoConfig.apikey
}
Push-Location $serverDirectory
try {
@@ -272,5 +306,7 @@ finally {
Remove-Item Env:GOAUTO_DB_DRIVER -ErrorAction SilentlyContinue
Remove-Item Env:GOAUTO_SERVER_PORT -ErrorAction SilentlyContinue
Remove-Item Env:GOAUTO_CONFIG -ErrorAction SilentlyContinue
Remove-Item Env:GOAUTO_ERPGO_BASE_URL -ErrorAction SilentlyContinue
Remove-Item Env:GOAUTO_ERPGO_APIKEY -ErrorAction SilentlyContinue
$plainPassword = $null
}