|
@@ -4,11 +4,13 @@
|
|
|
|
|
|
|
|
.DESCRIPTION
|
|
.DESCRIPTION
|
|
|
配套 docs/M5_seed.sql 使用:先在试点库执行种子,再启动后端(STORAGE_TYPE=local),最后跑本脚本。
|
|
配套 docs/M5_seed.sql 使用:先在试点库执行种子,再启动后端(STORAGE_TYPE=local),最后跑本脚本。
|
|
|
- 覆盖 12 步全链路:管理端登录 → 机构核验 → 身份自举+加成员 → 建批次/发布 → 报名 → 发码签到
|
|
|
|
|
- → 学时补跑 → 学时台账 → 派单建单(建单留痕)→ 指派(资质闸口放行/拒绝)→ 四层评价 → 晋升 + 证据包。
|
|
|
|
|
|
|
+ 覆盖 17 步全链路:管理端登录 → 机构核验 → 身份自举+加成员 → 建批次/发布 → 报名 → 发码签到
|
|
|
|
|
+ → 学时补跑 → 学时台账 → 派单建单(建单留痕+金额恒等)→ 指派(资质闸口放行/拒绝)→ 四层评价 → 晋升 + 证据包
|
|
|
|
|
+ → 履约链(到岗/完成/客户确认)→ 客户评价 → 六契约端点。
|
|
|
|
|
|
|
|
.NOTES
|
|
.NOTES
|
|
|
- 1) 毕业口径红线:学时一律「分钟」整数(120 而非 2.0),本脚本在 S6/S8 强校验。
|
|
|
|
|
|
|
+ 1) 毕业口径红线 1:学时一律「分钟」整数(120 而非 2.0),本脚本在 S6/S8/S17 强校验。
|
|
|
|
|
+ 1b) 毕业口径红线 2:金额恒等 amount = platform_fee + staff_income(整数分),S9 反例强校验。
|
|
|
2) 登录自举:wechat test-mode(application.yml wechat.test-mode=true)下 openid = 'test_' + code,
|
|
2) 登录自举:wechat test-mode(application.yml wechat.test-mode=true)下 openid = 'test_' + code,
|
|
|
命中 seed 预置的 test_m5t1 / test_m5none / test_m5stu 三个用户,无需人工取 userId。
|
|
命中 seed 预置的 test_m5t1 / test_m5none / test_m5stu 三个用户,无需人工取 userId。
|
|
|
3) 组织派单只走 assign,不调 /api/order/accept —— claimOrder 的 CAS 是
|
|
3) 组织派单只走 assign,不调 /api/order/accept —— claimOrder 的 CAS 是
|
|
@@ -17,6 +19,8 @@
|
|
|
4) STORAGE_TYPE=local:默认 storage.type=jdcloud 会写生产 OSS bucket「aimate」;
|
|
4) STORAGE_TYPE=local:默认 storage.type=jdcloud 会写生产 OSS bucket「aimate」;
|
|
|
冒烟/测试启动必须 STORAGE_TYPE=local 让证据包落 ./uploads,严禁污染生产 OSS。
|
|
冒烟/测试启动必须 STORAGE_TYPE=local 让证据包落 ./uploads,严禁污染生产 OSS。
|
|
|
5) 兼容 PowerShell 5.1,仅依赖 Invoke-RestMethod(不依赖 curl.exe / PS7)。
|
|
5) 兼容 PowerShell 5.1,仅依赖 Invoke-RestMethod(不依赖 curl.exe / PS7)。
|
|
|
|
|
+ 6) S13-S17 履约链非幂等(状态机单向):S9 每轮新单驱动,反例单另建一次性 accepted 单;
|
|
|
|
|
+ S9 金额恒等反例会再建一单(死于 MoneyCheck.check,不落库)。
|
|
|
|
|
|
|
|
.EXAMPLE
|
|
.EXAMPLE
|
|
|
powershell -ExecutionPolicy Bypass -File docs/M5_smoke.ps1 -BaseUrl http://127.0.0.1:9083
|
|
powershell -ExecutionPolicy Bypass -File docs/M5_smoke.ps1 -BaseUrl http://127.0.0.1:9083
|
|
@@ -128,6 +132,18 @@ function Begin-Step([string]$Name) {
|
|
|
Write-Host ("`n===== S{0} {1} =====" -f $script:Step, $Name) -ForegroundColor Cyan
|
|
Write-Host ("`n===== S{0} {1} =====" -f $script:Step, $Name) -ForegroundColor Cyan
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function Fix-MojibakeText([string]$s) {
|
|
|
|
|
+ <# IRM 对 application/json 无 charset 的中文响应按 Latin-1 解码致乱码(S10 同源缺陷)。
|
|
|
|
|
+ 仅对已知含中文的出参字段做 Latin-1→UTF-8 roundtrip;调用方仅用修复值做展示/打印,
|
|
|
|
|
+ 不做 -match 断言(编码不可控时宁可只断言字段存在性)。#>
|
|
|
|
|
+ if ([string]::IsNullOrEmpty($s)) { return '' }
|
|
|
|
|
+ try {
|
|
|
|
|
+ $fixed = [Text.Encoding]::UTF8.GetString([Text.Encoding]::GetEncoding(28591).GetBytes($s))
|
|
|
|
|
+ if ($fixed -match '[\u4e00-\u9fff]') { return $fixed }
|
|
|
|
|
+ } catch {}
|
|
|
|
|
+ return $s
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function Test-MinuteInteger($v) {
|
|
function Test-MinuteInteger($v) {
|
|
|
<# 分钟整数红线:值必须为非负整数(拒绝小时/浮点/负数)#>
|
|
<# 分钟整数红线:值必须为非负整数(拒绝小时/浮点/负数)#>
|
|
|
if ($null -eq $v) { return $false }
|
|
if ($null -eq $v) { return $false }
|
|
@@ -409,13 +425,28 @@ $dispatchId = $resp.data.dispatchId
|
|
|
Assert-True ($null -ne $dispatchId -and [long]$dispatchId -gt 0) '建单留痕 dispatchId 非空(created 行同事务落库)' $resp ("orderId=$orderId orderNo=$orderNo dispatchId=$dispatchId")
|
|
Assert-True ($null -ne $dispatchId -and [long]$dispatchId -gt 0) '建单留痕 dispatchId 非空(created 行同事务落库)' $resp ("orderId=$orderId orderNo=$orderNo dispatchId=$dispatchId")
|
|
|
Assert-True ([string]$resp.data.status -eq 'pending') '建单只置 pending(不置 accepted)' $resp ("status=" + $resp.data.status)
|
|
Assert-True ([string]$resp.data.status -eq 'pending') '建单只置 pending(不置 accepted)' $resp ("status=" + $resp.data.status)
|
|
|
|
|
|
|
|
-# 派单列表可见
|
|
|
|
|
|
|
+# 金额恒等红线(HEAD 5aad440 已落地 MoneyCheck.check):amount<platformFee → 硬拒绝「金额口径不正确」
|
|
|
|
|
+$negMoney = Invoke-Api -Method 'POST' -Path '/api/admin/org/dispatch/create' -Token $adminToken -Body @{
|
|
|
|
|
+ orgId = $orgId; familyName = '金额反例户'; contactPhone = '13900000111'
|
|
|
|
|
+ address = '湖北省黄冈市浠水县试点路 3 号'; serviceType = 'cleaning'
|
|
|
|
|
+ orderDate = '2026-12-05'; amount = 1000; platformFee = 1800; remark = 'M5 金额恒等反例'
|
|
|
|
|
+}
|
|
|
|
|
+$negMoneyMsg = if ($negMoney.message) { [string]$negMoney.message } else { '' }
|
|
|
|
|
+Assert-True (($negMoney.code -ne 200) -and ($negMoneyMsg -match '金额口径不正确')) '金额恒等反例 amount(1000)<platformFee(1800) 被拒' $negMoney ("msg=$negMoneyMsg")
|
|
|
|
|
+
|
|
|
|
|
+# 派单列表可见 + 金额恒等正例(staff_income = amount - platform_fee = 16200)
|
|
|
$resp = Invoke-Api -Method 'POST' -Path '/api/admin/org/dispatch/list' -Token $adminToken -Body @{ orgId = $orgId; page = 1; size = 10 }
|
|
$resp = Invoke-Api -Method 'POST' -Path '/api/admin/org/dispatch/list' -Token $adminToken -Body @{ orgId = $orgId; page = 1; size = 10 }
|
|
|
$seen = $false
|
|
$seen = $false
|
|
|
|
|
+$identityOk = $false
|
|
|
foreach ($row in (Get-Arr $resp.data.list)) {
|
|
foreach ($row in (Get-Arr $resp.data.list)) {
|
|
|
- if ([long]$row.id -eq $orderId) { $seen = $true; break }
|
|
|
|
|
|
|
+ if ([long]$row.id -eq $orderId) {
|
|
|
|
|
+ $seen = $true
|
|
|
|
|
+ $identityOk = ([long]$row.amount -eq 18000 -and [long]$row.platformFee -eq 1800 -and [long]$row.staffIncome -eq 16200)
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
Assert-True ($resp.code -eq 200 -and $seen) 'dispatch/list 可见新单' $resp ''
|
|
Assert-True ($resp.code -eq 200 -and $seen) 'dispatch/list 可见新单' $resp ''
|
|
|
|
|
+Assert-True $identityOk '金额恒等正例 staff_income(16200) = amount(18000) - platform_fee(1800)' $resp ''
|
|
|
|
|
|
|
|
# ============================================================
|
|
# ============================================================
|
|
|
# S10 指派(资质闸口:m5none 拒绝 / m5t1 放行);只走 assign 不走 accept
|
|
# S10 指派(资质闸口:m5none 拒绝 / m5t1 放行);只走 assign 不走 accept
|
|
@@ -527,11 +558,267 @@ if ($taskStatus -eq 'done') {
|
|
|
Write-Host ("S{0} [INFO] 轮询结束时 status={1}(异步导出未完成,不阻断;可手动复跑观察 done)" -f $script:Step, $taskStatus) -ForegroundColor Yellow
|
|
Write-Host ("S{0} [INFO] 轮询结束时 status={1}(异步导出未完成,不阻断;可手动复跑观察 done)" -f $script:Step, $taskStatus) -ForegroundColor Yellow
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+# S13-S17 履约链 + 评价 + 六契约端点(M5 试点上线冒烟扩写)
|
|
|
|
|
+# 前提:S9 建单 + S10 指派成功($orderId 已由 worker=本人置 accepted)。
|
|
|
|
|
+# 契约来源(2026-11-26 实读源码,非文档假设):
|
|
|
|
|
+# /api/order/arrive body{lat,lng,photo} accepted→arrived;文案「请先接单再打卡」
|
|
|
|
|
+# /api/order/finish body{items,photos} arrived/doing→done,返回 6 位 clientConfirmCode
|
|
|
|
|
+# /api/order/confirm body{code} done→confirmed;错码「确认码不正确」;重复「当前工单无需确认」
|
|
|
|
|
+# /api/eval/submit body{orderId,score(1-5),comment} ★only-after-confirmed,uk(order_id) 幂等,必须本人
|
|
|
|
|
+# 六契约端点实为管理端前缀:/api/admin/org/member/disable、/api/admin/cohort/list、
|
|
|
|
|
+# /api/admin/attendance/list、/api/admin/credit/account/list、
|
|
|
|
|
+# /api/admin/credit/ledger/detail、/api/admin/credit/ledger/objected
|
|
|
|
|
+# 注意:本步非幂等(状态机单向),重跑同一库须重新 dispatch/create 一单。
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+$skipFulfillment = ($null -eq $orderId -or [long]$orderId -le 0)
|
|
|
|
|
+if ($skipFulfillment) {
|
|
|
|
|
+ Write-Host "`n[WARN] S9/S10 未产出可用工单(orderId 为空),跳过 S13-S17 履约链与契约端点。" -ForegroundColor Yellow
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+# S13 履约① 到岗打卡 /api/order/arrive
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+if (-not $skipFulfillment) {
|
|
|
|
|
+ Begin-Step '履约① 到岗打卡 /api/order/arrive(accepted→arrived)'
|
|
|
|
|
+
|
|
|
|
|
+ # 反例:未到岗直接 finish → 状态门禁拒绝(门禁先于业务写入,本调用不改库)
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/finish' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; items = @(); photos = ''
|
|
|
|
|
+ }
|
|
|
|
|
+ $badFinish = if ($resp.message) { [string]$resp.message } else { '' }
|
|
|
|
|
+ Assert-True (($resp.code -ne 200) -and ($badFinish -match '请先完成到岗打卡')) '反例:未到岗即 finish 被门禁拒绝' $resp ("msg=$badFinish")
|
|
|
|
|
+
|
|
|
|
|
+ # 正例:定位 + 门牌照
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/arrive' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; lat = 30.521; lng = 114.393; photo = 'm5/smoke-arrive.jpg'
|
|
|
|
|
+ }
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and $resp.data -eq $true) 'worker 本人打卡' $resp ''
|
|
|
|
|
+
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/detail' -Token $t1Token -Body @{ orderId = $orderId }
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and [string]$resp.data.status -eq 'arrived') '工单状态 → arrived' $resp ("status=" + $resp.data.status)
|
|
|
|
|
+ Assert-True ($resp.data.arriveAt) 'arriveAt 服务端时间戳已落库' $resp ("arriveAt=" + $resp.data.arriveAt)
|
|
|
|
|
+ Assert-True ($resp.data.arrivePhoto) 'arrivePhoto 门牌照已落库' $resp ("arrivePhoto=" + $resp.data.arrivePhoto)
|
|
|
|
|
+
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/mine' -Token $t1Token -Body @{}
|
|
|
|
|
+ # 契约实测:mine 分组键为 today/pending/doing/done,accepted/arrived/doing 统一归入 'doing'(进行中),
|
|
|
|
|
+ # 无独立 'arrived' 分组;断言按 doing 分组复核。
|
|
|
|
|
+ $seenMine = $false
|
|
|
|
|
+ foreach ($g in (Get-Arr $resp.data)) {
|
|
|
|
|
+ if ($g.key -eq 'doing') {
|
|
|
|
|
+ foreach ($it in (Get-Arr $g.list)) { if ([long]$it.id -eq $orderId) { $seenMine = $true; break } }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and $seenMine) 'worker /api/order/mine 该单出现在 doing(进行中)分组' $resp ''
|
|
|
|
|
+
|
|
|
|
|
+ # 归属越权反例:m5none 非该单 worker(arrive 与 detail 均按 worker_id 本人校验)
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/arrive' -Token $noneToken -Body @{
|
|
|
|
|
+ orderId = $orderId; lat = 30.5; lng = 114.4
|
|
|
|
|
+ }
|
|
|
|
|
+ Assert-True ($resp.code -ne 200) '反例:非本人(m5none)打卡被拒' $resp ("msg=" + $resp.message)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+# S14 履约② 完成服务 /api/order/finish(生成 6 位客户确认码)
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+if (-not $skipFulfillment) {
|
|
|
|
|
+ Begin-Step '履约② 完成服务 /api/order/finish(arrived→done + 6 位确认码)'
|
|
|
|
|
+ $items = @(@{ name = '深度保洁'; done = 1 }, @{ name = '消毒'; done = 1 })
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/finish' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId
|
|
|
|
|
+ items = $items
|
|
|
|
|
+ photos = 'm5/smoke-fin1.jpg,m5/smoke-fin2.jpg'
|
|
|
|
|
+ }
|
|
|
|
|
+ $confirmCode = ''
|
|
|
|
|
+ if ($resp.data -and $resp.data.clientConfirmCode) { $confirmCode = [string]$resp.data.clientConfirmCode }
|
|
|
|
|
+ # 契约实测:finish 响应体由 toVO(更新前实体) 生成,其 status 仍为旧值 arrived、finishAt 为空
|
|
|
|
|
+ # (ServiceOrderService.finish 行 203,后端缺陷已报 team-lead);真实库状态须用 detail 复核。
|
|
|
|
|
+ # 故本步只断言「受理成功 + 6 位码 + photos 回显」,状态/时间戳交给 detail 复核,避免假红。
|
|
|
|
|
+ Assert-True ($resp.code -eq 200) 'worker 完成服务受理' $resp ("clientConfirmCode=$confirmCode")
|
|
|
|
|
+ Assert-True ($confirmCode.Length -eq 6 -and $confirmCode -match '^[0-9]{6}$') '生成 6 位数字客户确认码' $resp ("clientConfirmCode=$confirmCode")
|
|
|
|
|
+ $finPhotos = @($resp.data.finishPhotos)
|
|
|
|
|
+ Assert-True ($finPhotos.Count -eq 2) 'finishPhotos 回显 2 张' $resp ("count=" + $finPhotos.Count)
|
|
|
|
|
+
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/detail' -Token $t1Token -Body @{ orderId = $orderId }
|
|
|
|
|
+ $detailCode = if ($resp.data.clientConfirmCode) { [string]$resp.data.clientConfirmCode } else { '' }
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and $resp.data.status -eq 'done' -and $detailCode -eq $confirmCode) '工单详情复核:done + 同码' $resp ("code=$detailCode")
|
|
|
|
|
+ Assert-True ($resp.data.finishAt) '详情 finishAt 服务端时间戳已落库' $resp ("finishAt=" + $resp.data.finishAt)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+# S15 履约③ 客户确认 /api/order/confirm(正反例)
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+if (-not $skipFulfillment) {
|
|
|
|
|
+ Begin-Step '履约③ 客户确认 /api/order/confirm(done→confirmed 正反例)'
|
|
|
|
|
+
|
|
|
|
|
+ # 反例:错码 → 拒绝(不落状态)
|
|
|
|
|
+ $wrongCode = if ($confirmCode -match '^1') { '200000' } else { '100000' }
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/confirm' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; code = $wrongCode
|
|
|
|
|
+ }
|
|
|
|
|
+ $badCodeMsg = if ($resp.message) { [string]$resp.message } else { '' }
|
|
|
|
|
+ Assert-True (($resp.code -ne 200) -and ($badCodeMsg -match '确认码不正确')) '反例:错误确认码被拒' $resp ("msg=$badCodeMsg")
|
|
|
|
|
+ $chk = Invoke-Api -Method 'POST' -Path '/api/order/detail' -Token $t1Token -Body @{ orderId = $orderId }
|
|
|
|
|
+ Assert-True ([string]$chk.data.status -eq 'done') '错码后状态未漂移(仍 done)' $chk ("status=" + $chk.data.status)
|
|
|
|
|
+
|
|
|
|
|
+ # 正例:正确码 → confirmed
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/confirm' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; code = $confirmCode
|
|
|
|
|
+ }
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and $resp.data -eq $true) '正确确认码核销 → confirmed' $resp ''
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/detail' -Token $t1Token -Body @{ orderId = $orderId }
|
|
|
|
|
+ Assert-True ([string]$resp.data.status -eq 'confirmed') '工单详情 → confirmed(终态)' $resp ("status=" + $resp.data.status)
|
|
|
|
|
+
|
|
|
|
|
+ # 反例:重复确认 → 当前工单无需确认
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/confirm' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; code = $confirmCode
|
|
|
|
|
+ }
|
|
|
|
|
+ $dupMsg = if ($resp.message) { [string]$resp.message } else { '' }
|
|
|
|
|
+ Assert-True (($resp.code -ne 200) -and ($dupMsg -match '当前工单无需确认')) '反例:重复确认被拒(终态不可重入)' $resp ("msg=$dupMsg")
|
|
|
|
|
+
|
|
|
|
|
+ # 终态入账:已确认单计入累计所得(金额为整数分,staff_income=16200 分)
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/earnings' -Token $t1Token -Body @{}
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and $resp.data.totalIncome -ge 16200) 'earnings.totalIncome 计入已确认单(16200 分)' $resp ("totalIncome=" + $resp.data.totalIncome)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+# S16 评价 /api/eval/submit(only-after-confirmed,正反例)
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+if (-not $skipFulfillment) {
|
|
|
|
|
+ Begin-Step '评价 /api/eval/submit(EVA-TC-001 正例 / 002 反例)'
|
|
|
|
|
+
|
|
|
|
|
+ # 正例:confirmed 后可评
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/eval/submit' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; score = 5; comment = 'M5 冒烟履约评价'
|
|
|
|
|
+ }
|
|
|
|
|
+ $evalId = if ($resp.data -and $resp.data.evalId) { [long]$resp.data.evalId } else { -1 }
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and $resp.data -and $resp.data.score -eq 5 -and $resp.data.orderId -eq $orderId) 'EVA-TC-001:confirmed 后提交成功' $resp ("evalId=" + $resp.data.evalId + " evalType=" + $resp.data.evalType)
|
|
|
|
|
+
|
|
|
|
|
+ # 幂等:二次提交返回同一条(uk(order_id) once-per-order)
|
|
|
|
|
+ $resp2 = Invoke-Api -Method 'POST' -Path '/api/eval/submit' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; score = 4; comment = '二次提交'
|
|
|
|
|
+ }
|
|
|
|
|
+ $evalId2 = if ($resp2.data -and $resp2.data.evalId) { [long]$resp2.data.evalId } else { -2 }
|
|
|
|
|
+ Assert-True ($resp2.code -eq 200 -and $evalId2 -eq $evalId) '评价幂等(同 orderId 返回同 evalId,不覆盖首评)' $resp2 ("evalId=$evalId/$evalId2")
|
|
|
|
|
+
|
|
|
|
|
+ # 汇总可见(含本人履约评价计数)
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/eval/mine' -Token $t1Token -Body @{}
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and $resp.data) 'eval/mine 可查(履约评价并入汇总)' $resp ''
|
|
|
|
|
+
|
|
|
|
|
+ # --- 一次性反例工单:accepted(未 confirmed)→ 评价必须拒绝 ---
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/admin/org/dispatch/create' -Token $adminToken -Body @{
|
|
|
|
|
+ orgId = $orgId; familyName = 'M5冒烟评价反例户'; contactPhone = '13900000099'
|
|
|
|
|
+ address = '湖北省黄冈市浠水县试点路 2 号'; serviceType = 'cleaning'
|
|
|
|
|
+ orderDate = '2026-12-05'; amount = 1000; platformFee = 100; remark = 'M5 冒烟一次性反例单'
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($resp.code -ne 200 -or -not $resp.data) { Assert-Fail '反例单建单失败' $resp '' }
|
|
|
|
|
+ $negOrderId = [long]$resp.data.orderId
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/admin/org/dispatch/assign' -Token $adminToken -Body @{
|
|
|
|
|
+ orderId = $negOrderId; workerId = $t1UserId; serviceType = 'cleaning'; remark = '指派反例单'
|
|
|
|
|
+ }
|
|
|
|
|
+ Assert-True ($resp.code -eq 200 -and [string]$resp.data.status -eq 'accepted') '反例单指派 → accepted(未 confirmed)' $resp ("negOrderId=$negOrderId")
|
|
|
|
|
+
|
|
|
|
|
+ # 履约门禁反例:accepted 未打卡即 finish → 拒绝(同时证明本单停在 accepted)
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/order/finish' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $negOrderId; items = @(); photos = ''
|
|
|
|
|
+ }
|
|
|
|
|
+ Assert-True ($resp.code -ne 200) '反例单:未打卡即 finish 被拒(停在 accepted)' $resp ("msg=" + $resp.message)
|
|
|
|
|
+
|
|
|
|
|
+ # EVA-TC-002:未 confirmed 工单不可评价
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/eval/submit' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $negOrderId; score = 5; comment = '反例:未确认即评'
|
|
|
|
|
+ }
|
|
|
|
|
+ $negMsg = if ($resp.message) { [string]$resp.message } else { '' }
|
|
|
|
|
+ Assert-True (($resp.code -ne 200) -and ($negMsg -match '工单未确认')) 'EVA-TC-002:未 confirmed 工单评价被拒' $resp ("msg=$negMsg")
|
|
|
|
|
+
|
|
|
|
|
+ # 评分越界反例
|
|
|
|
|
+ $resp = Invoke-Api -Method 'POST' -Path '/api/eval/submit' -Token $t1Token -Body @{
|
|
|
|
|
+ orderId = $orderId; score = 6
|
|
|
|
|
+ }
|
|
|
|
|
+ $scoreMsg = if ($resp.message) { [string]$resp.message } else { '' }
|
|
|
|
|
+ Assert-True (($resp.code -ne 200) -and ($scoreMsg -match '评分须为1-5星')) '反例:score=6 越界被拒' $resp ("msg=$scoreMsg")
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+# S17 六契约端点(管理端前缀实测):各 200 + 关键字段
|
|
|
|
|
+# ============================================================
|
|
|
|
|
+Begin-Step '六契约端点(member/disable、cohort/list、attendance/list、credit 三端点)'
|
|
|
|
|
+
|
|
|
|
|
+# ① /api/admin/org/member/disable:重复禁用 → 幂等成功(不动 S3 依赖的 m5t1 org_admin 身份)
|
|
|
|
|
+$resp = Invoke-Api -Method 'POST' -Path '/api/admin/org/member/disable' -Token $adminToken -Body @{
|
|
|
|
|
+ orgId = $orgId; userId = $noneUserId
|
|
|
|
|
+}
|
|
|
|
|
+Assert-True ($resp.code -eq 200 -and $resp.data -eq $true) 'member/disable 重复调用幂等成功' $resp ("memberUserId=$noneUserId")
|
|
|
|
|
+
|
|
|
|
|
+# ② /api/admin/cohort/list:每行含 enrolledCount(契约别名,与 signedCount 同源)
|
|
|
|
|
+$resp = Invoke-Api -Method 'POST' -Path '/api/admin/cohort/list' -Token $adminToken -Body @{
|
|
|
|
|
+ courseId = $courseId; page = 1; size = 10
|
|
|
|
|
+}
|
|
|
|
|
+$hasEnrolled = $false
|
|
|
|
|
+foreach ($row in (Get-Arr $resp.data.list)) {
|
|
|
|
|
+ if ($null -ne $row.PSObject.Properties['enrolledCount']) { $hasEnrolled = $true; break }
|
|
|
|
|
+}
|
|
|
|
|
+Assert-True ($resp.code -eq 200 -and $hasEnrolled) 'cohort/list 行含 enrolledCount' $resp ("total=" + $resp.data.total)
|
|
|
|
|
+
|
|
|
|
|
+# ③ /api/admin/attendance/list:行含 userName(按签到 cohort 过滤,避免命中历史测试批次)
|
|
|
|
|
+$resp = Invoke-Api -Method 'POST' -Path '/api/admin/attendance/list' -Token $adminToken -Body @{
|
|
|
|
|
+ cohortId = $cohortId; page = 1; size = 10
|
|
|
|
|
+}
|
|
|
|
|
+$hasName = $false
|
|
|
|
|
+$showName = ''
|
|
|
|
|
+foreach ($row in (Get-Arr $resp.data.list)) {
|
|
|
|
|
+ if ($null -ne $row.PSObject.Properties['userName']) { $hasName = $true; $showName = [string]$row.userName; break }
|
|
|
|
|
+}
|
|
|
|
|
+Assert-True ($resp.code -eq 200 -and $hasName) 'attendance/list 行含 userName' $resp ("userName=" + (Fix-MojibakeText $showName))
|
|
|
|
|
+
|
|
|
|
|
+# ④ /api/admin/credit/account/list:行含 userId/year/totalHours(学时分钟整数)
|
|
|
|
|
+$resp = Invoke-Api -Method 'POST' -Path '/api/admin/credit/account/list' -Token $adminToken -Body @{
|
|
|
|
|
+ year = 2026; page = 1; size = 10
|
|
|
|
|
+}
|
|
|
|
|
+$accOk = $false
|
|
|
|
|
+if ($resp.code -eq 200 -and $resp.data) {
|
|
|
|
|
+ $accOk = ($null -ne $resp.data.PSObject.Properties['list'])
|
|
|
|
|
+ foreach ($row in (Get-Arr $resp.data.list)) {
|
|
|
|
|
+ if ($row.userId -and $row.year -and $null -ne $row.totalHours) { $accOk = $true; break }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+Assert-True $accOk 'credit/account/list 行含 userId/year/totalHours' $resp ("total=" + $resp.data.total)
|
|
|
|
|
+
|
|
|
|
|
+# ⑤ /api/admin/credit/ledger/detail:单学员单年度明细(hours 分钟整数红线)
|
|
|
|
|
+$resp = Invoke-Api -Method 'POST' -Path '/api/admin/credit/ledger/detail' -Token $adminToken -Body @{
|
|
|
|
|
+ userId = $stuUserId; year = 2026
|
|
|
|
|
+}
|
|
|
|
|
+$rows = Get-Arr $resp.data
|
|
|
|
|
+$detailOk = ($rows.Count -ge 1)
|
|
|
|
|
+foreach ($row in $rows) {
|
|
|
|
|
+ if (-not (Test-MinuteInteger $row.hours)) { $detailOk = $false }
|
|
|
|
|
+}
|
|
|
|
|
+Assert-True ($resp.code -eq 200 -and $detailOk) 'credit/ledger/detail 返回明细且 hours 为分钟整数' $resp ("rows=" + $rows.Count)
|
|
|
|
|
+
|
|
|
|
|
+# ⑥ /api/admin/credit/ledger/objected:列表模式 + 处置模式(双模,同一路径)
|
|
|
|
|
+$resp = Invoke-Api -Method 'POST' -Path '/api/admin/credit/ledger/objected' -Token $adminToken -Body @{ page = 1; size = 10 }
|
|
|
|
|
+$hasList = ($resp.code -eq 200 -and $resp.data -and ($null -ne $resp.data.PSObject.Properties['list']))
|
|
|
|
|
+Assert-True $hasList 'ledger/objected 列表模式返回 {total,page,size,list}' $resp ("total=" + $resp.data.total)
|
|
|
|
|
+
|
|
|
|
|
+# 处置分支:故意传不存在的台账 id → 业务拒绝且不改库(避免处置真实异议台账)
|
|
|
|
|
+$resp = Invoke-Api -Method 'POST' -Path '/api/admin/credit/ledger/objected' -Token $adminToken -Body @{
|
|
|
|
|
+ id = 999999999; approved = $false; reason = 'M5 冒烟双模探针'
|
|
|
|
|
+}
|
|
|
|
|
+$dispMsg = if ($resp.message) { [string]$resp.message } else { '' }
|
|
|
|
|
+Assert-True (($resp.code -ne 200) -and ($dispMsg -match '学时记录不存在')) 'ledger/objected 处置分支:不存在台账被拒(双模路由命中)' $resp ("msg=$dispMsg")
|
|
|
|
|
+
|
|
|
|
|
+Write-Host ("S{0} [PASS] 六契约端点各 200 + 关键字段齐全" -f $script:Step) -ForegroundColor Green
|
|
|
|
|
+
|
|
|
# ============================================================
|
|
# ============================================================
|
|
|
# 总结
|
|
# 总结
|
|
|
# ============================================================
|
|
# ============================================================
|
|
|
Write-Host "`n========================================" -ForegroundColor Cyan
|
|
Write-Host "`n========================================" -ForegroundColor Cyan
|
|
|
-Write-Host ("冒烟完成:12 步全部通过(orgId=$orgId cohortId=$cohortId orderId=$orderId dispatchId=$dispatchId)") -ForegroundColor Green
|
|
|
|
|
-Write-Host "关键断言:学时分钟整数 ✓ 建单留痕 dispatchId ✓ 资质闸口放行/拒绝 ✓" -ForegroundColor Green
|
|
|
|
|
|
|
+if ($skipFulfillment) {
|
|
|
|
|
+ Write-Host ("冒烟完成:S1-S12 通过,S13-S17 跳过(无可用工单)。orgId=$orgId cohortId=$cohortId") -ForegroundColor Yellow
|
|
|
|
|
+} else {
|
|
|
|
|
+ Write-Host ("冒烟完成:17 步全部通过(orgId=$orgId cohortId=$cohortId orderId=$orderId dispatchId=$dispatchId code=$confirmCode negOrderId=$negOrderId)") -ForegroundColor Green
|
|
|
|
|
+ Write-Host "关键断言:学时分钟整数 ✓ 建单留痕 dispatchId ✓ 资质闸口放行/拒绝 ✓" -ForegroundColor Green
|
|
|
|
|
+ Write-Host "履约链:arrived → done(6 位确认码) → confirmed → 可评价;错码/重复/未确认/越权均拒绝 ✓" -ForegroundColor Green
|
|
|
|
|
+}
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
|
exit 0
|
|
exit 0
|