通知系统-1

This commit is contained in:
yml2213
2026-05-14 17:29:12 +08:00
parent 91d74b3e59
commit b6c493d5e7
22 changed files with 1314 additions and 11 deletions
@@ -30,6 +30,11 @@ import {
getKuaishouEticketSourceConfig,
resolveKuaishouEticketShopConfig,
} from '../platforms/kuaishou-eticket/source-config-service.js'
import {
notifyKuaishouCloudAssetNotEnough,
notifyKuaishouCloudBindUrlRefreshFailed,
notifyKuaishouCloudConsumeFailed,
} from '../notification/domain-notifications.js'
import { createHttpError } from '../../utils/http.js'
import { nowIso } from '../../utils/time.js'
@@ -284,6 +289,13 @@ export async function prepareKuaishouCloudFulfillmentTask(task, options = {}) {
const targetPrice = Number(targetSku.price || 0) || 0
const requiredAsset = targetPrice + flowWithResolvedBinding.purchase.minAssetReserve
if (assetBefore < requiredAsset) {
await notifyKuaishouCloudAssetNotEnough({
task,
flow: flowWithResolvedBinding,
assetBefore,
requiredAsset,
skuName: targetSku.name,
})
throw createHttpError(`余额不足,当前 ${assetBefore},至少需要 ${requiredAsset}`, {
statusCode: 409,
errorCode: 'kuaishou_cloud_asset_not_enough',
@@ -652,6 +664,11 @@ async function markKuaishouCloudBindUrlRefreshFailed(task, {
actor,
}, now)
await notifyKuaishouCloudBindUrlRefreshFailed({
task: updatedTask,
errorMessage,
})
return updatedTask
}
@@ -998,6 +1015,17 @@ export async function returnKuaishouCloudFulfillmentTask(task, options = {}) {
now,
)
if (consumeStatus !== 'success') {
await notifyKuaishouCloudConsumeFailed({
task: updatedTask,
order,
ticketCodeMasked: maskCode(ticketCode),
shopId,
shopName,
errorMessage: consumeErrorMessage,
})
}
return {
task: updatedTask,
flow: normalizeKuaishouCloudFlow(parseTaskContext(updatedTask).kuaishouCloudFulfillment),