yeg
2026-09-18 db704fbed062d5700a37b7858231bf7d0958e38d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
param(
    [string] $BaseUrl = 'http://127.0.0.1:8080',
    [long] $TalentId = 5,
    [long] $CardId = 5,
    [long] $MerchantId = 2,
    [decimal] $Amount = 0.01
)
 
$baseUrl = $BaseUrl.TrimEnd('/')
if ($Amount -le 0) {
    throw 'Amount must be greater than zero.'
}
 
$payload = @{
    talentId = $TalentId
    cardId = $CardId
    benefitId = $null
    merchantId = $MerchantId
    storeId = $null
    orderType = 'GROUP_BUY'
    orderAmount = $Amount
    subsidyAmount = 0
    payAmount = $Amount
} | ConvertTo-Json -Compress
 
$created = Invoke-RestMethod -Uri "$baseUrl/api/orders" -Method POST -ContentType 'application/json' -Body $payload
if ($created.code -ne 0 -or [string]::IsNullOrWhiteSpace($created.data.orderNo)) {
    throw "Order creation failed: $($created | ConvertTo-Json -Compress)"
}
 
$orderNo = [string] $created.data.orderNo
$detail = Invoke-RestMethod -Uri "$baseUrl/api/app/pending-orders/${orderNo}?talentId=$TalentId" -Method GET
if ($detail.code -ne 0 -or $detail.data.canPay -ne $true) {
    throw "Created order is not payable: $($detail | ConvertTo-Json -Compress)"
}
 
Write-Output "Created pending payment order: $orderNo"
Write-Output "Talent ID: $TalentId"
Write-Output "Amount: $($detail.data.payAmount) CNY"
Write-Output "Expires at: $($detail.data.expiresAt)"