diff --git a/.env.mac-docker.example b/.env.mac-docker.example index 2bfeb72e..9cc52528 100644 --- a/.env.mac-docker.example +++ b/.env.mac-docker.example @@ -12,6 +12,13 @@ HTTP_TRUST_PROXY=1 # Claim Links CLAIM_BASE_URL=http://localhost/h5 +LIVE_HUB_PLATFORM_FULFILLMENT_URL=http://host.docker.internal:8800 +PLATFORM_FULFILLMENT_INTEGRATION_KEY= +PLATFORM_FULFILLMENT_WEBHOOK_TOLERANCE_SECONDS=300 +INTEGRATION_OUTBOX_INTERVAL_MS=1000 +INTEGRATION_OUTBOX_BATCH_SIZE=20 +INTEGRATION_OUTBOX_MAX_ATTEMPTS=12 +PLATFORM_FULFILLMENT_RECONCILE_SECONDS=900 # Database POSTGRES_DB=order_site diff --git a/.env.server.example b/.env.server.example index 9e7eff0a..f339efdc 100644 --- a/.env.server.example +++ b/.env.server.example @@ -24,6 +24,15 @@ HTTP_TRUST_PROXY=1 # Claim Links CLAIM_BASE_URL=https://order.khhao.com/h5 +# 生产服务器间优先走私网;直播运营后台私网地址为 172.23.71.41 +LIVE_HUB_PLATFORM_FULFILLMENT_URL=http://172.23.71.41 +PLATFORM_FULFILLMENT_INTEGRATION_KEY= +# 签名 Webhook 时间窗;Outbox worker 与低频对账兜底 +PLATFORM_FULFILLMENT_WEBHOOK_TOLERANCE_SECONDS=300 +INTEGRATION_OUTBOX_INTERVAL_MS=1000 +INTEGRATION_OUTBOX_BATCH_SIZE=20 +INTEGRATION_OUTBOX_MAX_ATTEMPTS=12 +PLATFORM_FULFILLMENT_RECONCILE_SECONDS=900 CLAIM_TOKEN_TTL_HOURS=0 # Database diff --git a/README.md b/README.md index 2113f8c7..d5dd1b71 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,22 @@ docker compose -f docker-compose.dev.yml logs -f frontend docker compose -f docker-compose.dev.yml down ``` +`order_site` 根目录提供 `./dev.sh` 快捷入口。默认直接启动源码挂载开发环境: + +```bash +./dev.sh # 启动/更新并直接跟踪应用日志 +./dev.sh up # 只启动/更新,不占用终端 +./dev.sh logs # 跟踪 backend / frontend / web 日志 +./dev.sh logs frontend # 只看 Vite HMR 日志 +./dev.sh logs backend # 只看后端热重载日志 +./dev.sh ps # 查看 dev 容器 +./dev.sh down # 停止 dev 容器 +``` + +开发编排会把 `apps/frontend` 和 `apps/backend` 直接挂载进容器,前端由 Vite +提供 HMR,后端由 `tsx watch` 热重载;不要用生产 `docker-compose.yml` 重建 +`web` 看页面改动。 + Mac 也可使用: ```bash @@ -208,6 +224,19 @@ SEMI_AUTO_TASK_TEST_DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/ord npx tsx --test src/services/semi-auto/semi-auto-task.integration.test.ts ``` +### 斗鱼履约跨项目同步 + +订单变化、绑定阶段和二维码投影走“事务 Outbox + 签名 Webhook”: + +- 业务变更与 `integration_outbox` 同事务提交,worker 使用 + `FOR UPDATE SKIP LOCKED` 领取并指数退避; +- 请求携带 `X-Integration-Key`、`X-Integration-Event-Id`、 + `X-Integration-Timestamp`、`X-Integration-Signature`; +- 接收端用 `integration_inbox.event_id` 幂等,重复投递不会重复写业务状态; +- 工作台通过现有 SSE 收到刷新通知,不再定时向 live-hub 拉取状态; +- 15 分钟低频对账只作漏单兜底,可通过 + `PLATFORM_FULFILLMENT_RECONCILE_SECONDS` 调整。 + ## 运行数据 | 环境 | 路径 / Volume | diff --git a/apps/backend/src/app.integration.test.ts b/apps/backend/src/app.integration.test.ts index 06b8be0d..72c35072 100644 --- a/apps/backend/src/app.integration.test.ts +++ b/apps/backend/src/app.integration.test.ts @@ -4,6 +4,7 @@ import test from 'node:test' import { createApp } from './app.js' import { createDefaultRuntimeConfig } from './config/defaults.js' +import { buildWebhookSignature } from './services/integration/webhook-signature.js' import { createStartupState } from './startup/state.js' test('HTTP health route and explicit CORS preflight', async () => { @@ -38,3 +39,62 @@ test('HTTP health route and explicit CORS preflight', async () => { await once(server, 'close') } }) + +test('履约状态集成接口要求密钥并接受空快照', async () => { + const previousKey = process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY + process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY = 'integration-test-key' + const startupState = createStartupState() + startupState.core.ready = true + const config = createDefaultRuntimeConfig('/tmp/order-site') + const server = createApp({ + startupState, + isShutdownStarted: () => false, + config, + }).listen(0, '127.0.0.1') + await once(server, 'listening') + + try { + const address = server.address() + assert.ok(address && typeof address === 'object') + const endpoint = `http://127.0.0.1:${address.port}/api/integration/platform-fulfillment/binding-state` + + const unauthorized = await fetch(endpoint, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ items: [] }), + }) + assert.equal(unauthorized.status, 401) + + const rawBody = JSON.stringify({ + eventId: '8a8da35c-46c3-45a8-a914-3d7f28ee91ca', + eventType: 'platform_fulfillment.binding_state_changed', + items: [], + }) + const timestamp = String(Math.floor(Date.now() / 1000)) + const accepted = await fetch(endpoint, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-Integration-Key': 'integration-test-key', + 'X-Integration-Event-Id': '8a8da35c-46c3-45a8-a914-3d7f28ee91ca', + 'X-Integration-Timestamp': timestamp, + 'X-Integration-Signature': buildWebhookSignature( + 'integration-test-key', + timestamp, + rawBody, + ), + }, + body: rawBody, + }) + assert.equal(accepted.status, 200) + assert.deepEqual((await accepted.json()).data, { received: 0, updated: 0 }) + } finally { + if (previousKey === undefined) { + delete process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY + } else { + process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY = previousKey + } + server.close() + await once(server, 'close') + } +}) diff --git a/apps/backend/src/app.ts b/apps/backend/src/app.ts index 0445e72e..504c7c97 100644 --- a/apps/backend/src/app.ts +++ b/apps/backend/src/app.ts @@ -11,9 +11,11 @@ import customerFulfillmentRouter from './routes/customer-fulfillment.js' import devMockConnectorRouter from './routes/dev-mock-connector.js' import dcAuthRouter from './routes/dcauth.js' import douyinMashidaRouter from './routes/douyin-mashida.js' +import douyuFulfillmentRouter from './routes/douyu-fulfillment.js' import kuaishouIndustryRouter from './routes/kuaishou-industry.js' import open91Router from './routes/open-91.js' import pddExtensionRouter from './routes/pdd-extension.js' +import platformFulfillmentIntegrationRouter from './routes/platform-fulfillment-integration.js' import redeemRouter from './routes/redeem.js' import shortLinksRouter from './routes/short-links.js' import semiAutoInjectionsRouter from './routes/semi-auto-injections.js' @@ -116,9 +118,11 @@ export function createApp({ startupState, isShutdownStarted, config }: CreateApp app.use('/api/v1/open/affiliate-dash', affiliateDashRouter) app.use('/api/v1/open/91', open91Router) app.use('/api/v1/open/kuaishou-industry', kuaishouIndustryRouter) + app.use('/api/integration', platformFulfillmentIntegrationRouter) app.use('/api/v1/redeem', redeemRouter) app.use('/api/v1/claim', claimsRouter) app.use('/api/v1/customer-fulfillment', customerFulfillmentRouter) + app.use('/api/v1/douyu-fulfillment', douyuFulfillmentRouter) app.use('/api/v1/semi-auto/injections', semiAutoInjectionsRouter) app.use('/api/v1/o', orderServiceRouter) app.use('/api/v1/pdd/extension', pddExtensionRouter) diff --git a/apps/backend/src/config/env-documentation.test.ts b/apps/backend/src/config/env-documentation.test.ts index 15c3b361..8f8209bf 100644 --- a/apps/backend/src/config/env-documentation.test.ts +++ b/apps/backend/src/config/env-documentation.test.ts @@ -10,7 +10,17 @@ const CURRENT_DIR = path.dirname(fileURLToPath(import.meta.url)) const BACKEND_ROOT = path.resolve(CURRENT_DIR, '../..') const WORKSPACE_ROOT = process.env.WORKSPACE_ROOT || path.resolve(BACKEND_ROOT, '../..') -const SPECIAL_RUNTIME_ENV_NAMES = ['APP_BASE_URL', 'CLAIM_BASE_URL'] +const SPECIAL_RUNTIME_ENV_NAMES = [ + 'APP_BASE_URL', + 'CLAIM_BASE_URL', + 'INTEGRATION_OUTBOX_BATCH_SIZE', + 'INTEGRATION_OUTBOX_INTERVAL_MS', + 'INTEGRATION_OUTBOX_MAX_ATTEMPTS', + 'LIVE_HUB_PLATFORM_FULFILLMENT_URL', + 'PLATFORM_FULFILLMENT_INTEGRATION_KEY', + 'PLATFORM_FULFILLMENT_RECONCILE_SECONDS', + 'PLATFORM_FULFILLMENT_WEBHOOK_TOLERANCE_SECONDS', +] const DEPLOYMENT_ONLY_ENV_NAMES = [ 'APP_DOMAIN', diff --git a/apps/backend/src/db/migrate.test.ts b/apps/backend/src/db/migrate.test.ts index e1805c36..b0f2f366 100644 --- a/apps/backend/src/db/migrate.test.ts +++ b/apps/backend/src/db/migrate.test.ts @@ -1,7 +1,10 @@ import assert from 'node:assert/strict' import test from 'node:test' -import { planLegacyConsignmentMigrationCleanup } from './migrate.js' +import { + planLegacyConsignmentMigrationCleanup, + planLegacyDouyuFulfillmentMigrationCleanup, +} from './migrate.js' const MAIN_MIGRATIONS = [ '147_internal_sku_product_routing', @@ -91,6 +94,32 @@ test('迁移归一化:main 已执行、只剩旧寄卖记录时只清理旧名 assert.deepEqual(stale, ['147_consignment_platform', '148_consignment_sms_logs']) }) +test('迁移归一化:拆分版斗鱼履约迁移记录全部清理,由合并版重跑', () => { + const stale = planLegacyDouyuFulfillmentMigrationCleanup([ + '170_semi_auto_trace_logs', + '171_douyu_customer_fulfillment', + '172_platform_fulfillment_outbox', + '173_douyu_fulfillment_cached_binding', + '174_douyu_fulfillment_allocated_status', + ]) + + assert.deepEqual(stale, [ + '171_douyu_customer_fulfillment', + '172_platform_fulfillment_outbox', + '173_douyu_fulfillment_cached_binding', + '174_douyu_fulfillment_allocated_status', + ]) +}) + +test('迁移归一化:只剩合并版斗鱼履约记录时不清理', () => { + const stale = planLegacyDouyuFulfillmentMigrationCleanup([ + '170_semi_auto_trace_logs', + '171_douyu_fulfillment_integration', + ]) + + assert.deepEqual(stale, []) +}) + test('迁移归一化:159 已登记但 main 147–151 缺失时,159 也要重跑', () => { const stale = planLegacyConsignmentMigrationCleanup([ '001_init', diff --git a/apps/backend/src/db/migrate.ts b/apps/backend/src/db/migrate.ts index 8352339f..443195dd 100644 --- a/apps/backend/src/db/migrate.ts +++ b/apps/backend/src/db/migrate.ts @@ -27,6 +27,7 @@ const MIGRATION_FILE_PATTERN = /^(\d{3})_.+\.sql$/i /** 合并后的寄卖迁移文件名(不含 .sql);main 的 147–152、158 保持原编号,寄卖合并文件顺延到 159。 */ const CONSOLIDATED_CONSIGNMENT_MIGRATION = '159_consignment_platform' +const CONSOLIDATED_DOUYU_FULFILLMENT_MIGRATION = '171_douyu_fulfillment_integration' const MAIN_MIGRATIONS_BEFORE_CONSIGNMENT = [ '147_internal_sku_product_routing', '148_fulfillment_execution_truth', @@ -59,10 +60,18 @@ const LEGACY_CONSIGNMENT_MIGRATION_NAMES = [ '158_consignment_match_log_snapshot', ] as const +const LEGACY_DOUYU_FULFILLMENT_MIGRATION_NAMES = [ + '171_douyu_customer_fulfillment', + '172_platform_fulfillment_outbox', + '173_douyu_fulfillment_cached_binding', + '174_douyu_fulfillment_allocated_status', +] as const + export async function runDatabaseMigrations() { assertMigrationFilesOrdered() await ensureNodePgMigrateMetadataCompatibility() await normalizeLegacyConsignmentMigrationNames() + await normalizeLegacyDouyuFulfillmentMigrationNames() console.info(`[db:migrate] 迁移目录: ${MIGRATIONS_DIR}`) @@ -190,6 +199,13 @@ export function planLegacyConsignmentMigrationCleanup(appliedNames: readonly str return staleNames } +export function planLegacyDouyuFulfillmentMigrationCleanup( + appliedNames: readonly string[], +): string[] { + const applied = new Set(appliedNames) + return LEGACY_DOUYU_FULFILLMENT_MIGRATION_NAMES.filter((name) => applied.has(name)) +} + async function normalizeLegacyConsignmentMigrationNames() { const { rows } = await query<{ name: string }>(`SELECT name FROM ${MIGRATIONS_TABLE}`) const staleNames = planLegacyConsignmentMigrationCleanup(rows.map((row) => row.name)) @@ -204,6 +220,20 @@ async function normalizeLegacyConsignmentMigrationNames() { ) } +async function normalizeLegacyDouyuFulfillmentMigrationNames() { + const { rows } = await query<{ name: string }>(`SELECT name FROM ${MIGRATIONS_TABLE}`) + const staleNames = planLegacyDouyuFulfillmentMigrationCleanup(rows.map((row) => row.name)) + if (staleNames.length === 0) { + return + } + + await query(`DELETE FROM ${MIGRATIONS_TABLE} WHERE name = ANY($1::text[])`, [staleNames]) + console.warn( + `[db:migrate] 检测到拆分版斗鱼履约迁移,已清理 ${staleNames.length} 条记录: ${staleNames.join(', ')};` + + `将由合并迁移 ${CONSOLIDATED_DOUYU_FULFILLMENT_MIGRATION} 幂等重跑`, + ) +} + async function ensureNodePgMigrateMetadataCompatibility() { await query(` CREATE TABLE IF NOT EXISTS ${MIGRATIONS_TABLE} ( diff --git a/apps/backend/src/db/migrations/171_douyu_fulfillment_integration.sql b/apps/backend/src/db/migrations/171_douyu_fulfillment_integration.sql new file mode 100644 index 00000000..a498bca9 --- /dev/null +++ b/apps/backend/src/db/migrations/171_douyu_fulfillment_integration.sql @@ -0,0 +1,337 @@ +-- 171_douyu_fulfillment_integration.sql +-- +-- 斗鱼精英宝典半自动履约: +-- 1. 人工 SKU 配置可显式启用斗鱼客户领取; +-- 2. order_site 保存客户资料、绑定状态和 live-hub 安全投影; +-- 3. 事务 Outbox 保证订单与履约状态可靠同步到 live-hub。 + +ALTER TABLE manual_fulfillment_configs + ADD COLUMN IF NOT EXISTS douyu_fulfillment_enabled BOOLEAN NOT NULL DEFAULT FALSE; + +COMMENT ON COLUMN manual_fulfillment_configs.douyu_fulfillment_enabled IS + '是否启用斗鱼精英宝典客户领取与角色绑定'; + +CREATE TABLE IF NOT EXISTS integration_outbox ( + id BIGSERIAL PRIMARY KEY, + event_id UUID NOT NULL UNIQUE, + destination TEXT NOT NULL DEFAULT 'live_hub', + event_type TEXT NOT NULL, + dedupe_key TEXT UNIQUE, + payload_json JSONB NOT NULL, + status TEXT NOT NULL DEFAULT 'pending' + CHECK (status IN ('pending', 'processing', 'sent', 'dead')), + attempts INTEGER NOT NULL DEFAULT 0, + next_attempt_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + locked_at TIMESTAMPTZ, + sent_at TIMESTAMPTZ, + last_error TEXT NOT NULL DEFAULT '', + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_integration_outbox_due + ON integration_outbox (status, next_attempt_at, id); +CREATE INDEX IF NOT EXISTS idx_integration_outbox_destination + ON integration_outbox (destination, status, id); + +CREATE TABLE IF NOT EXISTS integration_inbox ( + event_id UUID PRIMARY KEY, + source TEXT NOT NULL DEFAULT '', + event_type TEXT NOT NULL DEFAULT '', + received_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + processed_at TIMESTAMPTZ +); + +CREATE TABLE IF NOT EXISTS douyu_fulfillment_tasks ( + id BIGSERIAL PRIMARY KEY, + order_id BIGINT NOT NULL REFERENCES orders(id) ON DELETE CASCADE, + order_item_id BIGINT NOT NULL UNIQUE REFERENCES order_items(id) ON DELETE CASCADE, + fulfillment_id BIGINT REFERENCES fulfillments(id) ON DELETE SET NULL, + manual_fulfillment_config_id BIGINT + REFERENCES manual_fulfillment_configs(id) ON DELETE SET NULL, + live_session_id BIGINT, + status TEXT NOT NULL DEFAULT 'waiting_profile' + CHECK (status IN ( + 'waiting_profile', + 'preparing', + 'allocated', + 'qr_pending', + 'role_ready', + 'bound', + 'waiting_operator', + 'processing', + 'completed', + 'failed', + 'manual_required', + 'cancelled' + )), + customer_role_name TEXT NOT NULL DEFAULT '', + customer_platform TEXT NOT NULL DEFAULT '' + CHECK (customer_platform IN ('', 'wechat', 'qq')), + customer_system TEXT NOT NULL DEFAULT '' + CHECK (customer_system IN ('', 'ios', 'android')), + binding_phase TEXT NOT NULL DEFAULT '', + live_execution_status TEXT NOT NULL DEFAULT '', + live_binding_status TEXT NOT NULL DEFAULT '', + issue_code TEXT NOT NULL DEFAULT '', + last_error TEXT NOT NULL DEFAULT '', + bound_role_name TEXT NOT NULL DEFAULT '', + bound_area_name TEXT NOT NULL DEFAULT '', + bound_plat_name TEXT NOT NULL DEFAULT '', + qr_url TEXT NOT NULL DEFAULT '', + qr_generated_at TIMESTAMPTZ, + qr_expires_at TIMESTAMPTZ, + customer_link_opened_at TIMESTAMPTZ, + binding_started_at TIMESTAMPTZ, + bound_at TIMESTAMPTZ, + completed_at TIMESTAMPTZ, + last_synced_at TIMESTAMPTZ, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_tasks_status + ON douyu_fulfillment_tasks (status, updated_at DESC, id DESC); +CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_tasks_order + ON douyu_fulfillment_tasks (order_id, id); +CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_tasks_live + ON douyu_fulfillment_tasks (live_session_id) + WHERE live_session_id IS NOT NULL; + +CREATE TABLE IF NOT EXISTS douyu_fulfillment_events ( + id BIGSERIAL PRIMARY KEY, + task_id BIGINT NOT NULL REFERENCES douyu_fulfillment_tasks(id) ON DELETE CASCADE, + event_type TEXT NOT NULL, + actor_type TEXT NOT NULL DEFAULT 'system' + CHECK (actor_type IN ('system', 'customer', 'admin', 'integration')), + actor_id TEXT NOT NULL DEFAULT '', + detail_json JSONB NOT NULL DEFAULT '{}'::jsonb, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_douyu_fulfillment_events_task + ON douyu_fulfillment_events (task_id, id DESC); + +CREATE OR REPLACE FUNCTION enqueue_live_hub_platform_fulfillment_event( + p_order_id BIGINT, + p_order_item_id BIGINT, + p_fulfillment_id BIGINT, + p_reason TEXT +) RETURNS VOID +LANGUAGE plpgsql +AS $$ +DECLARE + v_event_id UUID := gen_random_uuid(); + v_platform_order_id TEXT := ''; + v_dedupe_key TEXT; +BEGIN + SELECT platform_order_id + INTO v_platform_order_id + FROM orders + WHERE id = p_order_id; + + IF COALESCE(v_platform_order_id, '') = '' THEN + RETURN; + END IF; + + v_dedupe_key := CONCAT( + 'platform-fulfillment-order:', + COALESCE(p_order_item_id, 0), + ':', + p_reason + ); + + INSERT INTO integration_outbox ( + event_id, destination, event_type, dedupe_key, payload_json, status, created_at + ) VALUES ( + v_event_id, + 'live_hub', + 'platform_fulfillment.order_changed', + v_dedupe_key, + jsonb_build_object( + 'eventId', v_event_id::text, + 'eventType', 'platform_fulfillment.order_changed', + 'occurredAt', to_char( + clock_timestamp() AT TIME ZONE 'UTC', + 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"' + ), + 'data', jsonb_build_object( + 'orderId', p_order_id, + 'orderItemId', p_order_item_id, + 'fulfillmentId', p_fulfillment_id, + 'platformOrderId', v_platform_order_id, + 'reason', p_reason + ) + ), + 'pending', + NOW() + ) + ON CONFLICT (dedupe_key) DO NOTHING; +END; +$$; + +CREATE OR REPLACE FUNCTION enqueue_platform_fulfillment_from_order() +RETURNS TRIGGER +LANGUAGE plpgsql +AS $$ +DECLARE + v_row RECORD; +BEGIN + FOR v_row IN + SELECT oi.id AS order_item_id, f.id AS fulfillment_id + FROM order_items oi + JOIN fulfillments f ON f.order_item_id = oi.id + JOIN manual_fulfillment_configs cfg ON cfg.id = f.fulfillment_config_id + WHERE oi.order_id = NEW.id + AND cfg.douyu_fulfillment_enabled = TRUE + AND f.channel = 'manual' + AND f.status IN ('assigned', 'processing', 'completed') + LOOP + PERFORM enqueue_live_hub_platform_fulfillment_event( + NEW.id, + v_row.order_item_id, + v_row.fulfillment_id, + CONCAT('order:', NEW.pay_status, ':', NEW.order_status) + ); + END LOOP; + RETURN NEW; +END; +$$; + +CREATE OR REPLACE FUNCTION enqueue_platform_fulfillment_from_fulfillment() +RETURNS TRIGGER +LANGUAGE plpgsql +AS $$ +DECLARE + v_order_id BIGINT; + v_enabled BOOLEAN := FALSE; +BEGIN + SELECT oi.order_id + INTO v_order_id + FROM order_items oi + WHERE oi.id = NEW.order_item_id; + + SELECT cfg.douyu_fulfillment_enabled + INTO v_enabled + FROM manual_fulfillment_configs cfg + WHERE cfg.id = NEW.fulfillment_config_id; + + IF v_order_id IS NOT NULL + AND v_enabled = TRUE + AND NEW.channel = 'manual' + AND NEW.status IN ('assigned', 'processing', 'completed') THEN + PERFORM enqueue_live_hub_platform_fulfillment_event( + v_order_id, + NEW.order_item_id, + NEW.id, + CONCAT('fulfillment:', NEW.status) + ); + END IF; + RETURN NEW; +END; +$$; + +CREATE OR REPLACE FUNCTION enqueue_platform_fulfillment_from_config() +RETURNS TRIGGER +LANGUAGE plpgsql +AS $$ +DECLARE + v_row RECORD; +BEGIN + IF NEW.douyu_fulfillment_enabled = TRUE THEN + FOR v_row IN + SELECT o.id AS order_id, oi.id AS order_item_id, f.id AS fulfillment_id + FROM order_items oi + JOIN orders o ON o.id = oi.order_id + JOIN fulfillments f ON f.order_item_id = oi.id + WHERE f.fulfillment_config_id = NEW.id + AND f.channel = 'manual' + AND f.status IN ('assigned', 'processing', 'completed') + LOOP + PERFORM enqueue_live_hub_platform_fulfillment_event( + v_row.order_id, + v_row.order_item_id, + v_row.fulfillment_id, + 'config_enabled' + ); + END LOOP; + END IF; + RETURN NEW; +END; +$$; + +DROP TRIGGER IF EXISTS trg_platform_fulfillment_order_sync ON orders; +CREATE TRIGGER trg_platform_fulfillment_order_sync +AFTER INSERT OR UPDATE OF pay_status, order_status ON orders +FOR EACH ROW +EXECUTE FUNCTION enqueue_platform_fulfillment_from_order(); + +DROP TRIGGER IF EXISTS trg_platform_fulfillment_fulfillment_sync ON fulfillments; +CREATE TRIGGER trg_platform_fulfillment_fulfillment_sync +AFTER INSERT OR UPDATE OF channel, status, fulfillment_config_id ON fulfillments +FOR EACH ROW +EXECUTE FUNCTION enqueue_platform_fulfillment_from_fulfillment(); + +DROP TRIGGER IF EXISTS trg_platform_fulfillment_config_sync + ON manual_fulfillment_configs; +CREATE TRIGGER trg_platform_fulfillment_config_sync +AFTER UPDATE OF douyu_fulfillment_enabled ON manual_fulfillment_configs +FOR EACH ROW +WHEN (OLD.douyu_fulfillment_enabled IS DISTINCT FROM NEW.douyu_fulfillment_enabled) +EXECUTE FUNCTION enqueue_platform_fulfillment_from_config(); + +-- 上线时补一次存量待履约订单;之后全部由业务写入同事务触发。 +INSERT INTO integration_outbox ( + event_id, destination, event_type, dedupe_key, payload_json, status, created_at +) +SELECT + event_id, + 'live_hub', + 'platform_fulfillment.order_changed', + CONCAT('platform-fulfillment-backfill:', candidate.order_item_id), + jsonb_build_object( + 'eventId', event_id::text, + 'eventType', 'platform_fulfillment.order_changed', + 'occurredAt', to_char( + clock_timestamp() AT TIME ZONE 'UTC', + 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"' + ), + 'data', jsonb_build_object( + 'orderId', candidate.order_id, + 'orderItemId', candidate.order_item_id, + 'fulfillmentId', candidate.fulfillment_id, + 'platformOrderId', candidate.platform_order_id, + 'reason', 'migration_backfill' + ) + ), + 'pending', + NOW() +FROM ( + SELECT + gen_random_uuid() AS event_id, + o.id AS order_id, + oi.id AS order_item_id, + f.id AS fulfillment_id, + o.platform_order_id + FROM orders o + JOIN order_items oi ON oi.order_id = o.id + JOIN fulfillments f ON f.order_item_id = oi.id + JOIN manual_fulfillment_configs cfg ON cfg.id = f.fulfillment_config_id + WHERE cfg.douyu_fulfillment_enabled = TRUE + AND f.channel = 'manual' + AND f.status = 'assigned' + AND o.pay_status = 'paid' + AND o.order_status NOT IN ('refunded', 'cancelled', 'closed') + AND oi.quantity = 1 +) candidate +ON CONFLICT (dedupe_key) DO NOTHING; + +COMMENT ON TABLE integration_outbox IS + 'order_site 事务 Outbox;业务提交与待发送事件同事务,worker 负责签名投递'; +COMMENT ON TABLE integration_inbox IS + 'order_site 入站 Webhook 幂等表;event_id 全局唯一'; +COMMENT ON TABLE douyu_fulfillment_tasks IS + '斗鱼精英宝典客户领取任务;客户资料以本表为准,绑定状态为 live-hub 安全投影'; +COMMENT ON COLUMN douyu_fulfillment_tasks.live_session_id IS + 'live-hub platform_fulfillment_tasks.id;不得保存内部账号或 CK'; +COMMENT ON COLUMN douyu_fulfillment_tasks.qr_url IS + 'live-hub 绑定二维码的客户页投影;仅用于展示,不包含内部账号或 CK'; diff --git a/apps/backend/src/routes/admin.ts b/apps/backend/src/routes/admin.ts index fe90009e..05dfa2ec 100644 --- a/apps/backend/src/routes/admin.ts +++ b/apps/backend/src/routes/admin.ts @@ -6,6 +6,7 @@ import costCenterRouter from './admin/cost-center.js' import dashboardRouter from './admin/dashboard.js' import devMockRouter from './admin/dev-mock.js' import douyinMashidaRouter from './admin/douyin-mashida.js' +import douyuFulfillmentRouter from './admin/douyu-fulfillment.js' import financeRouter from './admin/finance.js' import fulfillmentChannelRouter from './admin/fulfillment-channel.js' import financeLedgerRouter from './admin/finance-ledger.js' @@ -38,6 +39,7 @@ router.use(fundRouter) router.use(usersRouter) router.use(rbacRouter) router.use(semiAutoRouter) +router.use(douyuFulfillmentRouter) router.use(auditLogsRouter) router.use(platformConfigRouter) router.use(kuaishouIndustryRouter) diff --git a/apps/backend/src/routes/admin/dev-mock.ts b/apps/backend/src/routes/admin/dev-mock.ts index 444e9c83..2910d9c7 100644 --- a/apps/backend/src/routes/admin/dev-mock.ts +++ b/apps/backend/src/routes/admin/dev-mock.ts @@ -3,6 +3,7 @@ import { Router } from 'express' import { buildOpen91QueryMock, createAffiliateDashMockClaim, + createDouyuFulfillmentMock, createKuaishouIndustryVoucherMockData, createSemiAutoIntegrationMock, createSemiAutoMock, @@ -77,6 +78,27 @@ router.post( }), ) +router.post( + '/dev-mock/douyu-fulfillment', + createJsonHandler((req) => createDouyuFulfillmentMock(req.body || {}), { + successMessage: '斗鱼直播账号履约测试单已生成', + errorMessage: '生成斗鱼直播账号履约测试单失败', + scope: '[admin/dev-mock/douyu-fulfillment]', + audit: (_req, data) => ({ + action: 'dev_mock_create_douyu_fulfillment', + targetType: 'dev_mock', + targetId: String((data as { orderNo?: string })?.orderNo || ''), + data: { + platform: 'douyu', + pipeline: 'order_service', + orderNo: (data as { orderNo?: string })?.orderNo, + orderItemId: (data as { orderItemId?: number })?.orderItemId, + skuKey: (data as { skuKey?: string })?.skuKey, + }, + }), + }), +) + router.post( '/dev-mock/semi-auto', createJsonHandler((req) => createSemiAutoMock(req.body || {}), { diff --git a/apps/backend/src/routes/admin/douyu-fulfillment.ts b/apps/backend/src/routes/admin/douyu-fulfillment.ts new file mode 100644 index 00000000..8151a404 --- /dev/null +++ b/apps/backend/src/routes/admin/douyu-fulfillment.ts @@ -0,0 +1,71 @@ +import { Router } from 'express' + +import { + getDouyuFulfillmentDetail, + listDouyuFulfillmentTasks, + refreshDouyuCustomerBinding, + startDouyuCustomerBinding, + syncDouyuFulfillmentTasks, +} from '../../services/douyu-fulfillment/douyu-fulfillment-service.js' +import { createJsonHandler, requireAdminRoles } from './session.js' + +const router = Router() + +router.use('/douyu-fulfillment', requireAdminRoles(['admin', 'operator', 'support'])) + +router.get( + '/douyu-fulfillment/tasks', + createJsonHandler((req) => listDouyuFulfillmentTasks(req.query as Record), { + successMessage: 'ok', + errorMessage: '读取斗鱼领取任务失败', + scope: '[admin/douyu-fulfillment/tasks]', + }), +) + +router.post( + '/douyu-fulfillment/sync', + createJsonHandler(() => syncDouyuFulfillmentTasks(), { + successMessage: '斗鱼领取任务已同步', + errorMessage: '同步斗鱼领取任务失败', + scope: '[admin/douyu-fulfillment/sync]', + audit: () => ({ + action: 'douyu_fulfillment_synced', + targetType: 'douyu_fulfillment_task', + targetId: 'all', + data: {}, + }), + }), +) + +router.get( + '/douyu-fulfillment/tasks/:orderNo', + createJsonHandler((req) => getDouyuFulfillmentDetail(String(req.params.orderNo || '')), { + successMessage: 'ok', + errorMessage: '读取斗鱼领取详情失败', + scope: '[admin/douyu-fulfillment/tasks/:orderNo]', + }), +) + +router.post( + '/douyu-fulfillment/tasks/:orderNo/binding/refresh', + createJsonHandler((req) => refreshDouyuCustomerBinding(String(req.params.orderNo || '')), { + successMessage: '绑定状态已刷新', + errorMessage: '刷新斗鱼绑定状态失败', + scope: '[admin/douyu-fulfillment/tasks/:orderNo/binding/refresh]', + }), +) + +router.post( + '/douyu-fulfillment/tasks/:orderNo/binding/start', + createJsonHandler( + (req) => + startDouyuCustomerBinding(String(req.params.orderNo || ''), req.body?.forceRefresh === true), + { + successMessage: '绑定二维码已重新准备', + errorMessage: '重新生成斗鱼绑定二维码失败', + scope: '[admin/douyu-fulfillment/tasks/:orderNo/binding/start]', + }, + ), +) + +export default router diff --git a/apps/backend/src/routes/douyu-fulfillment.ts b/apps/backend/src/routes/douyu-fulfillment.ts new file mode 100644 index 00000000..e877f623 --- /dev/null +++ b/apps/backend/src/routes/douyu-fulfillment.ts @@ -0,0 +1,64 @@ +import { Router } from 'express' + +import { + confirmDouyuCustomerBinding, + getDouyuCustomerFulfillmentCached, + getCustomerDouyuFulfillment, + saveDouyuCustomerProfile, + startDouyuCustomerBinding, +} from '../services/douyu-fulfillment/douyu-fulfillment-service.js' +import { createRouteHandler } from '../utils/http.js' + +const router = Router() + +router.get( + '/:orderNo', + createRouteHandler((req) => getCustomerDouyuFulfillment(String(req.params.orderNo || '')), { + errorMessage: '读取斗鱼领取信息失败', + scope: '[douyu-fulfillment/:orderNo]', + }), +) + +router.post( + '/:orderNo/profile', + createRouteHandler( + (req) => saveDouyuCustomerProfile(String(req.params.orderNo || ''), req.body || {}), + { + successMessage: '游戏资料已保存', + errorMessage: '保存游戏资料失败', + scope: '[douyu-fulfillment/:orderNo/profile]', + }, + ), +) + +router.post( + '/:orderNo/binding/start', + createRouteHandler( + (req) => + startDouyuCustomerBinding(String(req.params.orderNo || ''), req.body?.forceRefresh === true), + { + successMessage: '绑定二维码已准备', + errorMessage: '生成绑定二维码失败', + scope: '[douyu-fulfillment/:orderNo/binding/start]', + }, + ), +) + +router.get( + '/:orderNo/binding/status', + createRouteHandler((req) => getDouyuCustomerFulfillmentCached(String(req.params.orderNo || '')), { + errorMessage: '读取绑定状态失败', + scope: '[douyu-fulfillment/:orderNo/binding/status]', + }), +) + +router.post( + '/:orderNo/binding/confirm', + createRouteHandler((req) => confirmDouyuCustomerBinding(String(req.params.orderNo || '')), { + successMessage: '角色绑定已确认', + errorMessage: '确认角色绑定失败', + scope: '[douyu-fulfillment/:orderNo/binding/confirm]', + }), +) + +export default router diff --git a/apps/backend/src/routes/platform-fulfillment-integration.ts b/apps/backend/src/routes/platform-fulfillment-integration.ts new file mode 100644 index 00000000..b3c9772c --- /dev/null +++ b/apps/backend/src/routes/platform-fulfillment-integration.ts @@ -0,0 +1,88 @@ +import { timingSafeEqual } from 'node:crypto' + +import { Router } from 'express' + +import { applyLiveBindingStateSnapshot } from '../services/douyu-fulfillment/douyu-fulfillment-service.js' +import { + verifyWebhookSignature, + webhookToleranceSeconds, +} from '../services/integration/webhook-signature.js' +import { createHttpError, createRouteHandler } from '../utils/http.js' + +const router = Router() + +router.use('/platform-fulfillment', (req, res, next) => { + const expected = String(process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY || '').trim() + if (!expected) { + res.status(503).json({ + code: 1, + msg: '直播账号履约集成密钥未配置', + errorCode: 'integration_not_configured', + time: Math.floor(Date.now() / 1000), + data: null, + }) + return + } + + const provided = String(req.header('x-integration-key') || '').trim() + const expectedBuffer = Buffer.from(expected) + const providedBuffer = Buffer.from(provided) + if ( + expectedBuffer.length !== providedBuffer.length || + !timingSafeEqual(expectedBuffer, providedBuffer) + ) { + res.status(401).json({ + code: 1, + msg: '直播账号履约集成鉴权失败', + errorCode: 'integration_unauthorized', + time: Math.floor(Date.now() / 1000), + data: null, + }) + return + } + next() +}) + +router.post( + '/platform-fulfillment/binding-state', + createRouteHandler( + (req) => { + const integrationKey = String(process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY || '').trim() + const eventId = String(req.header('x-integration-event-id') || '').trim() + const timestamp = String(req.header('x-integration-timestamp') || '').trim() + const signature = String(req.header('x-integration-signature') || '').trim() + const body = req.body as Record | undefined + if ( + !verifyWebhookSignature({ + secret: integrationKey, + timestamp, + rawBody: req.rawBody || '', + signature, + toleranceSeconds: webhookToleranceSeconds(), + }) + ) { + throw createHttpError('履约 Webhook 签名无效', { + statusCode: 401, + errorCode: 'integration_signature_invalid', + }) + } + if (!body || String(body.eventId || '').trim() !== eventId) { + throw createHttpError('履约 Webhook 事件编号不一致', { + statusCode: 400, + errorCode: 'integration_event_id_mismatch', + }) + } + return applyLiveBindingStateSnapshot(body, { + eventId, + eventType: String(body.eventType || ''), + }) + }, + { + successMessage: '履约状态已同步', + errorMessage: '同步履约状态失败', + scope: '[integration/platform-fulfillment/binding-state]', + }, + ), +) + +export default router diff --git a/apps/backend/src/services/cost-center/manual-fulfillment-config-service.ts b/apps/backend/src/services/cost-center/manual-fulfillment-config-service.ts index 24c0a9b5..02856436 100644 --- a/apps/backend/src/services/cost-center/manual-fulfillment-config-service.ts +++ b/apps/backend/src/services/cost-center/manual-fulfillment-config-service.ts @@ -115,6 +115,7 @@ type ManualSkuRow = { config_semi_auto_enabled: boolean | null config_semi_auto_platform: string | null config_semi_auto_config_json: unknown + config_douyu_fulfillment_enabled: boolean | null } type ManualChannelConfig = { @@ -353,7 +354,8 @@ export async function listManualSkus(input: Record = {}) { cfg.channels_json AS config_channels_json, cfg.semi_auto_enabled AS config_semi_auto_enabled, cfg.semi_auto_platform AS config_semi_auto_platform, - cfg.semi_auto_config_json AS config_semi_auto_config_json + cfg.semi_auto_config_json AS config_semi_auto_config_json, + cfg.douyu_fulfillment_enabled AS config_douyu_fulfillment_enabled FROM product_catalog p JOIN internal_skus product_sku ON product_sku.id = p.internal_sku_id LEFT JOIN LATERAL ( @@ -468,6 +470,8 @@ export async function saveManualFulfillmentConfig(payload: JsonObject) { const enabled = payload.enabled === false ? false : true const note = optionalText(payload.note, 300) const semiAuto = normalizeSemiAutoConfig(payload) + const douyuFulfillmentEnabled = + payload.douyuFulfillmentEnabled === true || payload.douyu_fulfillment_enabled === true // 消耗积分为 0 = 成本不固定,客服确认履约时手填。 const costMode = primaryChannel.costMode @@ -560,7 +564,8 @@ export async function saveManualFulfillmentConfig(payload: JsonObject) { semi_auto_enabled = $10, semi_auto_platform = $11, semi_auto_config_json = $12::jsonb, - updated_at = $13 + douyu_fulfillment_enabled = $13, + updated_at = $14 WHERE id = $1 RETURNING *`, [ @@ -576,6 +581,7 @@ export async function saveManualFulfillmentConfig(payload: JsonObject) { semiAuto.enabled, semiAuto.platform, JSON.stringify(semiAuto.config), + douyuFulfillmentEnabled, now, ], ) @@ -584,10 +590,11 @@ export async function saveManualFulfillmentConfig(payload: JsonObject) { sku_key, canonical_product_id, platform_key, credit_quantity, cost_mode, enabled, note, channels_json, semi_auto_enabled, semi_auto_platform, semi_auto_config_json, + douyu_fulfillment_enabled, created_at, updated_at ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8::jsonb, - $9, $10, $11::jsonb, $12, $12 + $9, $10, $11::jsonb, $12, $13, $13 ) RETURNING *`, [ @@ -602,6 +609,7 @@ export async function saveManualFulfillmentConfig(payload: JsonObject) { semiAuto.enabled, semiAuto.platform, JSON.stringify(semiAuto.config), + douyuFulfillmentEnabled, now, ], ) @@ -1077,6 +1085,7 @@ export async function getManualFulfillmentConfig(skuKey: string) { semi_auto_enabled: boolean semi_auto_platform: string semi_auto_config_json: unknown + douyu_fulfillment_enabled: boolean created_at: string updated_at: string }>( @@ -1208,6 +1217,7 @@ function mapManualSku(row: ManualSkuRow, unitPrices: Record { - assertDevMockEnabled() - - const platform = normalizeMockSemiAutoPlatform(input.platform) - const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}` - const orderNo = String( - input.orderNo || `${platform === 'weibo' ? 'INTWB' : 'INTSA'}${suffix}`, - ).trim() - const skuKey = normalizeMockSemiAutoSku( - input.skuName || `${platform === 'weibo' ? '微博' : '虎牙'}真实链路测试-${suffix}`, - platform, - ) - const quantity = normalizeMockSemiAutoQuantity(input.quantity) - const connectorMode = - platform === 'weibo' ? 'embedded' : normalizeMockSemiAutoConnectorMode(input.connectorMode) - const provider = 'dev_integration' - const sourcePlatform = 'internal_test' - const shopId = 'dev-integration-shop' - const externalSkuCode = `INTEGRATION-${suffix}` - const pageTitle = String( - input.pageTitle || (platform === 'weibo' ? '微博账号登录授权' : '虎牙账号登录授权'), - ) - .trim() - .slice(0, 60) - const browserTargetUrl = String( - input.browserTargetUrl || - (platform === 'weibo' ? 'https://weibo.com/' : 'https://www.huya.com/'), - ) - .trim() - .slice(0, 1000) - - const existing = await findOrderByPlatformOrderId({ - provider, - platform: sourcePlatform, - shopId, - platformOrderId: orderNo, - }) - if (existing) { - throw createHttpError(`订单号已存在:${orderNo},请换一个或留空自动生成`, { - statusCode: 409, - errorCode: 'dev_integration_order_exists', - }) +type PersistManualIntegrationOrderInput = { + orderNo: string + skuKey: string + externalSkuCode: string + provider: string + sourcePlatform: string + shopId: string + shopName: string + buyerId: string + buyerName: string + sourceTag: string + rawPayload: Record + itemSnapshot: Record + configNote: string + quantity?: number + semiAuto?: { + platform: 'huya' | 'weibo' + config: Record } +} +type PersistManualIntegrationOrderResult = { + orderId: number + orderNo: string + orderItemId: number + fulfillmentId: number + configId: number + mappingId: number + skuKey: string +} + +/** + * 通过正式订单入口创建人工渠道测试单。 + * + * 是否生成旧半自动任务由 semi_auto_enabled 决定,调用方无需直接写订单、 + * 履约或任务表。 + */ +async function persistManualIntegrationOrder( + input: PersistManualIntegrationOrderInput, +): Promise { + const quantity = normalizeMockSemiAutoQuantity(input.quantity) const config = await saveManualFulfillmentConfig({ - skuKey, + skuKey: input.skuKey, enabled: true, - note: '开发集成测试:真实订单履约链路', + note: input.configNote, channels: [{ platformKey: 'fund_cash', creditQuantity: 100, enabled: true }], - semiAutoEnabled: true, - semiAutoPlatform: platform, - semiAutoConfig: { - pageTitle, - pageDescription: '真实入库链路测试订单:登录与 CK 获取使用当前 Connector。', - loginInstructions: '请使用本人账号完成登录授权,客服后续人工处理。', - loginMethods: ['sms', 'qr'], - browserTargets: [ - { - key: platform, - label: platform === 'weibo' ? '微博' : '虎牙', - url: browserTargetUrl, - }, - ], - }, + semiAutoEnabled: Boolean(input.semiAuto), + ...(input.semiAuto + ? { + semiAutoPlatform: input.semiAuto.platform, + semiAutoConfig: input.semiAuto.config, + } + : {}), }) const configId = Number(config.id || 0) if (!configId) { @@ -620,53 +614,47 @@ export async function createSemiAutoIntegrationMock( }) } const mappingId = await upsertInternalSkuMapping({ - provider, - shopId, + provider: input.provider, + shopId: input.shopId, matchType: 'sku_code', - matchValue: externalSkuCode, - internalSku: skuKey, + matchValue: input.externalSkuCode, + internalSku: input.skuKey, priority: 1000, - source: 'dev_integration', - note: `订单 ${orderNo}`, + source: input.sourceTag, + note: `订单 ${input.orderNo}`, }) const now = nowIso() const upserted = await upsertOrderFromSource( { - provider, - platform: sourcePlatform, - shopId, - shopName: '半自动真实链路测试店', - platformOrderId: orderNo, + provider: input.provider, + platform: input.sourcePlatform, + shopId: input.shopId, + shopName: input.shopName, + platformOrderId: input.orderNo, orderStatus: 'paid', payStatus: 'paid', - buyerId: `integration-buyer-${suffix}`, - buyerName: '集成测试客户', + buyerId: input.buyerId, + buyerName: input.buyerName, receiverContact: '', totalAmount: 100 * quantity, currency: 'CNY', rawPayload: { - source: 'dev_integration', - orderNo, - skuKey, - platform, + ...input.rawPayload, createdAt: now, }, paidAt: now, items: [ { quantity, - skuCode: externalSkuCode, - skuName: skuKey, + skuCode: input.externalSkuCode, + skuName: input.skuKey, spec: {}, - snapshot: { - source: 'dev_integration', - semiAuto: { platform }, - }, + snapshot: input.itemSnapshot, }, ], }, - { sourceLabel: 'dev_semi_auto_integration' }, + { sourceLabel: input.sourceTag }, ) if (upserted.ignored || !upserted.order) { throw createHttpError(upserted.ignoreReason || '真实链路订单入库失败', { @@ -727,38 +715,167 @@ export async function createSemiAutoIntegrationMock( expected: { status: 'assigned', channel: 'manual' }, onlyWhenConfigNull: true, }) - await ensureSemiAutoTasksForOrderItems([orderItemId]) const resolved = await query<{ fulfillment_id: number fulfillment_channel: string fulfillment_status: string - task_id: number }>( ` SELECT f.id AS fulfillment_id, f.channel AS fulfillment_channel, - f.status AS fulfillment_status, + f.status AS fulfillment_status + FROM fulfillments f + WHERE f.order_item_id = $1 + LIMIT 1 + `, + [orderItemId], + ) + const fulfillment = resolved.rows[0] + if ( + !fulfillment || + fulfillment.fulfillment_channel !== 'manual' || + fulfillment.fulfillment_status !== 'assigned' + ) { + throw createHttpError( + `真实链路未生成人工履约:channel=${fulfillment?.fulfillment_channel || ''}, status=${fulfillment?.fulfillment_status || ''}`, + { statusCode: 500, errorCode: 'dev_integration_manual_fulfillment_failed' }, + ) + } + + return { + orderId: Number(upserted.order.id), + orderNo: input.orderNo, + orderItemId, + fulfillmentId: Number(fulfillment.fulfillment_id), + configId, + mappingId, + skuKey: input.skuKey, + } +} + +/** + * 真实履约链路集成测试单。 + * + * 订单必须通过正式 upsertOrderFromSource 入库,再走 SKU 映射、渠道判定和 + * Carrier 补偿;不直接写 order/order_item/fulfillment。 + */ +export async function createSemiAutoIntegrationMock( + input: { + platform?: unknown + orderNo?: unknown + skuName?: unknown + quantity?: unknown + pageTitle?: unknown + browserTargetUrl?: unknown + connectorMode?: unknown + } = {}, +): Promise { + assertDevMockEnabled() + + const platform = normalizeMockSemiAutoPlatform(input.platform) + const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}` + const orderNo = String( + input.orderNo || `${platform === 'weibo' ? 'INTWB' : 'INTSA'}${suffix}`, + ).trim() + const skuKey = normalizeMockSemiAutoSku( + input.skuName || `${platform === 'weibo' ? '微博' : '虎牙'}真实链路测试-${suffix}`, + platform, + ) + const quantity = normalizeMockSemiAutoQuantity(input.quantity) + const connectorMode = + platform === 'weibo' ? 'embedded' : normalizeMockSemiAutoConnectorMode(input.connectorMode) + const provider = 'dev_integration' + const sourcePlatform = 'internal_test' + const shopId = 'dev-integration-shop' + const externalSkuCode = `INTEGRATION-${suffix}` + const pageTitle = String( + input.pageTitle || (platform === 'weibo' ? '微博账号登录授权' : '虎牙账号登录授权'), + ) + .trim() + .slice(0, 60) + const browserTargetUrl = String( + input.browserTargetUrl || + (platform === 'weibo' ? 'https://weibo.com/' : 'https://www.huya.com/'), + ) + .trim() + .slice(0, 1000) + + const existing = await findOrderByPlatformOrderId({ + provider, + platform: sourcePlatform, + shopId, + platformOrderId: orderNo, + }) + if (existing) { + throw createHttpError(`订单号已存在:${orderNo},请换一个或留空自动生成`, { + statusCode: 409, + errorCode: 'dev_integration_order_exists', + }) + } + + const persisted = await persistManualIntegrationOrder({ + orderNo, + skuKey, + externalSkuCode, + provider, + sourcePlatform, + shopId, + shopName: '半自动真实链路测试店', + buyerId: `integration-buyer-${suffix}`, + buyerName: '集成测试客户', + sourceTag: 'dev_semi_auto_integration', + rawPayload: { + source: 'dev_integration', + orderNo, + skuKey, + platform, + }, + itemSnapshot: { + source: 'dev_integration', + semiAuto: { platform }, + }, + configNote: '开发集成测试:真实订单履约链路', + quantity, + semiAuto: { + platform, + config: { + pageTitle, + pageDescription: '真实入库链路测试订单:登录与 CK 获取使用当前 Connector。', + loginInstructions: '请使用本人账号完成登录授权,客服后续人工处理。', + loginMethods: ['sms', 'qr'], + browserTargets: [ + { + key: platform, + label: platform === 'weibo' ? '微博' : '虎牙', + url: browserTargetUrl, + }, + ], + }, + }, + }) + await ensureSemiAutoTasksForOrderItems([persisted.orderItemId]) + + const resolved = await query<{ + task_id: number + }>( + ` + SELECT task.id AS task_id FROM fulfillments f LEFT JOIN semi_auto_tasks task ON task.order_item_id = f.order_item_id WHERE f.order_item_id = $1 LIMIT 1 `, - [orderItemId], + [persisted.orderItemId], ) const row = resolved.rows[0] - if ( - !row || - row.fulfillment_channel !== 'manual' || - row.fulfillment_status !== 'assigned' || - !Number(row.task_id) - ) { - throw createHttpError( - `真实链路未生成半自动任务:channel=${row?.fulfillment_channel || ''}, status=${row?.fulfillment_status || ''}, task=${row?.task_id || 0}`, - { statusCode: 500, errorCode: 'dev_integration_semi_auto_task_failed' }, - ) + if (!row || !Number(row.task_id)) { + throw createHttpError('真实链路未生成半自动任务', { + statusCode: 500, + errorCode: 'dev_integration_semi_auto_task_failed', + }) } await query('UPDATE semi_auto_tasks SET connector_mode = $2, updated_at = NOW() WHERE id = $1', [ @@ -771,17 +888,17 @@ export async function createSemiAutoIntegrationMock( platform: 'semi_auto', semiAutoPlatform: platform, pipeline: 'order_service', - orderId: Number(upserted.order.id), - orderNo, - orderItemId, - fulfillmentId: Number(row.fulfillment_id), - configId, + orderId: persisted.orderId, + orderNo: persisted.orderNo, + orderItemId: persisted.orderItemId, + fulfillmentId: persisted.fulfillmentId, + configId: persisted.configId, taskId: Number(row.task_id), - skuKey, + skuKey: persisted.skuKey, connectorMode, connectorConfigured, - mappingId, - customerPath: buildMockCustomerPath(platform, orderNo), + mappingId: persisted.mappingId, + customerPath: buildMockCustomerPath(platform, persisted.orderNo), adminPath: `/admin/semi-auto-tasks?keyword=${encodeURIComponent(orderNo)}`, tips: [ '订单通过正式 upsertOrderFromSource 入库。', @@ -794,6 +911,116 @@ export async function createSemiAutoIntegrationMock( } } +/** + * 斗鱼直播账号履约专用测试单。 + * + * 只生成 live-hub 工作台需要的正式人工履约数据,不启用 order_site 的 + * huya/weibo 半自动任务。 + */ +export async function createDouyuFulfillmentMock( + input: { + orderNo?: unknown + skuName?: unknown + } = {}, +): Promise { + assertDevMockEnabled() + + const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}` + const orderNo = String(input.orderNo || `LIVEHUBDOUYU${suffix}`).trim() + const requestedSkuKey = String(input.skuName || `斗鱼精英宝典联调-${suffix}`) + .trim() + .slice(0, 48) + if (!requestedSkuKey || !containsCjk(requestedSkuKey)) { + throw createHttpError('内部 SKU 名称必须包含中文', { + statusCode: 400, + errorCode: 'dev_douyu_fulfillment_sku_invalid', + }) + } + + const provider = 'livehub_douyu_dev' + const sourcePlatform = 'internal_test' + const shopId = 'livehub-douyu-dev-shop' + const existing = await findOrderByPlatformOrderId({ + provider, + platform: sourcePlatform, + shopId, + platformOrderId: orderNo, + }) + if (existing) { + throw createHttpError(`订单号已存在:${orderNo},请换一个或留空自动生成`, { + statusCode: 409, + errorCode: 'dev_douyu_fulfillment_order_exists', + }) + } + + const persisted = await persistManualIntegrationOrder({ + orderNo, + skuKey: requestedSkuKey, + externalSkuCode: `DOUYU-FULFILLMENT-${suffix}`, + provider, + sourcePlatform, + shopId, + shopName: '直播账号履约联调店', + buyerId: `douyu-fulfillment-buyer-${suffix}`, + buyerName: '斗鱼履约联调客户', + sourceTag: 'dev_douyu_fulfillment', + rawPayload: { + source: 'dev_douyu_fulfillment', + orderNo, + skuKey: requestedSkuKey, + targetPlatform: 'douyu', + }, + itemSnapshot: { + source: 'dev_douyu_fulfillment', + targetPlatform: 'douyu', + scope: 'elite', + }, + configNote: '开发 Mock:斗鱼直播账号履约', + }) + await query( + `UPDATE manual_fulfillment_configs + SET douyu_fulfillment_enabled = TRUE, updated_at = NOW() + WHERE id = $1`, + [persisted.configId], + ) + + const verification = await query<{ + semi_auto_task_count: number + semi_auto_enabled: boolean + }>( + ` + SELECT + COUNT(task.id)::int AS semi_auto_task_count, + BOOL_OR(cfg.semi_auto_enabled) AS semi_auto_enabled + FROM fulfillments f + JOIN manual_fulfillment_configs cfg ON cfg.id = f.fulfillment_config_id + LEFT JOIN semi_auto_tasks task ON task.order_item_id = f.order_item_id + WHERE f.id = $1 + `, + [persisted.fulfillmentId], + ) + const row = verification.rows[0] + if (Number(row?.semi_auto_task_count || 0) > 0 || row?.semi_auto_enabled === true) { + throw createHttpError('斗鱼专用 Mock 不应生成半自动任务', { + statusCode: 500, + errorCode: 'dev_douyu_fulfillment_semi_auto_conflict', + }) + } + + return { + platform: 'douyu', + pipeline: 'order_service', + ...persisted, + customerPath: `/coll/d/${encodeURIComponent(persisted.orderNo)}`, + adminPath: `/admin/orders/${persisted.orderId}`, + tips: [ + '订单已通过 upsertOrderFromSource 正式入库。', + '履约渠道为 manual,状态为 assigned,且不会生成 huya/weibo 半自动任务。', + `在 live-hub 直播账号履约工作台同步后,用内部 SKU「${persisted.skuKey}」配置斗鱼商品映射。`, + ], + } +} + function normalizeMockSemiAutoPlatform(value: unknown): 'huya' | 'weibo' { return String(value || '') .trim() diff --git a/apps/backend/src/services/douyu-fulfillment/douyu-fulfillment-service.ts b/apps/backend/src/services/douyu-fulfillment/douyu-fulfillment-service.ts new file mode 100644 index 00000000..01d31bb0 --- /dev/null +++ b/apps/backend/src/services/douyu-fulfillment/douyu-fulfillment-service.ts @@ -0,0 +1,871 @@ +import type { PoolClient } from 'pg' + +import { query, withTransaction } from '../../db/client.js' +import { publishRealtimeEvent } from '../realtime/realtime-event-service.js' +import { nowIso } from '../../utils/time.js' +import { createHttpError } from '../../utils/http.js' +import { logWarn } from '../../utils/logger.js' + +type DouyuTaskRow = { + id: number + order_id: number + order_item_id: number + fulfillment_id: number | null + manual_fulfillment_config_id: number | null + live_session_id: number | null + status: string + customer_role_name: string + customer_platform: string + customer_system: string + binding_phase: string + live_execution_status: string + live_binding_status: string + issue_code: string + last_error: string + bound_role_name: string + bound_area_name: string + bound_plat_name: string + customer_link_opened_at: string | null + binding_started_at: string | null + bound_at: string | null + completed_at: string | null + last_synced_at: string | null + qr_url: string + qr_generated_at: string | null + qr_expires_at: string | null + created_at: string + updated_at: string + platform_order_id: string + sku_code: string + sku_name: string + quantity: number + product_name: string + fulfillment_status: string +} + +type LiveBindingState = { + sessionId: number + platformOrderId: string + sourceOrderItemId: string + productName: string + quantity: number + executionStatus: string + bindingStatus: string + exchangeStatus: string + issueCode: string + message: string + accountReady: boolean + bindTaskId: number | null + bindTaskStatus: string + bindPhase: string + qrUrl: string + qrGeneratedAt: string + qrExpiresAt: string + roleName: string + areaName: string + platName: string + bindReadyForConfirm: boolean + bindConfirmed: boolean + customerProfileReset?: boolean + resetReason?: string + completedAt: string | null + updatedAt: string +} + +type LiveBindingBatchResponse = { + items: LiveBindingState[] +} + +const AUTO_DISCOVERY_INTERVAL_MS = 15_000 +const LIVE_STATE_SYNC_INTERVAL_MS = 60_000 +const TERMINAL_TASK_STATUSES = new Set(['completed', 'cancelled']) + +let lastAutomaticDiscoveryAt = 0 +let automaticDiscoveryInFlight: Promise<{ created: number; updated: number } | null> | null = null + +const TASK_SELECT = ` + SELECT + task.*, + o.platform_order_id, + oi.sku_code, + oi.sku_name, + oi.quantity, + COALESCE(NULLIF(oi.sku_name, ''), NULLIF(oi.sku_code, ''), '订单商品') AS product_name, + f.status AS fulfillment_status + FROM douyu_fulfillment_tasks task + JOIN orders o ON o.id = task.order_id + JOIN order_items oi ON oi.id = task.order_item_id + LEFT JOIN fulfillments f ON f.id = task.fulfillment_id +` + +function liveHubBaseUrl() { + return String(process.env.LIVE_HUB_PLATFORM_FULFILLMENT_URL || 'http://127.0.0.1:8800') + .trim() + .replace(/\/+$/, '') +} + +function integrationKey() { + const key = String(process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY || '').trim() + if (!key) { + throw createHttpError('直播账号履约集成密钥未配置', { + statusCode: 503, + errorCode: 'live_hub_integration_not_configured', + }) + } + return key +} + +async function liveHubRequest( + path: string, + init: { method?: string; body?: Record } = {}, +): Promise { + const response = await fetch(`${liveHubBaseUrl()}${path}`, { + method: init.method || 'GET', + headers: { + 'Content-Type': 'application/json', + 'X-Integration-Key': integrationKey(), + }, + ...(init.body ? { body: JSON.stringify(init.body) } : {}), + signal: AbortSignal.timeout(20_000), + }) + const text = await response.text() + let payload: unknown = null + try { + payload = text ? JSON.parse(text) : null + } catch { + payload = text + } + if (!response.ok) { + const detail = + payload && typeof payload === 'object' && 'detail' in payload + ? String((payload as { detail?: unknown }).detail || '') + : String(payload || '') + throw createHttpError(detail || '直播账号履约服务请求失败', { + statusCode: response.status >= 500 ? 502 : response.status, + errorCode: 'live_hub_fulfillment_request_failed', + }) + } + return payload as T +} + +async function appendEvent( + client: Pick, + taskId: number, + eventType: string, + actorType: 'system' | 'customer' | 'admin' | 'integration', + detail: Record = {}, +) { + await client.query( + ` + INSERT INTO douyu_fulfillment_events ( + task_id, event_type, actor_type, detail_json, created_at + ) VALUES ($1, $2, $3, $4::jsonb, NOW()) + `, + [taskId, eventType, actorType, JSON.stringify(detail)], + ) +} + +export async function ensureDouyuFulfillmentTasks(orderNo = '') { + const params: unknown[] = [] + let filter = '' + const normalizedOrderNo = String(orderNo || '').trim() + if (normalizedOrderNo) { + params.push(normalizedOrderNo) + filter = 'AND o.platform_order_id = $1' + } + const candidates = await query<{ + order_id: number + order_item_id: number + fulfillment_id: number + config_id: number + platform_order_id: string + }>( + ` + SELECT + o.id AS order_id, + oi.id AS order_item_id, + f.id AS fulfillment_id, + cfg.id AS config_id, + o.platform_order_id + FROM orders o + JOIN order_items oi ON oi.order_id = o.id + JOIN fulfillments f ON f.order_item_id = oi.id + JOIN manual_fulfillment_configs cfg ON cfg.id = f.fulfillment_config_id + WHERE cfg.enabled = TRUE + AND cfg.douyu_fulfillment_enabled = TRUE + AND f.channel = 'manual' + AND f.status IN ('assigned', 'processing', 'completed') + ${filter} + ORDER BY o.id DESC, oi.id ASC + `, + params, + ) + if (candidates.rows.length === 0) return { created: 0, updated: 0 } + + let created = 0 + await withTransaction(async (client) => { + for (const row of candidates.rows) { + const inserted = await client.query<{ id: number; inserted: boolean }>( + ` + INSERT INTO douyu_fulfillment_tasks ( + order_id, order_item_id, fulfillment_id, manual_fulfillment_config_id, + status, created_at, updated_at + ) VALUES ($1, $2, $3, $4, 'waiting_profile', NOW(), NOW()) + ON CONFLICT (order_item_id) DO UPDATE SET + fulfillment_id = EXCLUDED.fulfillment_id, + manual_fulfillment_config_id = EXCLUDED.manual_fulfillment_config_id, + updated_at = CASE + WHEN douyu_fulfillment_tasks.fulfillment_id IS DISTINCT FROM EXCLUDED.fulfillment_id + OR douyu_fulfillment_tasks.manual_fulfillment_config_id + IS DISTINCT FROM EXCLUDED.manual_fulfillment_config_id + THEN NOW() + ELSE douyu_fulfillment_tasks.updated_at + END + RETURNING id, (xmax = 0) AS inserted + `, + [row.order_id, row.order_item_id, row.fulfillment_id, row.config_id], + ) + const taskId = Number(inserted.rows[0]?.id || 0) + if (!taskId) continue + if (inserted.rows[0]?.inserted) { + created += 1 + await appendEvent(client, taskId, 'task_created', 'system', { + platformOrderId: row.platform_order_id, + }) + } + } + }) + return { created, updated: candidates.rows.length - created } +} + +async function ensureDouyuFulfillmentTasksAutomatically() { + if (automaticDiscoveryInFlight) return automaticDiscoveryInFlight + if (Date.now() - lastAutomaticDiscoveryAt < AUTO_DISCOVERY_INTERVAL_MS) return null + + lastAutomaticDiscoveryAt = Date.now() + const run = ensureDouyuFulfillmentTasks() + .catch((error) => { + lastAutomaticDiscoveryAt = 0 + throw error + }) + .finally(() => { + automaticDiscoveryInFlight = null + }) + automaticDiscoveryInFlight = run + return run +} + +async function loadTaskByOrderNo(orderNo: string) { + const normalized = String(orderNo || '').trim() + if (!normalized) { + throw createHttpError('订单号不能为空', { + statusCode: 400, + errorCode: 'douyu_order_no_required', + }) + } + await ensureDouyuFulfillmentTasks(normalized) + const result = await query( + `${TASK_SELECT} + WHERE o.platform_order_id = $1 + ORDER BY task.id ASC + LIMIT 1`, + [normalized], + ) + const task = result.rows[0] + if (!task) { + throw createHttpError('订单不存在或尚未启用斗鱼领取', { + statusCode: 404, + errorCode: 'douyu_fulfillment_not_found', + }) + } + return task +} + +async function loadTask(taskId: number) { + const result = await query(`${TASK_SELECT} WHERE task.id = $1 LIMIT 1`, [taskId]) + const task = result.rows[0] + if (!task) { + throw createHttpError('斗鱼领取任务不存在', { + statusCode: 404, + errorCode: 'douyu_fulfillment_not_found', + }) + } + return task +} + +function normalizeText(value: unknown) { + return String(value || '') + .replace(/\s+/g, '') + .toLowerCase() +} + +export function compareCustomerRole(task: DouyuTaskRow, live: LiveBindingState) { + const roleMatched = + Boolean(task.customer_role_name && live.roleName) && + normalizeText(task.customer_role_name) === normalizeText(live.roleName) + const liveParts = new Set([normalizeText(live.areaName), normalizeText(live.platName)]) + const expected: string[] = [] + if (task.customer_platform === 'wechat') expected.push('微信') + if (task.customer_platform === 'qq') expected.push('qq', '手q') + if (task.customer_system === 'ios') expected.push('苹果', 'ios') + if (task.customer_system === 'android') expected.push('安卓', 'android') + const channelMatched = expected.every((item) => + [...liveParts].some((part) => part.includes(item) || item.includes(part)), + ) + return { + matched: roleMatched && channelMatched, + roleMatched, + channelMatched, + message: + roleMatched && channelMatched + ? '客户资料与平台识别角色一致' + : '客户资料与平台识别角色不一致,请修改资料或联系客服', + } +} + +const BINDING_FAILURE_ISSUES = new Set([ + 'binding_failed', + 'account_role_cooldown', + 'customer_role_cooldown', +]) + +export function statusForLive(live: LiveBindingState): string { + if (live.customerProfileReset === true) return 'waiting_profile' + if (live.executionStatus === 'completed') return 'completed' + if (live.executionStatus === 'cancelled') return 'cancelled' + if (live.bindingStatus === 'failed' || BINDING_FAILURE_ISSUES.has(live.issueCode)) { + return 'failed' + } + if (live.executionStatus === 'manual_required') return 'manual_required' + if (live.executionStatus === 'allocated') return 'allocated' + if (live.bindConfirmed) return 'waiting_operator' + if (live.bindReadyForConfirm) return 'role_ready' + if (live.qrUrl) return 'qr_pending' + if ( + live.issueCode === 'mapping_missing' || + live.issueCode === 'no_eligible_account' || + live.issueCode === 'elite_not_opened' || + live.issueCode === 'points_short' || + !live.accountReady + ) { + return 'preparing' + } + if (live.issueCode) return 'failed' + return 'preparing' +} + +async function updateTaskFromLiveState( + client: Pick, + task: DouyuTaskRow, + live: LiveBindingState, + now: string, +) { + const resetCustomerProfile = live.customerProfileReset === true + const nextStatus = statusForLive(live) + await client.query( + ` + UPDATE douyu_fulfillment_tasks + SET live_session_id = $2, + status = $3, + binding_phase = $4, + live_execution_status = $5, + live_binding_status = $6, + issue_code = $7, + last_error = $8, + bound_role_name = $9, + bound_area_name = $10, + bound_plat_name = $11, + binding_started_at = CASE + WHEN $19 THEN NULL + WHEN $12 <> '' THEN COALESCE(binding_started_at, NOW()) + ELSE binding_started_at + END, + bound_at = CASE + WHEN $19 THEN NULL + WHEN $13 THEN COALESCE(bound_at, NOW()) + ELSE bound_at + END, + completed_at = CASE + WHEN $19 THEN NULL + WHEN $14 THEN COALESCE(completed_at, NOW()) + ELSE completed_at + END, + customer_role_name = CASE WHEN $19 THEN '' ELSE customer_role_name END, + customer_platform = CASE WHEN $19 THEN '' ELSE customer_platform END, + customer_system = CASE WHEN $19 THEN '' ELSE customer_system END, + qr_url = $15, + qr_generated_at = NULLIF($16, '')::timestamptz, + qr_expires_at = NULLIF($17, '')::timestamptz, + last_synced_at = NOW(), + updated_at = $18 + WHERE id = $1 + `, + [ + task.id, + live.sessionId, + nextStatus, + live.bindPhase, + live.executionStatus, + live.bindingStatus, + live.issueCode, + live.message, + live.roleName, + live.areaName, + live.platName, + live.qrUrl, + live.bindConfirmed, + live.executionStatus === 'completed', + live.qrUrl, + live.qrGeneratedAt, + live.qrExpiresAt, + now, + resetCustomerProfile, + ], + ) + if (nextStatus !== task.status) { + await appendEvent(client, task.id, 'status_changed', 'integration', { + fromStatus: task.status, + toStatus: nextStatus, + bindPhase: live.bindPhase, + }) + } + if (resetCustomerProfile) { + await appendEvent(client, task.id, 'customer_profile_reset', 'integration', { + reason: String(live.resetReason || ''), + }) + } +} + +async function applyLiveState(task: DouyuTaskRow, live: LiveBindingState) { + await withTransaction(async (client) => { + await updateTaskFromLiveState(client, task, live, nowIso()) + }) + const updated = await loadTask(task.id) + return { task: updated, live, comparison: compareCustomerRole(updated, live) } +} + +async function applyLiveStates(entries: Array<{ task: DouyuTaskRow; live: LiveBindingState }>) { + if (entries.length === 0) return + const now = nowIso() + await withTransaction(async (client) => { + for (const entry of entries) { + await updateTaskFromLiveState(client, entry.task, entry.live, now) + } + }) +} + +function isLiveBindingState(value: unknown): value is LiveBindingState { + if (!value || typeof value !== 'object') return false + const item = value as Partial + return ( + Number.isInteger(Number(item.sessionId)) && + Number(item.sessionId) > 0 && + typeof item.executionStatus === 'string' && + typeof item.bindingStatus === 'string' && + typeof item.exchangeStatus === 'string' && + typeof item.issueCode === 'string' && + typeof item.message === 'string' + ) +} + +function liveBindingStateFromTask(task: DouyuTaskRow): LiveBindingState { + return { + sessionId: Number(task.live_session_id), + platformOrderId: task.platform_order_id, + sourceOrderItemId: String(task.order_item_id), + productName: task.product_name, + quantity: Number(task.quantity || 1), + executionStatus: task.live_execution_status || 'preparing', + bindingStatus: task.live_binding_status || 'not_started', + exchangeStatus: '', + issueCode: task.issue_code || '', + message: task.last_error || '', + accountReady: !['waiting_profile', 'preparing'].includes(task.status), + bindTaskId: null, + bindTaskStatus: '', + bindPhase: task.binding_phase || '', + qrUrl: task.qr_url || '', + qrGeneratedAt: task.qr_generated_at || '', + qrExpiresAt: task.qr_expires_at || '', + roleName: task.bound_role_name || '', + areaName: task.bound_area_name || '', + platName: task.bound_plat_name || '', + bindReadyForConfirm: task.status === 'role_ready', + bindConfirmed: ['bound', 'waiting_operator', 'processing', 'completed'].includes(task.status), + completedAt: task.completed_at, + updatedAt: task.updated_at, + } +} + +export async function applyLiveBindingStateSnapshot( + input: unknown, + options: { eventId?: string; eventType?: string } = {}, +) { + const rawItems = + input && typeof input === 'object' && Array.isArray((input as { items?: unknown }).items) + ? (input as { items: unknown[] }).items + : [] + const items = rawItems.filter(isLiveBindingState) + if (items.length === 0) { + return { received: rawItems.length, updated: 0 } + } + + const sessionIds = Array.from( + new Set(items.map((item) => Number(item.sessionId)).filter((id) => id > 0)), + ) + const orderNos = Array.from( + new Set(items.map((item) => String(item.platformOrderId || '').trim()).filter(Boolean)), + ).slice(0, 50) + const orderItemIds = Array.from( + new Set(items.map((item) => String(item.sourceOrderItemId || '').trim()).filter(Boolean)), + ) + if (sessionIds.length === 0 && orderNos.length === 0 && orderItemIds.length === 0) { + return { received: rawItems.length, updated: 0 } + } + + // Webhook 可能先于客户首次打开领取页到达;先幂等补齐本地订单投影。 + for (const orderNo of orderNos) { + await ensureDouyuFulfillmentTasks(orderNo) + } + + const result = await withTransaction(async (client) => { + const eventId = String(options.eventId || '').trim() + if (eventId) { + const claimed = await client.query( + ` + INSERT INTO integration_inbox ( + event_id, source, event_type, received_at, processed_at + ) VALUES ($1, 'live_hub', $2, NOW(), NOW()) + ON CONFLICT (event_id) DO NOTHING + RETURNING event_id + `, + [eventId, String(options.eventType || '')], + ) + if (claimed.rowCount === 0) { + return { received: rawItems.length, updated: 0 } + } + } + + const tasks = await client.query( + `${TASK_SELECT} + WHERE task.live_session_id = ANY($1::bigint[]) + OR CAST(task.order_item_id AS text) = ANY($2::text[]) + OR o.platform_order_id = ANY($3::text[])`, + [sessionIds, orderItemIds, orderNos], + ) + const taskBySessionId = new Map( + tasks.rows + .filter((task) => task.live_session_id) + .map((task) => [Number(task.live_session_id), task]), + ) + const taskByOrderItemId = new Map(tasks.rows.map((task) => [String(task.order_item_id), task])) + const now = nowIso() + const entries = items.flatMap((live) => { + const task = + taskBySessionId.get(Number(live.sessionId)) || + taskByOrderItemId.get(String(live.sourceOrderItemId || '')) + return task ? [{ task, live }] : [] + }) + for (const entry of entries) { + await updateTaskFromLiveState(client, entry.task, entry.live, now) + } + return { received: rawItems.length, updated: entries.length } + }) + + if (result.updated > 0) { + publishRealtimeEvent({ + type: 'order.changed', + entityId: 0, + scopes: ['admin_douyu_fulfillment'], + operation: 'refresh', + data: { douyuFulfillmentUpdated: true }, + admin: true, + }) + } + return result +} + +async function ensureLiveSession(task: DouyuTaskRow) { + const live = await liveHubRequest( + '/api/integration/platform-fulfillment/customer-sessions/ensure', + { + method: 'POST', + body: { + source_order_item_id: String(task.order_item_id), + platform_order_id: task.platform_order_id, + }, + }, + ) + return applyLiveState(task, live) +} + +export async function getCustomerDouyuFulfillment(orderNo: string) { + const task = await loadTaskByOrderNo(orderNo) + if (!task.customer_link_opened_at) { + await withTransaction(async (client) => { + await client.query( + `UPDATE douyu_fulfillment_tasks + SET customer_link_opened_at = COALESCE(customer_link_opened_at, NOW()) + WHERE id = $1`, + [task.id], + ) + await appendEvent(client, task.id, 'customer_link_opened', 'customer') + }) + } + const session = await ensureLiveSession(task) + return { + task: session.task, + live: session.live, + comparison: session.comparison, + linkPath: `/coll/d/${encodeURIComponent(task.platform_order_id)}`, + } +} + +export async function saveDouyuCustomerProfile( + orderNo: string, + input: { roleName?: unknown; platform?: unknown; system?: unknown }, +) { + const task = await loadTaskByOrderNo(orderNo) + if (task.status === 'completed' || task.status === 'cancelled') { + throw createHttpError('当前订单已结束,不能修改资料', { + statusCode: 409, + errorCode: 'douyu_fulfillment_closed', + }) + } + const roleName = String(input.roleName ?? '') + .trim() + .slice(0, 100) + const platform = String(input.platform ?? '') + .trim() + .toLowerCase() + const system = String(input.system ?? '') + .trim() + .toLowerCase() + if (!roleName || !['wechat', 'qq'].includes(platform) || !['ios', 'android'].includes(system)) { + throw createHttpError('请完整填写角色名、微信/QQ 和苹果/安卓', { + statusCode: 400, + errorCode: 'douyu_customer_profile_invalid', + }) + } + await withTransaction(async (client) => { + await client.query( + ` + UPDATE douyu_fulfillment_tasks + SET customer_role_name = $2, + customer_platform = $3, + customer_system = $4, + status = CASE WHEN status = 'waiting_profile' THEN 'preparing' ELSE status END, + updated_at = NOW() + WHERE id = $1 + `, + [task.id, roleName, platform, system], + ) + await appendEvent(client, task.id, 'customer_profile_saved', 'customer', { + roleName, + platform, + system, + }) + }) + return getCustomerDouyuFulfillment(orderNo) +} + +export async function startDouyuCustomerBinding(orderNo: string, forceRefresh = false) { + let task = await loadTaskByOrderNo(orderNo) + const session = await ensureLiveSession(task) + task = session.task + if (!task.live_session_id) { + throw createHttpError('直播账号履约会话尚未准备完成', { + statusCode: 409, + errorCode: 'douyu_live_session_not_ready', + }) + } + const live = await liveHubRequest( + `/api/integration/platform-fulfillment/customer-sessions/${task.live_session_id}/binding/start`, + { method: 'POST', body: { force_refresh: forceRefresh } }, + ) + return applyLiveState(task, live) +} + +export async function refreshDouyuCustomerBinding(orderNo: string) { + const task = await loadTaskByOrderNo(orderNo) + if (!task.live_session_id) return ensureLiveSession(task) + const live = await liveHubRequest( + `/api/integration/platform-fulfillment/customer-sessions/${task.live_session_id}/status`, + ) + return applyLiveState(task, live) +} + +export async function getDouyuCustomerFulfillmentCached(orderNo: string) { + let task = await loadTaskByOrderNo(orderNo) + if (!task.live_session_id) { + return ensureLiveSession(task) + } + task = await loadTask(task.id) + const live = liveBindingStateFromTask(task) + return { + task, + live, + comparison: compareCustomerRole(task, live), + linkPath: `/coll/d/${encodeURIComponent(task.platform_order_id)}`, + } +} + +export async function confirmDouyuCustomerBinding(orderNo: string) { + const refreshed = await refreshDouyuCustomerBinding(orderNo) + if (!refreshed.comparison.matched) { + throw createHttpError(refreshed.comparison.message, { + statusCode: 409, + errorCode: 'douyu_customer_role_mismatch', + }) + } + const task = refreshed.task + if (!task.live_session_id) { + throw createHttpError('直播账号履约会话尚未准备完成', { + statusCode: 409, + errorCode: 'douyu_live_session_not_ready', + }) + } + const live = await liveHubRequest( + `/api/integration/platform-fulfillment/customer-sessions/${task.live_session_id}/binding/confirm`, + { method: 'POST' }, + ) + return applyLiveState(task, live) +} + +async function syncLiveStatesForTasks(tasks: DouyuTaskRow[], force = false) { + const now = Date.now() + const candidates = tasks.filter((task) => { + if (!task.live_session_id || TERMINAL_TASK_STATUSES.has(task.status)) return false + if (force) return true + const lastSyncedAt = Date.parse(task.last_synced_at || '') + return !lastSyncedAt || now - lastSyncedAt >= LIVE_STATE_SYNC_INTERVAL_MS + }) + if (candidates.length === 0) return + + try { + const response = await liveHubRequest( + '/api/integration/platform-fulfillment/customer-sessions/status/batch', + { + method: 'POST', + body: { + task_ids: candidates.map((task) => Number(task.live_session_id)), + }, + }, + ) + const taskBySessionId = new Map(candidates.map((task) => [Number(task.live_session_id), task])) + const entries = response.items.flatMap((live) => { + const task = taskBySessionId.get(Number(live.sessionId)) + return task ? [{ task, live }] : [] + }) + await applyLiveStates(entries) + if (entries.length > 0) { + publishRealtimeEvent({ + type: 'order.changed', + entityId: 0, + scopes: ['admin_douyu_fulfillment'], + operation: 'refresh', + data: { douyuFulfillmentUpdated: true }, + admin: true, + }) + } + } catch (error) { + logWarn('[douyu-fulfillment]', '自动同步直播账号履约状态失败', { error }) + } +} + +export async function reconcileDouyuFulfillmentStates() { + const rows = await query( + `${TASK_SELECT} + WHERE task.live_session_id IS NOT NULL + AND task.status NOT IN ('completed', 'cancelled') + ORDER BY task.updated_at ASC, task.id ASC + LIMIT 100`, + ) + await syncLiveStatesForTasks(rows.rows, true) + return { checked: rows.rows.length } +} + +export async function syncDouyuFulfillmentTasks() { + const synced = await ensureDouyuFulfillmentTasks() + const states = await reconcileDouyuFulfillmentStates() + return { ...synced, checked: states.checked } +} + +export async function listDouyuFulfillmentTasks( + input: { + keyword?: unknown + status?: unknown + page?: unknown + pageSize?: unknown + } = {}, +) { + await ensureDouyuFulfillmentTasksAutomatically() + const page = Math.max(1, Number(input.page || 1)) + const pageSize = Math.max(1, Math.min(100, Number(input.pageSize || 20))) + const keyword = String(input.keyword || '').trim() + const status = String(input.status || '').trim() + const params: unknown[] = [] + const filters: string[] = [] + if (keyword) { + params.push(`%${keyword}%`) + filters.push(`( + o.platform_order_id ILIKE $${params.length} + OR oi.sku_name ILIKE $${params.length} + OR task.customer_role_name ILIKE $${params.length} + )`) + } + if (status) { + params.push(status) + filters.push(`task.status = $${params.length}`) + } + const where = filters.length ? `WHERE ${filters.join(' AND ')}` : '' + const count = await query<{ total: number }>( + `SELECT COUNT(*)::int AS total + FROM douyu_fulfillment_tasks task + JOIN orders o ON o.id = task.order_id + JOIN order_items oi ON oi.id = task.order_item_id + ${where}`, + params, + ) + params.push(pageSize, (page - 1) * pageSize) + const rows = await query( + `${TASK_SELECT} + ${where} + ORDER BY task.updated_at DESC, task.id DESC + LIMIT $${params.length - 1} OFFSET $${params.length}`, + params, + ) + return { + items: rows.rows.map((task) => ({ + ...task, + linkPath: `/coll/d/${encodeURIComponent(task.platform_order_id)}`, + })), + pagination: { page, pageSize, total: Number(count.rows[0]?.total || 0) }, + } +} + +export async function getDouyuFulfillmentDetail(orderNo: string) { + const task = await loadTaskByOrderNo(orderNo) + const [session, events] = await Promise.all([ + ensureLiveSession(task), + query<{ + id: number + event_type: string + actor_type: string + detail_json: Record + created_at: string + }>( + `SELECT id, event_type, actor_type, detail_json, created_at + FROM douyu_fulfillment_events + WHERE task_id = $1 + ORDER BY id DESC + LIMIT 200`, + [task.id], + ), + ]) + return { + ...session, + linkPath: `/coll/d/${encodeURIComponent(task.platform_order_id)}`, + events: events.rows, + } +} diff --git a/apps/backend/src/services/douyu-fulfillment/douyu-fulfillment.test.ts b/apps/backend/src/services/douyu-fulfillment/douyu-fulfillment.test.ts new file mode 100644 index 00000000..03f2eecd --- /dev/null +++ b/apps/backend/src/services/douyu-fulfillment/douyu-fulfillment.test.ts @@ -0,0 +1,95 @@ +import assert from 'node:assert/strict' +import test from 'node:test' + +import { + applyLiveBindingStateSnapshot, + compareCustomerRole, + statusForLive, +} from './douyu-fulfillment-service.js' + +const task = { + customer_role_name: '狗鼻子弗尼亚bd', + customer_platform: 'wechat', + customer_system: 'android', +} as never + +const live = { + roleName: '狗鼻子弗尼亚bd', + areaName: '微信', + platName: '安卓(android)', +} as never + +test('斗鱼客户资料与平台角色一致', () => { + const result = compareCustomerRole(task, live) + assert.equal(result.matched, true) + assert.equal(result.roleMatched, true) + assert.equal(result.channelMatched, true) +}) + +test('斗鱼客户资料平台或系统不一致时禁止确认', () => { + const result = compareCustomerRole(task, { + ...live, + areaName: 'QQ', + platName: '苹果(iOS)', + } as never) + assert.equal(result.matched, false) + assert.equal(result.channelMatched, false) +}) + +test('斗鱼客户资料角色名不一致时禁止确认', () => { + const result = compareCustomerRole(task, { ...live, roleName: '另一个角色' } as never) + assert.equal(result.matched, false) + assert.equal(result.roleMatched, false) +}) + +test('绑定失败优先于旧角色确认标记', () => { + const status = statusForLive({ + executionStatus: 'manual_required', + bindingStatus: 'failed', + issueCode: 'customer_role_cooldown', + bindReadyForConfirm: true, + bindConfirmed: false, + qrUrl: 'https://example.com/old-qr', + accountReady: true, + } as never) + assert.equal(status, 'failed') +}) + +test('绑定失败代码优先于旧待确认状态', () => { + const status = statusForLive({ + executionStatus: 'role_ready', + bindingStatus: 'role_ready', + issueCode: 'binding_failed', + bindReadyForConfirm: true, + bindConfirmed: false, + qrUrl: '', + accountReady: true, + } as never) + assert.equal(status, 'failed') +}) + +test('已分配账号保持 allocated,不折叠成准备账号', () => { + const status = statusForLive({ + executionStatus: 'allocated', + bindingStatus: 'not_started', + issueCode: '', + bindReadyForConfirm: false, + bindConfirmed: false, + qrUrl: '', + accountReady: true, + } as never) + assert.equal(status, 'allocated') +}) + +test('直播账号状态推送忽略空数据和无效任务', async () => { + assert.deepEqual(await applyLiveBindingStateSnapshot({ items: [] }), { + received: 0, + updated: 0, + }) + assert.deepEqual( + await applyLiveBindingStateSnapshot({ + items: [{ sessionId: 0 }, null, { sessionId: 'bad' }], + }), + { received: 3, updated: 0 }, + ) +}) diff --git a/apps/backend/src/services/douyu-fulfillment/fulfillment-reconciler.ts b/apps/backend/src/services/douyu-fulfillment/fulfillment-reconciler.ts new file mode 100644 index 00000000..fc3394c8 --- /dev/null +++ b/apps/backend/src/services/douyu-fulfillment/fulfillment-reconciler.ts @@ -0,0 +1,51 @@ +import { logWarn } from '../../utils/logger.js' +import { reconcileDouyuFulfillmentStates } from './douyu-fulfillment-service.js' + +const DEFAULT_RECONCILE_SECONDS = 900 + +let timer: NodeJS.Timeout | null = null +let stopped = true + +function intervalMs() { + const value = Number(process.env.PLATFORM_FULFILLMENT_RECONCILE_SECONDS) + const seconds = + Number.isFinite(value) && value > 0 + ? Math.max(60, Math.trunc(value)) + : DEFAULT_RECONCILE_SECONDS + return seconds * 1000 +} + +async function run() { + if (stopped) return + try { + await reconcileDouyuFulfillmentStates() + } catch (error) { + logWarn('[douyu-fulfillment]', '低频对账失败', { error }) + } finally { + if (!stopped) { + timer = setTimeout(() => { + void run() + }, intervalMs()) + } + } +} + +export function startDouyuFulfillmentReconciler() { + if (timer || !stopped) return + stopped = false + // 启动后先让 Webhook 工作一分钟,再执行首轮兜底对账。 + timer = setTimeout( + () => { + void run() + }, + Math.min(60_000, intervalMs()), + ) +} + +export function stopDouyuFulfillmentReconciler() { + stopped = true + if (timer) { + clearTimeout(timer) + timer = null + } +} diff --git a/apps/backend/src/services/integration/outbox-migration.test.ts b/apps/backend/src/services/integration/outbox-migration.test.ts new file mode 100644 index 00000000..4e3da31c --- /dev/null +++ b/apps/backend/src/services/integration/outbox-migration.test.ts @@ -0,0 +1,15 @@ +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import test from 'node:test' + +test('Outbox migration keeps header event id and payload eventId identical', () => { + const sql = readFileSync( + new URL('../../db/migrations/171_douyu_fulfillment_integration.sql', import.meta.url), + 'utf8', + ) + + assert.match(sql, /'eventId', event_id::text/) + assert.doesNotMatch(sql, /'eventId', gen_random_uuid\(\)::text/) + assert.match(sql, /CREATE TABLE IF NOT EXISTS integration_outbox/) + assert.match(sql, /CREATE TABLE IF NOT EXISTS integration_inbox/) +}) diff --git a/apps/backend/src/services/integration/outbox-worker.ts b/apps/backend/src/services/integration/outbox-worker.ts new file mode 100644 index 00000000..75230001 --- /dev/null +++ b/apps/backend/src/services/integration/outbox-worker.ts @@ -0,0 +1,209 @@ +import { query, withTransaction } from '../../db/client.js' +import { logError, logInfo, logWarn } from '../../utils/logger.js' +import { buildWebhookSignature } from './webhook-signature.js' + +const DEFAULT_INTERVAL_MS = 1000 +const DEFAULT_BATCH_SIZE = 20 +const DEFAULT_MAX_ATTEMPTS = 12 +const REQUEST_TIMEOUT_MS = 5000 +const PROCESSING_STALE_SECONDS = 120 + +type OutboxRow = { + id: string + event_id: string + payload_json: unknown + attempts: number +} + +let timer: NodeJS.Timeout | null = null +let running = false +let stopped = true + +function envInt(name: string, fallback: number, min: number, max: number) { + const parsed = Number(process.env[name]) + if (!Number.isFinite(parsed)) return fallback + return Math.max(min, Math.min(max, Math.trunc(parsed))) +} + +export function integrationOutboxConfigured() { + return Boolean( + String(process.env.LIVE_HUB_PLATFORM_FULFILLMENT_URL || '').trim() && + String(process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY || '').trim(), + ) +} + +export function integrationOutboxBackoffSeconds(attempts: number) { + const normalized = Math.max(1, Math.trunc(Number(attempts) || 1)) + return Math.min(3600, 5 * 2 ** Math.min(normalized - 1, 10)) +} + +async function claimDueEvents(limit: number): Promise { + return withTransaction(async (client) => { + await client.query( + ` + UPDATE integration_outbox + SET status = 'pending', + locked_at = NULL, + next_attempt_at = NOW() + WHERE status = 'processing' + AND locked_at < NOW() - ($1 * INTERVAL '1 second') + `, + [PROCESSING_STALE_SECONDS], + ) + + const claimed = await client.query( + ` + SELECT id, event_id, payload_json, attempts + FROM integration_outbox + WHERE status = 'pending' + AND next_attempt_at <= NOW() + ORDER BY id ASC + LIMIT $1 + FOR UPDATE SKIP LOCKED + `, + [limit], + ) + const ids = claimed.rows.map((row) => Number(row.id)).filter((id) => id > 0) + if (ids.length === 0) return [] + + await client.query( + ` + UPDATE integration_outbox + SET status = 'processing', + locked_at = NOW() + WHERE id = ANY($1::bigint[]) + `, + [ids], + ) + return claimed.rows + }) +} + +async function deliverEvent(row: OutboxRow) { + const baseUrl = String(process.env.LIVE_HUB_PLATFORM_FULFILLMENT_URL || '') + .trim() + .replace(/\/+$/, '') + const integrationKey = String(process.env.PLATFORM_FULFILLMENT_INTEGRATION_KEY || '').trim() + const endpoint = `${baseUrl}/api/integration/platform-fulfillment/events/order-sync` + const rawBody = + typeof row.payload_json === 'string' ? row.payload_json : JSON.stringify(row.payload_json) + const timestamp = String(Math.floor(Date.now() / 1000)) + const signature = buildWebhookSignature(integrationKey, timestamp, rawBody) + + const response = await fetch(endpoint, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-Integration-Key': integrationKey, + 'X-Integration-Event-Id': row.event_id, + 'X-Integration-Timestamp': timestamp, + 'X-Integration-Signature': signature, + }, + body: rawBody, + signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), + }) + if (!response.ok) { + throw new Error(`live-hub 返回 HTTP ${response.status}`) + } +} + +async function markSent(eventId: string) { + await query( + ` + UPDATE integration_outbox + SET status = 'sent', + sent_at = NOW(), + locked_at = NULL, + last_error = '' + WHERE event_id = $1 + `, + [eventId], + ) +} + +async function markFailed(row: OutboxRow, error: unknown) { + const attempts = Number(row.attempts || 0) + 1 + const maxAttempts = envInt('INTEGRATION_OUTBOX_MAX_ATTEMPTS', DEFAULT_MAX_ATTEMPTS, 1, 100) + const dead = attempts >= maxAttempts + const message = (error instanceof Error ? error.message : String(error)).slice(0, 2000) + await query( + ` + UPDATE integration_outbox + SET status = $2, + attempts = $3, + locked_at = NULL, + next_attempt_at = NOW() + ($4 * INTERVAL '1 second'), + last_error = $5 + WHERE event_id = $1 + `, + [ + row.event_id, + dead ? 'dead' : 'pending', + attempts, + dead ? 0 : integrationOutboxBackoffSeconds(attempts), + message, + ], + ) + if (dead) { + logError('[integration/outbox]', '事件超过最大重试次数,已进入 dead', { + eventId: row.event_id, + attempts, + error: message, + }) + } +} + +async function publishDueEvents() { + if (!integrationOutboxConfigured()) return + const batchSize = envInt('INTEGRATION_OUTBOX_BATCH_SIZE', DEFAULT_BATCH_SIZE, 1, 100) + const rows = await claimDueEvents(batchSize) + for (const row of rows) { + try { + await deliverEvent(row) + await markSent(row.event_id) + } catch (error) { + await markFailed(row, error) + } + } +} + +async function runLoop() { + if (stopped || running) return + running = true + try { + await publishDueEvents() + } catch (error) { + logWarn('[integration/outbox]', '投递轮次失败', { error }) + } finally { + running = false + if (!stopped) { + timer = setTimeout( + () => { + void runLoop() + }, + envInt('INTEGRATION_OUTBOX_INTERVAL_MS', DEFAULT_INTERVAL_MS, 250, 60_000), + ) + } + } +} + +export function startIntegrationOutboxWorker() { + if (timer || !stopped) return + stopped = false + if (!integrationOutboxConfigured()) { + logWarn('[integration/outbox]', '未配置 live-hub 地址或集成密钥,worker 仅保持待命') + } else { + logInfo('[integration/outbox]', '事务 Outbox worker 已启动') + } + timer = setTimeout(() => { + void runLoop() + }, 0) +} + +export function stopIntegrationOutboxWorker() { + stopped = true + if (timer) { + clearTimeout(timer) + timer = null + } +} diff --git a/apps/backend/src/services/integration/webhook-signature.test.ts b/apps/backend/src/services/integration/webhook-signature.test.ts new file mode 100644 index 00000000..d574dd11 --- /dev/null +++ b/apps/backend/src/services/integration/webhook-signature.test.ts @@ -0,0 +1,49 @@ +import assert from 'node:assert/strict' +import test from 'node:test' + +import { buildWebhookSignature, verifyWebhookSignature } from './webhook-signature.js' + +test('webhook signature binds timestamp and raw body', () => { + const rawBody = '{"eventId":"evt-1","items":[]}' + const timestamp = '1783394219' + const signature = buildWebhookSignature('secret-key', timestamp, rawBody) + + assert.equal( + verifyWebhookSignature({ + secret: 'secret-key', + timestamp, + rawBody, + signature, + nowSeconds: Number(timestamp), + }), + true, + ) + assert.equal( + verifyWebhookSignature({ + secret: 'secret-key', + timestamp, + rawBody: `${rawBody} `, + signature, + nowSeconds: Number(timestamp), + }), + false, + ) +}) + +test('webhook signature rejects expired timestamps', () => { + const timestamp = '1783394219' + const rawBody = '{}' + const signature = buildWebhookSignature('secret-key', timestamp, rawBody) + + assert.equal( + verifyWebhookSignature({ + secret: 'secret-key', + timestamp, + rawBody, + signature, + toleranceSeconds: 300, + nowSeconds: Number(timestamp) + 301, + }), + false, + ) +}) diff --git a/apps/backend/src/services/integration/webhook-signature.ts b/apps/backend/src/services/integration/webhook-signature.ts new file mode 100644 index 00000000..090f0b15 --- /dev/null +++ b/apps/backend/src/services/integration/webhook-signature.ts @@ -0,0 +1,45 @@ +import { createHmac, timingSafeEqual } from 'node:crypto' + +const SIGNATURE_PREFIX = 'sha256=' +const DEFAULT_TOLERANCE_SECONDS = 300 + +export function buildWebhookSignature(secret: string, timestamp: string, rawBody: string) { + return ( + SIGNATURE_PREFIX + createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex') + ) +} + +export function verifyWebhookSignature(input: { + secret: string + timestamp: string + rawBody: string + signature: string + toleranceSeconds?: number + nowSeconds?: number +}) { + const secret = String(input.secret || '').trim() + const timestamp = String(input.timestamp || '').trim() + const signature = String(input.signature || '').trim() + if (!secret || !timestamp || !signature) return false + + const timestampSeconds = Number(timestamp) + if (!Number.isInteger(timestampSeconds) || timestampSeconds <= 0) return false + + const tolerance = Math.max( + 1, + Math.trunc(Number(input.toleranceSeconds) || DEFAULT_TOLERANCE_SECONDS), + ) + const nowSeconds = Math.trunc(Number(input.nowSeconds) || Date.now() / 1000) + if (Math.abs(nowSeconds - timestampSeconds) > tolerance) return false + + const expected = buildWebhookSignature(secret, timestamp, String(input.rawBody || '')) + const expectedBuffer = Buffer.from(expected) + const providedBuffer = Buffer.from(signature) + if (expectedBuffer.length !== providedBuffer.length) return false + return timingSafeEqual(expectedBuffer, providedBuffer) +} + +export function webhookToleranceSeconds() { + const value = Number(process.env.PLATFORM_FULFILLMENT_WEBHOOK_TOLERANCE_SECONDS || 300) + return Number.isFinite(value) && value > 0 ? Math.trunc(value) : DEFAULT_TOLERANCE_SECONDS +} diff --git a/apps/backend/src/services/semi-auto/semi-auto-task.integration.test.ts b/apps/backend/src/services/semi-auto/semi-auto-task.integration.test.ts index b8f34467..8ed618b4 100644 --- a/apps/backend/src/services/semi-auto/semi-auto-task.integration.test.ts +++ b/apps/backend/src/services/semi-auto/semi-auto-task.integration.test.ts @@ -902,3 +902,93 @@ test( } }, ) + +test( + '斗鱼直播账号履约 Mock 只生成正式人工履约,不生成半自动任务', + { skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false }, + async () => { + process.env.DATABASE_URL = TEST_DATABASE_URL + process.env.ENABLE_DEV_MOCK = '1' + const { closeDb, query, withTransaction } = await import('../../db/client.js') + const { createDouyuFulfillmentMock } = await import('../dev-mock/dev-mock-service.js') + const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}` + const orderNo = `IT-DOUYU-FULFILLMENT-${suffix}` + const skuKey = `斗鱼精英宝典联调-${suffix}` + let orderId = 0 + let configId = 0 + let mappingId = 0 + + try { + const result = await createDouyuFulfillmentMock({ + orderNo, + skuName: skuKey, + }) + orderId = result.orderId + configId = result.configId + mappingId = result.mappingId + + assert.equal(result.platform, 'douyu') + assert.equal(result.pipeline, 'order_service') + assert.equal(result.orderNo, orderNo) + assert.equal(result.skuKey, skuKey) + assert.ok(result.orderItemId > 0) + assert.ok(result.fulfillmentId > 0) + + const stored = await query<{ + channel: string + fulfillment_status: string + fulfillment_config_id: number + semi_auto_enabled: boolean + semi_auto_task_count: number + internal_sku: string + }>( + ` + SELECT + f.channel, + f.status AS fulfillment_status, + f.fulfillment_config_id, + cfg.semi_auto_enabled, + ( + SELECT COUNT(*)::int + FROM semi_auto_tasks task + WHERE task.order_item_id = f.order_item_id + ) AS semi_auto_task_count, + resolve_internal_sku(oi.manual_sku_key, oi.sku_name, oi.sku_code) AS internal_sku + FROM fulfillments f + JOIN order_items oi ON oi.id = f.order_item_id + JOIN manual_fulfillment_configs cfg ON cfg.id = f.fulfillment_config_id + WHERE f.id = $1 + `, + [result.fulfillmentId], + ) + assert.equal(stored.rows[0]?.channel, 'manual') + assert.equal(stored.rows[0]?.fulfillment_status, 'assigned') + assert.equal(Number(stored.rows[0]?.fulfillment_config_id), result.configId) + assert.equal(stored.rows[0]?.semi_auto_enabled, false) + assert.equal(Number(stored.rows[0]?.semi_auto_task_count), 0) + assert.equal(stored.rows[0]?.internal_sku, skuKey) + + const mapping = await query<{ internal_sku: string }>( + 'SELECT internal_sku FROM internal_sku_mappings WHERE id = $1', + [result.mappingId], + ) + assert.equal(mapping.rows[0]?.internal_sku, skuKey) + } finally { + await withTransaction(async (client) => { + await client.query("SET LOCAL session_replication_role = 'replica'") + if (configId > 0) { + await client.query('DELETE FROM manual_fulfillment_configs WHERE id = $1', [configId]) + } + if (orderId > 0) { + await client.query('DELETE FROM order_source_snapshots WHERE order_id = $1', [orderId]) + await client.query('DELETE FROM orders WHERE id = $1', [orderId]) + } + if (mappingId > 0) { + await client.query('DELETE FROM internal_sku_mappings WHERE id = $1', [mappingId]) + } + }) + delete process.env.ENABLE_DEV_MOCK + await closeDb() + } + }, +) diff --git a/apps/backend/src/startup/bootstrap.ts b/apps/backend/src/startup/bootstrap.ts index 9623ce37..d7ee3676 100644 --- a/apps/backend/src/startup/bootstrap.ts +++ b/apps/backend/src/startup/bootstrap.ts @@ -1,8 +1,10 @@ import { runDatabaseMigrations } from '../db/migrate.js' +import { startIntegrationOutboxWorker } from '../services/integration/outbox-worker.js' import { ensureAdminUsersBootstrapped } from '../services/admin/admin-auth-service.js' import { ensureFulfillmentCatalogBootstrapped } from '../services/bootstrap/fulfillment-bootstrap-service.js' import { migrateJsonConfigFilesToDatabase } from '../services/config/json-config-migration-service.js' import { startKuaishouIndustrySendCallbackRetryWorker } from '../services/platforms/kuaishou-industry/send-code-service.js' +import { startDouyuFulfillmentReconciler } from '../services/douyu-fulfillment/fulfillment-reconciler.js' import { startScheduledJobs } from '../services/scheduler/scheduler-service.js' import { logError, logInfo } from '../utils/logger.js' import { startMemoryReporter } from './memory-reporter.js' @@ -46,6 +48,8 @@ export async function bootstrapCoreServices( startScheduledJobs() startKuaishouIndustrySendCallbackRetryWorker() + startIntegrationOutboxWorker() + startDouyuFulfillmentReconciler() startMemoryReporter() break } catch (error) { diff --git a/apps/backend/src/startup/shutdown.ts b/apps/backend/src/startup/shutdown.ts index 3755a73e..a6a8c549 100644 --- a/apps/backend/src/startup/shutdown.ts +++ b/apps/backend/src/startup/shutdown.ts @@ -1,6 +1,8 @@ import type { Server } from 'node:http' import { stopKuaishouIndustrySendCallbackRetryWorker } from '../services/platforms/kuaishou-industry/send-code-service.js' +import { stopIntegrationOutboxWorker } from '../services/integration/outbox-worker.js' +import { stopDouyuFulfillmentReconciler } from '../services/douyu-fulfillment/fulfillment-reconciler.js' import { stopScheduledJobs } from '../services/scheduler/scheduler-service.js' import { closeDb } from '../db/client.js' import { logError, logInfo } from '../utils/logger.js' @@ -28,6 +30,8 @@ export function createShutdownController( stopScheduledJobs() stopKuaishouIndustrySendCallbackRetryWorker() + stopIntegrationOutboxWorker() + stopDouyuFulfillmentReconciler() if (server.listening) { await new Promise((resolve) => { diff --git a/apps/frontend/src/App.tsx b/apps/frontend/src/App.tsx index 95752b66..90487e23 100644 --- a/apps/frontend/src/App.tsx +++ b/apps/frontend/src/App.tsx @@ -12,7 +12,10 @@ import { import { getAdminRole, hasAdminSession } from '@/utils/admin-auth' import { isClaimPath, isH5ClaimPath } from '@/utils/claim-path' -import { isCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link' +import { + isCustomerFulfillmentPath, + isDouyuFulfillmentPath, +} from '@/utils/customer-fulfillment-link' import { isLegacySupplementPath, isOrderServicePath, @@ -44,6 +47,7 @@ const AdminPlatformShopsPage = lazy(() => import('@/pages/admin/platform/AdminPl const AdminTaskDetailPage = lazy(() => import('@/pages/admin/AdminTaskDetailPage')) const AdminTasksPage = lazy(() => import('@/pages/admin/AdminTasksPage')) const AdminSemiAutoTasksPage = lazy(() => import('@/pages/admin/AdminSemiAutoTasksPage')) +const AdminDouyuFulfillmentPage = lazy(() => import('@/pages/admin/AdminDouyuFulfillmentPage')) const AdminUsersPage = lazy(() => import('@/pages/admin/AdminUsersPage')) const AdminDevMockPage = lazy(() => import('@/pages/admin/AdminDevMockPage')) const AdminWorkerPlatformPage = lazy(() => import('@/pages/admin/AdminWorkerPlatformPage')) @@ -53,6 +57,7 @@ const OrderServicePage = lazy(() => import('@/pages/public/OrderServicePage')) const CustomerFulfillmentPage = lazy( () => import('@/pages/customer-fulfillment/CustomerFulfillmentPage'), ) +const DouyuFulfillmentPage = lazy(() => import('@/pages/douyu-fulfillment/DouyuFulfillmentPage')) const NotFoundPage = lazy(() => import('@/pages/NotFoundPage')) const RedeemPage = lazy(() => import('@/pages/redeem/RedeemPage')) const WorkerHallPage = lazy(() => import('@/pages/worker/WorkerHallPage')) @@ -136,6 +141,10 @@ export default function App() { return } + if (isDouyuFulfillmentPath(window.location.pathname)) { + return + } + if (isCustomerFulfillmentPath(window.location.pathname)) { return } @@ -152,6 +161,20 @@ export default function App() { return } +function DouyuFulfillmentApplication() { + useClearStrayHash() + return ( + + }> + + } /> + } /> + + + + ) +} + function OrderServiceApplication() { useClearStrayHash() return ( @@ -229,6 +252,7 @@ function AdminApplication() { } /> } /> } /> + } /> }> } /> diff --git a/apps/frontend/src/layouts/AdminLayout.tsx b/apps/frontend/src/layouts/AdminLayout.tsx index 5d28d6e2..903a56b0 100644 --- a/apps/frontend/src/layouts/AdminLayout.tsx +++ b/apps/frontend/src/layouts/AdminLayout.tsx @@ -17,6 +17,7 @@ import { SettingOutlined, SoundOutlined, TeamOutlined, + ThunderboltOutlined, TrophyOutlined, UnorderedListOutlined, UserOutlined, @@ -187,6 +188,7 @@ export default function AdminLayout() { void queryClient.invalidateQueries({ queryKey: ['admin-notifications'] }) void queryClient.invalidateQueries({ queryKey: ['admin-tasks'] }) void queryClient.invalidateQueries({ queryKey: ['admin-orders'] }) + void queryClient.invalidateQueries({ queryKey: ['admin-douyu-fulfillment'] }) void queryClient.invalidateQueries({ queryKey: ['admin-dashboard-summary'] }) }, // 会话过期时清登录态回登录页,避免 SSE 带着失效 token 无限重连刷 401。 @@ -252,6 +254,11 @@ export default function AdminLayout() { icon: , label: '半自动履约', }, + { + key: '/admin/douyu-fulfillment', + icon: , + label: '斗鱼领取', + }, { key: '/admin/worker-platform', icon: , label: '接单平台' }, { key: '/admin/kuaishou-industry', @@ -274,6 +281,11 @@ export default function AdminLayout() { icon: , label: '半自动履约', }, + { + key: '/admin/douyu-fulfillment', + icon: , + label: '斗鱼领取', + }, { key: '/admin/worker-platform', icon: , label: '接单平台' }, { key: '/admin/kuaishou-industry', @@ -511,6 +523,10 @@ function applyAdminRealtimeEvent( event: RealtimeEvent, queryClient: ReturnType, ) { + if (event.type === 'order.changed' && event.scopes.includes('admin_douyu_fulfillment')) { + void queryClient.invalidateQueries({ queryKey: ['admin-douyu-fulfillment'] }) + } + if (event.type === 'admin_notification.changed' && isRecord(event.data)) { queryClient.setQueryData(['admin-notifications'], (current: unknown) => { if (!isRecord(current) || !isRecord(current.data)) return current diff --git a/apps/frontend/src/pages/admin/AdminDevMockPage.tsx b/apps/frontend/src/pages/admin/AdminDevMockPage.tsx index c558022c..89f0c0a2 100644 --- a/apps/frontend/src/pages/admin/AdminDevMockPage.tsx +++ b/apps/frontend/src/pages/admin/AdminDevMockPage.tsx @@ -1,4 +1,13 @@ -import { BugOutlined, CopyOutlined, LinkOutlined } from '@ant-design/icons' +import { + ApiOutlined, + BugOutlined, + CopyOutlined, + GiftOutlined, + LinkOutlined, + SearchOutlined, + ThunderboltOutlined, + WalletOutlined, +} from '@ant-design/icons' import { Alert, App, @@ -6,13 +15,17 @@ import { Card, Col, Divider, + Empty, Form, Input, InputNumber, Result, Row, + Segmented, Select, Space, + Tabs, + Tag, Typography, } from 'antd' import { useMutation, useQuery } from '@tanstack/react-query' @@ -23,6 +36,7 @@ import PageHeader from '@/components/admin/PageHeader' import { buildOpen91QueryDevMock, createAffiliateDashDevMock, + createDouyuFulfillmentDevMock, createKuaishouIndustryVoucherDevMock, createSemiAutoDevMock, createSemiAutoIntegrationDevMock, @@ -31,16 +45,24 @@ import { type DevMockKuaishouIndustryVoucherResult, type DevMockOpen91QueryResult, type DevMockSemiAutoResult, + type DevDouyuFulfillmentMockResult, type DevSemiAutoIntegrationResult, } from '@/services/admin' import { buildCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link' +type MockTabKey = 'douyu' | 'semi-auto' | 'affiliate-dash' | 'kuaishou-voucher' | 'open91' +type SemiAutoMode = 'integration' | 'direct' + export default function AdminDevMockPage() { const { message } = App.useApp() + const [activeTab, setActiveTab] = useState('douyu') + const [semiAutoMode, setSemiAutoMode] = useState('integration') const [lastCreate, setLastCreate] = useState(null) const [lastVoucherCreate, setLastVoucherCreate] = useState(null) const [lastQuery, setLastQuery] = useState(null) + const [lastDouyuFulfillment, setLastDouyuFulfillment] = + useState(null) const [lastSemiAuto, setLastSemiAuto] = useState< DevMockSemiAutoResult | DevSemiAutoIntegrationResult | null >(null) @@ -109,8 +131,18 @@ export default function AdminDevMockPage() { }, }) + const douyuFulfillmentMutation = useMutation({ + mutationFn: createDouyuFulfillmentDevMock, + onSuccess: (response) => { + setLastDouyuFulfillment(response.data) + message.success('斗鱼直播账号履约测试单已生成') + }, + onError: (error) => { + message.error(error instanceof Error ? error.message : '生成失败') + }, + }) + const defaultOrderNo = useMemo(() => lastCreate?.orderNo || '', [lastCreate?.orderNo]) - // 页面展示按平台重新生成规范路径,避免历史 Mock 响应里的 customerPath 仍是 /c。 const semiAutoCustomerPath = lastSemiAuto ? buildCustomerFulfillmentPath(lastSemiAuto.orderNo, lastSemiAuto.semiAutoPlatform) || lastSemiAuto.customerPath @@ -148,314 +180,587 @@ export default function AdminDevMockPage() {
NODE_ENV={status?.nodeEnv || '-'} + + Mock 已开启 + NODE_ENV={status?.nodeEnv || '-'} + } /> } - message="Mock 会写入开发库真实订单/任务;除订单外,登录、绑定、票据注入和完成确认都可以走真实流程。" - description="默认使用 order_site 内置真实 Connector,不依赖 live-hub-py;只有显式选择内置 Mock 时才会 Mock 登录和绑定。" + message="仅用于开发环境" + description="Mock 会向当前开发库写入真实订单和任务。请先确认当前环境,再切换对应业务模块生成测试数据。" /> - - - - affiliateDashMutation.mutate(values)} - /> - - - - - - - semiAutoIntegrationMutation.mutate(values)} - /> - - - - - - semiAutoMutation.mutate(values)} - /> - - - - - - voucherMutation.mutate(values)} - /> - - - - - -
- open91Mutation.mutate({ - orderNo: values.orderNo, - execute: values.execute === '1', - }) - } - > - - - - - + + + + + + + + + + +
+ ) +} + function SemiAutoMockForm({ loading, submitText, diff --git a/apps/frontend/src/pages/admin/AdminDouyuFulfillmentPage.tsx b/apps/frontend/src/pages/admin/AdminDouyuFulfillmentPage.tsx new file mode 100644 index 00000000..3a59d180 --- /dev/null +++ b/apps/frontend/src/pages/admin/AdminDouyuFulfillmentPage.tsx @@ -0,0 +1,403 @@ +import { + CopyOutlined, + LinkOutlined, + ReloadOutlined, + SyncOutlined, + ThunderboltOutlined, +} from '@ant-design/icons' +import { + Alert, + App, + Button, + Card, + Descriptions, + Drawer, + Input, + Select, + Space, + Tag, + Timeline, + Typography, +} from 'antd' +import type { TableColumnsType } from 'antd' +import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' +import { useState } from 'react' + +import PageHeader from '@/components/admin/PageHeader' +import PercentTable from '@/components/common/PercentTable' +import { + fetchAdminDouyuFulfillmentDetail, + fetchAdminDouyuFulfillmentTasks, + refreshAdminDouyuBinding, + restartAdminDouyuBinding, + syncAdminDouyuFulfillmentTasks, +} from '@/services/admin' +import type { DouyuFulfillmentTask } from '@/types/douyu-fulfillment' +import { formatAdminDateTime } from '@/utils/admin-time' + +const { Text } = Typography + +const STATUS_LABELS: Record = { + waiting_profile: '待客户填资料', + preparing: '准备账号', + allocated: '已分配', + qr_pending: '待扫码', + role_ready: '待确认角色', + bound: '角色已绑定', + waiting_operator: '待客服处理', + processing: '处理中', + completed: '已完成', + failed: '绑定失败', + manual_required: '人工处理', + cancelled: '已取消', +} + +const STATUS_COLORS: Record = { + waiting_profile: 'blue', + preparing: 'gold', + allocated: 'geekblue', + qr_pending: 'cyan', + role_ready: 'orange', + bound: 'green', + waiting_operator: 'volcano', + processing: 'processing', + completed: 'success', + failed: 'error', + manual_required: 'warning', + cancelled: 'default', +} + +const PLATFORM_LABELS: Record = { + wechat: '微信', + qq: 'QQ', +} + +const SYSTEM_LABELS: Record = { + ios: '苹果', + android: '安卓', +} + +const EVENT_LABELS: Record = { + task_created: '订单进入斗鱼领取队列', + customer_link_opened: '客户打开领取链接', + customer_profile_saved: '客户保存游戏资料', + customer_profile_reset: '客服重置客户角色资料', + status_changed: '领取状态更新', +} + +export default function AdminDouyuFulfillmentPage() { + const { message } = App.useApp() + const queryClient = useQueryClient() + const [keyword, setKeyword] = useState('') + const [status, setStatus] = useState('') + const [page, setPage] = useState(1) + const [pageSize, setPageSize] = useState(20) + const [detailOrderNo, setDetailOrderNo] = useState('') + + const listQuery = useQuery({ + queryKey: ['admin-douyu-fulfillment', keyword, status, page, pageSize], + queryFn: () => + fetchAdminDouyuFulfillmentTasks({ + keyword: keyword.trim() || undefined, + status: status || undefined, + page, + pageSize, + }), + }) + const detailQuery = useQuery({ + queryKey: ['admin-douyu-fulfillment-detail', detailOrderNo], + queryFn: () => fetchAdminDouyuFulfillmentDetail(detailOrderNo), + enabled: Boolean(detailOrderNo), + }) + + const list = listQuery.data?.data.items || [] + const pagination = listQuery.data?.data.pagination + const detail = detailQuery.data?.data + + async function refreshAll() { + await Promise.all([ + queryClient.invalidateQueries({ queryKey: ['admin-douyu-fulfillment'] }), + detailOrderNo + ? queryClient.invalidateQueries({ + queryKey: ['admin-douyu-fulfillment-detail', detailOrderNo], + }) + : Promise.resolve(), + ]) + } + + const syncMutation = useMutation({ + mutationFn: syncAdminDouyuFulfillmentTasks, + onSuccess: async (response) => { + message.success( + `同步完成:新增 ${response.data.created},更新 ${response.data.updated},核验状态 ${response.data.checked}`, + ) + await refreshAll() + }, + onError: (error) => message.error(error instanceof Error ? error.message : '同步失败'), + }) + const refreshMutation = useMutation({ + mutationFn: refreshAdminDouyuBinding, + onSuccess: async () => { + message.success('绑定状态已刷新') + await refreshAll() + }, + onError: (error) => message.error(error instanceof Error ? error.message : '刷新失败'), + }) + const restartMutation = useMutation({ + mutationFn: restartAdminDouyuBinding, + onSuccess: async () => { + message.success('已重新生成绑定二维码') + await refreshAll() + }, + onError: (error) => message.error(error instanceof Error ? error.message : '重新生成失败'), + }) + + async function copyLink(task: DouyuFulfillmentTask) { + const url = `${window.location.origin}${task.linkPath}` + try { + await navigator.clipboard.writeText(url) + message.success('客户领取链接已复制') + } catch { + message.error('复制失败,请手动复制') + } + } + + const columns: TableColumnsType = [ + { + title: '订单 / 商品', + key: 'order', + width: 280, + render: (_, task) => ( + + {task.platform_order_id} + {task.product_name || task.sku_name || task.sku_code} + 订单项 #{task.order_item_id} + + ), + }, + { + title: '客户资料', + key: 'profile', + width: 220, + render: (_, task) => + task.customer_role_name ? ( + + {task.customer_role_name} + + {PLATFORM_LABELS[task.customer_platform] || '-'} ·{' '} + {SYSTEM_LABELS[task.customer_system] || '-'} + + + ) : ( + 待客户填写 + ), + }, + { + title: '绑定角色', + key: 'boundRole', + width: 220, + render: (_, task) => + task.bound_role_name ? ( + + {task.bound_role_name} + + {[task.bound_area_name, task.bound_plat_name].filter(Boolean).join(' · ') || '-'} + + + ) : ( + 未识别 + ), + }, + { + title: '状态', + dataIndex: 'status', + width: 140, + render: (value: string) => ( + {STATUS_LABELS[value] || value} + ), + }, + { + title: '更新时间', + dataIndex: 'updated_at', + width: 165, + render: (value: string) => formatAdminDateTime(value), + }, + { + title: '操作', + key: 'actions', + width: 360, + render: (_, task) => ( + + + + + + ), + }, + ] + + return ( +
+ + + + + { + setKeyword(event.target.value) + setPage(1) + }} + style={{ width: 300 }} + /> + setRoleName(event.target.value)} + placeholder="请输入和平精英角色名" + maxLength={100} + /> + + +
+ ) : waitingForSupport ? ( +
+ +
+ ) : ( +
+ {bindingFailed ? ( +
+ +

请截图本页面并联系客服处理,客服会根据截图重新安排绑定。

+
+ ) : ( + + )} + + {!bindingFailed && canRevealBindingQr ? ( + + ) : null} + + {!bindingFailed && + !live?.qrUrl && + !live?.bindReadyForConfirm && + task.status !== 'completed' ? ( +
+

游戏角色绑定二维码

+
+ +
+
+ +
+ +
+

+ 二维码准备完成后,必须使用微信扫码并选择游戏角色。 +

+ +
+ ) : null} + + {!bindingFailed && live?.qrUrl && showBindingQr ? ( +
+

游戏角色绑定二维码

+
+ +
+ {qrImage ? ( + 和平精英角色绑定二维码 + ) : ( +
+ + 正在生成二维码图片... +
+ )} +
+ +
+

+ 必须使用微信扫码,并选择与资料一致的和平精英角色。 +

+ {qrExpired ? ( +
二维码已过期
+ ) : ( +
+ 二维码有效期剩余 {formatRemainingTime(expiresInSeconds)} +
+ )} + +
+ +
+

+ {qrExpired + ? '二维码已过期,请刷新后重新扫码' + : '二维码有效期内无需刷新,过期后可重新生成'} +

+
+ ) : null} + + {!bindingFailed && live?.bindReadyForConfirm ? ( +
+

核对绑定角色

+

+ 平台识别角色:{live.roleName || '-'} · {live.areaName || '-'} ·{' '} + {live.platName || '-'} +

+

+ 已填资料:{task.customer_role_name} · {platformLabel(task.customer_platform)} ·{' '} + {systemLabel(task.customer_system)} +

+ + + + + +
+ ) : null} +
+ )} + + ) +} + +function ChoiceSwitch(input: { + value: T + options: ReadonlyArray<{ label: string; value: T }> + ariaLabel: string + onChange: (value: T) => void +}) { + return ( +
+ {input.options.map((option) => { + const selected = input.value === option.value + return ( + + ) + })} +
+ ) +} + +function CustomerFrame({ + title, + compact = false, + children, +}: { + title: string + compact?: boolean + children: ReactNode +}) { + return ( +
+
+
+
+
+

{title}

+
+
+
+
温馨提示:未成年人禁止下单
+
{children}
+
+
+ ) +} + +function OrderCard({ data }: { data: DouyuCustomerFulfillment }) { + return ( +
+
+

订单信息

+ + {STATUS_LABELS[data.task.status] || data.task.status} + +
+
+ 订单号 + {data.task.platform_order_id} +
+
+ 商品 + + {data.task.product_name || data.task.sku_name} × {data.task.quantity} + +
+
+ ) +} diff --git a/apps/frontend/src/services/admin/cost-center.ts b/apps/frontend/src/services/admin/cost-center.ts index bdff67b0..16e65ad3 100644 --- a/apps/frontend/src/services/admin/cost-center.ts +++ b/apps/frontend/src/services/admin/cost-center.ts @@ -365,6 +365,7 @@ export function saveAdminManualConfig(payload: { semiAutoEnabled?: boolean semiAutoPlatform?: '' | 'huya' | 'weibo' semiAutoConfig?: Record + douyuFulfillmentEnabled?: boolean }) { return apiPost('/api/v1/admin/cost-center/manual-configs', payload) } diff --git a/apps/frontend/src/services/admin/dev-mock.ts b/apps/frontend/src/services/admin/dev-mock.ts index 8f44645d..0707555a 100644 --- a/apps/frontend/src/services/admin/dev-mock.ts +++ b/apps/frontend/src/services/admin/dev-mock.ts @@ -73,6 +73,21 @@ export type DevSemiAutoIntegrationResult = DevMockSemiAutoResult & { mappingId: number } +export type DevDouyuFulfillmentMockResult = { + platform: 'douyu' + pipeline: 'order_service' + orderId: number + orderNo: string + orderItemId: number + fulfillmentId: number + configId: number + mappingId: number + skuKey: string + customerPath: string + adminPath: string + tips: string[] +} + export function fetchDevMockStatus() { return apiGet('/api/v1/admin/dev-mock/status') } @@ -122,6 +137,10 @@ export function createSemiAutoIntegrationDevMock(payload: { ) } +export function createDouyuFulfillmentDevMock(payload: { orderNo?: string; skuName?: string }) { + return apiPost('/api/v1/admin/dev-mock/douyu-fulfillment', payload) +} + export function buildOpen91QueryDevMock(payload: { orderNo: string execute?: boolean diff --git a/apps/frontend/src/services/admin/douyu-fulfillment.ts b/apps/frontend/src/services/admin/douyu-fulfillment.ts new file mode 100644 index 00000000..48ceb1dc --- /dev/null +++ b/apps/frontend/src/services/admin/douyu-fulfillment.ts @@ -0,0 +1,41 @@ +import { apiGet, apiPost } from '@/lib/http' +import type { DouyuFulfillmentDetail, DouyuFulfillmentTask } from '@/types/douyu-fulfillment' + +export function fetchAdminDouyuFulfillmentTasks(params: { + keyword?: string + status?: string + page?: number + pageSize?: number +}) { + return apiGet<{ + items: DouyuFulfillmentTask[] + pagination: { page: number; pageSize: number; total: number } + }>('/api/v1/admin/douyu-fulfillment/tasks', { params }) +} + +export function syncAdminDouyuFulfillmentTasks() { + return apiPost<{ created: number; updated: number; checked: number }>( + '/api/v1/admin/douyu-fulfillment/sync', + {}, + ) +} + +export function fetchAdminDouyuFulfillmentDetail(orderNo: string) { + return apiGet( + `/api/v1/admin/douyu-fulfillment/tasks/${encodeURIComponent(orderNo)}`, + ) +} + +export function refreshAdminDouyuBinding(orderNo: string) { + return apiPost( + `/api/v1/admin/douyu-fulfillment/tasks/${encodeURIComponent(orderNo)}/binding/refresh`, + {}, + ) +} + +export function restartAdminDouyuBinding(orderNo: string) { + return apiPost( + `/api/v1/admin/douyu-fulfillment/tasks/${encodeURIComponent(orderNo)}/binding/start`, + { forceRefresh: true }, + ) +} diff --git a/apps/frontend/src/services/admin/index.ts b/apps/frontend/src/services/admin/index.ts index 03b6d796..76c3e50d 100644 --- a/apps/frontend/src/services/admin/index.ts +++ b/apps/frontend/src/services/admin/index.ts @@ -15,3 +15,4 @@ export * from './tasks' export * from './dev-mock' export * from './notifications' export * from './worker-platform' +export * from './douyu-fulfillment' diff --git a/apps/frontend/src/services/douyu-fulfillment.ts b/apps/frontend/src/services/douyu-fulfillment.ts new file mode 100644 index 00000000..1781f729 --- /dev/null +++ b/apps/frontend/src/services/douyu-fulfillment.ts @@ -0,0 +1,46 @@ +import { apiGet, apiPost } from '@/lib/http' +import type { + DouyuCustomerFulfillment, + DouyuCustomerPlatform, + DouyuCustomerSystem, +} from '@/types/douyu-fulfillment' + +export function fetchDouyuFulfillment(orderNo: string) { + return apiGet( + `/api/v1/douyu-fulfillment/${encodeURIComponent(orderNo)}`, + ) +} + +export function saveDouyuProfile( + orderNo: string, + input: { + roleName: string + platform: DouyuCustomerPlatform + system: DouyuCustomerSystem + }, +) { + return apiPost( + `/api/v1/douyu-fulfillment/${encodeURIComponent(orderNo)}/profile`, + input, + ) +} + +export function startDouyuBinding(orderNo: string, forceRefresh = false) { + return apiPost( + `/api/v1/douyu-fulfillment/${encodeURIComponent(orderNo)}/binding/start`, + { forceRefresh }, + ) +} + +export function pollDouyuBinding(orderNo: string) { + return apiGet( + `/api/v1/douyu-fulfillment/${encodeURIComponent(orderNo)}/binding/status`, + ) +} + +export function confirmDouyuBinding(orderNo: string) { + return apiPost( + `/api/v1/douyu-fulfillment/${encodeURIComponent(orderNo)}/binding/confirm`, + {}, + ) +} diff --git a/apps/frontend/src/styles/base.css b/apps/frontend/src/styles/base.css index 8e2aff49..d67470f1 100644 --- a/apps/frontend/src/styles/base.css +++ b/apps/frontend/src/styles/base.css @@ -123,6 +123,18 @@ select { line-height: 1.5; } +.dev-mock-tabs > .ant-tabs-nav { + margin-bottom: 0; +} + +.dev-mock-tabs > .ant-tabs-content-holder { + margin-top: 16px; +} + +.dev-mock-tabs > .ant-tabs-nav .ant-tabs-tab { + padding-inline: 18px; +} + .total-badge { display: inline-flex; align-items: center; diff --git a/apps/frontend/src/styles/client.css b/apps/frontend/src/styles/client.css index 06422524..a7870bf5 100644 --- a/apps/frontend/src/styles/client.css +++ b/apps/frontend/src/styles/client.css @@ -1,3554 +1,6 @@ -/* ========================================================================== - 买家前台:提卡与信息收集页 (Buyer Claim & Collect Pages) - ========================================================================== */ +/** 买家前台公共样式入口:按领取流程拆分,具体规则见 client/。 */ -.claim-page { - min-height: 100vh; - padding: 24px; - background: linear-gradient(180deg, #f8fafc 0%, #eef4fb 100%); - display: flex; - flex-direction: column; - align-items: center; - gap: 18px; -} - -.claim-header-card, -.claim-content-card { - width: min(680px, 100%); - border-color: rgba(148, 163, 184, 0.18); - box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08); -} - -.claim-header-card { - position: relative; -} - -.claim-header-card .ant-card-body, -.claim-content-card .ant-card-body { - display: flex; - flex-direction: column; - gap: 18px; -} - -.claim-header-copy { - min-width: 0; - padding-right: 220px; -} - -.claim-header-copy h1 { - margin: 0; - color: #0f172a; - font-size: 30px; - line-height: 1.25; - overflow-wrap: anywhere; -} - -.claim-header-copy p, -.claim-muted { - margin: 0; - color: #64748b; - line-height: 1.6; -} - -.claim-step-indicator { - position: absolute; - top: 24px; - right: 24px; - max-width: 210px; - display: flex; - flex-direction: column; - align-items: flex-end; - gap: 7px; -} - -.claim-step-dots { - display: flex; - gap: 8px; -} - -.claim-step-dot { - width: 32px; - height: 32px; - border-radius: 50%; - background: #e5e7eb; - color: #94a3b8; - display: inline-flex; - align-items: center; - justify-content: center; - font-weight: 700; -} - -.claim-step-dot.active { - background: var(--theme-primary); - color: #ffffff; -} - -.claim-step-progress-text { - color: #64748b; - font-size: 13px; - font-weight: 700; - line-height: 1.4; - text-align: right; - overflow-wrap: anywhere; -} - -.claim-content-card .ant-typography { - margin: 0; -} - -.claim-state-card .ant-card-body { - min-height: 240px; - align-items: center; - justify-content: center; - text-align: center; -} - -.claim-large-icon { - font-size: 44px; -} - -.claim-icon-success { - color: #16a34a; -} - -.claim-icon-warning { - color: #d97706; -} - -.claim-icon-info { - color: var(--theme-primary); -} - -.claim-icon-error { - color: #dc2626; -} - -.claim-qr-block { - display: flex; - flex-direction: column; - align-items: center; - gap: 14px; - padding: 14px; - border-radius: 8px; - background: #f8fbff; - border: 1px solid #dbeafe; -} - -.claim-qr-guide-panel { - display: grid; - grid-template-columns: 42px minmax(0, 280px) 42px; - grid-template-areas: - 'left code right' - '. hint .'; - gap: 10px; - align-items: center; - justify-content: center; - width: 100%; - max-width: 410px; - min-width: 0; -} - -.claim-scan-label { - align-self: stretch; - min-height: 150px; - padding: 10px 6px; - color: #e11d48; - font-weight: 900; - font-size: 17px; - line-height: 1.2; - writing-mode: vertical-rl; - text-orientation: upright; - display: flex; - align-items: center; - justify-content: center; -} - -.claim-scan-label-left { - grid-area: left; -} - -.claim-scan-label-right { - grid-area: right; -} - -.claim-qr-code { - grid-area: code; - width: 100%; - max-width: 280px; - aspect-ratio: 1 / 1; - padding: 10px; - background: #ffffff; - border-radius: 8px; - border: 1px solid #dbeafe; -} - -.claim-save-hint { - grid-area: hint; - margin: 0; - justify-self: center; - color: #64748b; - font-size: 14px; - font-weight: 700; - line-height: 1.4; - text-align: center; -} - -.claim-role-panel { - display: grid; - grid-template-columns: 1fr; - gap: 8px; -} - -.claim-role-panel.pending { - opacity: 0.82; -} - -.claim-role-panel-item { - min-width: 0; - display: grid; - grid-template-columns: 88px minmax(0, 1fr); - align-items: center; - gap: 12px; -} - -.claim-role-panel-item span { - color: #64748b; - font-size: 13px; - line-height: 1.4; - white-space: nowrap; -} - -.claim-role-panel-item strong { - min-width: 0; - color: #0f172a; - font-size: 17px; - line-height: 1.45; - overflow-wrap: anywhere; -} - -.claim-action-row { - width: 100%; -} - -.claim-action-tooltip-wrap { - display: inline-flex; -} - -.claim-meta-footer { - display: flex; - flex-wrap: wrap; - gap: 4px 10px; - justify-content: center; - color: #94a3b8; - font-size: 11px; - line-height: 1.5; -} - -.claim-info-grid { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 14px; -} - -.claim-info-grid-compact { - gap: 8px; - margin-bottom: 10px; -} - -.claim-info-grid-compact .claim-info-item { - padding: 8px 10px; - gap: 2px; - border-radius: 6px; -} - -.claim-info-grid-compact .claim-info-item span { - font-size: 11px; - line-height: 1.3; -} - -.claim-info-grid-compact .claim-info-item strong { - font-size: 13px; - line-height: 1.35; - font-weight: 600; -} - -.claim-uid-step .ant-card-body { - gap: 10px; -} - -.claim-uid-step-title.ant-typography { - margin: 0 !important; - font-size: 20px !important; - line-height: 1.3 !important; -} - -.claim-uid-step-desc { - font-size: 13px; - line-height: 1.45; -} - -.claim-uid-guide { - margin: 4px 0 0; - padding: 6px; - border-radius: 8px; - background: #f8fafc; - border: 1px solid #e5e7eb; -} - -.claim-uid-guide-image { - display: block; - width: 100%; - max-width: 360px; - max-height: 160px; - margin: 0 auto; - border-radius: 6px; - border: 1px solid #e2e8f0; - object-fit: contain; - background: #fff; -} - -.claim-uid-guide-caption { - margin: 6px 0 0; - text-align: center; - color: #64748b; - font-size: 12px; - line-height: 1.35; -} - -.claim-uid-warning { - margin: 2px 0 0; - color: #ff4d4f; - font-size: 13px; - font-weight: 600; - line-height: 1.45; -} - -.claim-info-item { - min-width: 0; - padding: 16px; - border-radius: 6px; - background: #f8fafc; - border: 1px solid #e5e7eb; - display: flex; - flex-direction: column; - gap: 6px; -} - -.claim-info-item span { - color: #64748b; - font-size: 13px; -} - -.claim-info-item strong { - color: #0f172a; - font-size: 17px; - overflow-wrap: anywhere; -} - -.claim-result-header { - display: flex; - align-items: flex-start; - gap: 14px; -} - -.claim-feifei-main { - display: grid; - gap: 8px; -} - -.claim-feifei-main p { - margin: 0; - color: var(--theme-primary); - font-weight: 700; -} - -.claim-feifei-label { - color: #64748b; - font-size: 13px; -} - -.claim-product-items { - display: flex; - flex-direction: column; - gap: 10px; -} - -.claim-product-items-header { - display: flex; - align-items: center; - justify-content: space-between; - gap: 12px; - color: #64748b; - font-size: 13px; -} - -.claim-product-items-header strong { - color: var(--theme-primary); - font-weight: 700; -} - -.claim-product-items-list { - display: flex; - flex-direction: column; - gap: 8px; -} - -.claim-product-item-row { - min-height: 44px; - padding: 10px 12px; - border: 1px solid #e5e7eb; - border-radius: 6px; - background: #f8fafc; - display: flex; - align-items: center; - justify-content: space-between; - gap: 12px; -} - -.claim-product-item-row span { - min-width: 0; - color: #0f172a; - font-weight: 700; - line-height: 1.35; - overflow-wrap: anywhere; -} - -.claim-product-item-row strong { - flex: 0 0 auto; - color: #0f172a; - font-size: 15px; -} - -.claim-product-items.compact { - margin-top: 10px; - gap: 8px; -} - -.claim-product-items.compact .claim-product-items-list { - gap: 6px; -} - -.claim-product-items.compact .claim-product-item-row { - min-height: 36px; - padding: 8px 10px; - background: rgba(248, 250, 252, 0.72); -} - -/* 待领取物品图:居中大图;imageUrl 为空或加载失败时是同一尺寸的虚线占位块(不会出现破图) */ - -.claim-product-image-wrap { - display: flex; - justify-content: center; -} - -.claim-product-image { - width: min(160px, 48%); - aspect-ratio: 1 / 1; - border-radius: 16px; - object-fit: contain; - background: #f8fafc; - padding: 8px; - border: 1px solid rgba(148, 163, 184, 0.24); - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); -} - -.claim-product-image-fallback { - display: flex; - align-items: center; - justify-content: center; - font-size: 46px; - color: rgba(100, 116, 139, 0.55); - border-style: dashed; -} - -/* ===== 收集页 (Collect Page) ===== */ - -.collect-page { - min-height: 100vh; - display: grid; - place-items: center; - padding: 32px 16px; - background: #f5f7fb; -} - -.collect-card { - width: min(520px, 100%); -} - -.collect-order-input { - flex: 1; - margin-bottom: 0; -} - -/* ===== 一次性补资料链接页 (Collect Material Link) ===== */ - -.collect-link-page { - min-height: 100vh; - padding: 32px 16px; - background: #f5f7fb; - display: flex; - justify-content: center; - align-items: flex-start; -} - -.collect-link-card { - width: min(720px, 100%); -} - -.collect-link-card .ant-card-body { - padding: 28px; -} - -/* 一单多工单时,内层商品卡片比外层容器更紧凑 */ -.collect-link-order-card .ant-card-body { - padding: 16px; -} - -.collect-link-status-card { - background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%); -} - -.collect-link-status-card .ant-card-body { - padding: 16px; -} - -.collect-link-status-head { - display: flex; - align-items: center; - justify-content: space-between; - flex-wrap: wrap; - gap: 8px; - color: #0f172a; - font-size: 15px; -} - -.collect-link-status-head .ant-tag { - margin-inline-end: 0; -} - -.collect-link-order-meta { - display: flex; - flex-wrap: wrap; - gap: 4px 18px; - color: #64748b; - font-size: 13px; -} - -.collect-link-order-meta strong { - color: #0f172a; - font-weight: 600; -} - -.collect-link-description { - margin-top: 6px; - font-size: 12px; -} - -.collect-link-submitted { - display: grid; - gap: 10px; - padding: 12px; - background: #f8fafc; - border: 1px solid #e7edf5; - border-radius: 10px; -} - -.collect-link-submitted-head { - display: flex; - flex-wrap: wrap; - align-items: flex-start; - justify-content: space-between; - gap: 5px 14px; -} - -.collect-link-submitted-head > span { - display: grid; - gap: 1px; -} - -.collect-link-submitted-head .ant-typography:last-child { - font-size: 11px; -} - -.collect-link-submitted-head > .ant-typography { - font-size: 11px; -} - -.collect-link-submitted-fields { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 7px; -} - -.collect-link-submitted-fields > div { - display: grid; - gap: 2px; - min-width: 0; - padding: 8px 10px; - background: #ffffff; - border: 1px solid #edf1f6; - border-radius: 8px; -} - -.collect-link-submitted-fields span, -.collect-link-submitted-screenshots > span { - color: #94a3b8; - font-size: 11px; -} - -.collect-link-submitted-fields strong { - color: #1e293b; - font-size: 13px; - font-weight: 500; - line-height: 1.5; - white-space: pre-wrap; - overflow-wrap: anywhere; -} - -.collect-link-submitted-screenshots { - display: grid; - gap: 7px; -} - -.collect-link-submitted-screenshots > div { - display: flex; - flex-wrap: wrap; - gap: 8px; -} - -.collect-link-submitted-screenshots .ant-image { - overflow: hidden; - border: 1px solid #dbe3ee; - border-radius: 8px; -} - -.collect-link-submitted-screenshots .ant-image-img { - object-fit: cover; -} - -.collect-link-current-status { - display: grid; - grid-template-columns: auto minmax(0, 1fr); - gap: 12px; - align-items: flex-start; - padding: 13px; - color: #475569; - background: #f8fafc; - border: 1px solid #e8edf4; - border-left: 4px solid #94a3b8; - border-radius: 9px; -} - -.collect-link-current-status-index { - display: inline-flex; - align-items: center; - justify-content: center; - width: 30px; - height: 30px; - color: #ffffff; - font-size: 13px; - font-weight: 700; - background: #64748b; - border-radius: 999px; -} - -.collect-link-current-status-copy { - display: grid; - gap: 5px; - min-width: 0; -} - -.collect-link-current-status-copy > div { - display: flex; - flex-wrap: wrap; - gap: 3px 12px; - align-items: baseline; - justify-content: space-between; -} - -.collect-link-current-status-copy > div .ant-typography:last-child { - font-size: 11px; -} - -.collect-link-current-status-copy p { - margin: 0; - color: inherit; - font-size: 13px; - line-height: 1.7; - white-space: pre-wrap; - overflow-wrap: anywhere; -} - -.collect-link-current-status.is-open, -.collect-link-current-status.is-pending_material { - color: #8a4b00; - background: #fffaf0; - border-color: #ffe7ba; - border-left-color: #faad14; -} - -.collect-link-current-status.is-open .collect-link-current-status-index, -.collect-link-current-status.is-pending_material .collect-link-current-status-index { - background: #faad14; -} - -.collect-link-current-status.is-in_progress, -.collect-link-current-status.is-unassigned { - color: #0958d9; - background: #f0f7ff; - border-color: #d6e8ff; - border-left-color: #1677ff; -} - -.collect-link-current-status.is-in_progress .collect-link-current-status-index, -.collect-link-current-status.is-unassigned .collect-link-current-status-index { - background: #1677ff; -} - -.collect-link-current-status.is-pending_acceptance { - color: #531dab; - background: #f9f0ff; - border-color: #efdbff; - border-left-color: #722ed1; -} - -.collect-link-current-status.is-pending_acceptance .collect-link-current-status-index { - background: #722ed1; -} - -.collect-link-current-status.is-accepted { - color: #237804; - background: #f6ffed; - border-color: #d9f7be; - border-left-color: #52c41a; -} - -.collect-link-current-status.is-accepted .collect-link-current-status-index { - background: #52c41a; -} - -.collect-link-current-status.is-problem { - color: #a8071a; - background: #fff1f0; - border-color: #ffccc7; - border-left-color: #ff4d4f; -} - -.collect-link-current-status.is-problem .collect-link-current-status-index { - background: #ff4d4f; -} - -.collect-link-status-message { - padding: 10px 12px; - color: #475569; - font-size: 13px; - line-height: 1.65; - background: #f8fafc; - border-left: 3px solid #94a3b8; - border-radius: 0 8px 8px 0; -} - -.collect-link-status-message.is-open, -.collect-link-status-message.is-pending_material { - color: #8a4b00; - background: #fffaf0; - border-left-color: #faad14; -} - -.collect-link-status-message.is-in_progress, -.collect-link-status-message.is-unassigned { - color: #0958d9; - background: #f0f7ff; - border-left-color: #1677ff; -} - -.collect-link-status-message.is-pending_acceptance { - color: #531dab; - background: #f9f0ff; - border-left-color: #722ed1; -} - -.collect-link-status-message.is-accepted { - color: #237804; - background: #f6ffed; - border-left-color: #52c41a; -} - -.collect-link-status-message.is-problem { - color: #a8071a; - background: #fff1f0; - border-left-color: #ff4d4f; -} - -.collect-link-status-times { - display: flex; - flex-wrap: wrap; - gap: 4px 18px; - color: #94a3b8; - font-size: 12px; -} - -.collect-link-acceptance { - display: grid; - gap: 10px; - padding-top: 12px; - border-top: 1px solid #eef2f7; -} - -.collect-link-acceptance > div:first-child { - display: flex; - align-items: baseline; - justify-content: space-between; - flex-wrap: wrap; - gap: 4px 12px; -} - -.collect-link-acceptance > div:first-child .ant-typography:last-child { - font-size: 12px; -} - -.collect-link-acceptance-images { - display: flex; - flex-wrap: wrap; - gap: 10px; -} - -.collect-link-acceptance-images .ant-image { - overflow: hidden; - border: 1px solid #dbe3ee; - border-radius: 9px; -} - -.collect-link-acceptance-images .ant-image-img { - object-fit: cover; -} - -.collect-link-acceptance-video { - display: grid; - gap: 8px; -} - -.collect-link-acceptance-video video { - width: min(100%, 520px); - max-height: 360px; - background: #0f172a; - border: 1px solid #dbe3ee; - border-radius: 10px; -} - -.collect-link-acceptance-video > div { - display: flex; - flex-wrap: wrap; - gap: 4px 14px; - align-items: center; - justify-content: space-between; - font-size: 12px; -} - -.collect-link-acceptance-video a { - color: #1677ff; -} - -.collect-link-title { - margin: 0 0 4px !important; -} - -.collect-link-heading { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 12px; -} - -.collect-link-confirm { - display: grid; - gap: 12px; - max-height: 58vh; - padding-top: 4px; - padding-right: 4px; - overflow-y: auto; -} - -.collect-link-confirm-meta { - display: flex; - flex-wrap: wrap; - justify-content: space-between; - gap: 4px 16px; - color: #64748b; - font-size: 12px; -} - -.collect-link-confirm-meta span:first-child { - color: #0f172a; - font-size: 14px; - font-weight: 600; -} - -.collect-link-confirm-fields { - overflow: hidden; - border: 1px solid #e8edf4; - border-radius: 9px; -} - -.collect-link-confirm-field { - display: grid; - grid-template-columns: 110px minmax(0, 1fr); - gap: 12px; - padding: 9px 12px; - font-size: 13px; - border-bottom: 1px solid #eef2f7; -} - -.collect-link-confirm-field:last-child { - border-bottom: 0; -} - -.collect-link-confirm-field span, -.collect-link-confirm-screenshots span { - color: #64748b; -} - -.collect-link-confirm-field strong, -.collect-link-confirm-screenshots strong { - color: #0f172a; - font-weight: 500; - white-space: pre-wrap; - overflow-wrap: anywhere; -} - -.collect-link-confirm-field strong.is-empty { - color: #94a3b8; -} - -.collect-link-confirm-screenshots { - display: grid; - gap: 8px; - padding: 10px 12px; - font-size: 13px; - background: #f8fafc; - border-radius: 9px; -} - -.collect-link-confirm-screenshots > div:first-child { - display: flex; - justify-content: space-between; - gap: 12px; -} - -.collect-link-confirm-images { - display: flex; - flex-wrap: wrap; - gap: 8px; -} - -.collect-link-confirm-images img { - width: 58px; - height: 58px; - object-fit: cover; - background: #ffffff; - border: 1px solid #dbe3ee; - border-radius: 8px; -} - -.collect-link-confirm-content { - padding: 10px 12px; - color: #8a4b00; - font-size: 13px; - line-height: 1.7; - background: #fff7e6; - border: 1px solid #ffe7ba; - border-radius: 9px; - white-space: pre-wrap; - overflow-wrap: anywhere; -} - -/* 商品名与订单号放在同一个信息头里,避免标题和灰色信息块分离 */ -.collect-link-order-head { - display: flex; - align-items: baseline; - justify-content: space-between; - flex-wrap: wrap; - gap: 6px 20px; - padding-bottom: 12px; - border-bottom: 1px solid #eef2f7; -} - -.collect-link-order-name { - min-width: 0; - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 8px; - color: #0f172a; - font-size: 16px; - font-weight: 700; - overflow-wrap: anywhere; -} - -.collect-link-order-no { - min-width: 0; - display: flex; - align-items: baseline; - gap: 6px; - color: #64748b; - font-size: 12px; -} - -.collect-link-order-no strong { - color: #0f172a; - font-size: 14px; - font-weight: 600; - overflow-wrap: anywhere; -} - -.collect-link-state { - min-height: 220px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - gap: 16px; -} - -/* 提交成功:居中的成功状态,不再展示订单号 */ -.collect-link-success { - min-height: 380px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - gap: 10px; - padding: 24px 12px 8px; - text-align: center; -} - -.collect-link-success-icon { - font-size: 64px; - color: #22c55e; - filter: drop-shadow(0 10px 20px rgba(34, 197, 94, 0.18)); -} - -.collect-link-success-title { - margin: 2px 0 0 !important; - color: #0f172a; -} - -.collect-link-success-products { - max-width: 100%; - margin-top: 10px; - padding: 12px 22px; - border: 1px solid #dcfce7; - border-radius: 12px; - background: #f0fdf4; - display: flex; - flex-direction: column; - gap: 4px; -} - -.collect-link-success-products span { - color: #16a34a; - font-size: 12px; -} - -.collect-link-success-products strong { - color: #166534; - font-size: 15px; - overflow-wrap: anywhere; -} - -.collect-link-success .collect-link-footnote { - margin-top: 18px; -} - -.collect-link-screenshot-control { - display: grid; - gap: 14px; - align-items: start; -} - -.collect-link-screenshot-control.has-guide { - grid-template-columns: 120px minmax(180px, 260px); - gap: 16px; -} - -.collect-link-guide-example { - display: grid; - grid-template-columns: 1fr; - gap: 6px; - min-width: 0; - max-width: 100%; - align-content: start; - justify-items: start; -} - -.collect-link-guide-example .ant-image { - display: block; - width: 128px !important; - height: 88px !important; - overflow: hidden; - border: 1px solid #dbe3ee; - border-radius: 7px; - cursor: zoom-in; -} - -.collect-link-guide-example .ant-image-img { - display: block; - width: 128px !important; - height: 88px !important; - object-fit: cover; - object-position: center; -} - -.collect-link-guide-copy { - display: grid; - align-content: center; - gap: 3px; - min-width: 0; -} - -.collect-link-guide-copy .ant-typography:first-child { - color: #334155; - font-size: 12px; -} - -.collect-link-guide-copy .ant-typography:last-child { - max-width: 220px; - font-size: 11px; - line-height: 1.55; - white-space: pre-wrap; -} - -.collect-link-actions { - display: flex; - justify-content: flex-end; - margin-top: 4px; -} - -.collect-link-actions .ant-btn { - min-width: 180px; -} - -.collect-link-footnote { - display: block; - text-align: center; - font-size: 12px; - white-space: pre-wrap; -} - -@media (max-width: 720px) { - .collect-link-page { - padding: 14px; - } - - .collect-link-card .ant-card-body { - padding: 18px; - } - - .collect-link-screenshot-control.has-guide { - grid-template-columns: 112px minmax(160px, 220px); - gap: 12px; - } - - .collect-link-guide-example .ant-image { - width: 116px !important; - height: 80px !important; - } - - .collect-link-guide-example .ant-image-img { - width: 116px !important; - height: 80px !important; - } - - .collect-link-actions { - justify-content: stretch; - } - - .collect-link-actions .ant-btn { - width: 100%; - } -} - -@media (max-width: 480px) { - .collect-link-page { - padding: 10px; - } - - .collect-link-card .ant-card-body { - padding: 14px; - } - - .collect-link-screenshot-control.has-guide { - grid-template-columns: 104px minmax(0, 1fr); - gap: 8px; - } - - .collect-link-guide-example { - gap: 5px; - } - - .collect-link-guide-example .ant-image { - width: 96px !important; - height: 68px !important; - } - - .collect-link-guide-example .ant-image-img { - width: 96px !important; - height: 68px !important; - } - - .collect-link-guide-copy .ant-typography:first-child { - font-size: 11px; - } - - .collect-link-guide-copy .ant-typography:last-child { - font-size: 10px; - } - - .collect-link-success { - min-height: 320px; - padding: 16px 4px 4px; - } - - .collect-link-success-icon { - font-size: 52px; - } - - .collect-link-success-products { - padding: 10px 16px; - } - - .collect-link-confirm-field { - grid-template-columns: 88px minmax(0, 1fr); - padding: 8px 10px; - } - - .collect-link-order-meta, - .collect-link-submitted-fields { - grid-template-columns: 1fr; - } - - .collect-link-order-meta { - display: grid; - } -} - -/* ===== 兑换中心 (Redeem Page) ===== */ - -.redeem-page { - min-height: 100vh; - display: grid; - place-items: center; - padding: 32px 16px; - background: #f5f7fb; -} - -.redeem-card { - width: min(520px, 100%); -} - -.redeem-order-input { - flex: 1; - margin-bottom: 0; -} - -/* ===== H5 领取入口页(`/h5`,只有前缀没有订单号) ===== */ - -/* 复用领取页的卡片与背景,只把单卡在视口内垂直居中 */ -.h5-claim-entry { - justify-content: center; -} - -/* ===== 买家页面响应式断点 ===== */ - -@media (max-width: 720px) { - .claim-page { - padding: 14px; - } - - .claim-header-card .ant-card-body, - .claim-content-card .ant-card-body { - gap: 14px; - } - - .claim-header-copy { - padding-right: 150px; - } - - .claim-header-copy h1 { - font-size: 24px; - line-height: 1.22; - } - - .claim-header-copy p { - font-size: 14px; - line-height: 1.4; - } - - .claim-step-indicator { - top: 16px; - right: 16px; - max-width: 140px; - } - - .claim-step-dots { - gap: 5px; - } - - .claim-step-dot { - width: 26px; - height: 26px; - font-size: 13px; - } - - .claim-step-progress-text { - font-size: 12px; - } - - .claim-info-grid { - grid-template-columns: 1fr; - } - - .claim-qr-block { - padding: 12px; - } - - .claim-qr-guide-panel { - grid-template-columns: 34px minmax(0, 1fr) 34px; - gap: 8px; - max-width: 100%; - } - - .claim-scan-label { - min-height: 128px; - padding: 8px 4px; - font-size: 14px; - } - - .claim-qr-code { - max-width: 232px; - padding: 8px; - } - - .claim-save-hint { - font-size: 13px; - } - - .claim-role-panel-item { - grid-template-columns: 76px minmax(0, 1fr); - gap: 10px; - } - - .claim-role-panel-item span { - font-size: 12px; - } - - .claim-role-panel-item strong { - font-size: 16px; - } - - .claim-action-row { - display: flex; - flex-direction: column; - align-items: stretch; - } - - .claim-action-row .ant-space-item, - .claim-action-row .ant-btn, - .claim-action-tooltip-wrap { - width: 100%; - } - - .claim-meta-footer { - justify-content: flex-start; - } - - .claim-result-header { - display: grid; - } -} - -@media (max-width: 480px) { - .claim-page { - padding: 12px; - gap: 10px; - } - - .claim-header-card .ant-card-body, - .claim-content-card .ant-card-body { - gap: 12px; - } - - .claim-header-copy { - padding-right: 112px; - } - - .claim-header-copy h1 { - font-size: 22px; - } - - .claim-step-indicator { - position: absolute; - top: 16px; - right: 16px; - max-width: 100px; - align-items: flex-end; - } - - .claim-step-dot { - width: 26px; - height: 26px; - font-size: 12px; - } - - .claim-step-dots { - gap: 5px; - } - - .claim-step-progress-text { - text-align: right; - font-size: 12px; - } - - .claim-uid-step-title.ant-typography { - font-size: 18px !important; - } - - .claim-uid-guide-image { - max-height: 140px; - } -} - -@media (max-width: 420px) { - .claim-header-copy { - padding-right: 124px; - } - - .claim-header-copy h1 { - font-size: 22px; - } - - .claim-header-copy p { - padding-right: 0; - } - - .claim-step-indicator { - max-width: 116px; - } -} - -.customer-auth-page { - --auth-accent: #2f6fed; - --auth-accent-hover: #4a83ff; - --auth-panel: #232936; - --auth-panel-soft: #2a3140; - --auth-line: rgba(255, 255, 255, 0.08); - --auth-text: #f5f7fa; - --auth-muted: #9aa3b2; - min-height: 100vh; - display: flex; - justify-content: center; - overflow-x: hidden; - padding: 0; - color: var(--auth-text); - background: #232936; -} - -.customer-auth-shell { - width: min(560px, 100%); - min-width: 0; - align-self: stretch; - overflow: hidden; - border: none; - border-radius: 0; - background: transparent; - box-shadow: none; -} - -.customer-auth-hero { - position: relative; - min-height: clamp(112px, 15vw, 136px); - display: flex; - align-items: flex-end; - justify-content: flex-start; - padding: 12px 20px 14px; - overflow: hidden; - text-align: left; - background-color: #0b1220; - background-image: - linear-gradient(180deg, rgba(11, 18, 32, 0.06) 0%, rgba(11, 18, 32, 0.62) 72%, #232936 100%), - url('/images/customer/inside-kv.jpg'); - background-repeat: no-repeat; - background-position: center 38%; - background-size: cover; -} - -/* 微博与虎牙客户页统一使用同一套顶部 KV,不再单独覆盖背景。 */ -.customer-auth-page.is-weibo .customer-auth-brand { - width: 100%; - justify-content: flex-start; -} - -.customer-auth-page.is-weibo .customer-auth-brand h1 { - text-align: left; - text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72); -} - -@media (max-width: 640px) { - .customer-auth-hero { - min-height: 112px; - padding: 12px 16px 14px; - background-position: center 42%; - } -} - -.customer-auth-brand { - width: 100%; - display: flex; - align-items: center; - justify-content: flex-start; - gap: 0; - min-width: 0; -} - -.customer-auth-logo { - width: 62px; - height: 62px; - flex: none; - display: grid; - place-items: center; - border: 1px solid rgba(255, 255, 255, 0.22); - border-radius: 8px; - color: var(--auth-accent); - font-size: 34px; - background: rgba(3, 12, 34, 0.58); - box-shadow: inset 0 0 24px rgba(255, 138, 0, 0.06); -} - -.customer-auth-brand h1 { - margin: 0; - color: #fff; - font-size: 20px; - line-height: 1.4; - font-weight: 700; - letter-spacing: 0; - text-align: left; - text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72); - white-space: normal; - overflow-wrap: anywhere; -} - -.customer-auth-warning { - padding: 6px 16px 10px; - color: #ff6975; - text-align: center; - font-size: 14px; - font-weight: 600; - background: transparent; - border-bottom: none; -} - -.customer-auth-main { - min-width: 0; - padding-bottom: 24px; - color: var(--auth-text); - background: transparent; -} - -.customer-auth-content-stack { - min-width: 0; - display: flex; - flex-direction: column; -} - -.customer-auth-task-switcher { - display: flex; - align-items: flex-start; - gap: 16px; - padding: 20px 24px; - border-bottom: 1px solid var(--auth-line); -} - -.customer-auth-task-switcher > span { - flex: none; - padding-top: 5px; - color: var(--auth-muted); - font-size: 13px; -} - -.customer-auth-task-switcher > div { - display: flex; - flex-wrap: wrap; - gap: 8px; -} - -.customer-auth-task-switcher .ant-btn { - height: auto; - padding: 6px 10px; - color: #dce6f8; - white-space: normal; - text-align: left; - border-color: rgba(255, 255, 255, 0.16); - background: rgba(255, 255, 255, 0.04); -} - -.customer-auth-task-switcher .ant-btn-primary { - color: #111827; - border-color: var(--auth-accent); -} - -.customer-auth-facts { - min-width: 0; - padding: 0 26px; -} - -.customer-auth-facts > div { - display: grid; - grid-template-columns: 132px minmax(0, 1fr); - align-items: center; - gap: 18px; - min-height: 74px; - padding: 16px 4px; - border-bottom: 1px solid var(--auth-line); -} - -.customer-auth-facts > div > span { - color: #c0c8d8; - font-size: 16px; -} - -.customer-auth-facts > div > strong { - min-width: 0; - justify-self: end; - color: #f8fafc; - font-size: 18px; - line-height: 1.5; - font-weight: 600; - text-align: right; - word-break: break-all; - overflow-wrap: anywhere; -} - -.customer-auth-section { - min-width: 0; - padding: 16px; - border-bottom: none; -} - -.customer-auth-section-heading { - display: flex; - align-items: flex-start; - gap: 14px; -} - -.customer-auth-section-icon { - width: 36px; - height: 36px; - flex: none; - display: grid; - place-items: center; - border: 1px solid rgba(255, 255, 255, 0.15); - border-radius: 8px; - color: var(--auth-accent); - font-size: 18px; - background: rgba(255, 255, 255, 0.035); -} - -.customer-auth-section-heading h2, -.customer-auth-state h2 { - margin: 0 0 6px; - color: #fff; - font-size: 18px; - line-height: 1.4; - font-weight: 700; -} - -.customer-auth-section-heading p, -.customer-auth-state p, -.customer-auth-form-copy { - margin: 0; - color: var(--auth-muted); - font-size: 15px; - line-height: 1.75; -} - -.customer-auth-section-copy h2 { - margin: 0 0 8px; - color: #fff; - font-size: 23px; - line-height: 1.35; - font-weight: 700; -} - -.customer-auth-section-copy p { - margin: 0; - color: var(--auth-muted); - font-size: 15px; - line-height: 1.75; -} - -.customer-auth-tabs { - margin-top: 22px; -} - -.customer-auth-tabs .ant-tabs-nav { - margin-bottom: 18px; -} - -.customer-auth-tabs .ant-tabs-nav::before { - display: none; -} - -.customer-auth-tabs .ant-tabs-nav-list { - width: 100%; - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 5px; - padding: 5px; - border: 1px solid rgba(148, 163, 184, 0.18); - border-radius: 11px; - background: rgba(4, 15, 37, 0.72); -} - -.customer-auth-tabs .ant-tabs-tab { - justify-content: center; - margin: 0 !important; - padding: 11px 18px; - color: var(--auth-muted); - background: transparent; - border: 0 !important; - border-radius: 7px; -} - -.customer-auth-tabs .ant-tabs-tab.ant-tabs-tab-active { - background: var(--auth-accent); -} - -.customer-auth-tabs .ant-tabs-tab-btn { - color: inherit !important; - font-size: 16px; -} - -.customer-auth-tabs .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn { - color: #111827 !important; - font-weight: 700; -} - -.customer-auth-tabs .ant-tabs-ink-bar { - display: none; -} - -.customer-auth-form { - display: flex; - flex-direction: column; - gap: 14px; - padding-top: 18px; -} - -.customer-auth-field { - display: grid; - align-items: center; - min-height: 50px; - overflow: hidden; - border: 1px solid rgba(148, 163, 184, 0.24); - border-radius: 10px; - background: rgba(13, 29, 61, 0.72); - transition: - border-color 0.2s ease, - box-shadow 0.2s ease; -} - -.customer-auth-field:focus-within { - border-color: var(--auth-accent); - box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.12); -} - -.customer-auth-field > * { - min-width: 0; -} - -.customer-auth-phone-field { - grid-template-columns: 58px minmax(0, 1fr) 112px; - padding: 4px; -} - -.customer-auth-code-field { - grid-template-columns: minmax(0, 1fr) 122px; - gap: 5px; - padding: 5px; -} - -.customer-auth-field .ant-select-selector, -.customer-auth-field .ant-input, -.customer-auth-field .ant-input-affix-wrapper { - color: #f8fafc !important; - border: 0 !important; - border-radius: 0 !important; - background: transparent !important; - box-shadow: none !important; -} - -.customer-auth-field .ant-select-selector { - height: 48px !important; - padding-inline: 14px !important; - align-items: center; -} - -.customer-auth-field .ant-select { - height: 48px; - background: transparent !important; -} - -.customer-auth-field .ant-select-selection-item { - color: #f8fafc !important; - line-height: 46px !important; -} - -.customer-auth-field .ant-select-arrow { - color: #c4cede !important; -} - -.customer-auth-country-prefix { - display: grid; - place-items: center; - align-self: stretch; - color: #f8fafc; - font-size: 14px; - font-weight: 600; - border-right: 1px solid var(--auth-line); -} - -.customer-auth-field .ant-input-affix-wrapper { - height: 48px; - padding-inline: 15px; -} - -.customer-auth-field .ant-input { - height: 48px; - padding-inline: 10px; - font-size: 15px; -} - -.customer-auth-field .ant-input-affix-wrapper .ant-input { - padding-inline: 0; -} - -.customer-auth-field .ant-input::placeholder { - color: #7f8ca5; -} - -.customer-auth-field .ant-input-prefix { - margin-inline-end: 9px; - color: var(--auth-accent); -} - -.customer-auth-send-code { - height: 40px !important; - padding-inline: 10px !important; - color: #111827; - border: 0 !important; - border-radius: 7px !important; - background: var(--auth-accent) !important; - font-size: 14px !important; - font-weight: 700; -} - -.customer-auth-send-code:hover { - background: var(--auth-accent-hover) !important; -} - -.customer-auth-code-submit { - height: 40px !important; - color: #111827; - border: 0 !important; - border-radius: 7px !important; - background: var(--auth-accent) !important; - font-weight: 700; -} - -.customer-auth-code-submit:hover { - background: var(--auth-accent-hover) !important; -} - -.customer-auth-note { - padding: 11px 14px; - color: #fbbf24; - font-size: 13px; - line-height: 1.6; - border: 1px solid rgba(251, 191, 36, 0.48); - border-radius: 4px; - background: rgba(251, 191, 36, 0.06); -} - -.customer-auth-form-hint { - color: #7f8ca5; - font-size: 12px; -} - -.customer-auth-page .ant-btn-primary { - color: #fff; - border-color: var(--auth-accent); - background: var(--auth-accent); - font-weight: 700; - box-shadow: none; -} - -.customer-auth-page .ant-btn-primary:hover { - color: #fff !important; - border-color: var(--auth-accent-hover) !important; - background: var(--auth-accent-hover) !important; -} - -.customer-auth-page .customer-auth-secondary-button { - color: #fff; - border-color: rgba(148, 163, 184, 0.42); - background: rgba(19, 39, 77, 0.52); -} - -.customer-auth-page .customer-auth-secondary-button:hover { - color: #fff !important; - border-color: rgba(196, 210, 236, 0.72) !important; - background: rgba(31, 55, 102, 0.72) !important; -} - -.huya-slider-challenge { - display: flex; - flex-direction: column; - gap: 14px; -} - -.huya-slider-challenge > p { - display: flex; - flex-wrap: wrap; - justify-content: space-between; - gap: 6px 12px; - margin: 0; - color: #475569; - font-size: 14px; - line-height: 1.65; -} - -.huya-challenge-progress { - color: #c2410c; - font-size: 12px; - font-weight: 700; -} - -.huya-click-tip { - display: block; - max-width: 100%; - max-height: 64px; - object-fit: contain; -} - -.huya-slider-stage { - position: relative; - width: 100%; - overflow: hidden; - border: 1px solid rgba(148, 163, 184, 0.36); - border-radius: 8px; - background: #e2e8f0; - user-select: none; -} - -.huya-slider-stage.is-click { - cursor: crosshair; -} - -.huya-slider-background, -.huya-slider-puzzle { - pointer-events: none; - user-select: none; -} - -.huya-slider-puzzle.is-rotate { - transform-origin: center; -} - -.huya-click-point { - position: absolute; - display: grid; - width: 24px; - height: 24px; - place-items: center; - color: #fff; - font-size: 12px; - font-weight: 700; - border: 2px solid #fff; - border-radius: 50%; - background: #ea580c; - box-shadow: 0 2px 8px rgba(15, 23, 42, 0.32); - transform: translate(-50%, -50%); - pointer-events: none; -} - -.huya-slider-background { - display: block; - width: 100%; - height: 100%; -} - -.huya-slider-puzzle { - position: absolute; - max-width: none; - height: auto; -} - -.huya-slider-track { - position: relative; - height: 46px; - overflow: hidden; - border: 1px solid rgba(148, 163, 184, 0.36); - border-radius: 8px; - background: #f1f5f9; - touch-action: none; -} - -.huya-slider-track-fill { - position: absolute; - inset: 0 auto 0 0; - max-width: 100%; - background: rgba(249, 115, 22, 0.16); -} - -.huya-slider-handle { - position: absolute; - top: 3px; - left: 3px; - width: 58px; - height: 38px; - padding: 0; - color: #111827; - font-size: 13px; - font-weight: 700; - border: 0; - border-radius: 6px; - background: #f97316; - cursor: grab; - touch-action: none; -} - -.huya-slider-handle:active { - cursor: grabbing; -} - -.huya-rotate-control { - display: grid; - grid-template-columns: minmax(0, 1fr) 48px; - gap: 12px; - align-items: center; -} - -.huya-rotate-control > span { - color: #475569; - font-size: 13px; - font-variant-numeric: tabular-nums; - text-align: right; -} - -.customer-auth-qr { - display: flex; - flex-direction: column; - align-items: center; - gap: 13px; - padding-top: 22px; - text-align: center; -} - -.customer-auth-qr > p { - margin: 0; - color: var(--auth-muted); - line-height: 1.7; -} - -.customer-auth-qr-image, -.customer-auth-qr-placeholder { - display: grid; - place-items: center; - width: 252px; - min-height: 252px; - padding: 10px; - border-radius: 6px; - background: #fff; -} - -.customer-auth-qr-placeholder { - color: #64748b; - font-size: 13px; - background: rgba(255, 255, 255, 0.94); -} - -.customer-auth-role-card { - width: min(100%, 580px); - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - gap: 4px 18px; - padding: 15px 18px; - text-align: left; - border: 1px solid rgba(255, 138, 0, 0.42); - border-radius: 5px; - background: rgba(255, 138, 0, 0.06); -} - -.customer-auth-role-card span { - color: var(--auth-muted); - font-size: 13px; -} - -.customer-auth-role-card strong { - justify-self: end; - color: #fff; - font-size: 17px; -} - -.customer-auth-role-card small { - grid-column: 1 / -1; - color: var(--auth-muted); - font-size: 12px; -} - -.customer-auth-binding { - display: flex; - flex-direction: column; - gap: 16px; -} - -.customer-auth-binding-tip { - color: #ffb454; - font-size: 13px; -} - -.customer-auth-profile { - padding: 16px; - border: 1px solid #3a4150; - border-radius: 12px; - background: #212733; -} - -.customer-auth-profile-summary { - padding: 14px; - border: 1px solid rgba(255, 255, 255, 0.14); - border-radius: 6px; - background: rgba(255, 255, 255, 0.04); -} - -.customer-auth-profile > p { - margin: 0 0 12px; - color: #9aa3b2; - font-size: 13px; - line-height: 1.6; -} - -.customer-profile-form { - display: flex; - flex-direction: column; - gap: 12px; -} - -.customer-profile-form .customer-collect-label { - margin-top: 2px; -} - -.customer-auth-profile-summary { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: 10px; -} - -.customer-auth-profile-summary span { - color: var(--auth-muted); - font-size: 13px; -} - -.customer-auth-profile-summary strong { - color: #fff; - font-size: 15px; -} - -.customer-auth-profile-summary em { - color: var(--auth-muted); - font-style: normal; - font-size: 13px; -} - -/* 客户资料页(图 1) */ -.customer-collect-page { - min-height: 100vh; - background: #0b1220; - color: #e5e7eb; -} - -/* 资料页顶部 KV:原图 https://game.gtimg.cn/images/gp/web201908/inside_kv.jpg(本地 1600×510 q82) */ -.customer-collect-hero { - position: relative; - min-height: clamp(132px, 18vw, 160px); - display: flex; - align-items: flex-end; - justify-content: center; - padding: 0 18px 12px; - overflow: hidden; - text-align: center; - background-color: #0b1220; - background-image: - linear-gradient(180deg, rgba(11, 18, 32, 0) 38%, rgba(11, 18, 32, 0.55) 72%, #0b1220 100%), - url('/images/customer/inside-kv.jpg'); - background-repeat: no-repeat; - background-position: center 40%; - background-size: cover; -} - -.customer-collect-warning { - margin: 0; - text-align: center; - color: #f87171; - font-size: 17px; - font-weight: 600; - text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); -} - -@media (max-width: 640px) { - .customer-collect-hero { - min-height: 132px; - padding: 0 16px 12px; - background-position: center 42%; - } - - .customer-collect-warning { - font-size: 15px; - } -} - -.customer-collect-body { - max-width: 560px; - margin: 0 auto; - padding: 24px 20px 48px; - display: flex; - flex-direction: column; - gap: 12px; -} - -.customer-collect-label { - margin-top: 8px; - color: #e5e7eb; - font-size: 15px; - line-height: 1.4; -} - -.customer-collect-label span { - color: #f87171; -} - -.customer-collect-readonly { - height: 48px; - display: flex; - align-items: center; - padding: 0 16px; - border-radius: 12px; - background: #1b2436; - border: 1px solid #26344d; - color: #94a3b8; - font-size: 15px; -} - -.customer-collect-card { - margin: 10px 0; - padding: 16px; - border-radius: 12px; - border: 1px solid #1e2f4a; - background: #141d30; - display: flex; - flex-direction: column; - gap: 12px; -} - -.customer-collect-card > div { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 12px; - color: #cbd5e1; - font-size: 15px; - line-height: 1.5; -} - -.customer-collect-card > div > span { - flex: 0 0 auto; - white-space: nowrap; -} - -.customer-collect-card > div strong { - flex: 1 1 auto; - min-width: 0; - color: #fff; - font-weight: 600; - text-align: right; - overflow-wrap: anywhere; -} - -.customer-collect-card > p { - margin: 6px 0 0; - color: #fbbf24; - font-size: 13px; - text-align: center; -} - -.customer-collect-input.ant-input { - height: 48px; - border-radius: 12px; - background: #1b2436; - border-color: #26344d; - color: #fff; -} - -.customer-collect-input.ant-input::placeholder { - color: #64748b; -} - -.customer-collect-select.ant-select { - width: 100%; - height: 48px; - padding-inline: 16px; - align-items: center; - font-size: 15px; - border-radius: 12px; - border: 1px solid #26344d; - background: #1b2436; - color: #fff; - --ant-select-height: 48px; - --ant-select-border-radius: 12px; - --ant-select-border-color: #26344d; - --ant-select-background-color: #1b2436; - --ant-select-color: #fff; - --ant-select-hover-border-color: #3b4d6b; - --ant-select-active-border-color: #2563eb; - --ant-select-active-outline-color: rgba(37, 99, 235, 0.2); -} - -.customer-collect-select.ant-select:hover { - border-color: #3b4d6b; -} - -.customer-collect-select.ant-select.ant-select-focused { - border-color: #2563eb; - box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); -} - -.customer-collect-select .ant-select-content { - align-items: center; -} - -.customer-collect-select .ant-select-selection-item { - color: #fff; - line-height: 1.5; -} - -.customer-collect-select .ant-select-placeholder { - color: #64748b; -} - -.customer-collect-select .ant-select-suffix { - color: #94a3b8; -} - -.ant-select-dropdown.customer-collect-dropdown { - padding: 6px; - border-radius: 12px; - background: #141d30; - box-shadow: 0 14px 34px rgba(2, 6, 23, 0.55); - --ant-select-option-active-bg: #1b2436; - --ant-select-option-selected-bg: #1e3a8a; - --ant-select-option-selected-color: #fff; -} - -.customer-collect-dropdown .ant-select-item { - border-radius: 8px; - color: #cbd5e1; -} - -.customer-collect-dropdown .ant-select-item-option-active { - background: #1b2436 !important; - color: #fff; -} - -.customer-collect-dropdown .ant-select-item-option-selected { - background: #1e3a8a !important; - color: #fff; - font-weight: 600; -} - -.customer-collect-page .customer-collect-submit.ant-btn, -.customer-auth-profile .customer-collect-submit.ant-btn { - height: 52px; - margin-top: 14px; - border-radius: 14px; - font-size: 17px; - font-weight: 600; - --ant-btn-bg-color: #2563eb; - --ant-btn-bg-color-hover: #1d4ed8; - --ant-btn-bg-color-active: #1e40af; - --ant-btn-text-color: #fff; - --ant-btn-text-color-hover: #fff; - --ant-btn-text-color-active: #fff; - --ant-btn-border-color: #2563eb; - --ant-btn-border-color-hover: #1d4ed8; - --ant-btn-border-color-active: #1e40af; - background: #2563eb !important; - border-color: #2563eb !important; - color: #fff !important; -} - -.customer-collect-page .customer-collect-submit.ant-btn:hover, -.customer-collect-page .customer-collect-submit.ant-btn:focus-visible, -.customer-auth-profile .customer-collect-submit.ant-btn:hover, -.customer-auth-profile .customer-collect-submit.ant-btn:focus-visible { - background: #1d4ed8 !important; - border-color: #1d4ed8 !important; - color: #fff !important; -} - -/* 登录与绑定页(图 2-10) */ -.customer-login-form { - display: flex; - flex-direction: column; - gap: 12px; -} - -.customer-login-hint { - margin: 0 0 2px; - color: #d5dae3; - font-size: 16px; - line-height: 1.5; -} - -.customer-login-mobile-row { - display: flex; - align-items: stretch; - gap: 12px; -} - -.customer-login-mobile.ant-input { - flex: 1; - min-width: 0; - height: 48px; - padding: 0 16px; - border-radius: 8px; - border-color: #3a4150; - background: #1b2130; - color: #fff; - font-size: 15px; -} - -.customer-login-mobile.ant-input::placeholder { - color: #6b7482; -} - -.customer-login-code-button.ant-btn { - flex: none; - width: 118px; - height: 48px; - border-radius: 8px; - background: #3b82f6 !important; - border-color: #3b82f6 !important; - color: #fff !important; - font-size: 16px; -} - -.customer-login-code-input.ant-input { - height: 48px; - border-radius: 8px; - border-color: #3a4150; - background: #1b2130; - color: #fff; - text-align: center; - font-size: 15px; - letter-spacing: 6px; -} - -.customer-login-code-input.ant-input::placeholder { - color: #6b7482; -} - -.customer-login-submit.ant-btn { - height: 52px; - border-radius: 14px; - background: #2563eb !important; - border-color: #2563eb !important; - color: #fff !important; - font-size: 17px; - font-weight: 600; -} - -.customer-login-submit.ant-btn:hover, -.customer-login-submit.ant-btn:focus-visible { - background: #1d4ed8 !important; - border-color: #1d4ed8 !important; - color: #fff !important; -} - -.customer-login-alt.ant-btn { - height: 48px; - border-radius: 8px; - background: transparent !important; - border-color: #3a4150 !important; - color: #cbd5e1 !important; - font-size: 16px; -} - -.customer-huya-steps { - display: flex; - gap: 8px; - margin: 12px 16px 0; - padding: 12px 14px; - list-style: none; - border: 1px solid #3a4150; - border-radius: 12px; - background: #1b212c; -} - -.customer-huya-step { - display: flex; - flex: 1 1 0; - align-items: center; - gap: 7px; - min-width: 0; - color: #64748b; - font-size: 13px; - line-height: 1.3; -} - -.customer-huya-step-index { - display: inline-flex; - flex: 0 0 auto; - align-items: center; - justify-content: center; - width: 22px; - height: 22px; - border: 1px solid #3a4150; - border-radius: 50%; - color: #94a3b8; - font-size: 12px; - font-weight: 600; - background: #212733; -} - -.customer-huya-step-label { - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.customer-huya-step.is-active { - color: #f8fafc; - font-weight: 600; -} - -.customer-huya-step.is-active .customer-huya-step-index { - color: #fff; - border-color: #2563eb; - background: #2563eb; - box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); -} - -.customer-huya-step.is-done { - color: #6ee7b7; -} - -.customer-huya-step.is-done .customer-huya-step-index { - color: #6ee7b7; - border-color: #065f46; - background: rgba(6, 78, 59, 0.4); -} - -.customer-order-card { - margin: 10px 16px 0; - padding: 16px; - border: 1px solid #3a4150; - border-radius: 12px; - background: #212733; - display: flex; - flex-direction: column; - gap: 10px; -} - -.customer-order-card h3 { - margin: 0 0 4px; - color: #94a3b8; - font-size: 13px; - font-weight: 500; -} - -.customer-order-card > div { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 12px; - color: #cbd5e1; - font-size: 14px; - line-height: 1.5; -} - -.customer-order-card > div > span { - flex: 0 0 auto; - white-space: nowrap; - color: #9aa3b2; -} - -.customer-order-card > div strong { - flex: 1 1 auto; - min-width: 0; - color: #fff; - text-align: right; - overflow-wrap: anywhere; -} - -.customer-order-card > div strong.customer-order-status { - flex: 0 0 auto; - padding: 3px 12px; - border: 1px solid rgba(96, 165, 250, 0.38); - border-radius: 999px; - color: #dbeafe; - font-size: 13px; - font-weight: 600; - text-align: center; - background: rgba(47, 111, 237, 0.28); -} - -.customer-binding-stage { - display: flex; - flex-direction: column; - gap: 14px; - padding: 16px; -} - -.customer-binding-session-card { - display: flex; - flex-direction: column; - gap: 10px; - padding: 18px; - border: 1px solid #78350f; - border-radius: 12px; - background: rgba(120, 53, 15, 0.22); -} - -.customer-binding-session-title { - margin: 0; - color: #fbbf24; - font-size: 16px; - font-weight: 700; -} - -.customer-binding-session-desc { - margin: 0 0 4px; - color: #fcd34d; - font-size: 13px; - line-height: 1.6; -} - -.customer-binding-qr-error { - display: flex; - flex-direction: column; - align-items: center; - gap: 10px; - padding: 24px 12px; - text-align: center; -} - -.customer-binding-qr-error p { - margin: 0; - color: #fca5a5; - font-size: 15px; - font-weight: 600; -} - -.customer-binding-qr-error span { - color: #cbd5e1; - font-size: 13px; - line-height: 1.6; - overflow-wrap: anywhere; -} - -/* antd Alert 在绑定阶段统一走深色卡片,避免浅色块破坏整体深色风格 */ -.customer-binding-stage .ant-alert { - align-items: flex-start; - padding: 12px 14px; - border: 1px solid #3a4150; - border-radius: 12px; - background: #212733; -} - -.customer-binding-stage .ant-alert .ant-alert-message { - color: #e2e8f0; - font-size: 14px; - font-weight: 600; -} - -/* antd v6 的标题节点是 .ant-alert-title(v5 为 .ant-alert-message) */ -.customer-binding-stage .ant-alert .ant-alert-title { - color: #e2e8f0; - font-size: 14px; - font-weight: 600; - line-height: 1.5; -} - -.customer-binding-stage .ant-alert .ant-alert-description { - color: #cbd5e1; - font-size: 13px; - line-height: 1.6; -} - -.customer-binding-stage .ant-alert-warning { - border-color: #78350f; - background: rgba(120, 53, 15, 0.22); -} - -.customer-binding-stage .ant-alert-warning .ant-alert-icon, -.customer-binding-stage .ant-alert-warning .ant-alert-message, -.customer-binding-stage .ant-alert-warning .ant-alert-title { - color: #fbbf24; -} - -.customer-binding-stage .ant-alert-warning .ant-alert-description { - color: #fcd34d; -} - -.customer-binding-stage .ant-alert-error { - border-color: #7f1d1d; - background: rgba(127, 29, 29, 0.24); -} - -.customer-binding-stage .ant-alert-error .ant-alert-icon, -.customer-binding-stage .ant-alert-error .ant-alert-message, -.customer-binding-stage .ant-alert-error .ant-alert-title { - color: #fca5a5; -} - -.customer-binding-stage .ant-alert-error .ant-alert-description { - color: #fecaca; -} - -.customer-binding-stage .ant-alert-success { - border-color: #065f46; - background: rgba(6, 78, 59, 0.28); -} - -.customer-binding-stage .ant-alert-success .ant-alert-icon, -.customer-binding-stage .ant-alert-success .ant-alert-message, -.customer-binding-stage .ant-alert-success .ant-alert-title { - color: #6ee7b7; -} - -.customer-binding-stage .ant-alert-success .ant-alert-description { - color: #a7f3d0; -} - -.customer-binding-role-actions { - display: flex; - flex-direction: column; - gap: 12px; - width: 100%; -} - -.customer-binding-role-actions .customer-binding-confirm.ant-btn { - height: 52px; - border-radius: 14px; - background: #2563eb !important; - border-color: #2563eb !important; - color: #fff !important; - font-size: 17px; - font-weight: 600; -} - -.customer-binding-role-actions .customer-binding-confirm.ant-btn:hover, -.customer-binding-role-actions .customer-binding-confirm.ant-btn:focus-visible { - background: #1d4ed8 !important; - border-color: #1d4ed8 !important; - color: #fff !important; -} - -.customer-binding-role-actions .customer-binding-rebind.ant-btn { - height: 48px; - border-radius: 14px; - background: transparent !important; - border-color: #3a4150 !important; - color: #cbd5e1 !important; - font-size: 16px; - font-weight: 500; -} - -.customer-binding-role-actions .customer-binding-rebind.ant-btn .anticon { - color: #f59e0b; -} - -.customer-binding-role-actions .customer-binding-rebind.ant-btn:hover, -.customer-binding-role-actions .customer-binding-rebind.ant-btn:focus-visible { - background: rgba(245, 158, 11, 0.08) !important; - border-color: #b45309 !important; - color: #fbbf24 !important; -} - -.customer-binding-role-actions .customer-binding-accept.ant-btn { - height: 46px; - border-radius: 12px; - background: transparent !important; - border-color: transparent !important; - color: #94a3b8 !important; - font-size: 15px; - font-weight: 500; -} - -.customer-binding-role-actions .customer-binding-accept.ant-btn:hover, -.customer-binding-role-actions .customer-binding-accept.ant-btn:focus-visible { - background: rgba(148, 163, 184, 0.1) !important; - border-color: transparent !important; - color: #e2e8f0 !important; -} - -.customer-binding-info { - padding: 16px; - border: 1px solid #3a4150; - border-radius: 12px; - background: #212733; - display: flex; - flex-direction: column; - gap: 10px; -} - -.customer-binding-info h3 { - margin: 0 0 4px; - color: #9aa3b2; - font-size: 13px; - font-weight: 500; -} - -.customer-binding-info h3 small { - color: #64748b; - font-weight: 400; -} - -.customer-binding-info > div { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 12px; - color: #cbd5e1; - font-size: 14px; - line-height: 1.5; -} - -.customer-binding-info > div > span { - flex: 0 0 auto; - white-space: nowrap; -} - -.customer-binding-info > div strong { - flex: 1 1 auto; - min-width: 0; - color: #fff; - text-align: right; - overflow-wrap: anywhere; -} - -.customer-binding-alert { - padding: 12px 14px; - border-radius: 8px; - border: 1px solid transparent; - font-size: 14px; -} - -.customer-binding-alert.is-warning { - color: #fbbf24; - border-color: #78350f; - background: rgba(120, 53, 15, 0.25); -} - -.customer-binding-alert.is-info { - color: #93c5fd; - border-color: #1e3a8a; - background: rgba(30, 58, 138, 0.3); -} - -.customer-binding-verify { - padding: 18px; - border: 1px solid #3a4150; - border-radius: 12px; - background: transparent; - display: flex; - flex-direction: column; - gap: 16px; - text-align: center; -} - -.customer-binding-verify p { - margin: 0; - color: #e5e7eb; - font-size: 16px; - line-height: 1.6; -} - -.customer-binding-qr-card { - padding: 18px; - border-radius: 12px; - background: #fff; - color: #111827; - display: flex; - flex-direction: column; - align-items: center; - gap: 10px; -} - -.customer-binding-qr-card h3 { - margin: 0; - color: #6b7280; - font-size: 14px; - font-weight: 500; -} - -.customer-binding-qr-hint { - margin: 0; - color: #6b7280; - font-size: 13px; -} - -.customer-binding-qr-tip { - margin: 0; - color: #f59e0b; - font-size: 13px; -} - -.customer-binding-qr-countdown { - margin: 0; - color: #6b7280; - font-size: 13px; -} - -.customer-binding-qr-actions { - width: 100%; - margin-top: 4px; - display: grid; - grid-template-columns: 1fr 1fr; - gap: 10px; -} - -.customer-binding-qr-actions .ant-btn { - height: 40px; - border-radius: 8px; -} - -.customer-binding-next.ant-btn { - width: 100%; - height: 52px; - margin-top: 6px; - border-radius: 14px; - background: #2563eb !important; - border-color: #2563eb !important; - color: #fff !important; - font-size: 17px; - font-weight: 600; -} - -.customer-binding-modal-footer { - display: flex; - flex-direction: column; - gap: 10px; -} - -.customer-binding-modal-actions { - display: grid; - grid-template-columns: 1fr 1fr; - gap: 12px; -} - -.customer-binding-modal-actions .ant-btn { - height: 42px; - border-radius: 8px; -} - -.customer-binding-modal-actions.is-mismatch { - grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); -} - -.customer-binding-modal-error { - margin: 0; - color: #dc2626; - font-size: 13px; - text-align: center; -} - -.customer-binding-modal-warning { - margin: 0; - color: #d97706; - font-size: 13px; - text-align: center; -} - -.customer-binding-compare { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 12px; -} - -.customer-binding-compare-side { - display: flex; - flex-direction: column; - gap: 6px; - padding: 14px; - border: 1px solid rgba(15, 23, 42, 0.12); - border-radius: 6px; - background: rgba(15, 23, 42, 0.04); -} - -.customer-binding-compare-head { - display: flex; - align-items: center; - justify-content: space-between; - gap: 8px; - color: #64748b; - font-size: 13px; -} - -.customer-binding-compare-side strong { - color: #0f172a; - font-size: 16px; - word-break: break-all; -} - -.customer-binding-compare-side em { - color: #64748b; - font-style: normal; - font-size: 13px; -} - -@media (max-width: 480px) { - .customer-binding-compare { - grid-template-columns: minmax(0, 1fr); - } -} - -.customer-auth-button-stack { - width: min(100%, 580px); - display: flex; - flex-direction: column; - gap: 12px; -} - -.customer-auth-button-stack .ant-btn, -.customer-auth-form > .ant-btn { - height: 52px; - font-size: 17px; -} - -.customer-auth-status-pill { - display: inline-flex; - align-items: center; - justify-content: center; - min-height: 34px; - padding: 4px 15px; - color: #fff; - font-size: 15px !important; - font-weight: 600 !important; - text-align: center; - border-radius: 999px; - background: #3169aa; -} - -.customer-auth-status-pill.is-pending, -.customer-auth-status-pill.is-scanned { - background: #3a6fa8; -} - -.customer-auth-status-pill.is-success { - background: #237a57; -} - -.customer-auth-status-pill.is-danger { - background: #a33a48; -} - -.customer-auth-state { - display: flex; - flex-direction: column; - align-items: center; - gap: 12px; - padding: 48px 26px; - text-align: center; -} - -.customer-auth-state h2 { - margin: 0; -} - -.customer-auth-state p { - max-width: 560px; -} - -.customer-auth-state-icon { - width: 58px; - height: 58px; - display: grid; - place-items: center; - color: var(--auth-accent); - font-size: 29px; - border: 1px solid rgba(255, 255, 255, 0.16); - border-radius: 50%; - background: rgba(255, 255, 255, 0.045); -} - -.customer-auth-state.is-success .customer-auth-state-icon { - color: #52d39a; -} - -.customer-auth-state.is-error .customer-auth-state-icon { - color: #ff6975; -} - -.customer-auth-state-time { - color: var(--auth-muted); - font-size: 12px; -} - -.customer-auth-loading { - min-height: 240px; - display: grid; - place-items: center; - align-content: center; - gap: 14px; - color: var(--auth-muted); -} - -.customer-auth-privacy { - margin: 24px 26px 28px; - padding: 14px 18px; - color: #d8b46a; - font-size: 14px; - line-height: 1.65; - text-align: center; - border: 1px solid rgba(216, 180, 106, 0.64); - border-radius: 5px; - background: rgba(0, 0, 0, 0.08); -} - -.customer-auth-page .ant-spin-dot-item { - background: var(--auth-accent); -} - -@media (max-width: 640px) { - .customer-auth-page { - height: auto; - min-height: 100vh; - overflow: visible; - padding: 0; - background: var(--auth-panel); - } - - .customer-auth-shell { - width: 100%; - height: auto; - display: block; - border: 0; - border-radius: 0; - box-shadow: none; - } - - .customer-auth-hero { - min-height: 112px; - padding: 12px 16px 14px; - background-position: center 42%; - } - - .customer-auth-brand h1 { - font-size: 20px; - } - - .customer-auth-warning { - padding: 6px 16px 10px; - font-size: 14px; - } - - .customer-auth-main { - overflow: visible; - } - - .customer-auth-content-stack { - height: auto; - min-height: 0; - } - - .customer-huya-steps { - gap: 6px; - margin: 10px 16px 0; - padding: 10px 12px; - } - - .customer-huya-step { - gap: 5px; - font-size: 11px; - } - - .customer-huya-step-index { - width: 19px; - height: 19px; - font-size: 10px; - } - - .customer-auth-facts { - padding-inline: 20px; - } - - .customer-auth-facts > div { - grid-template-columns: 92px minmax(0, 1fr); - gap: 12px; - min-height: 52px; - padding-block: 8px; - } - - .customer-auth-facts > div > span { - font-size: 13px; - } - - .customer-auth-facts > div > strong { - font-size: 15px; - line-height: 1.35; - } - - .customer-auth-section { - padding: 16px; - } - - .customer-auth-section-copy h2, - .customer-auth-state h2 { - font-size: 20px; - } - - .customer-auth-section-copy p, - .customer-auth-state p, - .customer-auth-form-copy { - font-size: 13px; - line-height: 1.5; - } - - .customer-auth-tabs { - margin-top: 0; - } - - .customer-auth-tabs .ant-tabs-nav { - margin-bottom: 10px; - } - - .customer-auth-tabs .ant-tabs-nav-list { - gap: 4px; - padding: 4px; - } - - .customer-auth-tabs .ant-tabs-tab { - padding: 9px 14px; - } - - .customer-auth-tabs .ant-tabs-tab-btn { - font-size: 15px; - } - - .customer-auth-form { - gap: 10px; - padding-top: 0; - } - - .customer-auth-field { - min-height: 44px; - border-radius: 9px; - } - - .customer-auth-phone-field { - grid-template-columns: 50px minmax(0, 1fr) 104px; - } - - .customer-auth-code-field { - grid-template-columns: minmax(0, 1fr) 104px; - } - - .customer-auth-field .ant-select, - .customer-auth-field .ant-select-selector, - .customer-auth-field .ant-input, - .customer-auth-field .ant-input-affix-wrapper { - height: 44px; - } - - .customer-auth-field .ant-select-selection-item { - line-height: 42px !important; - } - - .customer-auth-field .ant-input-affix-wrapper { - padding-inline: 12px; - } - - .customer-auth-code-field { - padding: 4px; - } - - .customer-auth-code-submit { - height: 36px !important; - } - - .customer-auth-send-code { - height: 36px !important; - } - - .customer-auth-form-hint { - font-size: 10px; - line-height: 1.35; - } - - .customer-auth-qr-image, - .customer-auth-qr-placeholder { - width: 232px; - min-height: 232px; - } - - .customer-auth-privacy { - margin: 8px 16px 12px; - padding: 8px 12px; - font-size: 12px; - line-height: 1.45; - } -} - -/* ========================================================================== - 客户履约页(半自动)固定移动端 + 窄屏自适应 - -------------------------------------------------------------------------- - 全局 base.css 给 body 设了 min-width:320px,worker.css 又用 overflow-x:hidden - 裁掉横向溢出。应用内浏览器 / 分屏 / 系统显示放大时实际视口可能小于 320px, - 页面右侧(输入框、商品值、提示文案)会被直接裁掉。 - 下面只作用于客户履约页(body.customer-mobile-body),不影响后台与打手端。 - ========================================================================== */ - -html.customer-mobile-html, -body.customer-mobile-body { - min-width: 0; - width: 100%; - max-width: 100%; - overflow-x: hidden; -} - -body.customer-mobile-body #root { - width: 100%; - min-width: 0; - max-width: 100%; -} - -body.customer-mobile-body .customer-collect-page, -body.customer-mobile-body .customer-auth-page { - width: 100%; - min-width: 0; - max-width: 100%; - min-height: 100vh; - min-height: 100dvh; - overflow-x: hidden; -} - -body.customer-mobile-body .customer-collect-hero { - width: min(480px, 100%); - margin: 0 auto; -} - -body.customer-mobile-body .customer-collect-body { - width: 100%; - max-width: 480px; - margin: 0 auto; - padding: 20px clamp(12px, 4vw, 20px) calc(40px + env(safe-area-inset-bottom)); - padding-left: max(clamp(12px, 4vw, 20px), env(safe-area-inset-left)); - padding-right: max(clamp(12px, 4vw, 20px), env(safe-area-inset-right)); - gap: 10px; -} - -body.customer-mobile-body .customer-auth-shell { - width: min(480px, 100%); - min-width: 0; -} - -body.customer-mobile-body .customer-auth-main { - padding-bottom: calc(24px + env(safe-area-inset-bottom)); -} - -body.customer-mobile-body .customer-auth-content-stack, -body.customer-mobile-body .customer-auth-section, -body.customer-mobile-body .customer-auth-facts, -body.customer-mobile-body .customer-auth-facts > div, -body.customer-mobile-body .customer-auth-task-switcher, -body.customer-mobile-body .customer-login-form, -body.customer-mobile-body .customer-collect-card, -body.customer-mobile-body .customer-order-card { - min-width: 0; -} - -body.customer-mobile-body .customer-collect-card, -body.customer-mobile-body .customer-collect-readonly, -body.customer-mobile-body .customer-collect-input.ant-input, -body.customer-mobile-body .customer-collect-select.ant-select, -body.customer-mobile-body .customer-login-mobile.ant-input, -body.customer-mobile-body .customer-login-code-input.ant-input, -body.customer-mobile-body .customer-login-submit.ant-btn, -body.customer-mobile-body .customer-login-alt.ant-btn { - width: 100%; - min-width: 0; - max-width: 100%; -} - -/* 订单卡片自带左右 16px 外边距,不能用 width:100% 再加边距 */ -body.customer-mobile-body .customer-order-card { - width: auto; - max-width: 100%; -} - -body.customer-mobile-body .customer-collect-card > div, -body.customer-mobile-body .customer-order-card > div { - flex-wrap: wrap; -} - -body.customer-mobile-body .customer-collect-card > div strong, -body.customer-mobile-body .customer-order-card > div strong { - flex: 1 1 10ch; - min-width: 0; - overflow-wrap: anywhere; - word-break: break-word; -} - -/* 状态胶囊保持自身宽度,不参与长值换行规则 */ -body.customer-mobile-body .customer-order-card > div strong.customer-order-status { - flex: 0 0 auto; - max-width: 100%; - text-align: center; -} - -body.customer-mobile-body .customer-collect-readonly { - overflow-wrap: anywhere; - word-break: break-all; -} - -body.customer-mobile-body .customer-collect-card > p { - overflow-wrap: anywhere; - word-break: break-word; -} - -body.customer-mobile-body .customer-login-form, -body.customer-mobile-body .customer-login-mobile-row, -body.customer-mobile-body .customer-login-code-input.ant-input { - min-width: 0; -} - -body.customer-mobile-body .customer-auth-role-card, -body.customer-mobile-body .customer-auth-button-stack { - width: 100%; -} - -/* 登录/绑定二维码:容器与图片都不超过可用宽度,避免 232/252/260px 固定宽溢出 */ -body.customer-mobile-body .customer-auth-qr-image, -body.customer-mobile-body .customer-auth-qr-placeholder { - width: min(252px, 100%); - min-height: 0; - aspect-ratio: 1; -} - -body.customer-mobile-body .customer-auth-qr-image .ant-image, -body.customer-mobile-body .customer-auth-qr-image img, -body.customer-mobile-body .customer-binding-qr-card .ant-image, -body.customer-mobile-body .customer-binding-qr-card img { - max-width: 100%; - height: auto; -} - -/* 固定宽度弹窗(绑定确认 520 / 虎牙验证 430)在窄屏必须收到视口内 */ -@media (max-width: 640px) { - .customer-binding-modal, - .customer-huya-challenge-modal { - width: calc(100vw - 24px) !important; - max-width: 480px; - margin: 0 auto; - } - - .customer-binding-modal .ant-modal-content, - .customer-huya-challenge-modal .ant-modal-content { - max-height: calc(100vh - 32px); - overflow-y: auto; - } -} - -@media (max-width: 380px) { - body.customer-mobile-body .customer-binding-qr-actions, - body.customer-mobile-body .customer-binding-modal-actions { - grid-template-columns: minmax(0, 1fr); - } -} - -@media (max-width: 340px) { - body.customer-mobile-body .customer-collect-body { - padding-inline: 12px; - } - - /* 标签 + 长值改为上下排列,值不再被挤到屏幕外 */ - body.customer-mobile-body .customer-collect-card > div, - body.customer-mobile-body .customer-order-card > div { - flex-direction: column; - align-items: flex-start; - gap: 4px; - } - - body.customer-mobile-body .customer-collect-card > div strong, - body.customer-mobile-body .customer-order-card > div strong { - flex: 0 1 auto; - max-width: 100%; - justify-self: start; - text-align: left; - } - - body.customer-mobile-body .customer-order-card > div strong.customer-order-status { - flex: 0 0 auto; - text-align: center; - } - - body.customer-mobile-body .customer-collect-card > p { - text-align: left; - } - - body.customer-mobile-body .customer-login-mobile-row { - flex-direction: column; - gap: 10px; - } - - body.customer-mobile-body .customer-login-code-button.ant-btn { - width: 100%; - } - - body.customer-mobile-body .customer-auth-task-switcher { - flex-direction: column; - gap: 8px; - padding: 16px; - } - - body.customer-mobile-body .customer-auth-task-switcher > span { - padding-top: 0; - } - - body.customer-mobile-body .customer-auth-facts { - padding-inline: 12px; - } - - body.customer-mobile-body .customer-auth-facts > div { - grid-template-columns: minmax(0, 1fr); - gap: 4px; - min-height: 0; - padding-block: 12px; - } - - body.customer-mobile-body .customer-auth-facts > div > strong { - justify-self: start; - text-align: left; - } - - body.customer-mobile-body .customer-auth-state { - padding: 32px 16px; - } - - body.customer-mobile-body .customer-auth-privacy { - margin-inline: 16px; - } -} +@import './client/claim.css'; +@import './client/collect.css'; +@import './client/redeem.css'; +@import './client/responsive.css'; diff --git a/apps/frontend/src/styles/client/claim.css b/apps/frontend/src/styles/client/claim.css new file mode 100644 index 00000000..c70912f1 --- /dev/null +++ b/apps/frontend/src/styles/client/claim.css @@ -0,0 +1,462 @@ +/* ========================================================================== + 买家前台:提卡与信息收集页 (Buyer Claim & Collect Pages) + ========================================================================== */ + +.claim-page { + min-height: 100vh; + padding: 24px; + background: linear-gradient(180deg, #f8fafc 0%, #eef4fb 100%); + display: flex; + flex-direction: column; + align-items: center; + gap: 18px; +} + +.claim-header-card, +.claim-content-card { + width: min(680px, 100%); + border-color: rgba(148, 163, 184, 0.18); + box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08); +} + +.claim-header-card { + position: relative; +} + +.claim-header-card .ant-card-body, +.claim-content-card .ant-card-body { + display: flex; + flex-direction: column; + gap: 18px; +} + +.claim-header-copy { + min-width: 0; + padding-right: 220px; +} + +.claim-header-copy h1 { + margin: 0; + color: #0f172a; + font-size: 30px; + line-height: 1.25; + overflow-wrap: anywhere; +} + +.claim-header-copy p, +.claim-muted { + margin: 0; + color: #64748b; + line-height: 1.6; +} + +.claim-step-indicator { + position: absolute; + top: 24px; + right: 24px; + max-width: 210px; + display: flex; + flex-direction: column; + align-items: flex-end; + gap: 7px; +} + +.claim-step-dots { + display: flex; + gap: 8px; +} + +.claim-step-dot { + width: 32px; + height: 32px; + border-radius: 50%; + background: #e5e7eb; + color: #94a3b8; + display: inline-flex; + align-items: center; + justify-content: center; + font-weight: 700; +} + +.claim-step-dot.active { + background: var(--theme-primary); + color: #ffffff; +} + +.claim-step-progress-text { + color: #64748b; + font-size: 13px; + font-weight: 700; + line-height: 1.4; + text-align: right; + overflow-wrap: anywhere; +} + +.claim-content-card .ant-typography { + margin: 0; +} + +.claim-state-card .ant-card-body { + min-height: 240px; + align-items: center; + justify-content: center; + text-align: center; +} + +.claim-large-icon { + font-size: 44px; +} + +.claim-icon-success { + color: #16a34a; +} + +.claim-icon-warning { + color: #d97706; +} + +.claim-icon-info { + color: var(--theme-primary); +} + +.claim-icon-error { + color: #dc2626; +} + +.claim-qr-block { + display: flex; + flex-direction: column; + align-items: center; + gap: 14px; + padding: 14px; + border-radius: 8px; + background: #f8fbff; + border: 1px solid #dbeafe; +} + +.claim-qr-guide-panel { + display: grid; + grid-template-columns: 42px minmax(0, 280px) 42px; + grid-template-areas: + 'left code right' + '. hint .'; + gap: 10px; + align-items: center; + justify-content: center; + width: 100%; + max-width: 410px; + min-width: 0; +} + +.claim-scan-label { + align-self: stretch; + min-height: 150px; + padding: 10px 6px; + color: #e11d48; + font-weight: 900; + font-size: 17px; + line-height: 1.2; + writing-mode: vertical-rl; + text-orientation: upright; + display: flex; + align-items: center; + justify-content: center; +} + +.claim-scan-label-left { + grid-area: left; +} + +.claim-scan-label-right { + grid-area: right; +} + +.claim-qr-code { + grid-area: code; + width: 100%; + max-width: 280px; + aspect-ratio: 1 / 1; + padding: 10px; + background: #ffffff; + border-radius: 8px; + border: 1px solid #dbeafe; +} + +.claim-save-hint { + grid-area: hint; + margin: 0; + justify-self: center; + color: #64748b; + font-size: 14px; + font-weight: 700; + line-height: 1.4; + text-align: center; +} + +.claim-role-panel { + display: grid; + grid-template-columns: 1fr; + gap: 8px; +} + +.claim-role-panel.pending { + opacity: 0.82; +} + +.claim-role-panel-item { + min-width: 0; + display: grid; + grid-template-columns: 88px minmax(0, 1fr); + align-items: center; + gap: 12px; +} + +.claim-role-panel-item span { + color: #64748b; + font-size: 13px; + line-height: 1.4; + white-space: nowrap; +} + +.claim-role-panel-item strong { + min-width: 0; + color: #0f172a; + font-size: 17px; + line-height: 1.45; + overflow-wrap: anywhere; +} + +.claim-action-row { + width: 100%; +} + +.claim-action-tooltip-wrap { + display: inline-flex; +} + +.claim-meta-footer { + display: flex; + flex-wrap: wrap; + gap: 4px 10px; + justify-content: center; + color: #94a3b8; + font-size: 11px; + line-height: 1.5; +} + +.claim-info-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 14px; +} + +.claim-info-grid-compact { + gap: 8px; + margin-bottom: 10px; +} + +.claim-info-grid-compact .claim-info-item { + padding: 8px 10px; + gap: 2px; + border-radius: 6px; +} + +.claim-info-grid-compact .claim-info-item span { + font-size: 11px; + line-height: 1.3; +} + +.claim-info-grid-compact .claim-info-item strong { + font-size: 13px; + line-height: 1.35; + font-weight: 600; +} + +.claim-uid-step .ant-card-body { + gap: 10px; +} + +.claim-uid-step-title.ant-typography { + margin: 0 !important; + font-size: 20px !important; + line-height: 1.3 !important; +} + +.claim-uid-step-desc { + font-size: 13px; + line-height: 1.45; +} + +.claim-uid-guide { + margin: 4px 0 0; + padding: 6px; + border-radius: 8px; + background: #f8fafc; + border: 1px solid #e5e7eb; +} + +.claim-uid-guide-image { + display: block; + width: 100%; + max-width: 360px; + max-height: 160px; + margin: 0 auto; + border-radius: 6px; + border: 1px solid #e2e8f0; + object-fit: contain; + background: #fff; +} + +.claim-uid-guide-caption { + margin: 6px 0 0; + text-align: center; + color: #64748b; + font-size: 12px; + line-height: 1.35; +} + +.claim-uid-warning { + margin: 2px 0 0; + color: #ff4d4f; + font-size: 13px; + font-weight: 600; + line-height: 1.45; +} + +.claim-info-item { + min-width: 0; + padding: 16px; + border-radius: 6px; + background: #f8fafc; + border: 1px solid #e5e7eb; + display: flex; + flex-direction: column; + gap: 6px; +} + +.claim-info-item span { + color: #64748b; + font-size: 13px; +} + +.claim-info-item strong { + color: #0f172a; + font-size: 17px; + overflow-wrap: anywhere; +} + +.claim-result-header { + display: flex; + align-items: flex-start; + gap: 14px; +} + +.claim-feifei-main { + display: grid; + gap: 8px; +} + +.claim-feifei-main p { + margin: 0; + color: var(--theme-primary); + font-weight: 700; +} + +.claim-feifei-label { + color: #64748b; + font-size: 13px; +} + +.claim-product-items { + display: flex; + flex-direction: column; + gap: 10px; +} + +.claim-product-items-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + color: #64748b; + font-size: 13px; +} + +.claim-product-items-header strong { + color: var(--theme-primary); + font-weight: 700; +} + +.claim-product-items-list { + display: flex; + flex-direction: column; + gap: 8px; +} + +.claim-product-item-row { + min-height: 44px; + padding: 10px 12px; + border: 1px solid #e5e7eb; + border-radius: 6px; + background: #f8fafc; + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; +} + +.claim-product-item-row span { + min-width: 0; + color: #0f172a; + font-weight: 700; + line-height: 1.35; + overflow-wrap: anywhere; +} + +.claim-product-item-row strong { + flex: 0 0 auto; + color: #0f172a; + font-size: 15px; +} + +.claim-product-items.compact { + margin-top: 10px; + gap: 8px; +} + +.claim-product-items.compact .claim-product-items-list { + gap: 6px; +} + +.claim-product-items.compact .claim-product-item-row { + min-height: 36px; + padding: 8px 10px; + background: rgba(248, 250, 252, 0.72); +} + +/* 待领取物品图:居中大图;imageUrl 为空或加载失败时是同一尺寸的虚线占位块(不会出现破图) */ + +.claim-product-image-wrap { + display: flex; + justify-content: center; +} + +.claim-product-image { + width: min(160px, 48%); + aspect-ratio: 1 / 1; + border-radius: 16px; + object-fit: contain; + background: #f8fafc; + padding: 8px; + border: 1px solid rgba(148, 163, 184, 0.24); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); +} + +.claim-product-image-fallback { + display: flex; + align-items: center; + justify-content: center; + font-size: 46px; + color: rgba(100, 116, 139, 0.55); + border-style: dashed; +} diff --git a/apps/frontend/src/styles/client/collect.css b/apps/frontend/src/styles/client/collect.css new file mode 100644 index 00000000..c0cbe4e2 --- /dev/null +++ b/apps/frontend/src/styles/client/collect.css @@ -0,0 +1,770 @@ +/* ===== 收集页 (Collect Page) ===== */ + +.collect-page { + min-height: 100vh; + display: grid; + place-items: center; + padding: 32px 16px; + background: #f5f7fb; +} + +.collect-card { + width: min(520px, 100%); +} + +.collect-order-input { + flex: 1; + margin-bottom: 0; +} + +/* ===== 一次性补资料链接页 (Collect Material Link) ===== */ + +.collect-link-page { + min-height: 100vh; + padding: 32px 16px; + background: #f5f7fb; + display: flex; + justify-content: center; + align-items: flex-start; +} + +.collect-link-card { + width: min(720px, 100%); +} + +.collect-link-card .ant-card-body { + padding: 28px; +} + +/* 一单多工单时,内层商品卡片比外层容器更紧凑 */ +.collect-link-order-card .ant-card-body { + padding: 16px; +} + +.collect-link-status-card { + background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%); +} + +.collect-link-status-card .ant-card-body { + padding: 16px; +} + +.collect-link-status-head { + display: flex; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + gap: 8px; + color: #0f172a; + font-size: 15px; +} + +.collect-link-status-head .ant-tag { + margin-inline-end: 0; +} + +.collect-link-order-meta { + display: flex; + flex-wrap: wrap; + gap: 4px 18px; + color: #64748b; + font-size: 13px; +} + +.collect-link-order-meta strong { + color: #0f172a; + font-weight: 600; +} + +.collect-link-description { + margin-top: 6px; + font-size: 12px; +} + +.collect-link-submitted { + display: grid; + gap: 10px; + padding: 12px; + background: #f8fafc; + border: 1px solid #e7edf5; + border-radius: 10px; +} + +.collect-link-submitted-head { + display: flex; + flex-wrap: wrap; + align-items: flex-start; + justify-content: space-between; + gap: 5px 14px; +} + +.collect-link-submitted-head > span { + display: grid; + gap: 1px; +} + +.collect-link-submitted-head .ant-typography:last-child { + font-size: 11px; +} + +.collect-link-submitted-head > .ant-typography { + font-size: 11px; +} + +.collect-link-submitted-fields { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 7px; +} + +.collect-link-submitted-fields > div { + display: grid; + gap: 2px; + min-width: 0; + padding: 8px 10px; + background: #ffffff; + border: 1px solid #edf1f6; + border-radius: 8px; +} + +.collect-link-submitted-fields span, +.collect-link-submitted-screenshots > span { + color: #94a3b8; + font-size: 11px; +} + +.collect-link-submitted-fields strong { + color: #1e293b; + font-size: 13px; + font-weight: 500; + line-height: 1.5; + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +.collect-link-submitted-screenshots { + display: grid; + gap: 7px; +} + +.collect-link-submitted-screenshots > div { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.collect-link-submitted-screenshots .ant-image { + overflow: hidden; + border: 1px solid #dbe3ee; + border-radius: 8px; +} + +.collect-link-submitted-screenshots .ant-image-img { + object-fit: cover; +} + +.collect-link-current-status { + display: grid; + grid-template-columns: auto minmax(0, 1fr); + gap: 12px; + align-items: flex-start; + padding: 13px; + color: #475569; + background: #f8fafc; + border: 1px solid #e8edf4; + border-left: 4px solid #94a3b8; + border-radius: 9px; +} + +.collect-link-current-status-index { + display: inline-flex; + align-items: center; + justify-content: center; + width: 30px; + height: 30px; + color: #ffffff; + font-size: 13px; + font-weight: 700; + background: #64748b; + border-radius: 999px; +} + +.collect-link-current-status-copy { + display: grid; + gap: 5px; + min-width: 0; +} + +.collect-link-current-status-copy > div { + display: flex; + flex-wrap: wrap; + gap: 3px 12px; + align-items: baseline; + justify-content: space-between; +} + +.collect-link-current-status-copy > div .ant-typography:last-child { + font-size: 11px; +} + +.collect-link-current-status-copy p { + margin: 0; + color: inherit; + font-size: 13px; + line-height: 1.7; + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +.collect-link-current-status.is-open, +.collect-link-current-status.is-pending_material { + color: #8a4b00; + background: #fffaf0; + border-color: #ffe7ba; + border-left-color: #faad14; +} + +.collect-link-current-status.is-open .collect-link-current-status-index, +.collect-link-current-status.is-pending_material .collect-link-current-status-index { + background: #faad14; +} + +.collect-link-current-status.is-in_progress, +.collect-link-current-status.is-unassigned { + color: #0958d9; + background: #f0f7ff; + border-color: #d6e8ff; + border-left-color: #1677ff; +} + +.collect-link-current-status.is-in_progress .collect-link-current-status-index, +.collect-link-current-status.is-unassigned .collect-link-current-status-index { + background: #1677ff; +} + +.collect-link-current-status.is-pending_acceptance { + color: #531dab; + background: #f9f0ff; + border-color: #efdbff; + border-left-color: #722ed1; +} + +.collect-link-current-status.is-pending_acceptance .collect-link-current-status-index { + background: #722ed1; +} + +.collect-link-current-status.is-accepted { + color: #237804; + background: #f6ffed; + border-color: #d9f7be; + border-left-color: #52c41a; +} + +.collect-link-current-status.is-accepted .collect-link-current-status-index { + background: #52c41a; +} + +.collect-link-current-status.is-problem { + color: #a8071a; + background: #fff1f0; + border-color: #ffccc7; + border-left-color: #ff4d4f; +} + +.collect-link-current-status.is-problem .collect-link-current-status-index { + background: #ff4d4f; +} + +.collect-link-status-message { + padding: 10px 12px; + color: #475569; + font-size: 13px; + line-height: 1.65; + background: #f8fafc; + border-left: 3px solid #94a3b8; + border-radius: 0 8px 8px 0; +} + +.collect-link-status-message.is-open, +.collect-link-status-message.is-pending_material { + color: #8a4b00; + background: #fffaf0; + border-left-color: #faad14; +} + +.collect-link-status-message.is-in_progress, +.collect-link-status-message.is-unassigned { + color: #0958d9; + background: #f0f7ff; + border-left-color: #1677ff; +} + +.collect-link-status-message.is-pending_acceptance { + color: #531dab; + background: #f9f0ff; + border-left-color: #722ed1; +} + +.collect-link-status-message.is-accepted { + color: #237804; + background: #f6ffed; + border-left-color: #52c41a; +} + +.collect-link-status-message.is-problem { + color: #a8071a; + background: #fff1f0; + border-left-color: #ff4d4f; +} + +.collect-link-status-times { + display: flex; + flex-wrap: wrap; + gap: 4px 18px; + color: #94a3b8; + font-size: 12px; +} + +.collect-link-acceptance { + display: grid; + gap: 10px; + padding-top: 12px; + border-top: 1px solid #eef2f7; +} + +.collect-link-acceptance > div:first-child { + display: flex; + align-items: baseline; + justify-content: space-between; + flex-wrap: wrap; + gap: 4px 12px; +} + +.collect-link-acceptance > div:first-child .ant-typography:last-child { + font-size: 12px; +} + +.collect-link-acceptance-images { + display: flex; + flex-wrap: wrap; + gap: 10px; +} + +.collect-link-acceptance-images .ant-image { + overflow: hidden; + border: 1px solid #dbe3ee; + border-radius: 9px; +} + +.collect-link-acceptance-images .ant-image-img { + object-fit: cover; +} + +.collect-link-acceptance-video { + display: grid; + gap: 8px; +} + +.collect-link-acceptance-video video { + width: min(100%, 520px); + max-height: 360px; + background: #0f172a; + border: 1px solid #dbe3ee; + border-radius: 10px; +} + +.collect-link-acceptance-video > div { + display: flex; + flex-wrap: wrap; + gap: 4px 14px; + align-items: center; + justify-content: space-between; + font-size: 12px; +} + +.collect-link-acceptance-video a { + color: #1677ff; +} + +.collect-link-title { + margin: 0 0 4px !important; +} + +.collect-link-heading { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 12px; +} + +.collect-link-confirm { + display: grid; + gap: 12px; + max-height: 58vh; + padding-top: 4px; + padding-right: 4px; + overflow-y: auto; +} + +.collect-link-confirm-meta { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: 4px 16px; + color: #64748b; + font-size: 12px; +} + +.collect-link-confirm-meta span:first-child { + color: #0f172a; + font-size: 14px; + font-weight: 600; +} + +.collect-link-confirm-fields { + overflow: hidden; + border: 1px solid #e8edf4; + border-radius: 9px; +} + +.collect-link-confirm-field { + display: grid; + grid-template-columns: 110px minmax(0, 1fr); + gap: 12px; + padding: 9px 12px; + font-size: 13px; + border-bottom: 1px solid #eef2f7; +} + +.collect-link-confirm-field:last-child { + border-bottom: 0; +} + +.collect-link-confirm-field span, +.collect-link-confirm-screenshots span { + color: #64748b; +} + +.collect-link-confirm-field strong, +.collect-link-confirm-screenshots strong { + color: #0f172a; + font-weight: 500; + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +.collect-link-confirm-field strong.is-empty { + color: #94a3b8; +} + +.collect-link-confirm-screenshots { + display: grid; + gap: 8px; + padding: 10px 12px; + font-size: 13px; + background: #f8fafc; + border-radius: 9px; +} + +.collect-link-confirm-screenshots > div:first-child { + display: flex; + justify-content: space-between; + gap: 12px; +} + +.collect-link-confirm-images { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.collect-link-confirm-images img { + width: 58px; + height: 58px; + object-fit: cover; + background: #ffffff; + border: 1px solid #dbe3ee; + border-radius: 8px; +} + +.collect-link-confirm-content { + padding: 10px 12px; + color: #8a4b00; + font-size: 13px; + line-height: 1.7; + background: #fff7e6; + border: 1px solid #ffe7ba; + border-radius: 9px; + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +/* 商品名与订单号放在同一个信息头里,避免标题和灰色信息块分离 */ +.collect-link-order-head { + display: flex; + align-items: baseline; + justify-content: space-between; + flex-wrap: wrap; + gap: 6px 20px; + padding-bottom: 12px; + border-bottom: 1px solid #eef2f7; +} + +.collect-link-order-name { + min-width: 0; + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; + color: #0f172a; + font-size: 16px; + font-weight: 700; + overflow-wrap: anywhere; +} + +.collect-link-order-no { + min-width: 0; + display: flex; + align-items: baseline; + gap: 6px; + color: #64748b; + font-size: 12px; +} + +.collect-link-order-no strong { + color: #0f172a; + font-size: 14px; + font-weight: 600; + overflow-wrap: anywhere; +} + +.collect-link-state { + min-height: 220px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 16px; +} + +/* 提交成功:居中的成功状态,不再展示订单号 */ +.collect-link-success { + min-height: 380px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 10px; + padding: 24px 12px 8px; + text-align: center; +} + +.collect-link-success-icon { + font-size: 64px; + color: #22c55e; + filter: drop-shadow(0 10px 20px rgba(34, 197, 94, 0.18)); +} + +.collect-link-success-title { + margin: 2px 0 0 !important; + color: #0f172a; +} + +.collect-link-success-products { + max-width: 100%; + margin-top: 10px; + padding: 12px 22px; + border: 1px solid #dcfce7; + border-radius: 12px; + background: #f0fdf4; + display: flex; + flex-direction: column; + gap: 4px; +} + +.collect-link-success-products span { + color: #16a34a; + font-size: 12px; +} + +.collect-link-success-products strong { + color: #166534; + font-size: 15px; + overflow-wrap: anywhere; +} + +.collect-link-success .collect-link-footnote { + margin-top: 18px; +} + +.collect-link-screenshot-control { + display: grid; + gap: 14px; + align-items: start; +} + +.collect-link-screenshot-control.has-guide { + grid-template-columns: 120px minmax(180px, 260px); + gap: 16px; +} + +.collect-link-guide-example { + display: grid; + grid-template-columns: 1fr; + gap: 6px; + min-width: 0; + max-width: 100%; + align-content: start; + justify-items: start; +} + +.collect-link-guide-example .ant-image { + display: block; + width: 128px !important; + height: 88px !important; + overflow: hidden; + border: 1px solid #dbe3ee; + border-radius: 7px; + cursor: zoom-in; +} + +.collect-link-guide-example .ant-image-img { + display: block; + width: 128px !important; + height: 88px !important; + object-fit: cover; + object-position: center; +} + +.collect-link-guide-copy { + display: grid; + align-content: center; + gap: 3px; + min-width: 0; +} + +.collect-link-guide-copy .ant-typography:first-child { + color: #334155; + font-size: 12px; +} + +.collect-link-guide-copy .ant-typography:last-child { + max-width: 220px; + font-size: 11px; + line-height: 1.55; + white-space: pre-wrap; +} + +.collect-link-actions { + display: flex; + justify-content: flex-end; + margin-top: 4px; +} + +.collect-link-actions .ant-btn { + min-width: 180px; +} + +.collect-link-footnote { + display: block; + text-align: center; + font-size: 12px; + white-space: pre-wrap; +} + +@media (max-width: 720px) { + .collect-link-page { + padding: 14px; + } + + .collect-link-card .ant-card-body { + padding: 18px; + } + + .collect-link-screenshot-control.has-guide { + grid-template-columns: 112px minmax(160px, 220px); + gap: 12px; + } + + .collect-link-guide-example .ant-image { + width: 116px !important; + height: 80px !important; + } + + .collect-link-guide-example .ant-image-img { + width: 116px !important; + height: 80px !important; + } + + .collect-link-actions { + justify-content: stretch; + } + + .collect-link-actions .ant-btn { + width: 100%; + } +} + +@media (max-width: 480px) { + .collect-link-page { + padding: 10px; + } + + .collect-link-card .ant-card-body { + padding: 14px; + } + + .collect-link-screenshot-control.has-guide { + grid-template-columns: 104px minmax(0, 1fr); + gap: 8px; + } + + .collect-link-guide-example { + gap: 5px; + } + + .collect-link-guide-example .ant-image { + width: 96px !important; + height: 68px !important; + } + + .collect-link-guide-example .ant-image-img { + width: 96px !important; + height: 68px !important; + } + + .collect-link-guide-copy .ant-typography:first-child { + font-size: 11px; + } + + .collect-link-guide-copy .ant-typography:last-child { + font-size: 10px; + } + + .collect-link-success { + min-height: 320px; + padding: 16px 4px 4px; + } + + .collect-link-success-icon { + font-size: 52px; + } + + .collect-link-success-products { + padding: 10px 16px; + } + + .collect-link-confirm-field { + grid-template-columns: 88px minmax(0, 1fr); + padding: 8px 10px; + } + + .collect-link-order-meta, + .collect-link-submitted-fields { + grid-template-columns: 1fr; + } + + .collect-link-order-meta { + display: grid; + } +} diff --git a/apps/frontend/src/styles/client/redeem.css b/apps/frontend/src/styles/client/redeem.css new file mode 100644 index 00000000..38d47b1f --- /dev/null +++ b/apps/frontend/src/styles/client/redeem.css @@ -0,0 +1,25 @@ +/* ===== 兑换中心 (Redeem Page) ===== */ + +.redeem-page { + min-height: 100vh; + display: grid; + place-items: center; + padding: 32px 16px; + background: #f5f7fb; +} + +.redeem-card { + width: min(520px, 100%); +} + +.redeem-order-input { + flex: 1; + margin-bottom: 0; +} + +/* ===== H5 领取入口页(`/h5`,只有前缀没有订单号) ===== */ + +/* 复用领取页的卡片与背景,只把单卡在视口内垂直居中 */ +.h5-claim-entry { + justify-content: center; +} diff --git a/apps/frontend/src/styles/client/responsive.css b/apps/frontend/src/styles/client/responsive.css new file mode 100644 index 00000000..617a0e69 --- /dev/null +++ b/apps/frontend/src/styles/client/responsive.css @@ -0,0 +1,177 @@ +/* ===== 买家页面响应式断点 ===== */ + +@media (max-width: 720px) { + .claim-page { + padding: 14px; + } + + .claim-header-card .ant-card-body, + .claim-content-card .ant-card-body { + gap: 14px; + } + + .claim-header-copy { + padding-right: 150px; + } + + .claim-header-copy h1 { + font-size: 24px; + line-height: 1.22; + } + + .claim-header-copy p { + font-size: 14px; + line-height: 1.4; + } + + .claim-step-indicator { + top: 16px; + right: 16px; + max-width: 140px; + } + + .claim-step-dots { + gap: 5px; + } + + .claim-step-dot { + width: 26px; + height: 26px; + font-size: 13px; + } + + .claim-step-progress-text { + font-size: 12px; + } + + .claim-info-grid { + grid-template-columns: 1fr; + } + + .claim-qr-block { + padding: 12px; + } + + .claim-qr-guide-panel { + grid-template-columns: 34px minmax(0, 1fr) 34px; + gap: 8px; + max-width: 100%; + } + + .claim-scan-label { + min-height: 128px; + padding: 8px 4px; + font-size: 14px; + } + + .claim-qr-code { + max-width: 232px; + padding: 8px; + } + + .claim-save-hint { + font-size: 13px; + } + + .claim-role-panel-item { + grid-template-columns: 76px minmax(0, 1fr); + gap: 10px; + } + + .claim-role-panel-item span { + font-size: 12px; + } + + .claim-role-panel-item strong { + font-size: 16px; + } + + .claim-action-row { + display: flex; + flex-direction: column; + align-items: stretch; + } + + .claim-action-row .ant-space-item, + .claim-action-row .ant-btn, + .claim-action-tooltip-wrap { + width: 100%; + } + + .claim-meta-footer { + justify-content: flex-start; + } + + .claim-result-header { + display: grid; + } +} + +@media (max-width: 480px) { + .claim-page { + padding: 12px; + gap: 10px; + } + + .claim-header-card .ant-card-body, + .claim-content-card .ant-card-body { + gap: 12px; + } + + .claim-header-copy { + padding-right: 112px; + } + + .claim-header-copy h1 { + font-size: 22px; + } + + .claim-step-indicator { + position: absolute; + top: 16px; + right: 16px; + max-width: 100px; + align-items: flex-end; + } + + .claim-step-dot { + width: 26px; + height: 26px; + font-size: 12px; + } + + .claim-step-dots { + gap: 5px; + } + + .claim-step-progress-text { + text-align: right; + font-size: 12px; + } + + .claim-uid-step-title.ant-typography { + font-size: 18px !important; + } + + .claim-uid-guide-image { + max-height: 140px; + } +} + +@media (max-width: 420px) { + .claim-header-copy { + padding-right: 124px; + } + + .claim-header-copy h1 { + font-size: 22px; + } + + .claim-header-copy p { + padding-right: 0; + } + + .claim-step-indicator { + max-width: 116px; + } +} diff --git a/apps/frontend/src/styles/customer/auth-form.css b/apps/frontend/src/styles/customer/auth-form.css new file mode 100644 index 00000000..b60616d2 --- /dev/null +++ b/apps/frontend/src/styles/customer/auth-form.css @@ -0,0 +1,349 @@ +.customer-auth-tabs { + margin-top: 22px; +} + +.customer-auth-tabs .ant-tabs-nav { + margin-bottom: 18px; +} + +.customer-auth-tabs .ant-tabs-nav::before { + display: none; +} + +.customer-auth-tabs .ant-tabs-nav-list { + width: 100%; + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 5px; + padding: 5px; + border: 1px solid rgba(148, 163, 184, 0.18); + border-radius: 11px; + background: rgba(4, 15, 37, 0.72); +} + +.customer-auth-tabs .ant-tabs-tab { + justify-content: center; + margin: 0 !important; + padding: 11px 18px; + color: var(--auth-muted); + background: transparent; + border: 0 !important; + border-radius: 7px; +} + +.customer-auth-tabs .ant-tabs-tab.ant-tabs-tab-active { + background: var(--auth-accent); +} + +.customer-auth-tabs .ant-tabs-tab-btn { + color: inherit !important; + font-size: 16px; +} + +.customer-auth-tabs .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn { + color: #111827 !important; + font-weight: 700; +} + +.customer-auth-tabs .ant-tabs-ink-bar { + display: none; +} + +.customer-auth-form { + display: flex; + flex-direction: column; + gap: 14px; + padding-top: 18px; +} + +.customer-auth-field { + display: grid; + align-items: center; + min-height: 50px; + overflow: hidden; + border: 1px solid rgba(148, 163, 184, 0.24); + border-radius: 10px; + background: rgba(13, 29, 61, 0.72); + transition: + border-color 0.2s ease, + box-shadow 0.2s ease; +} + +.customer-auth-field:focus-within { + border-color: var(--auth-accent); + box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.12); +} + +.customer-auth-field > * { + min-width: 0; +} + +.customer-auth-phone-field { + grid-template-columns: 58px minmax(0, 1fr) 112px; + padding: 4px; +} + +.customer-auth-code-field { + grid-template-columns: minmax(0, 1fr) 122px; + gap: 5px; + padding: 5px; +} + +.customer-auth-field .ant-select-selector, +.customer-auth-field .ant-input, +.customer-auth-field .ant-input-affix-wrapper { + color: #f8fafc !important; + border: 0 !important; + border-radius: 0 !important; + background: transparent !important; + box-shadow: none !important; +} + +.customer-auth-field .ant-select-selector { + height: 48px !important; + padding-inline: 14px !important; + align-items: center; +} + +.customer-auth-field .ant-select { + height: 48px; + background: transparent !important; +} + +.customer-auth-field .ant-select-selection-item { + color: #f8fafc !important; + line-height: 46px !important; +} + +.customer-auth-field .ant-select-arrow { + color: #c4cede !important; +} + +.customer-auth-country-prefix { + display: grid; + place-items: center; + align-self: stretch; + color: #f8fafc; + font-size: 14px; + font-weight: 600; + border-right: 1px solid var(--auth-line); +} + +.customer-auth-field .ant-input-affix-wrapper { + height: 48px; + padding-inline: 15px; +} + +.customer-auth-field .ant-input { + height: 48px; + padding-inline: 10px; + font-size: 15px; +} + +.customer-auth-field .ant-input-affix-wrapper .ant-input { + padding-inline: 0; +} + +.customer-auth-field .ant-input::placeholder { + color: #7f8ca5; +} + +.customer-auth-field .ant-input-prefix { + margin-inline-end: 9px; + color: var(--auth-accent); +} + +.customer-auth-send-code { + height: 40px !important; + padding-inline: 10px !important; + color: #111827; + border: 0 !important; + border-radius: 7px !important; + background: var(--auth-accent) !important; + font-size: 14px !important; + font-weight: 700; +} + +.customer-auth-send-code:hover { + background: var(--auth-accent-hover) !important; +} + +.customer-auth-code-submit { + height: 40px !important; + color: #111827; + border: 0 !important; + border-radius: 7px !important; + background: var(--auth-accent) !important; + font-weight: 700; +} + +.customer-auth-code-submit:hover { + background: var(--auth-accent-hover) !important; +} + +.customer-auth-note { + padding: 11px 14px; + color: #fbbf24; + font-size: 13px; + line-height: 1.6; + border: 1px solid rgba(251, 191, 36, 0.48); + border-radius: 4px; + background: rgba(251, 191, 36, 0.06); +} + +.customer-auth-form-hint { + color: #7f8ca5; + font-size: 12px; +} + +.customer-auth-page .ant-btn-primary { + color: #fff; + border-color: var(--auth-accent); + background: var(--auth-accent); + font-weight: 700; + box-shadow: none; +} + +.customer-auth-page .ant-btn-primary:hover { + color: #fff !important; + border-color: var(--auth-accent-hover) !important; + background: var(--auth-accent-hover) !important; +} + +.customer-auth-page .customer-auth-secondary-button { + color: #fff; + border-color: rgba(148, 163, 184, 0.42); + background: rgba(19, 39, 77, 0.52); +} + +.customer-auth-page .customer-auth-secondary-button:hover { + color: #fff !important; + border-color: rgba(196, 210, 236, 0.72) !important; + background: rgba(31, 55, 102, 0.72) !important; +} + +.customer-auth-qr { + display: flex; + flex-direction: column; + align-items: center; + gap: 13px; + padding-top: 22px; + text-align: center; +} + +.customer-auth-qr > p { + margin: 0; + color: var(--auth-muted); + line-height: 1.7; +} + +.customer-auth-qr-image, +.customer-auth-qr-placeholder { + display: grid; + place-items: center; + width: 252px; + min-height: 252px; + padding: 10px; + border-radius: 6px; + background: #fff; +} + +.customer-auth-qr-placeholder { + color: #64748b; + font-size: 13px; + background: rgba(255, 255, 255, 0.94); +} + +.customer-auth-role-card { + width: min(100%, 580px); + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + gap: 4px 18px; + padding: 15px 18px; + text-align: left; + border: 1px solid rgba(255, 138, 0, 0.42); + border-radius: 5px; + background: rgba(255, 138, 0, 0.06); +} + +.customer-auth-role-card span { + color: var(--auth-muted); + font-size: 13px; +} + +.customer-auth-role-card strong { + justify-self: end; + color: #fff; + font-size: 17px; +} + +.customer-auth-role-card small { + grid-column: 1 / -1; + color: var(--auth-muted); + font-size: 12px; +} + +.customer-auth-binding { + display: flex; + flex-direction: column; + gap: 16px; +} + +.customer-auth-binding-tip { + color: #ffb454; + font-size: 13px; +} + +.customer-auth-profile { + padding: 16px; + border: 1px solid #3a4150; + border-radius: 12px; + background: #212733; +} + +.customer-auth-profile-summary { + padding: 14px; + border: 1px solid rgba(255, 255, 255, 0.14); + border-radius: 6px; + background: rgba(255, 255, 255, 0.04); +} + +.customer-auth-profile > p { + margin: 0 0 12px; + color: #9aa3b2; + font-size: 13px; + line-height: 1.6; +} + +.customer-profile-form { + display: flex; + flex-direction: column; + gap: 12px; +} + +.customer-profile-form .customer-collect-label { + margin-top: 2px; +} + +.customer-auth-profile-summary { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 10px; +} + +.customer-auth-profile-summary span { + color: var(--auth-muted); + font-size: 13px; +} + +.customer-auth-profile-summary strong { + color: #fff; + font-size: 15px; +} + +.customer-auth-profile-summary em { + color: var(--auth-muted); + font-style: normal; + font-size: 13px; +} diff --git a/apps/frontend/src/styles/customer/base.css b/apps/frontend/src/styles/customer/base.css new file mode 100644 index 00000000..6554a17f --- /dev/null +++ b/apps/frontend/src/styles/customer/base.css @@ -0,0 +1,10 @@ +/** 客户领取页公共样式入口:平台差异见 platform/huya.css、platform/weibo.css、platform/douyu.css。 */ + +@import './layout.css'; +@import './auth-form.css'; +@import './profile.css'; +@import './login.css'; +@import './order.css'; +@import './binding.css'; +@import './status.css'; +@import './responsive.css'; diff --git a/apps/frontend/src/styles/customer/binding.css b/apps/frontend/src/styles/customer/binding.css new file mode 100644 index 00000000..a505ef93 --- /dev/null +++ b/apps/frontend/src/styles/customer/binding.css @@ -0,0 +1,453 @@ +.customer-binding-stage { + display: flex; + flex-direction: column; + gap: 14px; + padding: 16px; +} + +.customer-binding-session-card { + display: flex; + flex-direction: column; + gap: 10px; + padding: 18px; + border: 1px solid #78350f; + border-radius: 12px; + background: rgba(120, 53, 15, 0.22); +} + +.customer-binding-session-title { + margin: 0; + color: #fbbf24; + font-size: 16px; + font-weight: 700; +} + +.customer-binding-session-desc { + margin: 0 0 4px; + color: #fcd34d; + font-size: 13px; + line-height: 1.6; +} + +.customer-binding-qr-error { + display: flex; + flex-direction: column; + align-items: center; + gap: 10px; + padding: 24px 12px; + text-align: center; +} + +.customer-binding-qr-error p { + margin: 0; + color: #fca5a5; + font-size: 15px; + font-weight: 600; +} + +.customer-binding-qr-error span { + color: #cbd5e1; + font-size: 13px; + line-height: 1.6; + overflow-wrap: anywhere; +} + +/* antd Alert 在绑定阶段统一走深色卡片,避免浅色块破坏整体深色风格 */ +.customer-binding-stage .ant-alert { + align-items: flex-start; + padding: 12px 14px; + border: 1px solid #3a4150; + border-radius: 12px; + background: #212733; +} + +.customer-binding-stage .ant-alert .ant-alert-message { + color: #e2e8f0; + font-size: 14px; + font-weight: 600; +} + +/* antd v6 的标题节点是 .ant-alert-title(v5 为 .ant-alert-message) */ +.customer-binding-stage .ant-alert .ant-alert-title { + color: #e2e8f0; + font-size: 14px; + font-weight: 600; + line-height: 1.5; +} + +.customer-binding-stage .ant-alert .ant-alert-description { + color: #cbd5e1; + font-size: 13px; + line-height: 1.6; +} + +.customer-binding-stage .ant-alert-warning { + border-color: #78350f; + background: rgba(120, 53, 15, 0.22); +} + +.customer-binding-stage .ant-alert-warning .ant-alert-icon, +.customer-binding-stage .ant-alert-warning .ant-alert-message, +.customer-binding-stage .ant-alert-warning .ant-alert-title { + color: #fbbf24; +} + +.customer-binding-stage .ant-alert-warning .ant-alert-description { + color: #fcd34d; +} + +.customer-binding-stage .ant-alert-error { + border-color: #7f1d1d; + background: rgba(127, 29, 29, 0.24); +} + +.customer-binding-stage .ant-alert-error .ant-alert-icon, +.customer-binding-stage .ant-alert-error .ant-alert-message, +.customer-binding-stage .ant-alert-error .ant-alert-title { + color: #fca5a5; +} + +.customer-binding-stage .ant-alert-error .ant-alert-description { + color: #fecaca; +} + +.customer-binding-stage .ant-alert-success { + border-color: #065f46; + background: rgba(6, 78, 59, 0.28); +} + +.customer-binding-stage .ant-alert-success .ant-alert-icon, +.customer-binding-stage .ant-alert-success .ant-alert-message, +.customer-binding-stage .ant-alert-success .ant-alert-title { + color: #6ee7b7; +} + +.customer-binding-stage .ant-alert-success .ant-alert-description { + color: #a7f3d0; +} + +.customer-binding-role-actions { + display: flex; + flex-direction: column; + gap: 12px; + width: 100%; +} + +.customer-binding-role-actions .customer-binding-confirm.ant-btn { + height: 52px; + border-radius: 14px; + background: #2563eb !important; + border-color: #2563eb !important; + color: #fff !important; + font-size: 17px; + font-weight: 600; +} + +.customer-binding-role-actions .customer-binding-confirm.ant-btn:hover, +.customer-binding-role-actions .customer-binding-confirm.ant-btn:focus-visible { + background: #1d4ed8 !important; + border-color: #1d4ed8 !important; + color: #fff !important; +} + +.customer-binding-role-actions .customer-binding-rebind.ant-btn { + height: 48px; + border-radius: 14px; + background: transparent !important; + border-color: #3a4150 !important; + color: #cbd5e1 !important; + font-size: 16px; + font-weight: 500; +} + +.customer-binding-role-actions .customer-binding-rebind.ant-btn .anticon { + color: #f59e0b; +} + +.customer-binding-role-actions .customer-binding-rebind.ant-btn:hover, +.customer-binding-role-actions .customer-binding-rebind.ant-btn:focus-visible { + background: rgba(245, 158, 11, 0.08) !important; + border-color: #b45309 !important; + color: #fbbf24 !important; +} + +.customer-binding-role-actions .customer-binding-accept.ant-btn { + height: 46px; + border-radius: 12px; + background: transparent !important; + border-color: transparent !important; + color: #94a3b8 !important; + font-size: 15px; + font-weight: 500; +} + +.customer-binding-role-actions .customer-binding-accept.ant-btn:hover, +.customer-binding-role-actions .customer-binding-accept.ant-btn:focus-visible { + background: rgba(148, 163, 184, 0.1) !important; + border-color: transparent !important; + color: #e2e8f0 !important; +} + +.customer-binding-info { + padding: 16px; + border: 1px solid #3a4150; + border-radius: 12px; + background: #212733; + display: flex; + flex-direction: column; + gap: 10px; +} + +.customer-binding-info h3 { + margin: 0 0 4px; + color: #9aa3b2; + font-size: 13px; + font-weight: 500; +} + +.customer-binding-info h3 small { + color: #64748b; + font-weight: 400; +} + +.customer-binding-info > div { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 12px; + color: #cbd5e1; + font-size: 14px; + line-height: 1.5; +} + +.customer-binding-info > div > span { + flex: 0 0 auto; + white-space: nowrap; +} + +.customer-binding-info > div strong { + flex: 1 1 auto; + min-width: 0; + color: #fff; + text-align: right; + overflow-wrap: anywhere; +} + +.customer-binding-alert { + padding: 12px 14px; + border-radius: 8px; + border: 1px solid transparent; + font-size: 14px; +} + +.customer-binding-alert.is-warning { + color: #fbbf24; + border-color: #78350f; + background: rgba(120, 53, 15, 0.25); +} + +.customer-binding-alert.is-info { + color: #93c5fd; + border-color: #1e3a8a; + background: rgba(30, 58, 138, 0.3); +} + +.customer-binding-verify { + padding: 18px; + border: 1px solid #3a4150; + border-radius: 12px; + background: transparent; + display: flex; + flex-direction: column; + gap: 16px; + text-align: center; +} + +.customer-binding-verify p { + margin: 0; + color: #e5e7eb; + font-size: 16px; + line-height: 1.6; +} + +.customer-binding-qr-card { + padding: 18px; + border-radius: 12px; + background: #fff; + color: #111827; + display: flex; + flex-direction: column; + align-items: center; + gap: 10px; +} + +.customer-binding-qr-card h3 { + margin: 0; + color: #6b7280; + font-size: 14px; + font-weight: 500; +} + +.customer-binding-qr-hint { + margin: 0; + color: #6b7280; + font-size: 13px; +} + +.customer-binding-qr-tip { + margin: 0; + color: #f59e0b; + font-size: 13px; +} + +.customer-binding-qr-countdown { + margin: 0; + color: #6b7280; + font-size: 13px; +} + +.customer-binding-qr-actions { + width: 100%; + margin-top: 4px; + display: grid; + grid-template-columns: 1fr 1fr; + gap: 10px; +} + +.customer-binding-qr-actions .ant-btn { + height: 40px; + border-radius: 8px; +} + +/* 斗鱼客户领取页沿用后台深色二维码面板,避免大块纯白卡片刺眼。 */ +.customer-choice-switch { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 3px; + padding: 3px; + overflow: hidden; + border: 1px solid #354052; + border-radius: 10px; + background: #171d27; +} + +.customer-choice-option { + height: 42px; + min-width: 0; + padding: 0 10px; + color: #aeb8c8; + border: 0; + border-radius: 8px; + outline: none; + background: transparent; + font: inherit; + font-size: 14px; + cursor: pointer; + transition: color 100ms ease; +} + +.customer-choice-option:hover { + color: #e2e8f0; + background: #242c39; +} + +.customer-choice-option.is-selected { + color: #fff; + background: #2f6fed; + font-weight: 700; +} + +.customer-choice-option:focus-visible { + outline: 2px solid #60a5fa; + outline-offset: 2px; +} + +.customer-binding-next.ant-btn { + width: 100%; + height: 52px; + margin-top: 6px; + border-radius: 14px; + background: #2563eb !important; + border-color: #2563eb !important; + color: #fff !important; + font-size: 17px; + font-weight: 600; +} + +.customer-binding-modal-footer { + display: flex; + flex-direction: column; + gap: 10px; +} + +.customer-binding-modal-actions { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 12px; +} + +.customer-binding-modal-actions .ant-btn { + height: 42px; + border-radius: 8px; +} + +.customer-binding-modal-actions.is-mismatch { + grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); +} + +.customer-binding-modal-error { + margin: 0; + color: #dc2626; + font-size: 13px; + text-align: center; +} + +.customer-binding-modal-warning { + margin: 0; + color: #d97706; + font-size: 13px; + text-align: center; +} + +.customer-binding-compare { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 12px; +} + +.customer-binding-compare-side { + display: flex; + flex-direction: column; + gap: 6px; + padding: 14px; + border: 1px solid rgba(15, 23, 42, 0.12); + border-radius: 6px; + background: rgba(15, 23, 42, 0.04); +} + +.customer-binding-compare-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + color: #64748b; + font-size: 13px; +} + +.customer-binding-compare-side strong { + color: #0f172a; + font-size: 16px; + word-break: break-all; +} + +.customer-binding-compare-side em { + color: #64748b; + font-style: normal; + font-size: 13px; +} + +@media (max-width: 480px) { + .customer-binding-compare { + grid-template-columns: minmax(0, 1fr); + } +} diff --git a/apps/frontend/src/styles/customer/layout.css b/apps/frontend/src/styles/customer/layout.css new file mode 100644 index 00000000..1b10109d --- /dev/null +++ b/apps/frontend/src/styles/customer/layout.css @@ -0,0 +1,240 @@ +/** 客户领取页公共样式:布局、表单、登录、订单、角色绑定与状态。 */ + +/** + * 客户领取页样式 + * + * 覆盖虎牙、微博、斗鱼客户领取、资料收集、角色绑定与二维码阶段。 + * 从 client.css 拆分,保持原选择器和层叠顺序不变。 + */ + +.customer-auth-page { + --auth-accent: #2f6fed; + --auth-accent-hover: #4a83ff; + --auth-panel: #232936; + --auth-panel-soft: #2a3140; + --auth-line: rgba(255, 255, 255, 0.08); + --auth-text: #f5f7fa; + --auth-muted: #9aa3b2; + min-height: 100vh; + display: flex; + justify-content: center; + overflow-x: hidden; + padding: 0; + color: var(--auth-text); + background: #232936; +} + +.customer-auth-shell { + width: min(560px, 100%); + min-width: 0; + align-self: stretch; + overflow: hidden; + border: none; + border-radius: 0; + background: transparent; + box-shadow: none; +} + +.customer-auth-hero { + position: relative; + min-height: clamp(112px, 15vw, 136px); + display: flex; + align-items: flex-end; + justify-content: flex-start; + padding: 12px 20px 14px; + overflow: hidden; + text-align: left; + background-color: #0b1220; + background-image: + linear-gradient(180deg, rgba(11, 18, 32, 0.06) 0%, rgba(11, 18, 32, 0.62) 72%, #232936 100%), + url('/images/customer/inside-kv.jpg'); + background-repeat: no-repeat; + background-position: center 38%; + background-size: cover; +} + +/* 微博与虎牙客户页统一使用同一套顶部 KV,不再单独覆盖背景。 */ +.customer-auth-brand { + width: 100%; + display: flex; + align-items: center; + justify-content: flex-start; + gap: 0; + min-width: 0; +} + +.customer-auth-logo { + width: 62px; + height: 62px; + flex: none; + display: grid; + place-items: center; + border: 1px solid rgba(255, 255, 255, 0.22); + border-radius: 8px; + color: var(--auth-accent); + font-size: 34px; + background: rgba(3, 12, 34, 0.58); + box-shadow: inset 0 0 24px rgba(255, 138, 0, 0.06); +} + +.customer-auth-brand h1 { + margin: 0; + color: #fff; + font-size: 20px; + line-height: 1.4; + font-weight: 700; + letter-spacing: 0; + text-align: left; + text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72); + white-space: normal; + overflow-wrap: anywhere; +} + +.customer-auth-warning { + padding: 6px 16px 10px; + color: #ff6975; + text-align: center; + font-size: 14px; + font-weight: 600; + background: transparent; + border-bottom: none; +} + +.customer-auth-main { + min-width: 0; + padding-bottom: 24px; + color: var(--auth-text); + background: transparent; +} + +.customer-auth-content-stack { + min-width: 0; + display: flex; + flex-direction: column; +} + +.customer-auth-task-switcher { + display: flex; + align-items: flex-start; + gap: 16px; + padding: 20px 24px; + border-bottom: 1px solid var(--auth-line); +} + +.customer-auth-task-switcher > span { + flex: none; + padding-top: 5px; + color: var(--auth-muted); + font-size: 13px; +} + +.customer-auth-task-switcher > div { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.customer-auth-task-switcher .ant-btn { + height: auto; + padding: 6px 10px; + color: #dce6f8; + white-space: normal; + text-align: left; + border-color: rgba(255, 255, 255, 0.16); + background: rgba(255, 255, 255, 0.04); +} + +.customer-auth-task-switcher .ant-btn-primary { + color: #111827; + border-color: var(--auth-accent); +} + +.customer-auth-facts { + min-width: 0; + padding: 0 26px; +} + +.customer-auth-facts > div { + display: grid; + grid-template-columns: 132px minmax(0, 1fr); + align-items: center; + gap: 18px; + min-height: 74px; + padding: 16px 4px; + border-bottom: 1px solid var(--auth-line); +} + +.customer-auth-facts > div > span { + color: #c0c8d8; + font-size: 16px; +} + +.customer-auth-facts > div > strong { + min-width: 0; + justify-self: end; + color: #f8fafc; + font-size: 18px; + line-height: 1.5; + font-weight: 600; + text-align: right; + word-break: break-all; + overflow-wrap: anywhere; +} + +.customer-auth-section { + min-width: 0; + padding: 16px; + border-bottom: none; +} + +.customer-auth-section-heading { + display: flex; + align-items: flex-start; + gap: 14px; +} + +.customer-auth-section-icon { + width: 36px; + height: 36px; + flex: none; + display: grid; + place-items: center; + border: 1px solid rgba(255, 255, 255, 0.15); + border-radius: 8px; + color: var(--auth-accent); + font-size: 18px; + background: rgba(255, 255, 255, 0.035); +} + +.customer-auth-section-heading h2, +.customer-auth-state h2 { + margin: 0 0 6px; + color: #fff; + font-size: 18px; + line-height: 1.4; + font-weight: 700; +} + +.customer-auth-section-heading p, +.customer-auth-state p, +.customer-auth-form-copy { + margin: 0; + color: var(--auth-muted); + font-size: 15px; + line-height: 1.75; +} + +.customer-auth-section-copy h2 { + margin: 0 0 8px; + color: #fff; + font-size: 23px; + line-height: 1.35; + font-weight: 700; +} + +.customer-auth-section-copy p { + margin: 0; + color: var(--auth-muted); + font-size: 15px; + line-height: 1.75; +} diff --git a/apps/frontend/src/styles/customer/login.css b/apps/frontend/src/styles/customer/login.css new file mode 100644 index 00000000..d155b9d4 --- /dev/null +++ b/apps/frontend/src/styles/customer/login.css @@ -0,0 +1,87 @@ +/* 登录与绑定页(图 2-10) */ +.customer-login-form { + display: flex; + flex-direction: column; + gap: 12px; +} + +.customer-login-hint { + margin: 0 0 2px; + color: #d5dae3; + font-size: 16px; + line-height: 1.5; +} + +.customer-login-mobile-row { + display: flex; + align-items: stretch; + gap: 12px; +} + +.customer-login-mobile.ant-input { + flex: 1; + min-width: 0; + height: 48px; + padding: 0 16px; + border-radius: 8px; + border-color: #3a4150; + background: #1b2130; + color: #fff; + font-size: 15px; +} + +.customer-login-mobile.ant-input::placeholder { + color: #6b7482; +} + +.customer-login-code-button.ant-btn { + flex: none; + width: 118px; + height: 48px; + border-radius: 8px; + background: #3b82f6 !important; + border-color: #3b82f6 !important; + color: #fff !important; + font-size: 16px; +} + +.customer-login-code-input.ant-input { + height: 48px; + border-radius: 8px; + border-color: #3a4150; + background: #1b2130; + color: #fff; + text-align: center; + font-size: 15px; + letter-spacing: 6px; +} + +.customer-login-code-input.ant-input::placeholder { + color: #6b7482; +} + +.customer-login-submit.ant-btn { + height: 52px; + border-radius: 14px; + background: #2563eb !important; + border-color: #2563eb !important; + color: #fff !important; + font-size: 17px; + font-weight: 600; +} + +.customer-login-submit.ant-btn:hover, +.customer-login-submit.ant-btn:focus-visible { + background: #1d4ed8 !important; + border-color: #1d4ed8 !important; + color: #fff !important; +} + +.customer-login-alt.ant-btn { + height: 48px; + border-radius: 8px; + background: transparent !important; + border-color: #3a4150 !important; + color: #cbd5e1 !important; + font-size: 16px; +} diff --git a/apps/frontend/src/styles/customer/mobile.css b/apps/frontend/src/styles/customer/mobile.css new file mode 100644 index 00000000..07ee22aa --- /dev/null +++ b/apps/frontend/src/styles/customer/mobile.css @@ -0,0 +1,240 @@ +/* ========================================================================== + 客户履约页(半自动)固定移动端 + 窄屏自适应 + -------------------------------------------------------------------------- + 全局 base.css 给 body 设了 min-width:320px,worker.css 又用 overflow-x:hidden + 裁掉横向溢出。应用内浏览器 / 分屏 / 系统显示放大时实际视口可能小于 320px, + 页面右侧(输入框、商品值、提示文案)会被直接裁掉。 + 下面只作用于客户履约页(body.customer-mobile-body),不影响后台与打手端。 + ========================================================================== */ + +html.customer-mobile-html, +body.customer-mobile-body { + min-width: 0; + width: 100%; + max-width: 100%; + overflow-x: hidden; +} + +body.customer-mobile-body #root { + width: 100%; + min-width: 0; + max-width: 100%; +} + +body.customer-mobile-body .customer-collect-page, +body.customer-mobile-body .customer-auth-page { + width: 100%; + min-width: 0; + max-width: 100%; + min-height: 100vh; + min-height: 100dvh; + overflow-x: hidden; +} + +body.customer-mobile-body .customer-collect-hero { + width: min(480px, 100%); + margin: 0 auto; +} + +body.customer-mobile-body .customer-collect-body { + width: 100%; + max-width: 480px; + margin: 0 auto; + padding: 20px clamp(12px, 4vw, 20px) calc(40px + env(safe-area-inset-bottom)); + padding-left: max(clamp(12px, 4vw, 20px), env(safe-area-inset-left)); + padding-right: max(clamp(12px, 4vw, 20px), env(safe-area-inset-right)); + gap: 10px; +} + +body.customer-mobile-body .customer-auth-shell { + width: min(480px, 100%); + min-width: 0; +} + +body.customer-mobile-body .customer-auth-main { + padding-bottom: calc(24px + env(safe-area-inset-bottom)); +} + +body.customer-mobile-body .customer-auth-content-stack, +body.customer-mobile-body .customer-auth-section, +body.customer-mobile-body .customer-auth-facts, +body.customer-mobile-body .customer-auth-facts > div, +body.customer-mobile-body .customer-auth-task-switcher, +body.customer-mobile-body .customer-login-form, +body.customer-mobile-body .customer-collect-card, +body.customer-mobile-body .customer-order-card { + min-width: 0; +} + +body.customer-mobile-body .customer-collect-card, +body.customer-mobile-body .customer-collect-readonly, +body.customer-mobile-body .customer-collect-input.ant-input, +body.customer-mobile-body .customer-collect-select.ant-select, +body.customer-mobile-body .customer-login-mobile.ant-input, +body.customer-mobile-body .customer-login-code-input.ant-input, +body.customer-mobile-body .customer-login-submit.ant-btn, +body.customer-mobile-body .customer-login-alt.ant-btn { + width: 100%; + min-width: 0; + max-width: 100%; +} + +/* 订单卡片自带左右 16px 外边距,不能用 width:100% 再加边距 */ +body.customer-mobile-body .customer-order-card { + width: auto; + max-width: 100%; +} + +body.customer-mobile-body .customer-collect-card > div, +body.customer-mobile-body .customer-order-card > div { + flex-wrap: wrap; +} + +body.customer-mobile-body .customer-collect-card > div strong, +body.customer-mobile-body .customer-order-card > div strong { + flex: 1 1 10ch; + min-width: 0; + overflow-wrap: anywhere; + word-break: break-word; +} + +/* 状态胶囊保持自身宽度,不参与长值换行规则 */ +body.customer-mobile-body .customer-order-card > div strong.customer-order-status { + flex: 0 0 auto; + max-width: 100%; + text-align: center; +} + +body.customer-mobile-body .customer-collect-readonly { + overflow-wrap: anywhere; + word-break: break-all; +} + +body.customer-mobile-body .customer-collect-card > p { + overflow-wrap: anywhere; + word-break: break-word; +} + +body.customer-mobile-body .customer-login-form, +body.customer-mobile-body .customer-login-mobile-row, +body.customer-mobile-body .customer-login-code-input.ant-input { + min-width: 0; +} + +body.customer-mobile-body .customer-auth-role-card, +body.customer-mobile-body .customer-auth-button-stack { + width: 100%; +} + +/* 登录/绑定二维码:容器与图片都不超过可用宽度,避免 232/252/260px 固定宽溢出 */ +body.customer-mobile-body .customer-auth-qr-image, +body.customer-mobile-body .customer-auth-qr-placeholder { + width: min(252px, 100%); + min-height: 0; + aspect-ratio: 1; +} + +body.customer-mobile-body .customer-auth-qr-image .ant-image, +body.customer-mobile-body .customer-auth-qr-image img, +body.customer-mobile-body .customer-binding-qr-card .ant-image, +body.customer-mobile-body .customer-binding-qr-card img { + max-width: 100%; + height: auto; +} + +/* 固定宽度弹窗(绑定确认 520 / 虎牙验证 430)在窄屏必须收到视口内 */ +@media (max-width: 640px) { + .customer-binding-modal, + .customer-huya-challenge-modal { + width: calc(100vw - 24px) !important; + max-width: 480px; + margin: 0 auto; + } + + .customer-binding-modal .ant-modal-content, + .customer-huya-challenge-modal .ant-modal-content { + max-height: calc(100vh - 32px); + overflow-y: auto; + } +} + +@media (max-width: 380px) { + body.customer-mobile-body .customer-binding-qr-actions, + body.customer-mobile-body .customer-binding-modal-actions { + grid-template-columns: minmax(0, 1fr); + } +} + +@media (max-width: 340px) { + body.customer-mobile-body .customer-collect-body { + padding-inline: 12px; + } + + /* 标签 + 长值改为上下排列,值不再被挤到屏幕外 */ + body.customer-mobile-body .customer-collect-card > div, + body.customer-mobile-body .customer-order-card > div { + flex-direction: column; + align-items: flex-start; + gap: 4px; + } + + body.customer-mobile-body .customer-collect-card > div strong, + body.customer-mobile-body .customer-order-card > div strong { + flex: 0 1 auto; + max-width: 100%; + justify-self: start; + text-align: left; + } + + body.customer-mobile-body .customer-order-card > div strong.customer-order-status { + flex: 0 0 auto; + text-align: center; + } + + body.customer-mobile-body .customer-collect-card > p { + text-align: left; + } + + body.customer-mobile-body .customer-login-mobile-row { + flex-direction: column; + gap: 10px; + } + + body.customer-mobile-body .customer-login-code-button.ant-btn { + width: 100%; + } + + body.customer-mobile-body .customer-auth-task-switcher { + flex-direction: column; + gap: 8px; + padding: 16px; + } + + body.customer-mobile-body .customer-auth-task-switcher > span { + padding-top: 0; + } + + body.customer-mobile-body .customer-auth-facts { + padding-inline: 12px; + } + + body.customer-mobile-body .customer-auth-facts > div { + grid-template-columns: minmax(0, 1fr); + gap: 4px; + min-height: 0; + padding-block: 12px; + } + + body.customer-mobile-body .customer-auth-facts > div > strong { + justify-self: start; + text-align: left; + } + + body.customer-mobile-body .customer-auth-state { + padding: 32px 16px; + } + + body.customer-mobile-body .customer-auth-privacy { + margin-inline: 16px; + } +} diff --git a/apps/frontend/src/styles/customer/order.css b/apps/frontend/src/styles/customer/order.css new file mode 100644 index 00000000..122ff4a5 --- /dev/null +++ b/apps/frontend/src/styles/customer/order.css @@ -0,0 +1,53 @@ +.customer-order-card { + margin: 10px 16px 0; + padding: 16px; + border: 1px solid #3a4150; + border-radius: 12px; + background: #212733; + display: flex; + flex-direction: column; + gap: 10px; +} + +.customer-order-card h3 { + margin: 0 0 4px; + color: #94a3b8; + font-size: 13px; + font-weight: 500; +} + +.customer-order-card > div { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 12px; + color: #cbd5e1; + font-size: 14px; + line-height: 1.5; +} + +.customer-order-card > div > span { + flex: 0 0 auto; + white-space: nowrap; + color: #9aa3b2; +} + +.customer-order-card > div strong { + flex: 1 1 auto; + min-width: 0; + color: #fff; + text-align: right; + overflow-wrap: anywhere; +} + +.customer-order-card > div strong.customer-order-status { + flex: 0 0 auto; + padding: 3px 12px; + border: 1px solid rgba(96, 165, 250, 0.38); + border-radius: 999px; + color: #dbeafe; + font-size: 13px; + font-weight: 600; + text-align: center; + background: rgba(47, 111, 237, 0.28); +} diff --git a/apps/frontend/src/styles/customer/platform/douyu.css b/apps/frontend/src/styles/customer/platform/douyu.css new file mode 100644 index 00000000..6f6ed284 --- /dev/null +++ b/apps/frontend/src/styles/customer/platform/douyu.css @@ -0,0 +1,563 @@ +/** 斗鱼客户领取页平台差异样式。 */ + +.customer-auth-page.is-douyu .customer-binding-qr-card { + padding: 18px; + color: var(--auth-text); + border: 1px solid #3a4150; + border-radius: 14px; + background: #202631; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035); +} + +.customer-auth-page.is-douyu .customer-binding-qr-card h3 { + color: #d7dee9; + font-size: 15px; + font-weight: 600; +} + +.customer-auth-page.is-douyu .customer-binding-qr-code { + width: min(100%, 292px); + aspect-ratio: 1; + display: grid; + place-items: center; + padding: 14px; + overflow: hidden; + border: 1px solid #4a5262; + border-radius: 12px; + background: #e8ebef; + box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22); +} + +.customer-auth-page.is-douyu .customer-binding-qr-code .ant-image, +.customer-auth-page.is-douyu .customer-binding-qr-code img { + width: 100%; + height: 100%; + display: block; + border-radius: 7px; +} + +.customer-auth-page.is-douyu .customer-auth-qr-placeholder { + width: 100%; + min-height: 100%; + color: #8f9aab; + border: 1px dashed #485162; + border-radius: 9px; + background: #171c24; +} + +.customer-auth-page.is-douyu .customer-binding-qr-hint { + max-width: 340px; + color: #b8c1cf; + font-size: 13px; + line-height: 1.6; + text-align: center; +} + +.customer-auth-page.is-douyu .customer-binding-qr-countdown { + color: #cbd5e1; + font-variant-numeric: tabular-nums; +} + +.customer-auth-page.is-douyu .customer-binding-qr-card .ant-progress { + width: min(100%, 292px); +} + +.customer-auth-page.is-douyu .customer-binding-qr-card .ant-progress-inner { + background: #353d4b; +} + +.customer-auth-page.is-douyu .customer-binding-qr-card .ant-progress-bg { + background: #f59e0b; +} + +.customer-auth-page.is-douyu .customer-binding-qr-actions .ant-btn { + color: #e2e8f0; + border-color: #465063; + background: #2a313d; + box-shadow: none; +} + +.customer-auth-page.is-douyu .customer-binding-qr-actions .ant-btn:hover, +.customer-auth-page.is-douyu .customer-binding-qr-actions .ant-btn:focus-visible { + color: #fff; + border-color: #657186; + background: #343c4a; +} + +.customer-auth-page.is-douyu .customer-binding-qr-toggle.ant-btn { + align-self: flex-end; + height: 34px; + padding-inline: 12px; + color: #b8c1cf; + border-color: #3f495a; + border-radius: 8px; + background: transparent; + font-size: 13px; + box-shadow: none; +} + +.customer-auth-page.is-douyu .customer-binding-qr-toggle.ant-btn:hover, +.customer-auth-page.is-douyu .customer-binding-qr-toggle.ant-btn:focus-visible { + color: #fff; + border-color: #64748b; + background: #2a313d; +} + +.customer-auth-page.is-douyu .customer-auth-hero { + min-height: 148px; + align-items: flex-end; + justify-content: center; + padding: 0 16px 18px; + background-color: #111827; + background-image: + linear-gradient(180deg, rgba(11, 18, 32, 0.08) 0%, rgba(11, 18, 32, 0.56) 68%, #232936 100%), + url('/images/customer/inside-kv.jpg'); + background-repeat: no-repeat; + background-position: center 38%; + background-size: cover; +} + +.customer-auth-page.is-douyu .customer-auth-brand { + width: auto; + align-items: flex-end; + justify-content: center; +} + +.customer-auth-page.is-douyu .customer-auth-brand h1 { + font-size: 16px; + line-height: 1.4; + text-align: center; + text-shadow: 0 2px 12px rgba(0, 0, 0, 0.82); +} + +.customer-auth-page.is-douyu .customer-auth-warning { + padding-top: 12px; +} + +.customer-auth-page.is-douyu .customer-order-closed-alert.ant-alert { + align-items: flex-start; + margin: 10px 16px 0; + padding: 12px 14px; + color: #f6c66f; + border: 1px solid #6b4d1f; + border-radius: 10px; + background: #2a2418; +} + +.customer-auth-page.is-douyu .customer-order-closed-alert .ant-alert-icon { + margin-top: 2px; + color: #f6ad3c; + font-size: 16px; +} + +.customer-auth-page.is-douyu .customer-order-closed-alert .ant-alert-message, +.customer-auth-page.is-douyu .customer-order-closed-alert .ant-alert-title { + color: #f7d394; + font-size: 14px; + font-weight: 600; + line-height: 1.4; +} + +.customer-auth-page.is-douyu .customer-order-closed-alert .ant-alert-description { + margin-top: 3px; + color: #d8c39b; + font-size: 13px; + line-height: 1.5; +} + +.customer-auth-page.is-douyu .customer-douyu-order-card { + padding: 0; + overflow: hidden; + gap: 0; + border-radius: 12px; + background: #202631; +} + +.customer-auth-page.is-douyu .customer-douyu-order-head { + align-items: center; + gap: 12px; + padding: 13px 16px; + border-bottom: 1px solid #343d4c; +} + +.customer-auth-page.is-douyu .customer-douyu-order-head h3 { + margin: 0; + color: #9aa3b2; + font-size: 13px; + font-weight: 600; +} + +.customer-auth-page.is-douyu .customer-douyu-order-field { + display: grid; + grid-template-columns: 72px minmax(0, 1fr); + align-items: start; + gap: 12px; + padding: 11px 16px; + border-bottom: 1px solid #343d4c; +} + +.customer-auth-page.is-douyu .customer-douyu-order-field:last-child { + border-bottom: 0; +} + +.customer-auth-page.is-douyu .customer-douyu-order-field > span { + color: #8f9aaa; + font-size: 13px; + line-height: 1.5; +} + +.customer-auth-page.is-douyu .customer-douyu-order-field > strong { + min-width: 0; + color: #f1f5f9; + font-size: 14px; + font-weight: 600; + line-height: 1.5; + text-align: right; + overflow-wrap: anywhere; +} + +.customer-auth-page.is-douyu .customer-douyu-order-status { + flex: 0 0 auto; + padding: 2px 10px; + border-color: rgba(96, 165, 250, 0.36); + color: #dbeafe; + font-size: 12px; + font-weight: 600; + background: rgba(47, 111, 237, 0.22); +} + +.customer-auth-page.is-douyu .customer-douyu-order-status.is-cancelled { + border-color: rgba(245, 158, 11, 0.38); + color: #f8d28a; + background: rgba(245, 158, 11, 0.14); +} + +.customer-auth-page.is-douyu .customer-douyu-order-status.is-completed { + border-color: rgba(52, 211, 153, 0.38); + color: #a7f3d0; + background: rgba(6, 95, 70, 0.24); +} + +.customer-auth-page.is-douyu .customer-douyu-order-status.is-failed { + border-color: rgba(248, 113, 113, 0.38); + color: #fecaca; + background: rgba(127, 29, 29, 0.24); +} + +.customer-douyu-qr-main { + width: 100%; + display: grid; + grid-template-columns: 30px minmax(0, 220px) 30px; + align-items: stretch; + justify-content: center; + gap: 7px; +} + +.customer-douyu-qr-rail { + display: flex; + align-items: center; + justify-content: center; + min-height: 0; + padding: 0; + color: #ff5a67; + font-size: 12px; + font-weight: 800; + line-height: 1.05; + letter-spacing: 1px; + text-align: center; + writing-mode: vertical-rl; + text-orientation: upright; + background: none; +} + +.customer-auth-page.is-douyu .customer-douyu-qr-main .customer-binding-qr-code { + width: 100%; + max-width: none; + padding: 10px; +} + +.customer-auth-page.is-douyu .customer-douyu-qr-preparing { + position: relative; + width: 100%; + height: 100%; + min-height: 100%; + display: grid; + place-items: center; + overflow: hidden; + border-radius: 7px; + background: #171c24; +} + +.customer-auth-page.is-douyu .customer-douyu-qr-skeleton { + position: absolute; + inset: 18px; + opacity: 0.16; + background-image: + linear-gradient(90deg, #9fb1ca 50%, transparent 50%), + linear-gradient(#9fb1ca 50%, transparent 50%); + background-position: + 0 0, + 0 0; + background-size: + 18px 18px, + 18px 18px; + -webkit-mask-image: linear-gradient(135deg, #000 12%, transparent 82%); + mask-image: linear-gradient(135deg, #000 12%, transparent 82%); +} + +.customer-auth-page.is-douyu .customer-douyu-qr-preparing-copy { + position: relative; + z-index: 1; + display: flex; + flex-direction: column; + align-items: center; + gap: 8px; + color: #b8c1cf; + text-align: center; +} + +.customer-auth-page.is-douyu .customer-douyu-qr-preparing-copy strong { + color: #e2e8f0; + font-size: 14px; + font-weight: 600; +} + +.customer-auth-page.is-douyu .customer-douyu-qr-preparing-copy span { + color: #8f9aaa; + font-size: 12px; +} + +.customer-auth-page.is-douyu .customer-douyu-preparing-button.ant-btn { + color: #e2e8f0; + border-color: #465063; + background: #2a313d; + box-shadow: none; +} + +.customer-auth-page.is-douyu .customer-douyu-preparing-button.ant-btn:hover, +.customer-auth-page.is-douyu .customer-douyu-preparing-button.ant-btn:focus-visible { + color: #fff; + border-color: #657186; + background: #343c4a; +} + +.customer-auth-page.is-douyu .customer-binding-qr-actions.is-single { + grid-template-columns: minmax(0, 1fr); +} + +.customer-auth-page.is-douyu .customer-binding-qr-actions .ant-btn:disabled { + color: #7d8797; + border-color: #394353; + background: #252c37; + opacity: 1; +} + +.customer-auth-page.is-douyu .customer-binding-qr-countdown.is-expired { + color: #ff7a84; + font-weight: 700; +} + +.customer-auth-page.is-douyu .customer-douyu-qr-refresh-note { + margin: -2px 0 0; + color: #8f9aaa; + font-size: 11px; + line-height: 1.4; + text-align: center; +} + +.customer-auth-page.is-douyu .customer-douyu-binding-alert.is-wechat { + border-color: rgba(248, 113, 113, 0.34); + background: linear-gradient(135deg, rgba(127, 29, 29, 0.26), rgba(32, 38, 49, 0.9)); +} + +.customer-auth-page.is-douyu .customer-douyu-binding-alert.is-wechat .ant-alert-icon, +.customer-auth-page.is-douyu .customer-douyu-binding-alert.is-wechat .ant-alert-message, +.customer-auth-page.is-douyu .customer-douyu-binding-alert.is-wechat .ant-alert-title { + color: #ff8a92; +} + +.customer-douyu-binding-failure { + display: flex; + flex-direction: column; + gap: 10px; +} + +.customer-douyu-binding-failure > p { + margin: 0; + padding: 12px 14px; + color: #fecaca; + font-size: 13px; + line-height: 1.6; + text-align: center; + border: 1px solid rgba(248, 113, 113, 0.3); + border-radius: 10px; + background: rgba(127, 29, 29, 0.18); +} + +.customer-auth-page.is-douyu.is-compact { + height: 100vh; + height: 100dvh; + min-height: 0; + overflow: hidden; +} + +.customer-auth-page.is-douyu.is-compact .customer-auth-shell { + height: 100%; + display: flex; + flex-direction: column; +} + +.customer-auth-page.is-douyu.is-compact .customer-auth-hero { + min-height: 148px; + padding: 0 16px 18px; + background-position: center 34%; +} + +.customer-auth-page.is-douyu.is-compact .customer-auth-warning { + padding: 8px 16px 12px; + font-size: 14px; +} + +.customer-auth-page.is-douyu.is-compact .customer-auth-main { + display: flex; + flex-direction: column; + flex: 1 1 auto; + min-height: 0; + padding-bottom: 0; + overflow: hidden; +} + +.customer-auth-page.is-douyu.is-compact .customer-douyu-order-card { + flex: none; + margin: 10px 16px 0; +} + +.customer-auth-page.is-douyu.is-compact .customer-douyu-order-head { + padding: 13px 16px; +} + +.customer-auth-page.is-douyu.is-compact .customer-douyu-order-field { + grid-template-columns: 72px minmax(0, 1fr); + gap: 12px; + padding: 11px 16px; +} + +.customer-auth-page.is-douyu.is-compact .customer-douyu-order-field > span, +.customer-auth-page.is-douyu.is-compact .customer-douyu-order-field > strong { + font-size: 14px; + line-height: 1.5; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-stage { + flex: 1 1 auto; + min-height: 0; + justify-content: center; + gap: 14px; + padding: 16px; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-stage .ant-alert { + flex: none; + padding: 12px 14px; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-stage .ant-alert-description { + margin-top: 4px; + font-size: 13px; + line-height: 1.6; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-qr-card { + flex: 0 1 auto; + justify-content: center; + gap: 10px; + padding: 18px; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-qr-card h3 { + font-size: 15px; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-qr-hint { + font-size: 13px; + line-height: 1.6; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-qr-countdown { + font-size: 13px; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-qr-card .ant-progress { + line-height: 1.5; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-qr-actions { + margin-top: 4px; +} + +.customer-auth-page.is-douyu.is-compact .customer-binding-qr-actions .ant-btn { + height: 40px; + font-size: 14px; +} + +@media (max-height: 720px) { + .customer-auth-page.is-douyu.is-compact .customer-auth-hero { + min-height: 60px; + padding-bottom: 6px; + } + + .customer-auth-page.is-douyu.is-compact .customer-auth-warning { + padding-block: 1px 4px; + font-size: 11px; + } + + .customer-auth-page.is-douyu.is-compact .customer-douyu-order-head { + padding-block: 6px; + } + + .customer-auth-page.is-douyu.is-compact .customer-douyu-order-field { + padding-block: 5px; + } + + .customer-auth-page.is-douyu.is-compact .customer-binding-stage { + justify-content: flex-start; + gap: 6px; + padding-block: 6px; + } + + .customer-auth-page.is-douyu.is-compact .customer-binding-stage .ant-alert-description { + display: none; + } + + .customer-auth-page.is-douyu.is-compact .customer-binding-qr-card { + gap: 4px; + padding-block: 7px; + } + + .customer-auth-page.is-douyu.is-compact .customer-douyu-qr-main { + grid-template-columns: 26px minmax(0, clamp(154px, 30dvh, 190px)) 26px; + gap: 5px; + } + + .customer-auth-page.is-douyu.is-compact .customer-douyu-qr-rail { + font-size: 10px; + } +} + +.customer-auth-page.is-douyu .customer-collect-submit.ant-btn { + height: 48px; + margin-top: 14px; + color: #fff !important; + border-color: #2f6fed !important; + border-radius: 10px; + background: #2f6fed !important; + font-size: 15px; + font-weight: 700; +} + +.customer-auth-page.is-douyu .customer-collect-submit.ant-btn:hover, +.customer-auth-page.is-douyu .customer-collect-submit.ant-btn:focus-visible { + color: #fff !important; + border-color: #4a83ff !important; + background: #4a83ff !important; +} diff --git a/apps/frontend/src/styles/customer/platform/huya.css b/apps/frontend/src/styles/customer/platform/huya.css new file mode 100644 index 00000000..33170bcf --- /dev/null +++ b/apps/frontend/src/styles/customer/platform/huya.css @@ -0,0 +1,221 @@ +/** 虎牙客户安全验证样式。 */ + +.customer-huya-steps { + display: flex; + gap: 8px; + margin: 12px 16px 0; + padding: 12px 14px; + list-style: none; + border: 1px solid #3a4150; + border-radius: 12px; + background: #1b212c; +} + +.customer-huya-step { + display: flex; + flex: 1 1 0; + align-items: center; + gap: 7px; + min-width: 0; + color: #64748b; + font-size: 13px; + line-height: 1.3; +} + +.customer-huya-step-index { + display: inline-flex; + flex: 0 0 auto; + align-items: center; + justify-content: center; + width: 22px; + height: 22px; + border: 1px solid #3a4150; + border-radius: 50%; + color: #94a3b8; + font-size: 12px; + font-weight: 600; + background: #212733; +} + +.customer-huya-step-label { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.customer-huya-step.is-active { + color: #f8fafc; + font-weight: 600; +} + +.customer-huya-step.is-active .customer-huya-step-index { + color: #fff; + border-color: #2563eb; + background: #2563eb; + box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); +} + +.customer-huya-step.is-done { + color: #6ee7b7; +} + +.customer-huya-step.is-done .customer-huya-step-index { + color: #6ee7b7; + border-color: #065f46; + background: rgba(6, 78, 59, 0.4); +} + +@media (max-width: 640px) { + .customer-huya-steps { + gap: 6px; + margin: 10px 16px 0; + padding: 10px 12px; + } + + .customer-huya-step { + gap: 5px; + font-size: 11px; + } + + .customer-huya-step-index { + width: 19px; + height: 19px; + font-size: 10px; + } +} + +.huya-slider-challenge { + display: flex; + flex-direction: column; + gap: 14px; +} + +.huya-slider-challenge > p { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: 6px 12px; + margin: 0; + color: #475569; + font-size: 14px; + line-height: 1.65; +} + +.huya-challenge-progress { + color: #c2410c; + font-size: 12px; + font-weight: 700; +} + +.huya-click-tip { + display: block; + max-width: 100%; + max-height: 64px; + object-fit: contain; +} + +.huya-slider-stage { + position: relative; + width: 100%; + overflow: hidden; + border: 1px solid rgba(148, 163, 184, 0.36); + border-radius: 8px; + background: #e2e8f0; + user-select: none; +} + +.huya-slider-stage.is-click { + cursor: crosshair; +} + +.huya-slider-background, +.huya-slider-puzzle { + pointer-events: none; + user-select: none; +} + +.huya-slider-puzzle.is-rotate { + transform-origin: center; +} + +.huya-click-point { + position: absolute; + display: grid; + width: 24px; + height: 24px; + place-items: center; + color: #fff; + font-size: 12px; + font-weight: 700; + border: 2px solid #fff; + border-radius: 50%; + background: #ea580c; + box-shadow: 0 2px 8px rgba(15, 23, 42, 0.32); + transform: translate(-50%, -50%); + pointer-events: none; +} + +.huya-slider-background { + display: block; + width: 100%; + height: 100%; +} + +.huya-slider-puzzle { + position: absolute; + max-width: none; + height: auto; +} + +.huya-slider-track { + position: relative; + height: 46px; + overflow: hidden; + border: 1px solid rgba(148, 163, 184, 0.36); + border-radius: 8px; + background: #f1f5f9; + touch-action: none; +} + +.huya-slider-track-fill { + position: absolute; + inset: 0 auto 0 0; + max-width: 100%; + background: rgba(249, 115, 22, 0.16); +} + +.huya-slider-handle { + position: absolute; + top: 3px; + left: 3px; + width: 58px; + height: 38px; + padding: 0; + color: #111827; + font-size: 13px; + font-weight: 700; + border: 0; + border-radius: 6px; + background: #f97316; + cursor: grab; + touch-action: none; +} + +.huya-slider-handle:active { + cursor: grabbing; +} + +.huya-rotate-control { + display: grid; + grid-template-columns: minmax(0, 1fr) 48px; + gap: 12px; + align-items: center; +} + +.huya-rotate-control > span { + color: #475569; + font-size: 13px; + font-variant-numeric: tabular-nums; + text-align: right; +} diff --git a/apps/frontend/src/styles/customer/platform/weibo.css b/apps/frontend/src/styles/customer/platform/weibo.css new file mode 100644 index 00000000..d071f920 --- /dev/null +++ b/apps/frontend/src/styles/customer/platform/weibo.css @@ -0,0 +1,11 @@ +/** 微博客户领取页平台差异样式。 */ + +.customer-auth-page.is-weibo .customer-auth-brand { + width: 100%; + justify-content: flex-start; +} + +.customer-auth-page.is-weibo .customer-auth-brand h1 { + text-align: left; + text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72); +} diff --git a/apps/frontend/src/styles/customer/profile.css b/apps/frontend/src/styles/customer/profile.css new file mode 100644 index 00000000..e78575ac --- /dev/null +++ b/apps/frontend/src/styles/customer/profile.css @@ -0,0 +1,234 @@ +/* 客户资料页(图 1) */ +.customer-collect-page { + min-height: 100vh; + background: #0b1220; + color: #e5e7eb; +} + +/* 资料页顶部 KV:原图 https://game.gtimg.cn/images/gp/web201908/inside_kv.jpg(本地 1600×510 q82) */ +.customer-collect-hero { + position: relative; + min-height: clamp(132px, 18vw, 160px); + display: flex; + align-items: flex-end; + justify-content: center; + padding: 0 18px 12px; + overflow: hidden; + text-align: center; + background-color: #0b1220; + background-image: + linear-gradient(180deg, rgba(11, 18, 32, 0) 38%, rgba(11, 18, 32, 0.55) 72%, #0b1220 100%), + url('/images/customer/inside-kv.jpg'); + background-repeat: no-repeat; + background-position: center 40%; + background-size: cover; +} + +.customer-collect-warning { + margin: 0; + text-align: center; + color: #f87171; + font-size: 17px; + font-weight: 600; + text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); +} + +@media (max-width: 640px) { + .customer-collect-hero { + min-height: 132px; + padding: 0 16px 12px; + background-position: center 42%; + } + + .customer-collect-warning { + font-size: 15px; + } +} + +.customer-collect-body { + max-width: 560px; + margin: 0 auto; + padding: 24px 20px 48px; + display: flex; + flex-direction: column; + gap: 12px; +} + +.customer-collect-label { + margin-top: 8px; + color: #e5e7eb; + font-size: 15px; + line-height: 1.4; +} + +.customer-collect-label span { + color: #f87171; +} + +.customer-collect-readonly { + height: 48px; + display: flex; + align-items: center; + padding: 0 16px; + border-radius: 12px; + background: #1b2436; + border: 1px solid #26344d; + color: #94a3b8; + font-size: 15px; +} + +.customer-collect-card { + margin: 10px 0; + padding: 16px; + border-radius: 12px; + border: 1px solid #1e2f4a; + background: #141d30; + display: flex; + flex-direction: column; + gap: 12px; +} + +.customer-collect-card > div { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 12px; + color: #cbd5e1; + font-size: 15px; + line-height: 1.5; +} + +.customer-collect-card > div > span { + flex: 0 0 auto; + white-space: nowrap; +} + +.customer-collect-card > div strong { + flex: 1 1 auto; + min-width: 0; + color: #fff; + font-weight: 600; + text-align: right; + overflow-wrap: anywhere; +} + +.customer-collect-card > p { + margin: 6px 0 0; + color: #fbbf24; + font-size: 13px; + text-align: center; +} + +.customer-collect-input.ant-input { + height: 48px; + border-radius: 12px; + background: #1b2436; + border-color: #26344d; + color: #fff; +} + +.customer-collect-input.ant-input::placeholder { + color: #64748b; +} + +.customer-collect-select.ant-select { + width: 100%; + height: 48px; + padding-inline: 16px; + align-items: center; + font-size: 15px; + border-radius: 12px; + border: 1px solid #26344d; + background: #1b2436; + color: #fff; + --ant-select-height: 48px; + --ant-select-border-radius: 12px; + --ant-select-border-color: #26344d; + --ant-select-background-color: #1b2436; + --ant-select-color: #fff; + --ant-select-hover-border-color: #3b4d6b; + --ant-select-active-border-color: #2563eb; + --ant-select-active-outline-color: rgba(37, 99, 235, 0.2); +} + +.customer-collect-select.ant-select:hover { + border-color: #3b4d6b; +} + +.customer-collect-select.ant-select.ant-select-focused { + border-color: #2563eb; + box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); +} + +.customer-collect-select .ant-select-content { + align-items: center; +} + +.customer-collect-select .ant-select-selection-item { + color: #fff; + line-height: 1.5; +} + +.customer-collect-select .ant-select-placeholder { + color: #64748b; +} + +.customer-collect-select .ant-select-suffix { + color: #94a3b8; +} + +.ant-select-dropdown.customer-collect-dropdown { + padding: 6px; + border-radius: 12px; + background: #141d30; + box-shadow: 0 14px 34px rgba(2, 6, 23, 0.55); + --ant-select-option-active-bg: #1b2436; + --ant-select-option-selected-bg: #1e3a8a; + --ant-select-option-selected-color: #fff; +} + +.customer-collect-dropdown .ant-select-item { + border-radius: 8px; + color: #cbd5e1; +} + +.customer-collect-dropdown .ant-select-item-option-active { + background: #1b2436 !important; + color: #fff; +} + +.customer-collect-dropdown .ant-select-item-option-selected { + background: #1e3a8a !important; + color: #fff; + font-weight: 600; +} + +.customer-collect-page .customer-collect-submit.ant-btn, +.customer-auth-profile .customer-collect-submit.ant-btn { + height: 52px; + margin-top: 14px; + border-radius: 14px; + font-size: 17px; + font-weight: 600; + --ant-btn-bg-color: #2563eb; + --ant-btn-bg-color-hover: #1d4ed8; + --ant-btn-bg-color-active: #1e40af; + --ant-btn-text-color: #fff; + --ant-btn-text-color-hover: #fff; + --ant-btn-text-color-active: #fff; + --ant-btn-border-color: #2563eb; + --ant-btn-border-color-hover: #1d4ed8; + --ant-btn-border-color-active: #1e40af; + background: #2563eb !important; + border-color: #2563eb !important; + color: #fff !important; +} + +.customer-collect-page .customer-collect-submit.ant-btn:hover, +.customer-collect-page .customer-collect-submit.ant-btn:focus-visible, +.customer-auth-profile .customer-collect-submit.ant-btn:hover, +.customer-auth-profile .customer-collect-submit.ant-btn:focus-visible { + background: #1d4ed8 !important; + border-color: #1d4ed8 !important; + color: #fff !important; +} diff --git a/apps/frontend/src/styles/customer/responsive.css b/apps/frontend/src/styles/customer/responsive.css new file mode 100644 index 00000000..31ece25f --- /dev/null +++ b/apps/frontend/src/styles/customer/responsive.css @@ -0,0 +1,162 @@ +@media (max-width: 640px) { + .customer-auth-page { + height: auto; + min-height: 100vh; + overflow: visible; + padding: 0; + background: var(--auth-panel); + } + + .customer-auth-shell { + width: 100%; + height: auto; + display: block; + border: 0; + border-radius: 0; + box-shadow: none; + } + + .customer-auth-hero { + min-height: 112px; + padding: 12px 16px 14px; + background-position: center 42%; + } + + .customer-auth-brand h1 { + font-size: 20px; + } + + .customer-auth-warning { + padding: 6px 16px 10px; + font-size: 14px; + } + + .customer-auth-main { + overflow: visible; + } + + .customer-auth-content-stack { + height: auto; + min-height: 0; + } + + .customer-auth-facts { + padding-inline: 20px; + } + + .customer-auth-facts > div { + grid-template-columns: 92px minmax(0, 1fr); + gap: 12px; + min-height: 52px; + padding-block: 8px; + } + + .customer-auth-facts > div > span { + font-size: 13px; + } + + .customer-auth-facts > div > strong { + font-size: 15px; + line-height: 1.35; + } + + .customer-auth-section { + padding: 16px; + } + + .customer-auth-section-copy h2, + .customer-auth-state h2 { + font-size: 20px; + } + + .customer-auth-section-copy p, + .customer-auth-state p, + .customer-auth-form-copy { + font-size: 13px; + line-height: 1.5; + } + + .customer-auth-tabs { + margin-top: 0; + } + + .customer-auth-tabs .ant-tabs-nav { + margin-bottom: 10px; + } + + .customer-auth-tabs .ant-tabs-nav-list { + gap: 4px; + padding: 4px; + } + + .customer-auth-tabs .ant-tabs-tab { + padding: 9px 14px; + } + + .customer-auth-tabs .ant-tabs-tab-btn { + font-size: 15px; + } + + .customer-auth-form { + gap: 10px; + padding-top: 0; + } + + .customer-auth-field { + min-height: 44px; + border-radius: 9px; + } + + .customer-auth-phone-field { + grid-template-columns: 50px minmax(0, 1fr) 104px; + } + + .customer-auth-code-field { + grid-template-columns: minmax(0, 1fr) 104px; + } + + .customer-auth-field .ant-select, + .customer-auth-field .ant-select-selector, + .customer-auth-field .ant-input, + .customer-auth-field .ant-input-affix-wrapper { + height: 44px; + } + + .customer-auth-field .ant-select-selection-item { + line-height: 42px !important; + } + + .customer-auth-field .ant-input-affix-wrapper { + padding-inline: 12px; + } + + .customer-auth-code-field { + padding: 4px; + } + + .customer-auth-code-submit { + height: 36px !important; + } + + .customer-auth-send-code { + height: 36px !important; + } + + .customer-auth-form-hint { + font-size: 10px; + line-height: 1.35; + } + + .customer-auth-qr-image, + .customer-auth-qr-placeholder { + width: 232px; + min-height: 232px; + } + + .customer-auth-privacy { + margin: 8px 16px 12px; + padding: 8px 12px; + font-size: 12px; + line-height: 1.45; + } +} diff --git a/apps/frontend/src/styles/customer/status.css b/apps/frontend/src/styles/customer/status.css new file mode 100644 index 00000000..dcf8972f --- /dev/null +++ b/apps/frontend/src/styles/customer/status.css @@ -0,0 +1,106 @@ +.customer-auth-button-stack { + width: min(100%, 580px); + display: flex; + flex-direction: column; + gap: 12px; +} + +.customer-auth-button-stack .ant-btn, +.customer-auth-form > .ant-btn { + height: 52px; + font-size: 17px; +} + +.customer-auth-status-pill { + display: inline-flex; + align-items: center; + justify-content: center; + min-height: 34px; + padding: 4px 15px; + color: #fff; + font-size: 15px !important; + font-weight: 600 !important; + text-align: center; + border-radius: 999px; + background: #3169aa; +} + +.customer-auth-status-pill.is-pending, +.customer-auth-status-pill.is-scanned { + background: #3a6fa8; +} + +.customer-auth-status-pill.is-success { + background: #237a57; +} + +.customer-auth-status-pill.is-danger { + background: #a33a48; +} + +.customer-auth-state { + display: flex; + flex-direction: column; + align-items: center; + gap: 12px; + padding: 48px 26px; + text-align: center; +} + +.customer-auth-state h2 { + margin: 0; +} + +.customer-auth-state p { + max-width: 560px; +} + +.customer-auth-state-icon { + width: 58px; + height: 58px; + display: grid; + place-items: center; + color: var(--auth-accent); + font-size: 29px; + border: 1px solid rgba(255, 255, 255, 0.16); + border-radius: 50%; + background: rgba(255, 255, 255, 0.045); +} + +.customer-auth-state.is-success .customer-auth-state-icon { + color: #52d39a; +} + +.customer-auth-state.is-error .customer-auth-state-icon { + color: #ff6975; +} + +.customer-auth-state-time { + color: var(--auth-muted); + font-size: 12px; +} + +.customer-auth-loading { + min-height: 240px; + display: grid; + place-items: center; + align-content: center; + gap: 14px; + color: var(--auth-muted); +} + +.customer-auth-privacy { + margin: 24px 26px 28px; + padding: 14px 18px; + color: #d8b46a; + font-size: 14px; + line-height: 1.65; + text-align: center; + border: 1px solid rgba(216, 180, 106, 0.64); + border-radius: 5px; + background: rgba(0, 0, 0, 0.08); +} + +.customer-auth-page .ant-spin-dot-item { + background: var(--auth-accent); +} diff --git a/apps/frontend/src/styles/main.css b/apps/frontend/src/styles/main.css index fc728f8c..41af16a5 100644 --- a/apps/frontend/src/styles/main.css +++ b/apps/frontend/src/styles/main.css @@ -3,12 +3,18 @@ * 按业务模块拆分,便于维护与多人协作开发: * 1. base.css - 全局主题变量、基础排版、重置、通用工具类 * 2. admin.css - 后台管理端 (Admin Portal & Login) - * 3. client.css - 买家前台提卡与聚合页 (Buyer Claim & Collect) - * 4. worker.css - 打手接单端 PC 与移动端 (Worker Portal & Mobile) + * 3. client.css - 买家提卡、补资料与兑换页样式入口 + * 4. customer/ - 客户领取页公共流程及平台差异 + * 5. worker.css - 打手接单端 PC 与移动端 (Worker Portal & Mobile) */ @import './base.css'; @import './admin.css'; @import './client.css'; +@import './customer/base.css'; +@import './customer/platform/huya.css'; +@import './customer/platform/weibo.css'; +@import './customer/platform/douyu.css'; +@import './customer/mobile.css'; @import './worker.css'; @import './table.css'; diff --git a/apps/frontend/src/types/admin/cost-center.ts b/apps/frontend/src/types/admin/cost-center.ts index 122490b5..63eb7d7e 100644 --- a/apps/frontend/src/types/admin/cost-center.ts +++ b/apps/frontend/src/types/admin/cost-center.ts @@ -432,6 +432,7 @@ export interface ManualFulfillmentConfig { enabled: boolean semiAutoEnabled: boolean semiAutoPlatform: '' | 'huya' | 'weibo' + douyuFulfillmentEnabled: boolean semiAutoConfig: { pageTitle?: string pageDescription?: string diff --git a/apps/frontend/src/types/douyu-fulfillment.ts b/apps/frontend/src/types/douyu-fulfillment.ts new file mode 100644 index 00000000..68c38552 --- /dev/null +++ b/apps/frontend/src/types/douyu-fulfillment.ts @@ -0,0 +1,91 @@ +export type DouyuCustomerPlatform = 'wechat' | 'qq' +export type DouyuCustomerSystem = 'ios' | 'android' + +export type DouyuFulfillmentTask = { + id: number + order_id: number + order_item_id: number + fulfillment_id: number | null + live_session_id: number | null + status: string + customer_role_name: string + customer_platform: string + customer_system: string + binding_phase: string + live_execution_status: string + live_binding_status: string + issue_code: string + last_error: string + bound_role_name: string + bound_area_name: string + bound_plat_name: string + customer_link_opened_at: string | null + binding_started_at: string | null + bound_at: string | null + completed_at: string | null + last_synced_at: string | null + created_at: string + updated_at: string + platform_order_id: string + sku_code: string + sku_name: string + quantity: number + product_name: string + fulfillment_status: string + linkPath: string +} + +export type DouyuLiveBindingState = { + sessionId: number + platformOrderId: string + sourceOrderItemId: string + productName: string + quantity: number + executionStatus: string + bindingStatus: string + exchangeStatus: string + issueCode: string + message: string + accountReady: boolean + bindTaskId: number | null + bindTaskStatus: string + bindPhase: string + qrUrl: string + qrGeneratedAt: string + qrExpiresAt: string + roleName: string + areaName: string + platName: string + bindReadyForConfirm: boolean + bindConfirmed: boolean + customerProfileReset?: boolean + resetReason?: string + completedAt: string | null + updatedAt: string +} + +export type DouyuRoleComparison = { + matched: boolean + roleMatched: boolean + channelMatched: boolean + message: string +} + +export type DouyuCustomerFulfillment = { + task: DouyuFulfillmentTask + live: DouyuLiveBindingState + comparison: DouyuRoleComparison + linkPath: string +} + +export type DouyuFulfillmentEvent = { + id: number + event_type: string + actor_type: string + detail_json: Record + created_at: string +} + +export type DouyuFulfillmentDetail = DouyuCustomerFulfillment & { + events: DouyuFulfillmentEvent[] +} diff --git a/apps/frontend/src/utils/customer-fulfillment-link.ts b/apps/frontend/src/utils/customer-fulfillment-link.ts index 295a3c91..c1535659 100644 --- a/apps/frontend/src/utils/customer-fulfillment-link.ts +++ b/apps/frontend/src/utils/customer-fulfillment-link.ts @@ -20,6 +20,21 @@ export function isCustomerFulfillmentPath(pathname: unknown): boolean { return first === 'c' || first === 'd' } +/** 斗鱼客户领取入口:/coll/d/:orderNo。 */ +export function buildDouyuFulfillmentPath(orderNo: unknown): string { + const normalizedOrderNo = String(orderNo || '').trim() + return normalizedOrderNo ? `/coll/d/${encodeURIComponent(normalizedOrderNo)}` : '' +} + +export function isDouyuFulfillmentPath(pathname: unknown): boolean { + const parts = String(pathname || '') + .trim() + .split(/[?#]/)[0] + .split('/') + .filter(Boolean) + return parts[0] === 'coll' && parts[1] === 'd' +} + /** * 严格绑定下的自动归一化:当前路径对应平台没有任务、但订单只有另一个平台任务时, * 返回应跳转的平台;双平台订单返回 null(各路径只展示自己的任务), diff --git a/apps/frontend/tests/customer-fulfillment-binding-compare.test.ts b/apps/frontend/tests/customer-fulfillment-binding-compare.test.ts index 55ddcda7..619eb758 100644 --- a/apps/frontend/tests/customer-fulfillment-binding-compare.test.ts +++ b/apps/frontend/tests/customer-fulfillment-binding-compare.test.ts @@ -9,7 +9,7 @@ const source = readFileSync( join(root, '../src/pages/customer-fulfillment/CustomerFulfillmentPage.tsx'), 'utf8', ) -const styles = readFileSync(join(root, '../src/styles/client.css'), 'utf8') +const styles = readFileSync(join(root, '../src/styles/customer/binding.css'), 'utf8') test('资料不一致时不自动弹核对框,由页面两个按钮处理', () => { assert.ok(source.includes("if (bindingInfo.comparison.verdict !== 'match') return")) diff --git a/apps/frontend/tests/customer-fulfillment-link.test.ts b/apps/frontend/tests/customer-fulfillment-link.test.ts index 4b724053..5838cd68 100644 --- a/apps/frontend/tests/customer-fulfillment-link.test.ts +++ b/apps/frontend/tests/customer-fulfillment-link.test.ts @@ -3,8 +3,10 @@ import { readFile } from 'node:fs/promises' import test from 'node:test' import { + buildDouyuFulfillmentPath, buildCustomerFulfillmentPath, isCustomerFulfillmentPath, + isDouyuFulfillmentPath, resolveCustomerPlatformRedirect, } from '../src/utils/customer-fulfillment-link.ts' @@ -29,6 +31,15 @@ test('客户半自动履约入口不误伤相似前缀和其他路径', () => { assert.equal(isCustomerFulfillmentPath('d/1'), false) }) +test('斗鱼领取入口固定为 /coll/d/订单号', () => { + assert.equal(buildDouyuFulfillmentPath('DY-001'), '/coll/d/DY-001') + assert.equal(buildDouyuFulfillmentPath(''), '') + assert.equal(isDouyuFulfillmentPath('/coll/d/DY-001'), true) + assert.equal(isDouyuFulfillmentPath('/coll/d/DY-001?from=chat'), true) + assert.equal(isDouyuFulfillmentPath('/coll/other/DY-001'), false) + assert.equal(isDouyuFulfillmentPath('/admin/coll/d/DY-001'), false) +}) + test('按平台生成客户链接:虎牙 /c、微博 /d', () => { assert.equal( buildCustomerFulfillmentPath('INTSA1794902905684_360848', 'huya'), @@ -80,6 +91,7 @@ test('客户页路由与严格绑定接线', async () => { assert.match(page, /resolveCustomerPlatformRedirect/) assert.match(page, /buildCustomerFulfillmentPath/) assert.match(page, /task\.platform === expectedPlatform/) + assert.match(app, /path="\/coll\/d\/:orderNo"/) }) test('开发 Mock 页按平台重新生成客户路径', async () => { diff --git a/apps/frontend/tests/customer-fulfillment-mobile.test.ts b/apps/frontend/tests/customer-fulfillment-mobile.test.ts index c262210e..81242655 100644 --- a/apps/frontend/tests/customer-fulfillment-mobile.test.ts +++ b/apps/frontend/tests/customer-fulfillment-mobile.test.ts @@ -15,7 +15,7 @@ function source(relativePath: string) { test('客户履约页必须覆盖 body 320px 最小宽度并使用 480px 移动端壳', async () => { const [app, css] = await Promise.all([ readFile(source('App.tsx'), 'utf8'), - readFile(source('styles/client.css'), 'utf8'), + readFile(source('styles/customer/mobile.css'), 'utf8'), ]) assert.match(app, /customer-mobile-html/) @@ -38,7 +38,7 @@ test('客户履约页固定宽度弹窗必须收进手机视口', async () => { const [page, huya, css] = await Promise.all([ readFile(source('pages/customer-fulfillment/CustomerFulfillmentPage.tsx'), 'utf8'), readFile(source('pages/customer-fulfillment/HuyaChallengeModal.tsx'), 'utf8'), - readFile(source('styles/client.css'), 'utf8'), + readFile(source('styles/customer/mobile.css'), 'utf8'), ]) assert.match(page, /className="customer-binding-modal"/) diff --git a/apps/frontend/tests/customer-fulfillment-weibo-ui.test.ts b/apps/frontend/tests/customer-fulfillment-weibo-ui.test.ts index 6bce0e2b..b536a67a 100644 --- a/apps/frontend/tests/customer-fulfillment-weibo-ui.test.ts +++ b/apps/frontend/tests/customer-fulfillment-weibo-ui.test.ts @@ -11,8 +11,12 @@ const source = readFileSync( ), 'utf8', ) -const styles = readFileSync( - join(dirname(fileURLToPath(import.meta.url)), '../src/styles/client.css'), +const layoutStyles = readFileSync( + join(dirname(fileURLToPath(import.meta.url)), '../src/styles/customer/layout.css'), + 'utf8', +) +const weiboStyles = readFileSync( + join(dirname(fileURLToPath(import.meta.url)), '../src/styles/customer/platform/weibo.css'), 'utf8', ) @@ -53,10 +57,10 @@ test('微博订单卡只展示订单号/商品/平台/状态,不含游戏和 test('客户登录/绑定页顶部统一显示 inside-kv 背景,不再按平台区分', () => { assert.match( - styles, + layoutStyles, /\.customer-auth-hero \{[^}]*url\('\/images\/customer\/inside-kv\.jpg'\)[^}]*\}/s, ) - assert.ok(!styles.includes('.customer-auth-page.is-weibo .customer-auth-hero')) - assert.ok(!styles.includes('.customer-auth-page.is-huya .customer-auth-hero')) - assert.ok(styles.includes('.customer-auth-page.is-weibo .customer-auth-brand')) + assert.ok(!weiboStyles.includes('.customer-auth-page.is-weibo .customer-auth-hero')) + assert.ok(!layoutStyles.includes('.customer-auth-page.is-huya .customer-auth-hero')) + assert.ok(weiboStyles.includes('.customer-auth-page.is-weibo .customer-auth-brand')) }) diff --git a/dev.sh b/dev.sh new file mode 100755 index 00000000..a1d12a5c --- /dev/null +++ b/dev.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +COMPOSE_FILE="${ROOT_DIR}/docker-compose.dev.yml" +LOG_TAIL="${DEV_LOG_TAIL:-120}" + +follow_app_logs() { + printf '\n[dev] 跟踪 backend / frontend / web 日志(Ctrl+C 只退出日志,不停止容器)\n' + docker compose -f "${COMPOSE_FILE}" logs -f --tail="${LOG_TAIL}" backend frontend web +} + +case "${1:-}" in + up|start) + exec bash "${ROOT_DIR}/deploy/mac-dev.sh" + ;; + logs) + shift + if [[ $# -eq 0 ]]; then + set -- backend frontend web + fi + exec docker compose -f "${COMPOSE_FILE}" logs -f --tail="${LOG_TAIL}" "$@" + ;; + down|stop) + exec docker compose -f "${COMPOSE_FILE}" down + ;; + ps|status) + exec docker compose -f "${COMPOSE_FILE}" ps + ;; + "") + bash "${ROOT_DIR}/deploy/mac-dev.sh" + follow_app_logs + ;; + *) + exec bash "${ROOT_DIR}/deploy/mac-dev.sh" "$@" + ;; +esac diff --git a/docker-compose.yml b/docker-compose.yml index 7112f9f5..e3b04ae3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -141,6 +141,8 @@ services: SEMI_AUTO_CONNECTOR_API_KEY: ${SEMI_AUTO_CONNECTOR_API_KEY:-} SEMI_AUTO_DEFAULT_CONNECTOR_MODE: ${SEMI_AUTO_DEFAULT_CONNECTOR_MODE:-embedded} SEMI_AUTO_CONNECTOR_TIMEOUT_MS: ${SEMI_AUTO_CONNECTOR_TIMEOUT_MS:-15000} + LIVE_HUB_PLATFORM_FULFILLMENT_URL: ${LIVE_HUB_PLATFORM_FULFILLMENT_URL:-http://host.docker.internal:8800} + PLATFORM_FULFILLMENT_INTEGRATION_KEY: ${PLATFORM_FULFILLMENT_INTEGRATION_KEY:-} logging: *json-log-rotation volumes: - ./apps/backend/data:/app/data diff --git a/docs/斗鱼客户领取与角色绑定.md b/docs/斗鱼客户领取与角色绑定.md new file mode 100644 index 00000000..18b50507 --- /dev/null +++ b/docs/斗鱼客户领取与角色绑定.md @@ -0,0 +1,79 @@ +# 斗鱼客户领取与角色绑定 + +更新时间:2026-11-17 + +## 入口 + +客户领取链接固定为: + +```text +<域名>/coll/d/<订单号> +``` + +例如: + +```text +https://order.khhao.com/coll/d/COLLD-E2E-001 +``` + +## 职责 + +- `order_site`:订单读取、客户资料、客户领取页、运营工作台和状态时间线。 +- `live-hub`:内部斗鱼账号、CK、二维码生成、角色识别、绑定确认、积分和兑换。 +- 客户不提交 CK,也不会看到内部账号、积分、租约或限兑信息。 + +## 客户流程 + +1. 打开 `/coll/d/<订单号>`。 +2. 填写游戏角色名、微信/QQ、苹果/安卓。 +3. `order_site` 通过服务端接口通知 live-hub 准备订单和内部账号。 +4. live-hub 返回安全绑定状态和二维码。 +5. 客户微信扫码选择和平精英角色。 +6. 平台角色与客户资料一致后,客户确认绑定。 +7. 绑定完成后等待运营在 live-hub 人工兑换。 + +斗鱼接口没有游戏 UID / 角色 ID。资料核对只使用角色名、平台和系统区服。 + +## 状态 + +```text +waiting_profile +preparing +qr_pending +role_ready +bound +waiting_operator +processing +completed +failed +manual_required +cancelled +``` + +最终绑定只认 `bindAct=1`。`bindRole=1, bindAct=0` 表示已识别角色但尚未最终确认。 + +## 环境变量 + +`order_site`: + +```env +LIVE_HUB_PLATFORM_FULFILLMENT_URL=http://127.0.0.1:8800 +PLATFORM_FULFILLMENT_INTEGRATION_KEY=<共享密钥> +``` + +`live-hub`: + +```env +PLATFORM_FULFILLMENT_INTEGRATION_KEY=<共享密钥> +PLATFORM_FULFILLMENT_INTEGRATION_ACTOR_ID= +PLATFORM_BINDING_QR_TTL_SECONDS=600 +``` + +集成操作人不填时,live-hub 使用最早创建的有效超级管理员。 + +## 数据边界 + +- `douyu_fulfillment_tasks` 只保存客户资料和 live-hub 安全状态投影。 +- `live_session_id` 指向 live-hub 履约任务。 +- 二维码原始 URL 由 live-hub 返回,不在 order_site 数据库长期保存。 +- 内部账号、Cookie、积分和租约不得进入 order_site 客户接口。