统一前后端代码格式化配置
This commit is contained in:
@@ -65,7 +65,11 @@ export function isDevMockEnabled(env: NodeJS.ProcessEnv = process.env): boolean
|
||||
if (String(env.ENABLE_DEV_MOCK || '').trim() === '1') {
|
||||
return true
|
||||
}
|
||||
if (String(env.ENABLE_DEV_MOCK || '').trim().toLowerCase() === 'true') {
|
||||
if (
|
||||
String(env.ENABLE_DEV_MOCK || '')
|
||||
.trim()
|
||||
.toLowerCase() === 'true'
|
||||
) {
|
||||
return true
|
||||
}
|
||||
return !isProductionLike(env)
|
||||
@@ -111,14 +115,16 @@ export function getDevMockStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function createLewanMockClaim(input: {
|
||||
step?: unknown
|
||||
orderNo?: unknown
|
||||
productNo?: unknown
|
||||
uid?: unknown
|
||||
items?: unknown
|
||||
frontendBaseUrl?: unknown
|
||||
} = {}): Promise<DevMockCreateResult> {
|
||||
export async function createLewanMockClaim(
|
||||
input: {
|
||||
step?: unknown
|
||||
orderNo?: unknown
|
||||
productNo?: unknown
|
||||
uid?: unknown
|
||||
items?: unknown
|
||||
frontendBaseUrl?: unknown
|
||||
} = {},
|
||||
): Promise<DevMockCreateResult> {
|
||||
assertDevMockEnabled()
|
||||
|
||||
const step = normalizeLewanStep(input.step)
|
||||
@@ -192,7 +198,10 @@ export async function createLewanMockClaim(input: {
|
||||
})
|
||||
|
||||
if (!task) {
|
||||
throw createHttpError('履约任务创建失败', { statusCode: 500, errorCode: 'dev_mock_task_failed' })
|
||||
throw createHttpError('履约任务创建失败', {
|
||||
statusCode: 500,
|
||||
errorCode: 'dev_mock_task_failed',
|
||||
})
|
||||
}
|
||||
|
||||
const claimToken = await createTaskClaimToken(task.id)
|
||||
@@ -223,15 +232,17 @@ export async function createLewanMockClaim(input: {
|
||||
})
|
||||
}
|
||||
|
||||
export async function createFeifeiMockClaim(input: {
|
||||
step?: unknown
|
||||
orderNo?: unknown
|
||||
productName?: unknown
|
||||
productCode?: unknown
|
||||
uid?: unknown
|
||||
h5Url?: unknown
|
||||
frontendBaseUrl?: unknown
|
||||
} = {}): Promise<DevMockCreateResult> {
|
||||
export async function createFeifeiMockClaim(
|
||||
input: {
|
||||
step?: unknown
|
||||
orderNo?: unknown
|
||||
productName?: unknown
|
||||
productCode?: unknown
|
||||
uid?: unknown
|
||||
h5Url?: unknown
|
||||
frontendBaseUrl?: unknown
|
||||
} = {},
|
||||
): Promise<DevMockCreateResult> {
|
||||
assertDevMockEnabled()
|
||||
|
||||
const step = normalizeFeifeiStep(input.step)
|
||||
@@ -296,7 +307,12 @@ export async function createFeifeiMockClaim(input: {
|
||||
? TASK_STATUS.MANUAL_REVIEW
|
||||
: TASK_STATUS.LINK_GENERATED,
|
||||
deliveryStatus: step === 'completed' ? 'delivered' : 'pending',
|
||||
resultCode: step === 'completed' ? 'kuaishou_feifei_completed' : step === 'failed' ? 'kuaishou_feifei_status_40' : '',
|
||||
resultCode:
|
||||
step === 'completed'
|
||||
? 'kuaishou_feifei_completed'
|
||||
: step === 'failed'
|
||||
? 'kuaishou_feifei_status_40'
|
||||
: '',
|
||||
resultMessage: rechargeStatusLabel,
|
||||
claimToken: '',
|
||||
claimExpiresAt: null,
|
||||
@@ -349,7 +365,10 @@ export async function createFeifeiMockClaim(input: {
|
||||
})
|
||||
|
||||
if (!task) {
|
||||
throw createHttpError('履约任务创建失败', { statusCode: 500, errorCode: 'dev_mock_task_failed' })
|
||||
throw createHttpError('履约任务创建失败', {
|
||||
statusCode: 500,
|
||||
errorCode: 'dev_mock_task_failed',
|
||||
})
|
||||
}
|
||||
|
||||
const claimToken = await createTaskClaimToken(task.id)
|
||||
@@ -383,14 +402,16 @@ type AffiliateDashMockStep = 'uid' | 'bind' | 'submitted' | 'completed' | 'faile
|
||||
* 生成 affiliate-dash 领取 mock:不调用真实 affiliate-dash 平台。
|
||||
* 上下文带 mock 标记,sync/refresh/submit 全部短路,领取页可走完四步。
|
||||
*/
|
||||
export async function createAffiliateDashMockClaim(input: {
|
||||
step?: unknown
|
||||
orderNo?: unknown
|
||||
productName?: unknown
|
||||
productSku?: unknown
|
||||
uid?: unknown
|
||||
frontendBaseUrl?: unknown
|
||||
} = {}): Promise<DevMockCreateResult> {
|
||||
export async function createAffiliateDashMockClaim(
|
||||
input: {
|
||||
step?: unknown
|
||||
orderNo?: unknown
|
||||
productName?: unknown
|
||||
productSku?: unknown
|
||||
uid?: unknown
|
||||
frontendBaseUrl?: unknown
|
||||
} = {},
|
||||
): Promise<DevMockCreateResult> {
|
||||
assertDevMockEnabled()
|
||||
|
||||
const step = normalizeAffiliateDashStep(input.step)
|
||||
@@ -457,11 +478,7 @@ export async function createAffiliateDashMockClaim(input: {
|
||||
? TASK_STATUS.REDEEMING
|
||||
: TASK_STATUS.LINK_GENERATED,
|
||||
deliveryStatus:
|
||||
step === 'completed'
|
||||
? 'delivered'
|
||||
: step === 'submitted'
|
||||
? 'delivering'
|
||||
: 'pending',
|
||||
step === 'completed' ? 'delivered' : step === 'submitted' ? 'delivering' : 'pending',
|
||||
resultCode:
|
||||
step === 'completed'
|
||||
? 'affiliate_dash_delivered'
|
||||
@@ -541,7 +558,10 @@ export async function createAffiliateDashMockClaim(input: {
|
||||
})
|
||||
|
||||
if (!task) {
|
||||
throw createHttpError('履约任务创建失败', { statusCode: 500, errorCode: 'dev_mock_task_failed' })
|
||||
throw createHttpError('履约任务创建失败', {
|
||||
statusCode: 500,
|
||||
errorCode: 'dev_mock_task_failed',
|
||||
})
|
||||
}
|
||||
|
||||
const claimToken = await createTaskClaimToken(task.id)
|
||||
@@ -573,9 +593,11 @@ export async function createAffiliateDashMockClaim(input: {
|
||||
* 生成电子凭证列表测试数据,不调用快手接口。
|
||||
* 覆盖未使用、已核销、已销毁和发码失败等运营页面常见状态。
|
||||
*/
|
||||
export async function createKuaishouIndustryVoucherMockData(input: {
|
||||
sellerId?: unknown
|
||||
} = {}): Promise<DevMockKuaishouIndustryVoucherResult> {
|
||||
export async function createKuaishouIndustryVoucherMockData(
|
||||
input: {
|
||||
sellerId?: unknown
|
||||
} = {},
|
||||
): Promise<DevMockKuaishouIndustryVoucherResult> {
|
||||
assertDevMockEnabled()
|
||||
|
||||
const now = nowIso()
|
||||
@@ -668,11 +690,13 @@ export async function createKuaishouIndustryVoucherMockData(input: {
|
||||
/**
|
||||
* 生成 91 查询请求体(带签名),可选对本机发起查询。
|
||||
*/
|
||||
export async function buildOpen91QueryMock(input: {
|
||||
orderNo?: unknown
|
||||
execute?: unknown
|
||||
baseUrl?: unknown
|
||||
} = {}) {
|
||||
export async function buildOpen91QueryMock(
|
||||
input: {
|
||||
orderNo?: unknown
|
||||
execute?: unknown
|
||||
baseUrl?: unknown
|
||||
} = {},
|
||||
) {
|
||||
assertDevMockEnabled()
|
||||
|
||||
const orderNo = String(input.orderNo || '').trim()
|
||||
@@ -767,7 +791,10 @@ async function ensureProfile(profileKey: string, name: string, requiresClaim: bo
|
||||
})
|
||||
|
||||
if (!profile) {
|
||||
throw createHttpError('履约配置创建失败', { statusCode: 500, errorCode: 'dev_mock_profile_failed' })
|
||||
throw createHttpError('履约配置创建失败', {
|
||||
statusCode: 500,
|
||||
errorCode: 'dev_mock_profile_failed',
|
||||
})
|
||||
}
|
||||
return profile
|
||||
}
|
||||
@@ -853,19 +880,19 @@ async function createBaseOrderItem(input: {
|
||||
},
|
||||
}
|
||||
: {
|
||||
source: OPEN_91_PROVIDER,
|
||||
orderNo: input.orderNo,
|
||||
productNo: input.productNo,
|
||||
productName: input.productName,
|
||||
shopId: input.consumeShopId,
|
||||
cloudtentacles: {
|
||||
matchMode: 'mock',
|
||||
normalizedProductName: input.productName,
|
||||
cloudSourceKeys: ['mock-cloudtentacles'],
|
||||
resolvedSourceKey: 'mock-cloudtentacles',
|
||||
deliveryItems: input.deliveryItems,
|
||||
},
|
||||
}
|
||||
source: OPEN_91_PROVIDER,
|
||||
orderNo: input.orderNo,
|
||||
productNo: input.productNo,
|
||||
productName: input.productName,
|
||||
shopId: input.consumeShopId,
|
||||
cloudtentacles: {
|
||||
matchMode: 'mock',
|
||||
normalizedProductName: input.productName,
|
||||
cloudSourceKeys: ['mock-cloudtentacles'],
|
||||
resolvedSourceKey: 'mock-cloudtentacles',
|
||||
deliveryItems: input.deliveryItems,
|
||||
},
|
||||
}
|
||||
|
||||
const [orderItem] = await replaceOrderItems(input.orderId, [
|
||||
{
|
||||
@@ -885,7 +912,10 @@ async function createBaseOrderItem(input: {
|
||||
])
|
||||
|
||||
if (!orderItem) {
|
||||
throw createHttpError('订单商品创建失败', { statusCode: 500, errorCode: 'dev_mock_item_failed' })
|
||||
throw createHttpError('订单商品创建失败', {
|
||||
statusCode: 500,
|
||||
errorCode: 'dev_mock_item_failed',
|
||||
})
|
||||
}
|
||||
return orderItem
|
||||
}
|
||||
@@ -931,9 +961,7 @@ function buildLewanMockContext(input: {
|
||||
configId: `mock:${input.productName}`,
|
||||
internalSkuCode: input.productName,
|
||||
internalSkuName: input.productName,
|
||||
deliveryItems: input.deliveryItems.length
|
||||
? input.deliveryItems
|
||||
: [primaryItem],
|
||||
deliveryItems: input.deliveryItems.length ? input.deliveryItems : [primaryItem],
|
||||
mock: {
|
||||
enabled: true,
|
||||
orderNo: input.orderNo,
|
||||
@@ -960,9 +988,7 @@ function buildLewanMockContext(input: {
|
||||
vnKey: '1',
|
||||
vnId: roleReady ? 900001 : 0,
|
||||
vnPhone: roleReady ? '13800000000' : '',
|
||||
bindUrl: roleReady
|
||||
? `https://example.com/mock-kuaishou-cloud-bind/${input.orderNo}`
|
||||
: '',
|
||||
bindUrl: roleReady ? `https://example.com/mock-kuaishou-cloud-bind/${input.orderNo}` : '',
|
||||
bindPreparedAt: roleReady ? input.timestamp : null,
|
||||
bindExpiresAt: roleReady ? addHours(input.timestamp, 24) : null,
|
||||
bindProbeAt: roleReady ? input.timestamp : null,
|
||||
@@ -1190,7 +1216,10 @@ function buildAffiliateDashTips(step: AffiliateDashMockStep, uid: string) {
|
||||
return [`打开领取链接,Step1 填 UID:${uid}(或自定义)`, '提交后进入绑定步,mock 会给出二维码']
|
||||
}
|
||||
if (step === 'bind') {
|
||||
return [`已预填 UID=${uid},绑定二维码为 mock 生成(扫描无效)`, '正常流程:扫码完成真实绑定后自动进入下一步']
|
||||
return [
|
||||
`已预填 UID=${uid},绑定二维码为 mock 生成(扫描无效)`,
|
||||
'正常流程:扫码完成真实绑定后自动进入下一步',
|
||||
]
|
||||
}
|
||||
if (step === 'submitted') {
|
||||
return ['已模拟绑定成功,可点「提交发货」(mock 直接模拟发货成功)']
|
||||
|
||||
Reference in New Issue
Block a user