优化兑换成功后截图逻辑
This commit is contained in:
@@ -0,0 +1,75 @@
|
|||||||
|
2701835328032037898 2209880145223 海底捞第五人格皮肤 0.01 测试连接
|
||||||
|
{
|
||||||
|
"item_id": 1038123159888,
|
||||||
|
"seller_id": 2209880145223,
|
||||||
|
"MsgTypeDes": "订单已付款",
|
||||||
|
"biz_order_id": "2701835328032037898",
|
||||||
|
"order_status": 2,
|
||||||
|
"_agisoTradeDetail": {
|
||||||
|
"sku": "6227949975509|类型:海底捞第五人格皮肤",
|
||||||
|
"item": {
|
||||||
|
"price": 1,
|
||||||
|
"title": "测试链接,勿拍",
|
||||||
|
"item_id": 1038123159888,
|
||||||
|
"pic_url": "https://gw.alicdn.com/bao/uploaded/i1/2209880145223/O1CN0178ZkcG1oSBmmmr1V8_!!4611686018427387207-53-xy_item.heic"
|
||||||
|
},
|
||||||
|
"payment": 1,
|
||||||
|
"end_time": 0,
|
||||||
|
"pay_time": 1776144458000,
|
||||||
|
"post_fee": 0,
|
||||||
|
"isEticket": false,
|
||||||
|
"ship_time": 0,
|
||||||
|
"buy_amount": 1,
|
||||||
|
"buyer_nick": "梦里梦",
|
||||||
|
"isRecharge": false,
|
||||||
|
"create_time": 1776144455000,
|
||||||
|
"seller_nick": "大锤号商",
|
||||||
|
"biz_order_id": "2701835328032037898",
|
||||||
|
"order_status": 2,
|
||||||
|
"coupon_eticket_info": [],
|
||||||
|
"encryption_buyer_id": "enV7xJs5DRbJBzIH8uUUcg=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SKU: 6227949975509
|
||||||
|
ItemId: 1038123159888
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
(现货秒发)海底捞第五人格联动限定兑换码cdk拉拉队员皮肤+
|
||||||
|
SKU: 1038123159888
|
||||||
|
ItemId: 1038123159888
|
||||||
|
|
||||||
|
{
|
||||||
|
"item_id": 1038123159888,
|
||||||
|
"seller_id": 2209880145223,
|
||||||
|
"MsgTypeDes": "交易成功",
|
||||||
|
"biz_order_id": "4502265554049011443",
|
||||||
|
"order_status": 4,
|
||||||
|
"_agisoTradeDetail": {
|
||||||
|
"item": {
|
||||||
|
"price": 4000,
|
||||||
|
"title": "(现货秒发)海底捞第五人格联动限定兑换码cdk拉拉队员皮肤+",
|
||||||
|
"item_id": 1038123159888,
|
||||||
|
"pic_url": "https://gw.alicdn.com/bao/uploaded/i2/2209880145223/O1CN01xGf3721oSBmd1W0DI_!!4611686018427387207-53-xy_item.heic"
|
||||||
|
},
|
||||||
|
"payment": 4000,
|
||||||
|
"end_time": 1776143786000,
|
||||||
|
"pay_time": 1775279772000,
|
||||||
|
"post_fee": 0,
|
||||||
|
"isEticket": false,
|
||||||
|
"ship_time": 1775279779000,
|
||||||
|
"buy_amount": 1,
|
||||||
|
"buyer_nick": "b***5",
|
||||||
|
"isRecharge": false,
|
||||||
|
"create_time": 1775279753000,
|
||||||
|
"seller_nick": "大锤号商",
|
||||||
|
"biz_order_id": "4502265554049011443",
|
||||||
|
"order_status": 4,
|
||||||
|
"coupon_eticket_info": [],
|
||||||
|
"encryption_buyer_id": "6iabfI7bB2cCa4y8JR2VQw=="
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,10 +3,10 @@
|
|||||||
"provider": "agiso",
|
"provider": "agiso",
|
||||||
"platform": "xianyu",
|
"platform": "xianyu",
|
||||||
"shopId": "2209880145223",
|
"shopId": "2209880145223",
|
||||||
"skuCode": "三角洲海底捞动作",
|
"skuCode": "海底捞第五人格皮肤",
|
||||||
"skuName": "海底捞第五人格皮肤",
|
"skuName": "海底捞第五人格皮肤",
|
||||||
"profileKey": "tencent_claim_redeem",
|
"profileKey": "tencent_claim_redeem",
|
||||||
"enabled": true,
|
"enabled": false,
|
||||||
"priority": 100,
|
"priority": 100,
|
||||||
"config": {},
|
"config": {},
|
||||||
"match": {
|
"match": {
|
||||||
@@ -36,24 +36,5 @@
|
|||||||
"resolvedSkuName": "海底捞干员庆生动作1个"
|
"resolvedSkuName": "海底捞干员庆生动作1个"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"provider": "agiso",
|
|
||||||
"platform": "xianyu",
|
|
||||||
"shopId": "693760716",
|
|
||||||
"skuCode": "三角洲海底捞动作",
|
|
||||||
"skuName": "三角洲行动-自动领取",
|
|
||||||
"profileKey": "tencent_claim_assisted",
|
|
||||||
"enabled": true,
|
|
||||||
"priority": 100,
|
|
||||||
"config": {},
|
|
||||||
"match": {
|
|
||||||
"externalSkuCode": "6228372634012",
|
|
||||||
"externalItemId": "1040695550204",
|
|
||||||
"externalSkuName": "周边",
|
|
||||||
"config": {
|
|
||||||
"resolvedSkuName": "三角洲行动-自动领取"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import path from 'node:path'
|
|||||||
|
|
||||||
import { runtimeConfig } from '../../config/runtime.js'
|
import { runtimeConfig } from '../../config/runtime.js'
|
||||||
|
|
||||||
const BAIDU_BEIJING_TIME_URL = 'https://www.baidu.com/s?wd=%E5%8C%97%E4%BA%AC%E6%97%B6%E9%97%B4'
|
const BAIDU_BEIJING_TIME_URL = 'https://www.baidu.com/s?ie=utf-8&f=3&rsv_bp=1&rsv_idx=1&tn=baidu&wd=%E5%8C%97%E4%BA%AC%E6%97%B6%E9%97%B4&fenlei=256&rsv_pq=0xa7d529b30000a6eb&rsv_t=2d404COdLspTa8jnKQl%2FyCU%2BSCmRyb%2BvSqxxjk%2B7E1scokLYTuDbehaQ0Dvq&rqlang=en&rsv_enter=1&rsv_dl=ih_0&rsv_sug3=1&rsv_sug1=1&rsv_sug7=001&rsv_sug2=1&rsv_btype=i&rsp=0&rsv_sug9=es_2_1&rsv_sug=1'
|
||||||
const BEIJING_TIME_PROOF_VIEWPORT = { width: 1440, height: 860 }
|
const BEIJING_TIME_PROOF_VIEWPORT = { width: 1440, height: 860 }
|
||||||
const BEIJING_TIME_PROOF_CLIP = {
|
const BEIJING_TIME_PROOF_CLIP = {
|
||||||
x: 0,
|
x: 0,
|
||||||
@@ -95,23 +95,27 @@ export async function writeRedeemArtifactFiles({
|
|||||||
error: '',
|
error: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (shouldCaptureBeijingTimeProof(finalResult)) {
|
||||||
beijingTimeProof = await captureBeijingTimeProof(browserContext, {
|
try {
|
||||||
screenshotPath: beijingTimeScreenshotPath,
|
beijingTimeProof = await captureBeijingTimeProof(browserContext, {
|
||||||
})
|
screenshotPath: beijingTimeScreenshotPath,
|
||||||
await composeProofScreenshot(browserContext, {
|
})
|
||||||
outputPath: screenshotPath,
|
await composeProofScreenshot(browserContext, {
|
||||||
redeemImagePath: redeemPageScreenshotPath,
|
outputPath: screenshotPath,
|
||||||
timeImagePath: beijingTimeProof.screenshotPath,
|
redeemImagePath: redeemPageScreenshotPath,
|
||||||
redeemMessage: String(finalResult.redeem?.sMsg || '兑换完成'),
|
timeImagePath: beijingTimeProof.screenshotPath,
|
||||||
timePageUrl: beijingTimeProof.pageUrl,
|
redeemMessage: String(finalResult.redeem?.sMsg || '兑换完成'),
|
||||||
})
|
timePageUrl: beijingTimeProof.pageUrl,
|
||||||
} catch (error) {
|
})
|
||||||
beijingTimeProof = {
|
} catch (error) {
|
||||||
screenshotPath: '',
|
beijingTimeProof = {
|
||||||
pageUrl: BAIDU_BEIJING_TIME_URL,
|
screenshotPath: '',
|
||||||
error: error instanceof Error ? error.message : '北京时间截图生成失败',
|
pageUrl: BAIDU_BEIJING_TIME_URL,
|
||||||
|
error: error instanceof Error ? error.message : '北京时间截图生成失败',
|
||||||
|
}
|
||||||
|
await fs.copyFile(redeemPageScreenshotPath, screenshotPath)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
await fs.copyFile(redeemPageScreenshotPath, screenshotPath)
|
await fs.copyFile(redeemPageScreenshotPath, screenshotPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +155,19 @@ export function resolveRedeemProofMode(rawMode = runtimeConfig.redeem.proofMode)
|
|||||||
return DEFAULT_REDEEM_PROOF_MODE
|
return DEFAULT_REDEEM_PROOF_MODE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function shouldCaptureBeijingTimeProof(finalResult) {
|
||||||
|
if (finalResult?.classification?.success === true) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finalResult?.classification?.success === false) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const retCode = Number(finalResult?.redeem?.iRet ?? finalResult?.redeem?.ret)
|
||||||
|
return Number.isFinite(retCode) && retCode === 0
|
||||||
|
}
|
||||||
|
|
||||||
function buildArtifactPaths(outputDir) {
|
function buildArtifactPaths(outputDir) {
|
||||||
return {
|
return {
|
||||||
redeemPageScreenshotPath: path.join(outputDir, 'redeem-page.png'),
|
redeemPageScreenshotPath: path.join(outputDir, 'redeem-page.png'),
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import test from 'node:test'
|
||||||
|
import assert from 'node:assert/strict'
|
||||||
|
|
||||||
|
import { shouldCaptureBeijingTimeProof } from './session-proof.js'
|
||||||
|
|
||||||
|
test('shouldCaptureBeijingTimeProof only returns true for successful redeem results', () => {
|
||||||
|
assert.equal(
|
||||||
|
shouldCaptureBeijingTimeProof({
|
||||||
|
classification: {
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
shouldCaptureBeijingTimeProof({
|
||||||
|
classification: {
|
||||||
|
success: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
shouldCaptureBeijingTimeProof({
|
||||||
|
redeem: {
|
||||||
|
iRet: 0,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
shouldCaptureBeijingTimeProof({
|
||||||
|
redeem: {
|
||||||
|
iRet: -183,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(shouldCaptureBeijingTimeProof(null), false)
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user