# 京粉订单 goodsInfo 回填脚本（需先部署 Jarvis_java + ruoyi-java，并已登录获取 token）
# 用法示例见下方 $body

param(
    [string]$BaseUrl = "https://jarvis.van333.cn/jarvis-api",
    [string]$Token = "",
    [string]$OrderIds = "",
    [switch]$Missing,
    [int]$Limit = 100
)

$body = @{}
if ($Missing) {
    $body.missing = $true
    $body.limit = $Limit
} elseif ($OrderIds) {
    $body.orderIds = $OrderIds
} else {
    Write-Host "请指定 -OrderIds '订单号1,订单号2' 或 -Missing"
    exit 1
}

$headers = @{ "Content-Type" = "application/json" }
if ($Token) {
    $headers.Authorization = "Bearer $Token"
}

$uri = "$BaseUrl/system/jdorder/orderRows/backfillGoodsInfo"
Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body ($body | ConvertTo-Json)
