通知系统-1
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user