弱网核销功能
This commit is contained in:
@@ -111,6 +111,36 @@ export function generateRedeemNo(): string {
|
||||
return `RD${Date.now()}${Math.floor(Math.random() * 1000)}`;
|
||||
}
|
||||
|
||||
export function generateRedeemPendingNo(): string {
|
||||
return `RP${Date.now()}${Math.floor(Math.random() * 1000)}`;
|
||||
}
|
||||
|
||||
/** 弱网核销:网络类失败达到该次数后触发兜底 */
|
||||
export const REDEEM_WEAKNET_FAIL_THRESHOLD = 5;
|
||||
|
||||
export type RedeemErrorClass = 'NETWORK' | 'BUSINESS';
|
||||
|
||||
/** 门店端/服务端共用:区分网络类与业务类核销错误(仅 NETWORK 计入 5 次) */
|
||||
export function classifyRedeemClientError(input: {
|
||||
status?: number | null;
|
||||
message?: string | null;
|
||||
}): RedeemErrorClass {
|
||||
const status = input.status;
|
||||
const message = (input.message ?? '').toLowerCase();
|
||||
if (status != null && status >= 500) return 'NETWORK';
|
||||
if (status === 0 || status === 408 || status === 429 || status === 502 || status === 503 || status === 504) {
|
||||
return 'NETWORK';
|
||||
}
|
||||
if (
|
||||
/failed to fetch|network|timeout|timed out|econnreset|econnrefused|etimedout|abort|offline|连接|网络|超时/.test(
|
||||
message,
|
||||
)
|
||||
) {
|
||||
return 'NETWORK';
|
||||
}
|
||||
return 'BUSINESS';
|
||||
}
|
||||
|
||||
export function orderTabToStatuses(tab: string): string[] | undefined {
|
||||
switch (tab) {
|
||||
case 'pending_pay':
|
||||
|
||||
Reference in New Issue
Block a user