功能(订单服务): 增加可配置未成年提示门禁
This commit is contained in:
@@ -66,7 +66,11 @@ export const WORKER_PLATFORM_TAB_QUERY_KEYS: Record<string, string[][]> = {
|
||||
finance: [['admin-finance-settlements'], ['admin-finance-withdrawals']],
|
||||
levels: [['admin-worker-levels']],
|
||||
notifications: [['admin-notifications']],
|
||||
announcement: [['admin-announcements'], ['admin-worker-support-contact']],
|
||||
announcement: [
|
||||
['admin-announcements'],
|
||||
['admin-worker-support-contact'],
|
||||
['admin-order-service-age-gate'],
|
||||
],
|
||||
'hall-config': [['admin-hall-config']],
|
||||
'risk-control': [['admin-worker-risk-overview'], ['admin-worker-risk-events']],
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import type { OrderServiceAgeGateConfig } from '@/types/worker-platform'
|
||||
|
||||
export type OrderServiceAgeGateDecision = 'pending' | 'adult' | 'minor'
|
||||
|
||||
export type OrderServiceAgeGateState = {
|
||||
orderNo: string
|
||||
decision: OrderServiceAgeGateDecision
|
||||
}
|
||||
|
||||
export const DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG: OrderServiceAgeGateConfig = {
|
||||
enabled: false,
|
||||
title: '购买前必读',
|
||||
warningText: '无法向未成年人操作发货,请认真阅读作答!!!',
|
||||
content: `1. 购买商品和角色信息有没有错误
|
||||
角色名/系统/区服有无遗漏
|
||||
如未核对导致送错,本店概不负责哦~
|
||||
|
||||
2. 购买本人实际为成年用户!!
|
||||
|
||||
3. 虚拟商品到您的游戏里,一旦发货完成,概不退款。
|
||||
|
||||
4. 发货时间具体以排单顺序为准,活动期间可能会延迟送达,未发货前协商可退。
|
||||
|
||||
5. 由于市场成本原因,价格会有所浮动,不支持以此原因退差价。
|
||||
|
||||
6. 禁止私自交易,私自交易被骗本店概不负责!!!!`,
|
||||
importantNotice:
|
||||
'【重要提示】近期有人冒充本店售后专员,以“道具回收”为由实施诈骗。请广大玩家务必以本店官方售后渠道为准,谨防上当受骗。',
|
||||
adultButtonText: '我已成年',
|
||||
minorButtonText: '我是未成年',
|
||||
minorBlockedTitle: '未成年不能购买',
|
||||
minorBlockedContent:
|
||||
'根据平台规则,本店无法向未成年人销售或操作发货。当前资料提交流程已停止,请勿继续操作。',
|
||||
}
|
||||
|
||||
export type OrderServiceAgeGateContentBlock = {
|
||||
key: string
|
||||
number: string
|
||||
title: string
|
||||
lines: string[]
|
||||
}
|
||||
|
||||
export function parseOrderServiceAgeGateContent(
|
||||
content: string,
|
||||
): OrderServiceAgeGateContentBlock[] {
|
||||
const blocks: OrderServiceAgeGateContentBlock[] = []
|
||||
for (const rawLine of String(content || '').split(/\r?\n/)) {
|
||||
const line = rawLine.trim()
|
||||
if (!line) continue
|
||||
const numbered = line.match(/^(\d+)[.、::]\s*(.*)$/)
|
||||
if (numbered) {
|
||||
blocks.push({
|
||||
key: `item-${blocks.length}`,
|
||||
number: numbered[1] || '',
|
||||
title: String(numbered[2] || '').trim(),
|
||||
lines: [],
|
||||
})
|
||||
continue
|
||||
}
|
||||
const current = blocks[blocks.length - 1]
|
||||
if (current) {
|
||||
current.lines.push(line)
|
||||
continue
|
||||
}
|
||||
blocks.push({ key: 'item-0', number: '', title: line, lines: [] })
|
||||
}
|
||||
return blocks
|
||||
}
|
||||
|
||||
export function shouldRequireOrderServiceAgeGate(input: {
|
||||
enabled?: boolean
|
||||
pendingCount: number
|
||||
}) {
|
||||
return input.enabled === true && Number(input.pendingCount || 0) > 0
|
||||
}
|
||||
|
||||
export function resolveOrderServiceAgeGateDecision(
|
||||
state: OrderServiceAgeGateState,
|
||||
orderNo: string,
|
||||
): OrderServiceAgeGateDecision {
|
||||
return state.orderNo === orderNo ? state.decision : 'pending'
|
||||
}
|
||||
|
||||
export function canAccessOrderServiceMaterial(input: {
|
||||
required: boolean
|
||||
decision: OrderServiceAgeGateDecision
|
||||
}) {
|
||||
return !input.required || input.decision === 'adult'
|
||||
}
|
||||
|
||||
export function isOrderServiceAgeGateOpen(input: {
|
||||
required: boolean
|
||||
decision: OrderServiceAgeGateDecision
|
||||
}) {
|
||||
return !canAccessOrderServiceMaterial(input)
|
||||
}
|
||||
|
||||
export function mergeOrderServiceAgeGateConfig(
|
||||
value?: Partial<OrderServiceAgeGateConfig> | null,
|
||||
): OrderServiceAgeGateConfig {
|
||||
const source = value || {}
|
||||
const text = (input: unknown, fallback: string) => String(input || '').trim() || fallback
|
||||
return {
|
||||
enabled: source.enabled === true,
|
||||
title: text(source.title, DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.title),
|
||||
warningText: text(source.warningText, DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.warningText),
|
||||
content: text(source.content, DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.content),
|
||||
importantNotice: text(
|
||||
source.importantNotice,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.importantNotice,
|
||||
),
|
||||
adultButtonText: text(
|
||||
source.adultButtonText,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.adultButtonText,
|
||||
),
|
||||
minorButtonText: text(
|
||||
source.minorButtonText,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.minorButtonText,
|
||||
),
|
||||
minorBlockedTitle: text(
|
||||
source.minorBlockedTitle,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.minorBlockedTitle,
|
||||
),
|
||||
minorBlockedContent: text(
|
||||
source.minorBlockedContent,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.minorBlockedContent,
|
||||
),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user