# Login
$loginBody = '{"username":"admin","password":"admin123","tenantCode":"T202605253515"}'
$resp = Invoke-RestMethod -Uri 'http://localhost:8006/login' -Method POST -Body $loginBody -Headers @{'Content-Type'='application/json; charset=utf-8'}
$token = $resp.token
$authHeaders = @{'Authorization'="Bearer $token"; 'tenant-code'='T202605253515'; 'X-Frontend-Type'='company'}

# Test correct paths (matching what frontend actually calls)
$correctPaths = @(
  '/index/statistics/rechargeComsumption',
  '/index/statistics/trafficLog',
  '/index/statistics/smsBalance',
  '/index/statistics/dealerAggregated',
  '/crm/statistics/customer',
  '/his/redPacket/list',
  '/store/storeStatistics/list',
  '/store/store/statistics/storeOrder'
)

foreach ($p in $correctPaths) {
  try {
    $r = Invoke-WebRequest -Uri "http://localhost:8006$p" -Method GET -Headers $authHeaders -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
    $body = $r.Content | ConvertFrom-Json
    Write-Output "OK $p -> code=$($body.code)"
  } catch {
    $statusCode = 0
    if ($_.Exception.Response) { $statusCode = [int]$_.Exception.Response.StatusCode }
    Write-Output "$statusCode $p"
  }
}
