hujiarui il y a 1 mois
Parent
commit
8e325d12ce
60 fichiers modifiés avec 9671 ajouts et 1052 suppressions
  1. 21 4
      src/app/admin/layout.tsx
  2. 98 10
      src/app/admin/node-configurations/page.tsx
  3. 251 4
      src/app/admin/orders/new/page.tsx
  4. 66 9
      src/app/admin/orders/page.tsx
  5. 10 4
      src/app/admin/plugins/page.tsx
  6. 26 0
      src/app/admin/products/page.tsx
  7. 74 0
      src/app/admin/settlement/page.tsx
  8. 4 3
      src/app/services/page.tsx
  9. 9 0
      src/components/CreateOrderForm.tsx
  10. 4 3
      src/components/PaymentProcessor.tsx
  11. 199 535
      src/components/ServiceList.tsx
  12. 2 1
      src/components/admin/AdminSidebar.tsx
  13. 15 2
      src/components/admin/agent/AgentDrawer.tsx
  14. 40 23
      src/components/admin/agent/AgentFloatingTrigger.tsx
  15. 270 0
      src/components/admin/node-configurations/ClusterNodeModal.tsx
  16. 478 0
      src/components/admin/node-configurations/ClusterNodeTable.tsx
  17. 14 0
      src/components/admin/node-configurations/NodeClusterTelemetryBar.tsx
  18. 7 13
      src/components/admin/node-configurations/NodeConfigCloneModal.tsx
  19. 454 129
      src/components/admin/node-configurations/NodeConfigCreateWizardModal.tsx
  20. 720 83
      src/components/admin/node-configurations/NodeConfigEditModal.tsx
  21. 535 0
      src/components/admin/node-configurations/NodeTelemetryModal.tsx
  22. 408 103
      src/components/admin/node-configurations/ProviderModal.tsx
  23. 16 9
      src/components/admin/node-configurations/ProviderTable.tsx
  24. 266 0
      src/components/admin/node-configurations/RegisteredNodeSelect.tsx
  25. 378 0
      src/components/admin/node-configurations/nodeConfigConstants.ts
  26. 104 0
      src/components/admin/orders/OrderDetailDrawer.tsx
  27. 263 56
      src/components/admin/orders/OrderEditModal.tsx
  28. 46 2
      src/components/admin/orders/OrderFilterBar.tsx
  29. 113 14
      src/components/admin/orders/OrderTable.tsx
  30. 7 0
      src/components/admin/payments/ProviderModal.tsx
  31. 4 1
      src/components/admin/payments/paymentIcons.ts
  32. 49 2
      src/components/admin/plugins/PluginDetailDrawer.tsx
  33. 64 2
      src/components/admin/plugins/PluginEditModal.tsx
  34. 107 4
      src/components/admin/plugins/PluginPublishModal.tsx
  35. 40 1
      src/components/admin/plugins/PluginTable.tsx
  36. 55 11
      src/components/admin/products/ProductDetailDrawer.tsx
  37. 21 3
      src/components/admin/products/ProductList.tsx
  38. 844 17
      src/components/admin/products/ProductModal.tsx
  39. 425 0
      src/components/admin/settlement/AgenciesTab.tsx
  40. 466 0
      src/components/admin/settlement/CostRecordsTab.tsx
  41. 363 0
      src/components/admin/settlement/FaultCompensationsTab.tsx
  42. 750 0
      src/components/admin/settlement/SettlementEngineTab.tsx
  43. 207 0
      src/components/admin/settlement/SettlementPeriodDetailModal.tsx
  44. 207 0
      src/components/common/AdminUserSelect.tsx
  45. 292 0
      src/components/common/ProductTutorialBanner.tsx
  46. 315 0
      src/components/services/ServicePoster.tsx
  47. 8 0
      src/lib/services/accountService.ts
  48. 1 0
      src/lib/services/index.ts
  49. 59 0
      src/lib/services/nodeConfigService.ts
  50. 42 3
      src/lib/services/orderService.ts
  51. 1 1
      src/lib/services/productService.ts
  52. 8 0
      src/lib/services/proxyService.ts
  53. 151 0
      src/lib/services/settlementService.ts
  54. 8 0
      src/lib/services/userService.ts
  55. 1 0
      src/types/index.ts
  56. 31 0
      src/types/node_config.ts
  57. 10 0
      src/types/order.ts
  58. 11 0
      src/types/plugin.ts
  59. 45 0
      src/types/product.ts
  60. 188 0
      src/types/settlement.ts

+ 21 - 4
src/app/admin/layout.tsx

@@ -15,12 +15,14 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
   const [isAuthorized, setIsAuthorized] = useState(false);
   const [user, setUser] = useState<any>(null);
   const [isCopilotOpen, setIsCopilotOpen] = useState(false);
+  const [showFloatingTrigger, setShowFloatingTrigger] = useState(false);
 
   useEffect(() => {
     const handleKeyDown = (e: KeyboardEvent) => {
       if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'j') {
         e.preventDefault();
         setIsCopilotOpen((prev) => !prev);
+        setShowFloatingTrigger(false);
       }
     };
     window.addEventListener('keydown', handleKeyDown);
@@ -66,7 +68,10 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
             {/* Copilot 快捷呼出按钮 */}
             <button
               type="button"
-              onClick={() => setIsCopilotOpen((prev) => !prev)}
+              onClick={() => {
+                setIsCopilotOpen((prev) => !prev);
+                setShowFloatingTrigger(false);
+              }}
               className="flex items-center gap-1.5 px-3 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase"
               title="呼出 AI 智能副驾 (⌘J)"
             >
@@ -108,14 +113,26 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
         </div>
       </main>
 
-      {/* 全局 Copilot 抽屉与浮动按钮 */}
+      {/* 全局 Copilot 抽屉与浮动按钮 (一般时候保持隐藏) */}
       <AgentFloatingTrigger
-        onClick={() => setIsCopilotOpen(true)}
+        onClick={() => {
+          setIsCopilotOpen(true);
+          setShowFloatingTrigger(false);
+        }}
         isOpen={isCopilotOpen}
+        isVisible={showFloatingTrigger}
+        onHide={() => setShowFloatingTrigger(false)}
       />
       <AgentDrawer
         isOpen={isCopilotOpen}
-        onClose={() => setIsCopilotOpen(false)}
+        onClose={() => {
+          setIsCopilotOpen(false);
+          setShowFloatingTrigger(false);
+        }}
+        onMinimize={() => {
+          setIsCopilotOpen(false);
+          setShowFloatingTrigger(true);
+        }}
       />
     </div>
   );

+ 98 - 10
src/app/admin/node-configurations/page.tsx

@@ -13,6 +13,7 @@ import {
   ProviderItem,
   NodeConfigurationItem,
   NodeRuntimeStatus,
+  ClusterNode,
 } from '@/types';
 import { providerService } from '@/lib/services/providerService';
 import { nodeConfigService } from '@/lib/services/nodeConfigService';
@@ -27,8 +28,10 @@ import NodeConfigCloneModal from '@/components/admin/node-configurations/NodeCon
 import NodeConfigDetailDrawer from '@/components/admin/node-configurations/NodeConfigDetailDrawer';
 import NodeClusterTelemetryBar from '@/components/admin/node-configurations/NodeClusterTelemetryBar';
 import LivePluginInstancesModal from '@/components/admin/node-configurations/LivePluginInstancesModal';
+import ClusterNodeTable from '@/components/admin/node-configurations/ClusterNodeTable';
+import ClusterNodeModal from '@/components/admin/node-configurations/ClusterNodeModal';
 
-type ActiveTabType = 'provider' | NodeConfigEntryType;
+type ActiveTabType = 'nodes' | 'provider' | NodeConfigEntryType;
 
 export default function NodeConfigurationsPage() {
   const [activeTab, setActiveTab] = useState<ActiveTabType>('provider');
@@ -39,6 +42,13 @@ export default function NodeConfigurationsPage() {
   const [isProviderModalOpen, setIsProviderModalOpen] = useState(false);
   const [editingProvider, setEditingProvider] = useState<ProviderItem | null>(null);
 
+  // Cluster Nodes state
+  const [clusterNodes, setClusterNodes] = useState<ClusterNode[]>([]);
+  const [loadingClusterNodes, setLoadingClusterNodes] = useState(false);
+  const [isNodeModalOpen, setIsNodeModalOpen] = useState(false);
+  const [editingNode, setEditingNode] = useState<ClusterNode | null>(null);
+  const [presetRegisterNodeId, setPresetRegisterNodeId] = useState<string>('');
+
   // Node config state
   const [configs, setConfigs] = useState<NodeConfigurationItem[]>([]);
   const [loadingConfigs, setLoadingConfigs] = useState(false);
@@ -148,13 +158,43 @@ export default function NodeConfigurationsPage() {
     return () => clearInterval(timer);
   }, [autoRefreshTelemetry, fetchTelemetry]);
 
+  // Load Cluster Nodes
+  const fetchClusterNodes = useCallback(async () => {
+    setLoadingClusterNodes(true);
+    try {
+      const res = await nodeConfigService.listRegisteredNodes();
+      if (res.code === 0 && res.data) {
+        setClusterNodes(Array.isArray(res.data) ? res.data : []);
+      } else {
+        setClusterNodes([]);
+      }
+    } catch (e: any) {
+      console.error('Failed to fetch cluster nodes:', e);
+      toast.error('获取集群节点档案失败');
+      setClusterNodes([]);
+    } finally {
+      setLoadingClusterNodes(false);
+    }
+  }, []);
+
+  const registeredNodeIds = React.useMemo(
+    () => new Set(clusterNodes.map((n) => n.node_id)),
+    [clusterNodes]
+  );
+
+  useEffect(() => {
+    fetchClusterNodes();
+  }, [fetchClusterNodes]);
+
   useEffect(() => {
-    if (activeTab === 'provider') {
+    if (activeTab === 'nodes') {
+      fetchClusterNodes();
+    } else if (activeTab === 'provider') {
       fetchProviders();
     } else {
       fetchNodeConfigs(activeTab);
     }
-  }, [activeTab, fetchProviders, fetchNodeConfigs]);
+  }, [activeTab, fetchClusterNodes, fetchProviders, fetchNodeConfigs]);
 
   const handleTabChange = (newTab: ActiveTabType) => {
     setActiveTab(newTab);
@@ -162,7 +202,9 @@ export default function NodeConfigurationsPage() {
   };
 
   const handleRefresh = () => {
-    if (activeTab === 'provider') {
+    if (activeTab === 'nodes') {
+      fetchClusterNodes();
+    } else if (activeTab === 'provider') {
       fetchProviders();
     } else {
       fetchNodeConfigs(activeTab);
@@ -290,10 +332,28 @@ export default function NodeConfigurationsPage() {
         onRefresh={fetchTelemetry}
         onInspectInstances={handleOpenInstancesModal}
         lastUpdatedTime={lastTelemetryTime}
+        registeredNodeIds={registeredNodeIds}
+        onQuickRegisterNode={(nodeId) => {
+          setEditingNode(null);
+          setPresetRegisterNodeId(nodeId);
+          setIsNodeModalOpen(true);
+        }}
       />
 
       {/* 顶部 Tab 栏 (Retro Brutalist Tabs) */}
       <div className="flex flex-wrap gap-2">
+        <button
+          type="button"
+          onClick={() => handleTabChange('nodes')}
+          className={`px-4 py-2 border-2 border-black text-xs font-mono uppercase transition shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 ${
+            activeTab === 'nodes'
+              ? 'bg-amber-300 text-black font-black'
+              : 'bg-white text-neutral-800 font-bold hover:bg-neutral-100'
+          }`}
+        >
+          [ 节点档案注册 NODES ({clusterNodes.length}) ]
+        </button>
+
         <button
           type="button"
           onClick={() => handleTabChange('provider')}
@@ -344,7 +404,7 @@ export default function NodeConfigurationsPage() {
       </div>
 
       {/* 搜索与过滤栏 (Filter Bar) */}
-      {activeTab !== 'provider' && (
+      {activeTab !== 'provider' && activeTab !== 'nodes' && (
         <div className="bg-neutral-100 border-2 border-black p-4 shadow-[4px_4px_0px_#000] flex flex-wrap items-center gap-3">
           <div className="flex-1 min-w-[200px] relative">
             <input
@@ -405,7 +465,26 @@ export default function NodeConfigurationsPage() {
       )}
 
       {/* 主视图内容 */}
-      {activeTab === 'provider' ? (
+      {activeTab === 'nodes' ? (
+        <ClusterNodeTable
+          nodes={clusterNodes}
+          runtimeNodes={runtimeNodes}
+          loading={loadingClusterNodes}
+          onRefresh={() => {
+            fetchClusterNodes();
+            fetchTelemetry();
+          }}
+          onOpenCreate={() => {
+            setEditingNode(null);
+            setPresetRegisterNodeId('');
+            setIsNodeModalOpen(true);
+          }}
+          onOpenEdit={(node) => {
+            setEditingNode(node);
+            setIsNodeModalOpen(true);
+          }}
+        />
+      ) : activeTab === 'provider' ? (
         <ProviderTable
           data={providers}
           loading={loadingProviders}
@@ -470,7 +549,7 @@ export default function NodeConfigurationsPage() {
       />
 
       {/* Node Config 3-Step Wizard Modal */}
-      {activeTab !== 'provider' && (
+      {activeTab !== 'provider' && activeTab !== 'nodes' && (
         <NodeConfigCreateWizardModal
           isOpen={isCreateWizardOpen}
           onClose={() => setIsCreateWizardOpen(false)}
@@ -480,7 +559,7 @@ export default function NodeConfigurationsPage() {
       )}
 
       {/* Node Config Edit Modal */}
-      {activeTab !== 'provider' && (
+      {activeTab !== 'provider' && activeTab !== 'nodes' && (
         <NodeConfigEditModal
           isOpen={isEditModalOpen}
           onClose={() => setIsEditModalOpen(false)}
@@ -491,7 +570,7 @@ export default function NodeConfigurationsPage() {
       )}
 
       {/* Node Config Clone Modal */}
-      {activeTab !== 'provider' && (
+      {activeTab !== 'provider' && activeTab !== 'nodes' && (
         <NodeConfigCloneModal
           isOpen={isCloneModalOpen}
           onClose={() => setIsCloneModalOpen(false)}
@@ -502,7 +581,7 @@ export default function NodeConfigurationsPage() {
       )}
 
       {/* Node Config Detail & Revisions Drawer */}
-      {activeTab !== 'provider' && (
+      {activeTab !== 'provider' && activeTab !== 'nodes' && (
         <NodeConfigDetailDrawer
           isOpen={isDetailDrawerOpen}
           onClose={() => setIsDetailDrawerOpen(false)}
@@ -514,6 +593,15 @@ export default function NodeConfigurationsPage() {
         />
       )}
 
+      {/* Cluster Node Modal */}
+      <ClusterNodeModal
+        isOpen={isNodeModalOpen}
+        onClose={() => setIsNodeModalOpen(false)}
+        onSuccess={fetchClusterNodes}
+        editingNode={editingNode}
+        initialNodeId={presetRegisterNodeId}
+      />
+
       {/* Live Plugin Instances Modal */}
       <LivePluginInstancesModal
         isOpen={isInstancesModalOpen}

+ 251 - 4
src/app/admin/orders/new/page.tsx

@@ -2,12 +2,14 @@
 
 import { useState, useEffect } from 'react';
 import { useRouter } from 'next/navigation';
-import { ArrowLeft } from 'lucide-react';
-import { productService, orderService } from '@/lib/services';
+import { ArrowLeft, Users, Building2, Globe, DollarSign } from 'lucide-react';
+import { productService, orderService, settlementService } from '@/lib/services';
+import { getCurrentUser } from '@/lib/auth';
 import ProductSearchSelector from '@/components/admin/orders/ProductSearchSelector';
 import AiDataParserPanel from '@/components/admin/orders/AiDataParserPanel';
 import DynamicOrderSchemaForm from '@/components/admin/orders/DynamicOrderSchemaForm';
-import { SchemaProperty } from '@/types';
+import AdminUserSelect from '@/components/common/AdminUserSelect';
+import { SchemaProperty, VasAgency } from '@/types';
 import { toast } from 'react-hot-toast';
 
 export default function AdminCreateOrderPage() {
@@ -17,11 +19,48 @@ export default function AdminCreateOrderPage() {
   // 1. 商品状态
   const [selectedProduct, setSelectedProduct] = useState<any>(null);
 
-  // 2. 表单与 Schema 状态
+  // 2. 渠道与分润归属状态
+  const [channelType, setChannelType] = useState<'direct' | 'agency' | 'website'>('direct');
+  const [agencies, setAgencies] = useState<VasAgency[]>([]);
+  const [selectedAgencyId, setSelectedAgencyId] = useState<string>('');
+  const [handlerId, setHandlerId] = useState<string>('');
+  const [customPrice, setCustomPrice] = useState<string>(''); // 单位: 元
+
+  // 3. 表单与 Schema 状态
   const [formSchema, setFormSchema] = useState<any>(null);
   const [formValues, setFormValues] = useState<Record<string, any>>({});
   const [sortedFields, setSortedFields] = useState<string[]>([]);
 
+  // 加载中介列表与当前用户信息
+  useEffect(() => {
+    const user = getCurrentUser();
+    if (user?.nickname || user?.id) {
+      setHandlerId(user.nickname || user.id);
+    }
+
+    async function loadAgencies() {
+      try {
+        const res = await settlementService.listAgencies({ active_only: true });
+        const list = res?.data?.items || res?.data || [];
+        setAgencies(Array.isArray(list) ? list : []);
+      } catch {
+        setAgencies([]);
+      }
+    }
+    loadAgencies();
+  }, []);
+
+  // 选中中介时自动锁定 handler_id
+  const handleAgencySelect = (agencyId: string) => {
+    setSelectedAgencyId(agencyId);
+    const agency = agencies.find((a) => a.id === agencyId);
+    if (agency) {
+      setHandlerId(agency.owner_id);
+    }
+  };
+
+  const selectedAgency = agencies.find((a) => a.id === selectedAgencyId);
+
   // 加载 Schema
   useEffect(() => {
     async function loadSchema() {
@@ -29,9 +68,15 @@ export default function AdminCreateOrderPage() {
         setFormSchema(null);
         setSortedFields([]);
         setFormValues({});
+        setCustomPrice('');
         return;
       }
       try {
+        // 默认价格填充 (分转元)
+        if (selectedProduct.base_price !== undefined) {
+          setCustomPrice((selectedProduct.base_price / 100).toFixed(2));
+        }
+
         const res = await productService.getSchemaDetail(selectedProduct.schema_id);
         const data = res?.data || res;
         const schemaJson =
@@ -82,11 +127,36 @@ export default function AdminCreateOrderPage() {
     e.preventDefault();
     if (!selectedProduct) return toast.error('请先搜索并选择商品');
 
+    // 中介底价校验
+    let finalAmountCents: number | undefined = undefined;
+    if (customPrice && !isNaN(Number(customPrice))) {
+      finalAmountCents = Math.round(Number(customPrice) * 100);
+    }
+
+    if (channelType === 'agency') {
+      if (!selectedAgencyId) {
+        return toast.error('请选择合作中介机构');
+      }
+      if (selectedAgency && finalAmountCents !== undefined && finalAmountCents < selectedAgency.min_floor_price) {
+        return toast.error(
+          `录入价格 ¥${(finalAmountCents / 100).toFixed(2)} 低于该中介协议最低结算底价 ¥${(selectedAgency.min_floor_price / 100).toFixed(2)}!`
+        );
+      }
+    }
+
+    if (channelType === 'direct' && !handlerId.trim()) {
+      return toast.error('社交自收直客单必须填写40%提成归属人ID/姓名');
+    }
+
     setLoading(true);
     try {
       const payload = {
         product_id: selectedProduct.id,
         user_inputs: formValues,
+        channel_type: channelType,
+        agency_id: channelType === 'agency' ? selectedAgencyId : undefined,
+        handler_id: channelType === 'website' ? undefined : handlerId.trim(),
+        final_amount: finalAmountCents,
       };
 
       const res = await orderService.createByAdmin(payload);
@@ -131,6 +201,183 @@ export default function AdminCreateOrderPage() {
           onSelectProduct={setSelectedProduct}
         />
 
+        {/* Step 1.5: 渠道来源与合伙分润设置 */}
+        {selectedProduct && (
+          <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
+            <div className="px-5 py-3 border-b-2 border-black bg-neutral-200 text-black flex items-center justify-between">
+              <div className="flex items-center gap-2">
+                <span className="w-5 h-5 bg-amber-300 border border-black flex items-center justify-center text-black text-[10px] font-black">
+                  1.5
+                </span>
+                <label className="text-xs font-black uppercase tracking-wider text-black">
+                  [ CHANNEL & ASSIGNMENT // 渠道来源、销售归属与协议定价 ]
+                </label>
+              </div>
+              <span className="text-[10px] text-neutral-500 font-bold uppercase">
+                40% 销售包干提成归属判定
+              </span>
+            </div>
+
+            <div className="p-5 space-y-4">
+              {/* 渠道类型选择 */}
+              <div>
+                <label className="text-xs font-black text-black uppercase block mb-2">
+                  [ 1. 选择业务合作渠道模式 ]
+                </label>
+                <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
+                  {/* Direct */}
+                  <div
+                    onClick={() => {
+                      setChannelType('direct');
+                      const u = getCurrentUser();
+                      if (u?.nickname || u?.id) setHandlerId(u.nickname || u.id);
+                    }}
+                    className={`p-3.5 border-2 cursor-pointer transition ${
+                      channelType === 'direct'
+                        ? 'border-black bg-amber-100 shadow-[3px_3px_0px_#000]'
+                        : 'border-neutral-300 bg-neutral-50 hover:border-black'
+                    }`}
+                  >
+                    <div className="flex items-center gap-2 mb-1">
+                      <Users size={16} className="text-black" />
+                      <span className="text-xs font-black text-black uppercase">[ 社交自收直客 ]</span>
+                    </div>
+                    <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
+                      小红书/微信自引流直客,拿该单 <strong>40% 销售包干提成</strong>,对录错承担全额赔偿。
+                    </p>
+                  </div>
+
+                  {/* Agency */}
+                  <div
+                    onClick={() => setChannelType('agency')}
+                    className={`p-3.5 border-2 cursor-pointer transition ${
+                      channelType === 'agency'
+                        ? 'border-black bg-purple-100 shadow-[3px_3px_0px_#000]'
+                        : 'border-neutral-300 bg-neutral-50 hover:border-black'
+                    }`}
+                  >
+                    <div className="flex items-center gap-2 mb-1">
+                      <Building2 size={16} className="text-purple-900" />
+                      <span className="text-xs font-black text-black uppercase">[ 中介同行渠道 ]</span>
+                    </div>
+                    <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
+                      旅行社或同行转介绍,受<strong>专属底价</strong>保护,40%提成自动锁定归属该中介拓展人。
+                    </p>
+                  </div>
+
+                  {/* Website */}
+                  <div
+                    onClick={() => {
+                      setChannelType('website');
+                      setHandlerId('');
+                    }}
+                    className={`p-3.5 border-2 cursor-pointer transition ${
+                      channelType === 'website'
+                        ? 'border-black bg-neutral-200 shadow-[3px_3px_0px_#000]'
+                        : 'border-neutral-300 bg-neutral-50 hover:border-black'
+                    }`}
+                  >
+                    <div className="flex items-center gap-2 mb-1">
+                      <Globe size={16} className="text-black" />
+                      <span className="text-xs font-black text-black uppercase">[ 官网自主下单 ]</span>
+                    </div>
+                    <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
+                      公海自然流量,无专属对接人,40%销售提成由合伙双方(各20%)平分。
+                    </p>
+                  </div>
+                </div>
+              </div>
+
+              {/* 细化字段配置 */}
+              <div className="grid grid-cols-1 md:grid-cols-2 gap-4 pt-3 border-t-2 border-dashed border-neutral-300">
+                {/* Direct: 接单客服 */}
+                {channelType === 'direct' && (
+                  <div>
+                    <AdminUserSelect
+                      value={handlerId}
+                      onChange={setHandlerId}
+                      label="40% 销售包干提成归属人 (系统管理员)"
+                      badgeText="客服/销售"
+                      placeholder="选择系统管理员作为提成人"
+                      helperText="若录错护照/姓名导致废单,损失从该人当期提成中全额扣减。"
+                      required
+                    />
+                  </div>
+                )}
+
+                {/* Agency: 选择中介 */}
+                {channelType === 'agency' && (
+                  <div className="space-y-2">
+                    <label className="text-xs font-black text-black uppercase block mb-1">
+                      [ 合作中介机构档案 ] <span className="text-rose-600">*</span>
+                    </label>
+                    <select
+                      value={selectedAgencyId}
+                      onChange={(e) => handleAgencySelect(e.target.value)}
+                      className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black cursor-pointer"
+                    >
+                      <option value="">-- 请选择合作中介机构 --</option>
+                      {agencies.map((agency) => (
+                        <option key={agency.id} value={agency.id}>
+                          {agency.name} (最低底价: ¥{(agency.min_floor_price / 100).toFixed(2)})
+                        </option>
+                      ))}
+                    </select>
+
+                    {selectedAgency && (
+                      <div className="p-2.5 bg-neutral-100 border border-black text-[11px] font-mono space-y-1">
+                        <div>
+                          <span className="text-neutral-500 font-bold">专属拓展维系人: </span>
+                          <span className="text-black font-black">{selectedAgency.owner_id}</span>
+                          <span className="text-[10px] text-purple-700 ml-1">(自动绑定拿40%提成)</span>
+                        </div>
+                        <div>
+                          <span className="text-neutral-500 font-bold">协议最低底价: </span>
+                          <span className="text-rose-600 font-black">¥{(selectedAgency.min_floor_price / 100).toFixed(2)}</span>
+                          <span className="text-[10px] text-neutral-400 ml-1">低于此底价系统将阻断提交</span>
+                        </div>
+                      </div>
+                    )}
+                  </div>
+                )}
+
+                {/* Website */}
+                {channelType === 'website' && (
+                  <div className="p-3 bg-neutral-100 border border-black text-xs font-mono">
+                    <span className="text-neutral-500 font-bold block mb-1">公海单利润流转:</span>
+                    <p className="text-[11px] text-neutral-700 font-sans">
+                      该单无专属对接人。40% 销售提成与 40% 合伙分红合并,由合伙人甲乙双方各按 50%(每人到手40%净利)平分;技术版权费 20% 归脚本开发者。
+                    </p>
+                  </div>
+                )}
+
+                {/* 自定义结算价格 */}
+                <div>
+                  <label className="text-xs font-black text-black uppercase block mb-1">
+                    [ 实收结算价格 (元) ]
+                  </label>
+                  <div className="relative">
+                    <span className="absolute left-3 top-2 text-xs font-bold text-black pointer-events-none">
+                      ¥
+                    </span>
+                    <input
+                      type="number"
+                      step="0.01"
+                      value={customPrice}
+                      onChange={(e) => setCustomPrice(e.target.value)}
+                      placeholder="默认商品指导价"
+                      className="w-full pl-7 pr-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
+                    />
+                  </div>
+                  <span className="text-[10px] text-neutral-500 font-mono mt-1 block">
+                    留空则使用商品默认标价。若填写将覆盖商品基础价。
+                  </span>
+                </div>
+              </div>
+            </div>
+          </div>
+        )}
+
         {/* Step 2: 填写表单 (含 AI) */}
         {selectedProduct && (
           <form onSubmit={handleSubmit}>

+ 66 - 9
src/app/admin/orders/page.tsx

@@ -28,6 +28,8 @@ export default function AdminOrdersPage() {
 
   const [keyword, setKeyword] = useState('');
   const [statusFilter, setStatusFilter] = useState<OrderStatusFilter>('all');
+  const [channelFilter, setChannelFilter] = useState<string>('all');
+  const [settlementFilter, setSettlementFilter] = useState<string>('all');
 
   const [selectedOrder, setSelectedOrder] = useState<ExtendedOrderDetail | null>(null);
   const [isDrawerOpen, setIsDrawerOpen] = useState(false);
@@ -36,7 +38,13 @@ export default function AdminOrdersPage() {
   const [isPriceModalOpen, setIsPriceModalOpen] = useState(false);
   const [editingOrder, setEditingOrder] = useState<OrderDetail | null>(null);
 
-  const fetchOrders = useCallback(async (targetPage: number = page, targetStatus: OrderStatusFilter = statusFilter, targetKeyword: string = keyword) => {
+  const fetchOrders = useCallback(async (
+    targetPage: number = page,
+    targetStatus: OrderStatusFilter = statusFilter,
+    targetKeyword: string = keyword,
+    targetChannel: string = channelFilter,
+    targetSettlement: string = settlementFilter
+  ) => {
     setLoading(true);
     try {
       const params: Record<string, any> = {
@@ -48,6 +56,12 @@ export default function AdminOrdersPage() {
       if (targetStatus !== 'all') {
         params.status = targetStatus;
       }
+      if (targetChannel !== 'all') {
+        params.channel_type = targetChannel;
+      }
+      if (targetSettlement !== 'all') {
+        params.settlement_status = targetSettlement;
+      }
 
       const res = await orderService.listAll(params);
       const data = res?.data;
@@ -70,20 +84,53 @@ export default function AdminOrdersPage() {
     } finally {
       setLoading(false);
     }
-  }, [page, pageSize, statusFilter, keyword]);
+  }, [page, pageSize, statusFilter, keyword, channelFilter, settlementFilter]);
 
   useEffect(() => {
-    fetchOrders(1, statusFilter, keyword);
-  }, [statusFilter]);
+    fetchOrders(1, statusFilter, keyword, channelFilter, settlementFilter);
+  }, [statusFilter, channelFilter, settlementFilter]);
 
   const handleSearch = () => {
-    fetchOrders(1, statusFilter, keyword);
+    fetchOrders(1, statusFilter, keyword, channelFilter, settlementFilter);
   };
 
   const handleStatusChange = (newStatus: OrderStatusFilter) => {
     setStatusFilter(newStatus);
   };
 
+  const handleChannelChange = (newChannel: string) => {
+    setChannelFilter(newChannel);
+  };
+
+  const handleSettlementChange = (newSettlement: string) => {
+    setSettlementFilter(newSettlement);
+  };
+
+  const handleMarkCompleted = async (orderId: string, riskDays: number = 7) => {
+    const ok = await retroConfirm({
+      title: '[ CONFIRM // 标记履约出签完成 ]',
+      message: `确定要将订单 #${orderId} 标记为已完成履约吗?系统将自动开启 ${riskDays} 天退款风险期,期满后转入待分润结算池。`,
+      type: 'warning',
+      confirmText: '[ 确认履约完成 ]',
+    });
+    if (!ok) return;
+    try {
+      await orderService.markCompleted(orderId, riskDays);
+      toast.success(`订单 #${orderId} 履约状态已更新,已开启 T+${riskDays} 风险期。`);
+      fetchOrders(page, statusFilter, keyword, channelFilter, settlementFilter);
+      if (selectedOrder?.id === orderId) {
+        setSelectedOrder((prev) => prev ? {
+          ...prev,
+          status: 'completed',
+          settlement_status: 'risk_period',
+          completed_at: new Date().toISOString()
+        } : null);
+      }
+    } catch (e: any) {
+      toast.error('操作失败: ' + (e.response?.data?.message || '未知错误'));
+    }
+  };
+
   const handleCancelOrder = async (orderId: string) => {
     const ok = await retroConfirm({
       title: '[ CONFIRM // 取消订单 ]',
@@ -137,10 +184,14 @@ export default function AdminOrdersPage() {
       return;
     }
     try {
-      await orderService.patchUserInputs(orderId, data);
-      toast.success('订单信息更新成功。');
+      const res = await orderService.updateOrder(orderId, data);
+      toast.success('订单配置更新成功。');
       setIsEditOpen(false);
       fetchOrders(page);
+      if (selectedOrder && selectedOrder.id === orderId) {
+        const updated = res?.data || res;
+        setSelectedOrder((prev) => (prev ? { ...prev, ...updated } : null));
+      }
     } catch (error: any) {
       toast.error('更新失败: ' + (error.response?.data?.message || error.message));
     }
@@ -221,10 +272,14 @@ export default function AdminOrdersPage() {
       <OrderFilterBar
         currentStatus={statusFilter}
         onStatusChange={handleStatusChange}
+        channelFilter={channelFilter}
+        onChannelChange={handleChannelChange}
+        settlementFilter={settlementFilter}
+        onSettlementChange={handleSettlementChange}
         keyword={keyword}
         onKeywordChange={setKeyword}
         onSearch={handleSearch}
-        onRefresh={() => fetchOrders(page, statusFilter, keyword)}
+        onRefresh={() => fetchOrders(page, statusFilter, keyword, channelFilter, settlementFilter)}
         onExportCsv={handleExportCsv}
         onCreateOrder={() => router.push('/admin/orders/new')}
         loading={loading}
@@ -240,6 +295,7 @@ export default function AdminOrdersPage() {
         onEdit={handleEditOrder}
         onCheckPayments={handleCheckPayments}
         onAdjustPrice={handleAdjustPrice}
+        onMarkCompleted={handleMarkCompleted}
       />
 
       {/* 4. 分页器 */}
@@ -248,7 +304,7 @@ export default function AdminOrdersPage() {
           currentPage={page}
           total={total}
           pageSize={pageSize}
-          onPageChange={(p) => fetchOrders(p, statusFilter, keyword)}
+          onPageChange={(p) => fetchOrders(p, statusFilter, keyword, channelFilter, settlementFilter)}
         />
       </div>
 
@@ -261,6 +317,7 @@ export default function AdminOrdersPage() {
         onCheckPayments={handleCheckPayments}
         onEdit={handleEditOrder}
         onCancel={handleCancelOrder}
+        onMarkCompleted={handleMarkCompleted}
       />
 
       {/* 6. 编辑用户输入弹窗 */}

+ 10 - 4
src/app/admin/plugins/page.tsx

@@ -35,6 +35,7 @@ export default function AdminPluginsPage() {
 
   const [isEditModalOpen, setIsEditModalOpen] = useState(false);
   const [editingPlugin, setEditingPlugin] = useState<PluginItem | null>(null);
+  const [drawerRefreshTrigger, setDrawerRefreshTrigger] = useState(0);
 
   const fetchPlugins = useCallback(async () => {
     setLoading(true);
@@ -258,9 +259,7 @@ export default function AdminPluginsPage() {
         initialPlugin={publishTargetPlugin}
         onSuccess={() => {
           fetchPlugins();
-          if (isDrawerOpen && selectedDrawerPluginId) {
-            setSelectedDrawerPluginId(selectedDrawerPluginId);
-          }
+          setDrawerRefreshTrigger((prev) => prev + 1);
         }}
       />
 
@@ -268,11 +267,15 @@ export default function AdminPluginsPage() {
         isOpen={isDrawerOpen}
         onClose={() => setIsDrawerOpen(false)}
         pluginId={selectedDrawerPluginId}
+        refreshKey={drawerRefreshTrigger}
         onRefreshList={fetchPlugins}
         onOpenPublishVersion={(detail) => {
           setIsPublishModalOpen(true);
           setPublishTargetPlugin(detail as any);
         }}
+        onOpenEdit={(detail) => {
+          handleOpenEdit(detail as any);
+        }}
       />
 
       <PluginUpgradeDispatchModal
@@ -286,7 +289,10 @@ export default function AdminPluginsPage() {
         isOpen={isEditModalOpen}
         onClose={() => setIsEditModalOpen(false)}
         plugin={editingPlugin}
-        onSuccess={fetchPlugins}
+        onSuccess={() => {
+          fetchPlugins();
+          setDrawerRefreshTrigger((prev) => prev + 1);
+        }}
       />
     </div>
   );

+ 26 - 0
src/app/admin/products/page.tsx

@@ -24,6 +24,7 @@ import ProductDetailDrawer from '@/components/admin/products/ProductDetailDrawer
 import Pagination from '@/components/common/Pagination';
 import { Product, FormSchema } from '@/types';
 import { productService } from '@/lib/services';
+import { retroConfirm } from '@/lib/dialog';
 
 export default function AdminProductsPage() {
   const [allProducts, setAllProducts] = useState<Product[]>([]);
@@ -269,6 +270,29 @@ export default function AdminProductsPage() {
     setSchemaModalOpen(true);
   };
 
+  const handleDeleteProduct = async (product: Product) => {
+    const ok = await retroConfirm({
+      title: '[ CONFIRM DELETE // 删除商品确认 ]',
+      message: `确定要彻底删除签证商品 "${product.title}" (ID: #${product.id}) 吗?此操作无法撤销。`,
+      confirmText: '[ 确认永久删除 ]',
+      cancelText: '[ 取消 ]',
+      type: 'danger',
+    });
+    if (!ok) return;
+
+    try {
+      await productService.delete(product.id);
+      toast.success(`商品 #${product.id} 已成功删除`);
+      if (selectedProduct?.id === product.id) {
+        setIsDrawerOpen(false);
+        setSelectedProduct(null);
+      }
+      await fetchProductsOnly();
+    } catch (e: any) {
+      toast.error('删除商品失败: ' + (e.response?.data?.message || e.message));
+    }
+  };
+
   return (
     <div className="space-y-6 font-mono">
       
@@ -575,6 +599,7 @@ export default function AdminProductsPage() {
         onEdit={handleOpenEdit}
         onManageRouting={handleOpenRouting}
         onToggleStatus={handleToggleStatus}
+        onDelete={handleDeleteProduct}
       />
 
       {/* 5. 分页组件 */}
@@ -606,6 +631,7 @@ export default function AdminProductsPage() {
           handleOpenSchemaManager();
         }}
         onToggleStatus={handleToggleStatus}
+        onDelete={handleDeleteProduct}
       />
 
       {/* 7. 新增/编辑商品弹窗 */}

+ 74 - 0
src/app/admin/settlement/page.tsx

@@ -0,0 +1,74 @@
+// src/app/admin/settlement/page.tsx
+'use client';
+
+import { useState } from 'react';
+import { Calculator, Building2, Receipt, AlertTriangle, Coins } from 'lucide-react';
+import SettlementEngineTab from '@/components/admin/settlement/SettlementEngineTab';
+import AgenciesTab from '@/components/admin/settlement/AgenciesTab';
+import CostRecordsTab from '@/components/admin/settlement/CostRecordsTab';
+import FaultCompensationsTab from '@/components/admin/settlement/FaultCompensationsTab';
+
+type TabType = 'engine' | 'agencies' | 'costs' | 'faults';
+
+export default function AdminSettlementPage() {
+  const [activeTab, setActiveTab] = useState<TabType>('engine');
+
+  const tabs: { key: TabType; label: string; icon: any; count?: number }[] = [
+    { key: 'engine', label: '账期分润结算引擎', icon: Calculator },
+    { key: 'agencies', label: '合作中介机构档案', icon: Building2 },
+    { key: 'costs', label: '运行耗材支出台账', icon: Receipt },
+    { key: 'faults', label: '录入过失赔偿冲销', icon: AlertTriangle },
+  ];
+
+  return (
+    <div className="space-y-6 font-mono">
+      {/* 顶部标头 */}
+      <div className="bg-neutral-100 border-2 border-black p-6 shadow-[6px_6px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-4">
+        <div>
+          <div className="flex items-center gap-2">
+            <Coins size={18} className="text-amber-500" />
+            <span className="text-[10px] font-bold text-neutral-500 uppercase tracking-widest">
+              [ FINANCIAL SETTLEMENT // 利润分成与公账核算中枢 ]
+            </span>
+          </div>
+          <h1 className="text-xl sm:text-2xl font-black text-black uppercase mt-1">
+            财务结算与合伙利润分成系统
+          </h1>
+          <p className="text-xs text-neutral-600 font-sans mt-0.5">
+            40% 合伙分红平分 + 40% 销售包干提成 + 20% 底层脚本技术版权费;运行耗材单均公摊,个人失误全额从当期提成中扣减冲销。
+          </p>
+        </div>
+      </div>
+
+      {/* 4 大功能 Tab 导航栏 */}
+      <div className="flex items-center gap-2 overflow-x-auto pb-1">
+        {tabs.map((tab) => {
+          const Icon = tab.icon;
+          const isActive = activeTab === tab.key;
+          return (
+            <button
+              key={tab.key}
+              onClick={() => setActiveTab(tab.key)}
+              className={`flex items-center gap-2 px-4 py-2.5 border-2 text-xs font-black uppercase transition active:translate-x-0.5 active:translate-y-0.5 whitespace-nowrap ${
+                isActive
+                  ? 'bg-amber-300 border-black text-black shadow-[3px_3px_0px_#000]'
+                  : 'bg-white border-black text-neutral-700 hover:bg-neutral-100 shadow-[1px_1px_0px_#000]'
+              }`}
+            >
+              <Icon size={15} />
+              <span>[ {tab.label} ]</span>
+            </button>
+          );
+        })}
+      </div>
+
+      {/* Tab 页面主体 */}
+      <div>
+        {activeTab === 'engine' && <SettlementEngineTab />}
+        {activeTab === 'agencies' && <AgenciesTab />}
+        {activeTab === 'costs' && <CostRecordsTab />}
+        {activeTab === 'faults' && <FaultCompensationsTab />}
+      </div>
+    </div>
+  );
+}

+ 4 - 3
src/app/services/page.tsx

@@ -1,12 +1,13 @@
 'use client';
 
 import ServiceList from '@/components/ServiceList';
-import { useLanguage } from '@/lib/i18n/LanguageContext';
 
 export default function ServicesPage() {
   return (
-    <div className="max-w-7xl mx-auto px-4 sm:px-6 py-6 md:py-10">
-      <ServiceList />
+    <div className="min-h-screen bg-neutral-100 text-black py-8 px-4 sm:px-6 md:py-12 md:px-8">
+      <div className="max-w-7xl mx-auto">
+        <ServiceList />
+      </div>
     </div>
   );
 }

+ 9 - 0
src/components/CreateOrderForm.tsx

@@ -21,6 +21,7 @@ import ConfirmModal from '@/components/common/ConfirmModal';
 import MessageModal from '@/components/common/MessageModal';
 import { ProductDetail, SchemaProperty, JsonSchema } from '@/types';
 import { productService, authService, orderService } from '@/lib/services';
+import ProductTutorialBanner from '@/components/common/ProductTutorialBanner';
 
 // ==========================================
 // 辅助函数与常量 (原有字段美化逻辑保持不变)
@@ -547,6 +548,14 @@ export default function CreateOrderForm({ productId, productName }: CreateOrderF
         </div>
       </div>
 
+      {/* 1.5 用户使用教程与材料准备指南 (支持弹窗对话框、超链接及内嵌展开等多种形式) */}
+      {product?.extra_fields?.tutorial?.enabled && (
+        <ProductTutorialBanner
+          tutorial={product.extra_fields.tutorial}
+          productTitle={product.title}
+        />
+      )}
+
       {/* 2. 动态表单申报登记卡片 */}
       <div className="bg-white border-2 border-black p-6 md:p-8 shadow-[6px_6px_0px_#000]">
         <div className="flex items-center justify-between border-b-2 border-black pb-4 mb-6 font-mono">

+ 4 - 3
src/components/PaymentProcessor.tsx

@@ -44,7 +44,7 @@ export default function PaymentProcessor({ orderId }: PaymentProcessorProps) {
     if (!isSlotSubscription) return providers;
     return providers.filter((provider) => {
       const target = `${provider.name || ''} ${provider.title || ''}`.toLowerCase();
-      return target.includes('stripe') || target.includes('card');
+      return target.includes('stripe') || target.includes('card') || target.includes('creem');
     });
   }, [providers, isSlotSubscription]);
 
@@ -107,9 +107,10 @@ export default function PaymentProcessor({ orderId }: PaymentProcessorProps) {
       let providerCode = providerName.toLowerCase();
       if (providerCode.includes('wechat')) providerCode = 'wechat';
       else if (providerCode.includes('ali')) providerCode = 'alipay';
+      else if (providerCode.includes('creem')) providerCode = 'creem';
       else if (providerCode.includes('stripe') || providerCode.includes('card')) providerCode = 'stripe';
-      if (isSlotSubscription && providerCode !== 'stripe') {
-        showMessage(t('payment.subscription_only_stripe_hint') || '名额订阅仅支持通过 Stripe 国际卡渠道签约', 'info');
+      if (isSlotSubscription && providerCode !== 'stripe' && providerCode !== 'creem') {
+        showMessage(t('payment.subscription_only_stripe_hint') || '名额订阅仅支持通过 Stripe / Creem 国际卡渠道签约', 'info');
         setLoading(false);
         return;
       }

+ 199 - 535
src/components/ServiceList.tsx

@@ -1,23 +1,18 @@
+// src/components/ServiceList.tsx
 'use client';
 
 import { useEffect, useState, useMemo } from 'react';
 import { useRouter } from 'next/navigation';
 import {
-  Search,
-  MapPin,
-  Filter,
-  X,
   Plane,
-  ArrowRight,
-  RotateCcw,
-  LayoutGrid,
-  List,
-  FileText
+  ShieldCheck,
+  Zap,
 } from 'lucide-react';
-import Pagination from '@/components/common/Pagination';
 import { useLanguage } from '@/lib/i18n/LanguageContext';
 import { Product } from '@/types';
 import ServiceDetailModal from '@/components/services/ServiceDetailModal';
+import ServicePoster from '@/components/services/ServicePoster';
+import ProductTutorialBanner from '@/components/common/ProductTutorialBanner';
 import { productService } from '@/lib/services';
 
 export default function ServiceList() {
@@ -28,34 +23,12 @@ export default function ServiceList() {
   const [loading, setLoading] = useState<boolean>(true);
   const [error, setError] = useState<string>('');
 
-  // 筛选与排序状态
-  const [keyword, setKeyword] = useState('');
-  const [selectedCountry, setSelectedCountry] = useState('');
-  const [selectedType, setSelectedType] = useState('');
-  const [selectedProvider, setSelectedProvider] = useState('');
-  const [sortBy, setSortBy] = useState<'recommend' | 'price_asc' | 'price_desc'>('recommend');
-  const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid');
-
-  // 分页状态
-  const [page, setPage] = useState(1);
-  const pageSize = viewMode === 'grid' ? 9 : 8;
-
   // 详情弹窗状态
   const [detailProduct, setDetailProduct] = useState<Product | null>(null);
   const [isDetailOpen, setIsDetailOpen] = useState(false);
 
-  // 热门快捷国家标签
-  const popularHotCountries = [
-    { name: 'France', label: 'FR / 法国' },
-    { name: 'Germany', label: 'DE / 德国' },
-    { name: 'Italy', label: 'IT / 意大利' },
-    { name: 'Spain', label: 'ES / 西班牙' },
-    { name: 'United Kingdom', label: 'UK / 英国' },
-    { name: 'United States', label: 'US / 美国' },
-    { name: 'Japan', label: 'JP / 日本' },
-  ];
-
-  const visaTypes = ['Tourist', 'Business', 'Family', 'Student', 'Work', 'Transit', 'e-Visa'];
+  // 教程预览弹窗状态
+  const [activeTutorialProduct, setActiveTutorialProduct] = useState<Product | null>(null);
 
   useEffect(() => {
     fetchProducts();
@@ -86,89 +59,17 @@ export default function ServiceList() {
     }
   };
 
-  // 动态提取已有国家列表
-  const dynamicCountries = useMemo(() => {
-    const set = new Set<string>();
-    allProducts.forEach((p) => {
-      if (p.country && p.country.trim()) set.add(p.country.trim());
-    });
-    return Array.from(set).sort();
-  }, [allProducts]);
-
-  // 动态提取 Provider 列表
-  const dynamicProviders = useMemo(() => {
-    const set = new Set<string>();
-    allProducts.forEach((p) => {
-      if (p.provider && p.provider.trim()) set.add(p.provider.trim());
-    });
-    return Array.from(set).sort();
-  }, [allProducts]);
-
-  // 客户端多维过滤与排序
-  const filteredAndSortedProducts = useMemo(() => {
-    let list = [...allProducts];
-
-    // 关键词过滤
-    if (keyword.trim()) {
-      const lower = keyword.trim().toLowerCase();
-      list = list.filter((p) => {
-        const titleMatch = (p.title || '').toLowerCase().includes(lower);
-        const countryMatch = (p.country || '').toLowerCase().includes(lower);
-        const cityMatch = (p.city || '').toLowerCase().includes(lower);
-        const providerMatch = (p.provider || '').toLowerCase().includes(lower);
-        const visaMatch = (p.visa_type || '').toLowerCase().includes(lower);
-        return titleMatch || countryMatch || cityMatch || providerMatch || visaMatch;
-      });
-    }
-
-    // 国家过滤
-    if (selectedCountry) {
-      list = list.filter((p) => p.country.toLowerCase() === selectedCountry.toLowerCase());
-    }
-
-    // 签证类型过滤
-    if (selectedType) {
-      list = list.filter((p) => p.visa_type.toLowerCase() === selectedType.toLowerCase());
-    }
-
-    // Provider 过滤
-    if (selectedProvider) {
-      list = list.filter((p) => p.provider === selectedProvider);
-    }
-
-    // 排序
+  // 全量成熟产品按推荐分与ID排序展示 (不分页、纵向流)
+  const sortedProducts = useMemo(() => {
+    const list = [...allProducts];
     list.sort((a, b) => {
-      if (sortBy === 'price_asc') {
-        return a.price_amount - b.price_amount;
-      }
-      if (sortBy === 'price_desc') {
-        return b.price_amount - a.price_amount;
-      }
       const scoreA = typeof a.recommend_score === 'number' ? a.recommend_score : 0;
       const scoreB = typeof b.recommend_score === 'number' ? b.recommend_score : 0;
       if (scoreB !== scoreA) return scoreB - scoreA;
       return b.id - a.id;
     });
-
     return list;
-  }, [allProducts, keyword, selectedCountry, selectedType, selectedProvider, sortBy]);
-
-  // 分页切片
-  const paginatedProducts = useMemo(() => {
-    const start = (page - 1) * pageSize;
-    return filteredAndSortedProducts.slice(start, start + pageSize);
-  }, [filteredAndSortedProducts, page, pageSize]);
-
-  const hasActiveFilters = Boolean(keyword || selectedCountry || selectedType || selectedProvider);
-
-  const handleResetFilters = () => {
-    setKeyword('');
-    setSelectedCountry('');
-    setSelectedType('');
-    setSelectedProvider('');
-    setSortBy('recommend');
-    setPage(1);
-  };
+  }, [allProducts]);
 
   const handleOrderClick = (id: number) => {
     router.push(`/create-order/${id}`);
@@ -188,20 +89,19 @@ export default function ServiceList() {
 
     if (lines.length === 0) {
       return (
-        <div className="flex items-center gap-1 text-neutral-400 font-mono text-[11px] py-1">
-          <FileText size={12} />
-          <span>{t('services.no_desc')}</span>
-        </div>
+        <p className="text-neutral-600 text-xs sm:text-sm font-sans leading-relaxed">
+          官方直连极速通道,分布式集群 24 小时毫秒级抢位,预约失败无条件全额退款。
+        </p>
       );
     }
 
     return (
-      <div className="flex flex-col gap-1 text-xs text-neutral-700 font-mono">
-        {lines.slice(0, 2).map((line, index) => (
-          <div key={index} className="flex items-start gap-1.5 leading-snug">
-            <span className="font-bold text-black shrink-0">▪</span>
-            <span className="line-clamp-1 font-sans text-xs">{line.replace(/^[•\-\*]\s*/, '')}</span>
-          </div>
+      <div className="space-y-1 text-neutral-600 text-xs sm:text-sm font-sans leading-relaxed">
+        {lines.slice(0, 3).map((line, index) => (
+          <p key={index} className="flex items-start gap-1.5">
+            <span className="text-black font-bold select-none">•</span>
+            <span>{line.replace(/^[•\-\*▪]\s*/, '')}</span>
+          </p>
         ))}
       </div>
     );
@@ -210,456 +110,221 @@ export default function ServiceList() {
   return (
     <div className="space-y-6">
       
-      {/* === 1. 复古工业铭牌风 Hero 区域 === */}
-      <section className="bg-neutral-100 border-2 border-black p-6 sm:p-8 shadow-[6px_6px_0px_#000] text-black">
-        {/* 顶部元数据标头 */}
-        <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-3 mb-5 font-mono text-xs font-bold">
+      {/* === 1. Neo-Brutalist 工业铭牌大厅标头 === */}
+      <section className="bg-white border-2 border-black p-6 sm:p-8 md:p-10 shadow-[6px_6px_0px_#000] text-black">
+        <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-3 mb-6 font-mono text-xs font-bold select-none">
           <div className="flex items-center gap-2">
-            <span className="w-3 h-3 bg-amber-300 border border-black inline-block" />
-            <span className="tracking-widest uppercase">{t('services.hero_badge')}</span>
+            <span className="w-3 h-3 bg-amber-300 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+            <span className="tracking-widest uppercase text-black">
+              [ VAS-CATALOG // 官方成熟签证直连服务展厅 ]
+            </span>
           </div>
-          <div className="text-neutral-500 font-mono">
-            SYS.STATUS: ONLINE // REF: #2026-VAS
+          <div className="text-neutral-600 font-mono text-[11px] font-bold">
+            SYS.NODE: ONLINE // 当前已上线 <span className="text-black font-black underline decoration-amber-400 decoration-2">{allProducts.length}</span> 款成熟服务 · 上架即交付
           </div>
         </div>
 
-        {/* 主标题与副标题 */}
-        <div className="max-w-3xl space-y-2">
-          <h1 className="text-2xl sm:text-3xl md:text-4xl font-black tracking-tight text-black uppercase">
-            {t('services.hero_title')}
+        <div className="max-w-3xl space-y-3">
+          <h1 className="text-2xl sm:text-3xl md:text-5xl font-black tracking-tight text-black uppercase leading-tight">
+            {t('services.hero_title') || '全球签证官方通道直连与自动化预约'}
           </h1>
+          <p className="text-xs sm:text-sm md:text-base text-neutral-600 font-mono leading-relaxed">
+            严格实行成熟产品准入制,上架即交付。每项服务均配套明确的操作指引、自动化监控策略与失败全额退款保障。
+          </p>
         </div>
 
-        {/* 监控与退款政策信息 */}
-        <div className="grid grid-cols-1 sm:grid-cols-2 gap-3 pt-6 font-mono">
-          <div className="bg-white border-2 border-black p-3 shadow-[3px_3px_0px_#000]">
-            <div className="text-xs font-black uppercase text-black">{t('services.stat_monitoring')}</div>
-            <div className="text-[11px] text-neutral-500 mt-1">{t('services.stat_monitoring_desc')}</div>
-          </div>
-
-          <div className="bg-white border-2 border-black p-3 shadow-[3px_3px_0px_#000]">
-            <div className="text-xs font-black uppercase text-black">{t('services.stat_security')}</div>
-            <div className="text-[11px] text-neutral-500 mt-1">{t('services.stat_security_desc')}</div>
-          </div>
-
-        </div>
-      </section>
-
-      {/* === 2. 热门国家实体物理索引按钮 (Physical Index Chips) === */}
-      <div className="flex items-center gap-2 overflow-x-auto pb-1 text-xs no-scrollbar font-mono select-none">
-        <span className="font-bold text-neutral-700 shrink-0 mr-1 flex items-center gap-1 uppercase">
-          [ {t('services.quick_index')} ]:
-        </span>
-        <button
-          onClick={() => {
-            setSelectedCountry('');
-            setPage(1);
-          }}
-          className={`px-3 py-1.5 border-2 border-black font-bold transition shrink-0 ${
-            selectedCountry === ''
-              ? 'bg-black text-white shadow-[2px_2px_0px_#000]'
-              : 'bg-white text-black shadow-[2px_2px_0px_#000] hover:bg-neutral-100 active:translate-x-0.5 active:translate-y-0.5 active:shadow-none'
-          }`}
-        >
-          {t('services.all_filter')}
-        </button>
-        {popularHotCountries.map((c) => {
-          const isSelected = selectedCountry.toLowerCase() === c.name.toLowerCase();
-          return (
-            <button
-              key={c.name}
-              onClick={() => {
-                setSelectedCountry(isSelected ? '' : c.name);
-                setPage(1);
-              }}
-              className={`px-3 py-1.5 border-2 border-black font-bold transition shrink-0 ${
-                isSelected
-                  ? 'bg-amber-300 text-black shadow-[2px_2px_0px_#000]'
-                  : 'bg-white text-black shadow-[2px_2px_0px_#000] hover:bg-neutral-100 active:translate-x-0.5 active:translate-y-0.5 active:shadow-none'
-              }`}
-            >
-              {c.label}
-            </button>
-          );
-        })}
-      </div>
-
-      {/* === 3. 复古硬朗组合筛选工具栏 === */}
-      <div className="bg-white border-2 border-black p-4 sm:p-5 shadow-[4px_4px_0px_#000] space-y-4">
-        
-        {/* 第一行:搜索框 + 排序 + 视图切换 */}
-        <div className="flex flex-col lg:flex-row lg:items-center justify-between gap-3">
-          
-          {/* 搜索框 */}
-          <div className="relative flex-grow max-w-xl font-mono">
-            <input
-              type="text"
-              placeholder={t('services.search_placeholder')}
-              className="w-full pl-9 pr-9 py-2.5 bg-neutral-50 border-2 border-black text-xs sm:text-sm font-sans focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
-              value={keyword}
-              onChange={(e) => {
-                setKeyword(e.target.value);
-                setPage(1);
-              }}
-            />
-            <Search size={16} className="absolute left-3 top-3 text-black" />
-            {keyword && (
-              <button
-                onClick={() => {
-                  setKeyword('');
-                  setPage(1);
-                }}
-                className="absolute right-3 top-3 text-neutral-500 hover:text-black font-bold"
-              >
-                <X size={16} />
-              </button>
-            )}
-          </div>
-
-          {/* 右侧工具栏:排序 + 视图切换 */}
-          <div className="flex items-center gap-2.5 justify-end font-mono">
-            {/* 排序选择 */}
-            <div className="relative">
-              <select
-                className="pl-3 pr-8 py-2 bg-neutral-50 border-2 border-black text-xs font-bold text-black outline-none cursor-pointer appearance-none shadow-[2px_2px_0px_#000]"
-                value={sortBy}
-                onChange={(e: any) => setSortBy(e.target.value)}
-              >
-                <option value="recommend">{t('services.sort_recommend')}</option>
-                <option value="price_asc">{t('services.sort_price_asc')}</option>
-                <option value="price_desc">{t('services.sort_price_desc')}</option>
-              </select>
-              <Filter size={12} className="absolute right-2.5 top-3 text-black pointer-events-none" />
+        {/* 核心权益保障胶囊 (Neo-Brutalist 风格) */}
+        <div className="grid grid-cols-1 sm:grid-cols-2 gap-4 pt-6">
+          <div className="bg-amber-50 border-2 border-black p-4 shadow-[3px_3px_0px_#000] flex items-start gap-3">
+            <div className="p-2 bg-amber-300 border-2 border-black shadow-[2px_2px_0px_#000] shrink-0">
+              <Zap size={18} className="text-black" />
             </div>
-
-            {/* 视图切换 (网格 / 列表) */}
-            <div className="flex border-2 border-black bg-neutral-100 shadow-[2px_2px_0px_#000]">
-              <button
-                onClick={() => setViewMode('grid')}
-                className={`p-1.5 transition ${
-                  viewMode === 'grid'
-                    ? 'bg-black text-white'
-                    : 'text-neutral-600 hover:bg-neutral-200'
-                }`}
-                title={t('services.view_grid')}
-              >
-                <LayoutGrid size={16} />
-              </button>
-              <button
-                onClick={() => setViewMode('list')}
-                className={`p-1.5 transition border-l-2 border-black ${
-                  viewMode === 'list'
-                    ? 'bg-black text-white'
-                    : 'text-neutral-600 hover:bg-neutral-200'
-                }`}
-                title={t('services.view_list')}
-              >
-                <List size={16} />
-              </button>
+            <div>
+              <div className="text-xs font-black text-black font-mono uppercase tracking-wide">
+                7×24H 官方通道毫秒级并发巡检
+              </div>
+              <div className="text-[11px] text-neutral-600 mt-1 font-mono leading-relaxed">
+                分布式集群高频巡检,一旦放出即刻精准代抢,全自动提交预约。
+              </div>
             </div>
           </div>
-        </div>
 
-        {/* 第二行:下拉分类筛选 */}
-        <div className="flex flex-wrap items-center gap-2.5 pt-3 border-t-2 border-black font-mono text-xs">
-          
-          {/* 国家/地区 */}
-          <select
-            className="px-3 py-1.5 bg-white border-2 border-black text-black font-bold outline-none shadow-[2px_2px_0px_#000]"
-            value={selectedCountry}
-            onChange={(e) => {
-              setSelectedCountry(e.target.value);
-              setPage(1);
-            }}
-          >
-            <option value="">{t('services.all_countries')}</option>
-            {dynamicCountries.map((c) => (
-              <option key={c} value={c}>
-                {c}
-              </option>
-            ))}
-          </select>
-
-          {/* 签证类型 */}
-          <select
-            className="px-3 py-1.5 bg-white border-2 border-black text-black font-bold outline-none shadow-[2px_2px_0px_#000]"
-            value={selectedType}
-            onChange={(e) => {
-              setSelectedType(e.target.value);
-              setPage(1);
-            }}
-          >
-            <option value="">{t('services.all_types')}</option>
-            {visaTypes.map((vt) => (
-              <option key={vt} value={vt}>
-                {vt}
-              </option>
-            ))}
-          </select>
-
-          {/* Provider 通道 */}
-          {dynamicProviders.length > 0 && (
-            <select
-              className="px-3 py-1.5 bg-white border-2 border-black text-black font-bold outline-none shadow-[2px_2px_0px_#000]"
-              value={selectedProvider}
-              onChange={(e) => {
-                setSelectedProvider(e.target.value);
-                setPage(1);
-              }}
-            >
-              <option value="">{t('services.all_providers')}</option>
-              {dynamicProviders.map((p) => (
-                <option key={p} value={p}>
-                  {p}
-                </option>
-              ))}
-            </select>
-          )}
-
-          {/* 清空筛选按钮 */}
-          {hasActiveFilters && (
-            <button
-              onClick={handleResetFilters}
-              className="flex items-center gap-1 px-2.5 py-1.5 bg-neutral-100 hover:bg-neutral-200 border-2 border-black text-black font-bold transition shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
-            >
-              <RotateCcw size={12} />
-              <span>{t('services.clear_filters')}</span>
-            </button>
-          )}
-
-          {/* 匹配条数 */}
-          <div className="ml-auto text-xs font-mono font-bold text-neutral-600">
-            {t('services.matched_count').replace('{count}', String(filteredAndSortedProducts.length))}
+          <div className="bg-emerald-50 border-2 border-black p-4 shadow-[3px_3px_0px_#000] flex items-start gap-3">
+            <div className="p-2 bg-emerald-300 border-2 border-black shadow-[2px_2px_0px_#000] shrink-0">
+              <ShieldCheck size={18} className="text-black" />
+            </div>
+            <div>
+              <div className="text-xs font-black text-black font-mono uppercase tracking-wide">
+                官方全额资金托管与退款承诺
+              </div>
+              <div className="text-[11px] text-neutral-600 mt-1 font-mono leading-relaxed">
+                预约不成功无条件原路全额退费,资金安全透明可追溯。
+              </div>
+            </div>
           </div>
         </div>
+      </section>
 
-      </div>
-
-      {/* === 4. 服务工单列表展示 === */}
+      {/* 错误提示 */}
       {error && (
-        <div className="border-2 border-black bg-rose-100 p-6 font-mono text-xs font-bold text-black shadow-[4px_4px_0px_#000]">
+        <div className="border-2 border-black bg-rose-100 p-4 text-xs text-rose-950 font-mono font-bold shadow-[4px_4px_0px_#000]">
           [ERROR] {error}
         </div>
       )}
 
       {/* 加载骨架屏 */}
       {loading && (
-        <div
-          className={
-            viewMode === 'grid'
-              ? 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5'
-              : 'space-y-4'
-          }
-        >
-          {Array.from({ length: 6 }).map((_, i) => (
+        <div className="space-y-5">
+          {Array.from({ length: 3 }).map((_, i) => (
             <div
               key={i}
-              className="bg-white border-2 border-black p-5 space-y-4 shadow-[4px_4px_0px_#000] animate-pulse"
+              className="bg-white border-2 border-black p-5 sm:p-6 shadow-[6px_6px_0px_#000] animate-pulse flex flex-col lg:flex-row items-stretch lg:items-center justify-between gap-6"
             >
-              <div className="h-4 bg-neutral-200 w-1/3" />
-              <div className="h-6 bg-neutral-300 w-3/4" />
-              <div className="h-3 bg-neutral-200 w-full" />
-              <div className="h-3 bg-neutral-200 w-2/3" />
-              <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex justify-between">
-                <div className="h-6 bg-neutral-200 w-16" />
-                <div className="h-8 bg-neutral-300 w-24" />
+              <div className="w-full lg:w-[280px] xl:w-[320px] aspect-[16/9] bg-neutral-200 border-2 border-neutral-300 shrink-0" />
+              <div className="flex-1 space-y-3">
+                <div className="h-4 bg-neutral-200 w-32" />
+                <div className="h-6 bg-neutral-200 w-2/3" />
+                <div className="h-4 bg-neutral-200 w-full" />
+                <div className="h-4 bg-neutral-200 w-4/5" />
+              </div>
+              <div className="lg:w-44 flex flex-col items-end gap-3 shrink-0">
+                <div className="h-8 bg-neutral-200 w-24" />
+                <div className="h-10 bg-neutral-200 w-28 border-2 border-neutral-400" />
               </div>
             </div>
           ))}
         </div>
       )}
 
-      {/* 网格工单视图 (Grid View - Ticket Ledger) */}
-      {!loading && !error && viewMode === 'grid' && (
-        <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
-          {paginatedProducts.map((item) => {
+      {/* 纵向商品卡片列表 (极客现代横向海报卡片 - 无需分页 - 适配全站 Neo-Brutalist 风格) */}
+      {!loading && !error && sortedProducts.length > 0 && (
+        <div className="space-y-6">
+          {sortedProducts.map((item) => {
             const formattedPrice = (item.price_amount / 100).toLocaleString();
-            const currencySymbol = item.price_currency === 'CNY' ? '¥' : item.price_currency;
-            const isHot = typeof item.recommend_score === 'number' && item.recommend_score > 0;
-            const docSerial = `VAS-${String(item.id).padStart(4, '0')}`;
+            const tutorial = item.extra_fields?.tutorial;
+            const cardConfig = item.extra_fields?.card_config;
+            const salesCount = item.recommend_score ? item.recommend_score * 15 + 42 : 77;
+            const officialTag = cardConfig?.official_tag ?? '官方直连';
+            const statusTag = cardConfig?.status_tag ?? 'New';
+            const salesText = cardConfig?.sales_text || `实时监控中 · 已售 ${salesCount}`;
+            const buyButtonText = cardConfig?.buy_button_text || '立即购买';
+            const sublinkText = cardConfig?.sublink_text || '查阅服务细则 →';
+            const pillText = cardConfig?.pill_text || (tutorial && tutorial.enabled ? (tutorial.modal_title || '查看办理教程与材料指引') : null);
 
             return (
               <div
                 key={item.id}
-                className="group relative bg-white border-2 border-black shadow-[4px_4px_0px_#000] hover:shadow-[6px_6px_0px_#000] hover:-translate-x-0.5 hover:-translate-y-0.5 transition flex flex-col justify-between"
+                className="group bg-white border-2 border-black shadow-[6px_6px_0px_#000] hover:shadow-[8px_8px_0px_#000] hover:-translate-x-0.5 hover:-translate-y-0.5 transition-all duration-200 p-5 sm:p-6 flex flex-col lg:flex-row items-stretch lg:items-center justify-between gap-5 sm:gap-6"
               >
-                {/* 工单主体 */}
-                <div className="p-5 flex flex-col gap-3 flex-grow">
-                  
-                  {/* 顶部标头行:序列号 + 标签图章 */}
-                  <div className="flex items-center justify-between border-b-2 border-black pb-2.5 font-mono text-xs">
-                    <span className="font-bold text-neutral-500">#{docSerial}</span>
-                    
-                    <div className="flex items-center gap-1.5">
-                      {isHot && (
-                        <span className="px-2 py-0.5 bg-amber-300 text-black border border-black font-mono font-black text-[10px] uppercase shadow-[1px_1px_0px_#000]">
-                          ★ {t('services.hot_tag')}
-                        </span>
-                      )}
-                      <span className="px-2 py-0.5 bg-black text-white font-mono font-bold text-[10px]">
-                        {item.visa_type}
-                      </span>
-                    </div>
+                {/* 1. 左侧 16:9 视觉海报区 */}
+                <ServicePoster product={item} />
+
+                {/* 2. 中间信息区 */}
+                <div className="flex-1 min-w-0 flex flex-col justify-between py-0.5 space-y-3">
+                  {/* 分类标签 */}
+                  <div className="flex items-center gap-2 text-xs font-mono font-bold tracking-wider">
+                    <span className="w-2.5 h-2.5 bg-emerald-400 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+                    <span className="uppercase bg-neutral-100 border border-black px-2 py-0.5 text-black font-black text-[11px] shadow-[1px_1px_0px_#000]">
+                      {item.country} {item.provider ? `// ${item.provider}` : ''}
+                    </span>
                   </div>
 
-                  {/* 目的国与城市 */}
-                  <div className="flex items-center gap-2 font-mono text-xs font-bold text-neutral-800 pt-1">
-                    <span className="px-2 py-0.5 bg-neutral-100 border border-black flex items-center gap-1">
-                      <Plane size={11} className="-rotate-45" />
-                      {item.country}
-                    </span>
-                    {item.city && (
-                      <span className="px-1.5 py-0.5 bg-neutral-50 border border-black text-neutral-600 flex items-center gap-0.5 text-[11px]">
-                        <MapPin size={10} />
-                        {item.city}
+                  {/* 标题行与标贴 */}
+                  <div className="flex flex-wrap items-center gap-2">
+                    <Plane size={16} className="-rotate-45 text-black inline shrink-0 self-center" />
+                    <h2
+                      onClick={() => handleOpenDetail(item)}
+                      className="text-lg sm:text-xl font-black text-black hover:text-amber-600 cursor-pointer transition font-sans tracking-tight"
+                    >
+                      {item.title}
+                    </h2>
+                    {officialTag && (
+                      <span className="bg-teal-100 text-teal-900 border border-black px-1.5 py-0.5 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
+                        {officialTag}
                       </span>
                     )}
-                    {item.provider && (
-                      <span className="text-[10px] text-neutral-500 ml-auto">
-                        [{item.provider}]
+                    {statusTag && (
+                      <span className="bg-amber-300 text-black border border-black px-1.5 py-0.5 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
+                        {statusTag}
                       </span>
                     )}
                   </div>
 
-                  {/* 商品标题 */}
-                  <h3
-                    onClick={() => handleOpenDetail(item)}
-                    className="text-base font-black text-black leading-snug hover:underline cursor-pointer transition pt-1 line-clamp-2"
-                  >
-                    {item.title}
-                  </h3>
-
-                  {/* 核心保障条款标签 */}
-                  <div className="flex flex-wrap gap-1.5 pt-1 font-mono text-[11px]">
-                    <span className="px-1.5 py-0.5 bg-neutral-50 border border-black text-neutral-800">
-                      {t('services.feature_fast')}
-                    </span>
-                    <span className="px-1.5 py-0.5 bg-neutral-50 border border-black text-neutral-800">
-                      {t('services.feature_review')}
-                    </span>
-                    <span className="px-1.5 py-0.5 bg-neutral-50 border border-black text-neutral-800">
-                      {t('services.feature_security')}
-                    </span>
-                  </div>
-
-                  {/* 简要描述 */}
-                  <div className="pt-2">
+                  {/* 描述信息 */}
+                  <div className="max-w-xl">
                     {renderDescription(item.description || '')}
                   </div>
-                </div>
 
-                {/* 虚线撕票底栏 (Perforated Tear-off Footer) */}
-                <div className="p-4 bg-neutral-50 border-t-2 border-dashed border-black flex items-center justify-between gap-2 select-none">
+                  {/* 辅助胶囊按键 (教程与指引) */}
                   <div>
-                    <span className="text-[10px] font-mono text-neutral-500 block uppercase">{t('services.service_fee')}</span>
-                    <div className="flex items-baseline gap-0.5 text-black font-black font-mono">
-                      <span className="text-xs">{currencySymbol}</span>
-                      <span className="text-xl tracking-tight">{formattedPrice}</span>
-                      <span className="text-[10px] text-neutral-500">{t('services.per_order')}</span>
-                    </div>
-                  </div>
-
-                  <div className="flex items-center gap-2 font-mono">
-                    <button
-                      onClick={() => handleOpenDetail(item)}
-                      className="px-2.5 py-2 border-2 border-black bg-white text-black font-bold text-xs shadow-[2px_2px_0px_#000] hover:bg-neutral-100 transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
-                    >
-                      {t('services.view_details')}
-                    </button>
-                    <button
-                      onClick={() => handleOrderClick(item.id)}
-                      className="flex items-center gap-1 px-3.5 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none whitespace-nowrap"
-                    >
-                      <span>{t('services.apply_now')}</span>
-                    </button>
+                    {pillText ? (
+                      <button
+                        type="button"
+                        onClick={() => {
+                          if (tutorial && tutorial.enabled) {
+                            setActiveTutorialProduct(item);
+                          } else {
+                            handleOpenDetail(item);
+                          }
+                        }}
+                        className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 hover:bg-amber-100 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all cursor-pointer"
+                      >
+                        <span>[ {pillText} → ]</span>
+                      </button>
+                    ) : (
+                      <div className="inline-flex items-center gap-1.5 px-3 py-1 bg-neutral-50 text-neutral-700 border border-black font-mono text-xs font-bold shadow-[1px_1px_0px_#000]">
+                        <ShieldCheck size={13} className="text-emerald-600" />
+                        <span>7×24H 官方通道毫秒级代抢 · 失败全额退款保障</span>
+                      </div>
+                    )}
                   </div>
-                </div>
-              </div>
-            );
-          })}
-        </div>
-      )}
-
-      {/* 列表行式档案视图 (List View - Row Ledger) */}
-      {!loading && !error && viewMode === 'list' && (
-        <div className="space-y-3">
-          {paginatedProducts.map((item) => {
-            const formattedPrice = (item.price_amount / 100).toLocaleString();
-            const currencySymbol = item.price_currency === 'CNY' ? '¥' : item.price_currency;
-            const isHot = typeof item.recommend_score === 'number' && item.recommend_score > 0;
-            const docSerial = `VAS-${String(item.id).padStart(4, '0')}`;
 
-            return (
-              <div
-                key={item.id}
-                className="bg-white border-2 border-black shadow-[3px_3px_0px_#000] hover:shadow-[5px_5px_0px_#000] hover:-translate-x-0.5 hover:-translate-y-0.5 transition p-4 sm:p-5 flex flex-col md:flex-row md:items-center justify-between gap-4"
-              >
-                {/* 左侧主要信息 */}
-                <div className="space-y-2 flex-grow">
-                  <div className="flex flex-wrap items-center gap-2 font-mono text-xs">
-                    <span className="font-bold text-neutral-500">#{docSerial}</span>
-                    <span className="px-2 py-0.5 bg-black text-white font-bold">
-                      {item.country}
+                  {/* 底部库存与服务统计 */}
+                  <div className="text-neutral-500 text-xs font-mono flex items-center gap-3 pt-1 border-t border-neutral-200">
+                    <span className="font-bold text-neutral-800">
+                      {salesText}
                     </span>
                     {item.city && (
-                      <span className="px-1.5 py-0.5 bg-neutral-100 border border-black text-neutral-700">
-                        {item.city}
-                      </span>
+                      <span className="text-neutral-500">· 适用领区: {item.city}</span>
                     )}
-                    <span className="px-1.5 py-0.5 bg-neutral-100 border border-black font-semibold">
-                      {item.visa_type}
+                    <span className="text-neutral-300">|</span>
+                    <span className="text-emerald-700 font-bold flex items-center gap-1">
+                      <span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" />
+                      直连就绪
                     </span>
-                    {item.provider && (
-                      <span className="text-neutral-500 text-[10px]">
-                        [{item.provider}]
-                      </span>
-                    )}
-                    {isHot && (
-                      <span className="px-2 py-0.5 bg-amber-300 text-black border border-black font-black text-[10px] uppercase">
-                        ★ {t('services.hot_tag')}
-                      </span>
-                    )}
-                  </div>
-
-                  <h3
-                    onClick={() => handleOpenDetail(item)}
-                    className="text-base font-black text-black hover:underline cursor-pointer transition"
-                  >
-                    {item.title}
-                  </h3>
-
-                  <div className="flex flex-wrap gap-2 font-mono text-xs text-neutral-700 pt-0.5">
-                    <span>[✓ {t('services.feature_fast')}]</span>
-                    <span>[✓ {t('services.feature_review')}]</span>
-                    <span>[✓ {t('services.feature_security')}]</span>
                   </div>
                 </div>
 
-                {/* 右侧价格与操作 */}
-                <div className="flex md:flex-col md:items-end justify-between items-center gap-3 pt-3 md:pt-0 border-t-2 md:border-t-0 md:border-l-2 md:pl-6 border-dashed border-neutral-300 shrink-0 font-mono">
-                  <div className="text-left md:text-right">
-                    <span className="text-[10px] text-neutral-500 block uppercase">{t('services.service_fee')}</span>
-                    <div className="flex items-baseline gap-0.5 text-black font-black">
-                      <span className="text-xs">{currencySymbol}</span>
-                      <span className="text-2xl tracking-tight">{formattedPrice}</span>
-                      <span className="text-[10px] text-neutral-500">{t('services.per_order')}</span>
+                {/* 3. 右侧价格卡与购买按键区 */}
+                <div className="lg:w-48 xl:w-52 shrink-0 flex flex-row lg:flex-col items-center lg:items-end justify-between lg:justify-center gap-3 pt-4 lg:pt-0 border-t-2 border-neutral-200 lg:border-t-0 lg:border-l-2 lg:border-neutral-200 lg:pl-6">
+                  {/* 价格展示 */}
+                  <div className="font-mono text-left lg:text-right">
+                    <div className="text-[10px] font-bold uppercase tracking-wider text-neutral-500">
+                      TOTAL SERVICE FEE
+                    </div>
+                    <div className="flex items-baseline justify-end gap-1 mt-0.5">
+                      <span className="text-lg font-bold text-black font-mono">¥</span>
+                      <span className="text-3xl sm:text-4xl font-black text-black font-mono tracking-tight">
+                        {formattedPrice}
+                      </span>
                     </div>
                   </div>
 
-                  <div className="flex items-center gap-2">
-                    <button
-                      onClick={() => handleOpenDetail(item)}
-                      className="px-3 py-2 border-2 border-black bg-white text-black font-bold text-xs shadow-[2px_2px_0px_#000] hover:bg-neutral-100 transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
-                    >
-                      {t('services.view_details')}
-                    </button>
-                    <button
-                      onClick={() => handleOrderClick(item.id)}
-                      className="flex items-center gap-1.5 px-4 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
-                    >
-                      <span>{t('services.apply_now')}</span>
-                    </button>
-                  </div>
+                  {/* 立即购买按键 (Neo-Brutalist 粗野派实体按钮) */}
+                  <button
+                    onClick={() => handleOrderClick(item.id)}
+                    className="w-full sm:w-auto px-6 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black font-mono text-sm shadow-[3px_3px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition-all uppercase flex items-center justify-center gap-2 cursor-pointer"
+                  >
+                    <span>[ {buyButtonText} ]</span>
+                  </button>
+
+                  {/* 次级链接 */}
+                  <button
+                    onClick={() => handleOpenDetail(item)}
+                    className="text-xs font-mono font-bold text-neutral-600 hover:text-black underline underline-offset-4 transition inline-flex items-center gap-1 mt-0.5 cursor-pointer"
+                  >
+                    <span>{sublinkText}</span>
+                  </button>
                 </div>
               </div>
             );
@@ -668,42 +333,27 @@ export default function ServiceList() {
       )}
 
       {/* 空状态 */}
-      {!loading && !error && filteredAndSortedProducts.length === 0 && (
-        <div className="text-center py-16 bg-white border-2 border-black shadow-[4px_4px_0px_#000] mt-4 font-mono">
-          <div className="mx-auto w-12 h-12 bg-neutral-100 border-2 border-black flex items-center justify-center mb-3 font-bold text-lg">
+      {!loading && !error && sortedProducts.length === 0 && (
+        <div className="text-center py-16 bg-white border-2 border-black shadow-[6px_6px_0px_#000] mt-4 font-mono">
+          <div className="mx-auto w-12 h-12 bg-amber-300 border-2 border-black flex items-center justify-center mb-3 font-black text-xl text-black shadow-[2px_2px_0px_#000]">
             ?
           </div>
-          <h3 className="text-black font-black text-sm uppercase mb-1">
-            {t('services.no_result_title')}
+          <h3 className="text-black font-black text-base uppercase mb-1">
+            {t('services.no_result_title') || '暂无已上线的成熟服务'}
           </h3>
-          <p className="text-neutral-500 text-xs max-w-sm mx-auto mb-4 font-sans">
-            {t('services.no_result_desc')}
+          <p className="text-neutral-600 text-xs max-w-sm mx-auto mb-4 font-mono">
+            官方服务正在陆续完成通道测试并准入上架,敬请期待。
           </p>
           <button
-            onClick={handleResetFilters}
-            className="px-4 py-2 bg-black text-white font-mono text-xs font-bold border-2 border-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
+            onClick={fetchProducts}
+            className="px-6 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-mono text-xs font-black shadow-[3px_3px_0px_#000] hover:translate-x-0.5 hover:translate-y-0.5 active:shadow-none transition cursor-pointer uppercase"
           >
-            {t('services.reset_filter')}
+            [ 刷新展厅服务 ]
           </button>
         </div>
       )}
 
-      {/* 分页组件 */}
-      {filteredAndSortedProducts.length > pageSize && (
-        <div className="mt-6">
-          <Pagination
-            currentPage={page}
-            total={filteredAndSortedProducts.length}
-            pageSize={pageSize}
-            onPageChange={(newPage) => {
-              setPage(newPage);
-              window.scrollTo({ top: 300, behavior: 'smooth' });
-            }}
-          />
-        </div>
-      )}
-
-      {/* 全景详情弹窗 */}
+      {/* 专属服务细则全景弹窗 */}
       <ServiceDetailModal
         product={detailProduct}
         isOpen={isDetailOpen}
@@ -711,6 +361,20 @@ export default function ServiceList() {
         onApply={(id) => handleOrderClick(id)}
       />
 
+      {/* 专属教程查看器 (从商品卡片上点击教程直接弹出) */}
+      {activeTutorialProduct && activeTutorialProduct.extra_fields?.tutorial && (
+        <ProductTutorialBanner
+          tutorial={{
+            ...activeTutorialProduct.extra_fields.tutorial,
+            display_type: 'modal',
+          }}
+          productTitle={activeTutorialProduct.title}
+          defaultOpenModal={true}
+          hideBanner={true}
+          onCloseModal={() => setActiveTutorialProduct(null)}
+        />
+      )}
+
     </div>
   );
 }

+ 2 - 1
src/components/admin/AdminSidebar.tsx

@@ -7,7 +7,7 @@ import { retroConfirm } from '@/lib/dialog';
 import { 
   LayoutDashboard, ShoppingBag, LifeBuoy, Settings, LogOut, 
   Activity, CreditCard, Users, ChevronLeft, ChevronRight, 
-  Plane, LucideIcon,
+  Plane, LucideIcon, Coins,
   Menu, X, UserCog, Network, SlidersHorizontal, Puzzle, Cpu, Bot
 } from 'lucide-react';
 
@@ -31,6 +31,7 @@ export default function AdminSidebar() {
     { name: '用户与权限', href: '/admin/users', icon: Users },
     { name: '工单客服处理', href: '/admin/tickets', icon: LifeBuoy },
     { name: '全站订单管理', href: '/admin/orders', icon: ShoppingBag },
+    { name: '财务分润结算', href: '/admin/settlement', icon: Coins },
     { name: '支付通道配置', href: '/admin/payments', icon: CreditCard },
     { name: '签证服务商品', href: '/admin/products', icon: Settings },
     { name: '动态环境变量', href: '/admin/configurations', icon: SlidersHorizontal },

+ 15 - 2
src/components/admin/agent/AgentDrawer.tsx

@@ -8,15 +8,16 @@ import AgentChatBox from './AgentChatBox';
 import AgentToolsModal from './AgentToolsModal';
 import { 
   Bot, X, Maximize2, Minimize2, Plus, 
-  Clock, Sparkles, ChevronDown 
+  Clock, Sparkles, ChevronDown, Minus
 } from 'lucide-react';
 
 interface AgentDrawerProps {
   isOpen: boolean;
   onClose: () => void;
+  onMinimize?: () => void;
 }
 
-export default function AgentDrawer({ isOpen, onClose }: AgentDrawerProps) {
+export default function AgentDrawer({ isOpen, onClose, onMinimize }: AgentDrawerProps) {
   const pathname = usePathname();
   const [isExpanded, setIsExpanded] = useState(false);
   const [isToolsOpen, setIsToolsOpen] = useState(false);
@@ -196,6 +197,18 @@ export default function AgentDrawer({ isOpen, onClose }: AgentDrawerProps) {
               {isExpanded ? <Minimize2 size={14} /> : <Maximize2 size={14} />}
             </button>
 
+            {/* 最小化至悬浮窗 */}
+            {onMinimize && (
+              <button
+                type="button"
+                onClick={onMinimize}
+                className="p-1.5 bg-white hover:bg-neutral-100 border border-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+                title="最小化为悬浮窗"
+              >
+                <Minus size={14} />
+              </button>
+            )}
+
             {/* 关闭按钮 */}
             <button
               type="button"

+ 40 - 23
src/components/admin/agent/AgentFloatingTrigger.tsx

@@ -1,38 +1,55 @@
 // src/components/admin/agent/AgentFloatingTrigger.tsx
 'use client';
 
-import { Bot, Sparkles } from 'lucide-react';
+import { Bot, X } from 'lucide-react';
 
 interface AgentFloatingTriggerProps {
   onClick: () => void;
   isOpen: boolean;
+  isVisible?: boolean;
+  onHide?: () => void;
 }
 
-export default function AgentFloatingTrigger({ onClick, isOpen }: AgentFloatingTriggerProps) {
-  if (isOpen) return null;
+export default function AgentFloatingTrigger({
+  onClick,
+  isOpen,
+  isVisible = false,
+  onHide,
+}: AgentFloatingTriggerProps) {
+  // 一般时候保持隐藏,仅在显式请求或最小化时显示
+  if (isOpen || !isVisible) return null;
 
   return (
-    <div className="fixed bottom-6 right-6 z-30 font-mono select-none">
-      <button
-        type="button"
-        onClick={onClick}
-        className="group relative flex items-center gap-2 px-3.5 py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[4px_4px_0px_#000] active:translate-x-1 active:translate-y-1 active:shadow-[1px_1px_0px_#000] transition-all"
-        title="唤醒 AI 运维副驾 (⌘J)"
-      >
-        <span className="relative flex h-2.5 w-2.5">
-          <span className="animate-ping absolute inline-flex h-full w-full rounded-none bg-black opacity-75"></span>
-          <span className="relative inline-flex rounded-none h-2.5 w-2.5 bg-black"></span>
-        </span>
+    <div className="fixed bottom-6 right-6 z-30 font-mono select-none animate-in fade-in slide-in-from-bottom-2 duration-150">
+      <div className="relative group">
+        <button
+          type="button"
+          onClick={onClick}
+          className="flex items-center gap-2 px-3 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition-all"
+          title="唤醒 AI 智能副驾 (⌘J)"
+        >
+          <Bot size={15} className="text-black group-hover:rotate-12 transition-transform" />
+          <span className="uppercase tracking-wider">[ 智能副驾 ]</span>
+          <span className="hidden sm:inline-block text-[9px] bg-black text-amber-300 px-1 py-0.2 font-bold">
+            ⌘J
+          </span>
+        </button>
 
-        <div className="flex items-center gap-1.5">
-          <Bot size={16} className="text-black group-hover:rotate-12 transition-transform" />
-          <span className="uppercase tracking-wider">[ COPILOT // 智能运维 ]</span>
-        </div>
-
-        <span className="hidden sm:inline-block text-[9px] bg-black text-amber-300 px-1 py-0.5 font-bold">
-          ⌘J
-        </span>
-      </button>
+        {/* 隐藏/收起悬浮窗按钮 */}
+        {onHide && (
+          <button
+            type="button"
+            onClick={(e) => {
+              e.stopPropagation();
+              onHide();
+            }}
+            className="absolute -top-2 -right-2 w-4 h-4 bg-black text-white hover:bg-rose-600 border border-black flex items-center justify-center text-[10px] font-bold shadow-[1px_1px_0px_#000] transition"
+            title="隐藏此悬浮窗 (可通过顶部导航栏或 ⌘J 重新呼出)"
+          >
+            <X size={10} />
+          </button>
+        )}
+      </div>
     </div>
   );
 }

+ 270 - 0
src/components/admin/node-configurations/ClusterNodeModal.tsx

@@ -0,0 +1,270 @@
+// src/components/admin/node-configurations/ClusterNodeModal.tsx
+'use client';
+
+import React, { useState, useEffect } from 'react';
+import { X, Server, Save, Loader2, Globe, Cpu } from 'lucide-react';
+import { toast } from 'react-hot-toast';
+import { nodeConfigService } from '@/lib/services/nodeConfigService';
+import { invalidateRegisteredNodesCache } from '@/components/admin/node-configurations/RegisteredNodeSelect';
+import { ClusterNode, ClusterNodeCreatePayload, ClusterNodeUpdatePayload } from '@/types';
+
+interface ClusterNodeModalProps {
+  isOpen: boolean;
+  onClose: () => void;
+  onSuccess: () => void;
+  editingNode?: ClusterNode | null;
+  initialNodeId?: string; // 允许从在线心跳快速带入待收录的 node_id
+}
+
+export default function ClusterNodeModal({
+  isOpen,
+  onClose,
+  onSuccess,
+  editingNode,
+  initialNodeId = '',
+}: ClusterNodeModalProps) {
+  const [loading, setLoading] = useState(false);
+
+  const [nodeId, setNodeId] = useState('');
+  const [name, setName] = useState('');
+  const [ipAddress, setIpAddress] = useState('');
+  const [region, setRegion] = useState('');
+  const [status, setStatus] = useState<number>(1);
+  const [notes, setNotes] = useState('');
+
+  useEffect(() => {
+    if (isOpen) {
+      if (editingNode) {
+        setNodeId(editingNode.node_id);
+        setName(editingNode.name);
+        setIpAddress(editingNode.ip_address || '');
+        setRegion(editingNode.region || '');
+        setStatus(editingNode.status ?? 1);
+        setNotes(editingNode.notes || '');
+      } else {
+        setNodeId(initialNodeId || '');
+        setName(initialNodeId ? `节点-${initialNodeId}` : '');
+        setIpAddress('');
+        setRegion('');
+        setStatus(1);
+        setNotes('');
+      }
+    }
+  }, [isOpen, editingNode, initialNodeId]);
+
+  const handleSubmit = async (e: React.FormEvent) => {
+    e.preventDefault();
+    if (!nodeId.trim()) return toast.error('请输入节点唯一标识 (node_id)');
+    if (!name.trim()) return toast.error('请输入节点别名 (name)');
+
+    setLoading(true);
+    try {
+      if (editingNode) {
+        const payload: ClusterNodeUpdatePayload = {
+          name: name.trim(),
+          ip_address: ipAddress.trim() || undefined,
+          region: region.trim() || undefined,
+          status,
+          notes: notes.trim() || undefined,
+        };
+        await nodeConfigService.updateRegisteredNode(editingNode.node_id, payload);
+        toast.success(`节点 [${editingNode.node_id}] 档案更新成功`);
+      } else {
+        const payload: ClusterNodeCreatePayload = {
+          node_id: nodeId.trim(),
+          name: name.trim(),
+          ip_address: ipAddress.trim() || undefined,
+          region: region.trim() || undefined,
+          status,
+          notes: notes.trim() || undefined,
+        };
+        await nodeConfigService.createRegisteredNode(payload);
+        toast.success(`节点 [${nodeId.trim()}] 档案登记成功`);
+      }
+
+      invalidateRegisteredNodesCache();
+      onSuccess();
+      onClose();
+    } catch (err: any) {
+      toast.error('保存失败: ' + (err?.response?.data?.message || err.message || '未知错误'));
+    } finally {
+      setLoading(false);
+    }
+  };
+
+  if (!isOpen) return null;
+
+  return (
+    <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-grayscale font-mono">
+      <div className="bg-white border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100 flex flex-col">
+        {/* Header */}
+        <div className="bg-neutral-200 px-5 py-3 border-b-2 border-black flex items-center justify-between select-none">
+          <div className="flex items-center gap-2">
+            <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
+            <h3 className="text-xs font-black uppercase text-black">
+              [ {editingNode ? 'EDIT NODE // 编辑集群节点档案' : 'REGISTER NODE // 登记集群节点档案'} ]
+            </h3>
+          </div>
+          <button
+            onClick={onClose}
+            className="w-6 h-6 border border-black bg-white hover:bg-amber-300 flex items-center justify-center text-xs font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+          >
+            ✕
+          </button>
+        </div>
+
+        {/* Form Body */}
+        <form onSubmit={handleSubmit} className="p-5 space-y-4 text-xs bg-white">
+          {/* Node ID */}
+          <div>
+            <label className="font-black text-black uppercase block mb-1">
+              [ 1. 目标节点唯一标识 (NODE_ID) ] <span className="text-rose-600">*</span>
+            </label>
+            <input
+              type="text"
+              required
+              disabled={Boolean(editingNode)}
+              value={nodeId}
+              onChange={(e) => setNodeId(e.target.value)}
+              placeholder="例如: node01 或 worker-jp-01"
+              className={`w-full px-3 py-2 border-2 border-black text-xs font-mono font-bold outline-none shadow-[2px_2px_0px_#000] ${
+                editingNode ? 'bg-neutral-200 text-neutral-600 cursor-not-allowed' : 'bg-neutral-50 focus:bg-white text-black'
+              }`}
+            />
+            <span className="text-[10px] text-neutral-500 font-mono mt-0.5 block">
+              对应 Worker 运行进程启动参数中的 <code>--node-id</code>,注册后作为全局唯一键
+            </span>
+          </div>
+
+          {/* Node Name */}
+          <div>
+            <label className="font-black text-black uppercase block mb-1">
+              [ 2. 节点显示别名 / 描述 (NAME) ] <span className="text-rose-600">*</span>
+            </label>
+            <input
+              type="text"
+              required
+              value={name}
+              onChange={(e) => setName(e.target.value)}
+              placeholder="例如: 东京1号高速抢约机"
+              className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
+            />
+          </div>
+
+          {/* IP & Region */}
+          <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+            <div>
+              <label className="font-black text-black uppercase block mb-1">
+                [ 3. 服务器主机 IP (IP_ADDRESS) ]
+              </label>
+              <input
+                type="text"
+                value={ipAddress}
+                onChange={(e) => setIpAddress(e.target.value)}
+                placeholder="例如: 192.168.1.50"
+                className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
+              />
+            </div>
+
+            <div>
+              <label className="font-black text-black uppercase block mb-1">
+                [ 4. 物理地区 / 机房 (REGION) ]
+              </label>
+              <input
+                type="text"
+                value={region}
+                onChange={(e) => setRegion(e.target.value)}
+                placeholder="例如: 中国香港 或 cn-hongkong"
+                className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
+              />
+              <div className="flex flex-wrap items-center gap-1 mt-1.5">
+                {[
+                  'cn-hongkong',
+                  'cn-shanghai',
+                  'ap-southeast-1',
+                  'ap-northeast-1',
+                  'eu-central-1',
+                  'eu-west-3',
+                  'us-west-1',
+                ].map((r) => (
+                  <button
+                    key={r}
+                    type="button"
+                    onClick={() => setRegion(r)}
+                    className={`px-1.5 py-0.5 text-[10px] font-mono font-bold border transition ${
+                      region === r
+                        ? 'bg-amber-300 text-black border-black shadow-[1px_1px_0px_#000]'
+                        : 'bg-white text-neutral-700 border-neutral-300 hover:border-black hover:bg-neutral-100'
+                    }`}
+                  >
+                    {r}
+                  </button>
+                ))}
+              </div>
+            </div>
+          </div>
+
+          {/* Status */}
+          <div>
+            <label className="font-black text-black uppercase block mb-1">
+              [ 5. 节点调度启用状态 (STATUS) ]
+            </label>
+            <div className="grid grid-cols-2 gap-3">
+              <div
+                onClick={() => setStatus(1)}
+                className={`p-2.5 border-2 cursor-pointer flex items-center gap-2 transition select-none ${
+                  status === 1 ? 'border-black bg-emerald-100 font-black shadow-[2px_2px_0px_#000]' : 'border-neutral-300 bg-neutral-50'
+                }`}
+              >
+                <span className="w-2 h-2 rounded-full bg-emerald-600 inline-block" />
+                <span>1: 正常启用 (可下发任务)</span>
+              </div>
+              <div
+                onClick={() => setStatus(0)}
+                className={`p-2.5 border-2 cursor-pointer flex items-center gap-2 transition select-none ${
+                  status === 0 ? 'border-black bg-rose-100 font-black shadow-[2px_2px_0px_#000]' : 'border-neutral-300 bg-neutral-50'
+                }`}
+              >
+                <span className="w-2 h-2 rounded-full bg-neutral-400 inline-block" />
+                <span>0: 禁用下发 (暂停调度)</span>
+              </div>
+            </div>
+          </div>
+
+          {/* Notes */}
+          <div>
+            <label className="font-black text-black uppercase block mb-1">
+              [ 6. 机器配置与备注说明 (NOTES) ]
+            </label>
+            <textarea
+              rows={2}
+              value={notes}
+              onChange={(e) => setNotes(e.target.value)}
+              placeholder="记录服务器配置规格 (CPU/内存/带宽)、SSH登录端口或承载业务说明..."
+              className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
+            />
+          </div>
+
+          {/* Footer */}
+          <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex items-center justify-end gap-2">
+            <button
+              type="button"
+              onClick={onClose}
+              className="px-4 py-2 bg-neutral-100 hover:bg-neutral-200 border-2 border-black font-bold text-xs uppercase"
+            >
+              [ 取消 ]
+            </button>
+            <button
+              type="submit"
+              disabled={loading}
+              className="px-5 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase disabled:opacity-50 flex items-center gap-1.5"
+            >
+              {loading && <Loader2 size={13} className="animate-spin" />}
+              <span>{editingNode ? '[ 保存修改 ]' : '[ 确认登记入库 ]'}</span>
+            </button>
+          </div>
+        </form>
+      </div>
+    </div>
+  );
+}

+ 478 - 0
src/components/admin/node-configurations/ClusterNodeTable.tsx

@@ -0,0 +1,478 @@
+// src/components/admin/node-configurations/ClusterNodeTable.tsx
+'use client';
+
+import React, { useState, useMemo } from 'react';
+import {
+  Server,
+  Plus,
+  Edit2,
+  Trash2,
+  Globe,
+  Radio,
+  Search,
+  RefreshCw,
+  AlertCircle,
+  Activity,
+  Wifi,
+  WifiOff,
+} from 'lucide-react';
+import { toast } from 'react-hot-toast';
+import { retroConfirm } from '@/lib/dialog';
+import { nodeConfigService } from '@/lib/services/nodeConfigService';
+import { invalidateRegisteredNodesCache } from '@/components/admin/node-configurations/RegisteredNodeSelect';
+import { ClusterNode, NodeRuntimeStatus } from '@/types';
+import LocalTime from '@/components/common/LocalTime';
+import NodeTelemetryModal from './NodeTelemetryModal';
+
+interface ClusterNodeTableProps {
+  nodes: ClusterNode[];
+  runtimeNodes?: NodeRuntimeStatus[];
+  loading: boolean;
+  onRefresh: () => void;
+  onOpenCreate: () => void;
+  onOpenEdit: (node: ClusterNode) => void;
+}
+
+export default function ClusterNodeTable({
+  nodes,
+  runtimeNodes = [],
+  loading,
+  onRefresh,
+  onOpenCreate,
+  onOpenEdit,
+}: ClusterNodeTableProps) {
+  const [searchTerm, setSearchTerm] = useState('');
+  const [statusFilter, setStatusFilter] = useState<'all' | '1' | '0'>('all');
+  const [telemetryFilter, setTelemetryFilter] = useState<'all' | 'online' | 'offline' | 'nosignal'>('all');
+  const [togglingNodeId, setTogglingNodeId] = useState<string | null>(null);
+  const [selectedTelemetryNode, setSelectedTelemetryNode] = useState<ClusterNode | null>(null);
+
+  // 聚合计算单个节点的遥测数据
+  const getNodeTelemetrySummary = (nodeId: string) => {
+    const reports = runtimeNodes.filter((r) => r.node_id === nodeId);
+    const hasReports = reports.length > 0;
+    const isOnline = reports.some((r) => r.is_online);
+    const minAgeSec = hasReports
+      ? Math.min(...reports.map((r) => r.age_sec ?? 999999))
+      : 999999;
+    const latestReport = hasReports
+      ? reports.reduce((prev, cur) => ((cur.age_sec ?? 999999) < (prev.age_sec ?? 999999) ? cur : prev))
+      : null;
+    const roles = Array.from(new Set(reports.map((r) => r.role))).filter(Boolean);
+    return {
+      reports,
+      hasReports,
+      isOnline,
+      minAgeSec,
+      latestReport,
+      roles,
+    };
+  };
+
+  // 全局遥测汇总统计
+  const telemetryStats = useMemo(() => {
+    let onlineCount = 0;
+    let offlineCount = 0;
+    let noSignalCount = 0;
+
+    nodes.forEach((node) => {
+      const summary = getNodeTelemetrySummary(node.node_id);
+      if (summary.isOnline) {
+        onlineCount++;
+      } else if (summary.hasReports) {
+        offlineCount++;
+      } else {
+        noSignalCount++;
+      }
+    });
+
+    return { onlineCount, offlineCount, noSignalCount };
+  }, [nodes, runtimeNodes]);
+
+  const handleToggleStatus = async (node: ClusterNode) => {
+    const nextStatus = node.status === 1 ? 0 : 1;
+    const actionText = nextStatus === 1 ? '启用' : '禁用';
+    setTogglingNodeId(node.node_id);
+    try {
+      await nodeConfigService.updateRegisteredNode(node.node_id, { status: nextStatus });
+      toast.success(`节点 [${node.node_id}] 已成功${actionText}`);
+      invalidateRegisteredNodesCache();
+      onRefresh();
+    } catch (e: any) {
+      toast.error(`${actionText}失败: ` + (e?.response?.data?.message || e.message));
+    } finally {
+      setTogglingNodeId(null);
+    }
+  };
+
+  const handleDelete = async (node: ClusterNode) => {
+    const ok = await retroConfirm({
+      title: '注销节点档案',
+      message: `确定要注销并删除节点 [${node.node_id} / ${node.name}] 吗?删除后若已有任务绑定此节点,该任务在重新编辑前仍将锁定原标识。`,
+      confirmText: '确认注销',
+      cancelText: '取消',
+    });
+    if (!ok) return;
+
+    try {
+      await nodeConfigService.deleteRegisteredNode(node.node_id);
+      toast.success(`节点 [${node.node_id}] 已成功注销`);
+      invalidateRegisteredNodesCache();
+      onRefresh();
+    } catch (e: any) {
+      toast.error('注销失败: ' + (e?.response?.data?.message || e.message));
+    }
+  };
+
+  const formatAge = (sec: number) => {
+    if (sec < 60) return `${sec}s前`;
+    if (sec < 3600) return `${Math.floor(sec / 60)}m前`;
+    return `${Math.floor(sec / 3600)}h前`;
+  };
+
+  // 多条件过滤
+  const filteredNodes = nodes.filter((node) => {
+    // 状态过滤 (启用/禁用)
+    if (statusFilter !== 'all' && String(node.status) !== statusFilter) return false;
+
+    // 遥测过滤 (在线/离线/未上报)
+    const telemetry = getNodeTelemetrySummary(node.node_id);
+    if (telemetryFilter === 'online' && !telemetry.isOnline) return false;
+    if (telemetryFilter === 'offline' && (!telemetry.hasReports || telemetry.isOnline)) return false;
+    if (telemetryFilter === 'nosignal' && telemetry.hasReports) return false;
+
+    // 关键词搜索
+    if (searchTerm.trim()) {
+      const q = searchTerm.toLowerCase();
+      const matchId = node.node_id.toLowerCase().includes(q);
+      const matchName = node.name.toLowerCase().includes(q);
+      const matchIp = (node.ip_address || '').toLowerCase().includes(q);
+      const matchRegion = (node.region || '').toLowerCase().includes(q);
+      return matchId || matchName || matchIp || matchRegion;
+    }
+    return true;
+  });
+
+  return (
+    <div className="space-y-4 font-mono">
+      {/* 顶部操作工具栏与遥测过滤 */}
+      <div className="bg-white border-2 border-black p-4 shadow-[4px_4px_0px_#000] flex flex-col gap-3">
+        <div className="flex flex-col md:flex-row md:items-center justify-between gap-3">
+          <div className="flex flex-wrap items-center gap-3">
+            {/* 搜索框 */}
+            <div className="relative">
+              <Search size={14} className="absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-400" />
+              <input
+                type="text"
+                value={searchTerm}
+                onChange={(e) => setSearchTerm(e.target.value)}
+                placeholder="搜索 node_id / 名称 / IP / 地区..."
+                className="pl-8 pr-3 py-1.5 border-2 border-black bg-neutral-50 text-xs text-black font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000] w-64"
+              />
+            </div>
+
+            {/* 调度状态筛选 */}
+            <div className="flex items-center gap-1 text-xs">
+              <span className="font-bold text-neutral-500 uppercase">[ 调度 ]:</span>
+              <button
+                type="button"
+                onClick={() => setStatusFilter('all')}
+                className={`px-2 py-1 border border-black font-bold text-[11px] ${
+                  statusFilter === 'all' ? 'bg-neutral-800 text-white shadow-[1px_1px_0px_#000]' : 'bg-white hover:bg-neutral-100'
+                }`}
+              >
+                全部 ({nodes.length})
+              </button>
+              <button
+                type="button"
+                onClick={() => setStatusFilter('1')}
+                className={`px-2 py-1 border border-black font-bold text-[11px] ${
+                  statusFilter === '1' ? 'bg-emerald-200 text-emerald-950 shadow-[1px_1px_0px_#000]' : 'bg-white hover:bg-neutral-100'
+                }`}
+              >
+                已启用 ({nodes.filter((n) => n.status === 1).length})
+              </button>
+              <button
+                type="button"
+                onClick={() => setStatusFilter('0')}
+                className={`px-2 py-1 border border-black font-bold text-[11px] ${
+                  statusFilter === '0' ? 'bg-neutral-300 text-black shadow-[1px_1px_0px_#000]' : 'bg-white hover:bg-neutral-100'
+                }`}
+              >
+                已停用 ({nodes.filter((n) => n.status === 0).length})
+              </button>
+            </div>
+          </div>
+
+          <div className="flex items-center gap-2">
+            <button
+              type="button"
+              onClick={onRefresh}
+              disabled={loading}
+              className="px-3 py-1.5 border-2 border-black bg-white hover:bg-neutral-100 font-bold text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1.5 transition"
+            >
+              <RefreshCw size={12} className={loading ? 'animate-spin' : ''} />
+              <span>刷新</span>
+            </button>
+
+            <button
+              type="button"
+              onClick={onOpenCreate}
+              className="px-4 py-1.5 border-2 border-black bg-amber-300 hover:bg-amber-400 font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 uppercase transition"
+            >
+              <Plus size={14} />
+              <span>登记新节点档案</span>
+            </button>
+          </div>
+        </div>
+
+        {/* 遥测专属筛选条 (Telemetry Filter Row) */}
+        <div className="flex flex-wrap items-center justify-between border-t border-dashed border-neutral-300 pt-2.5 gap-2">
+          <div className="flex items-center gap-1.5 text-xs">
+            <Radio size={14} className="text-black shrink-0" />
+            <span className="font-black text-black uppercase text-[11px]">[ 遥测在线/离线筛选 ]:</span>
+            <button
+              type="button"
+              onClick={() => setTelemetryFilter('all')}
+              className={`px-2 py-0.5 border border-black font-bold text-[11px] ${
+                telemetryFilter === 'all'
+                  ? 'bg-amber-300 text-black shadow-[1px_1px_0px_#000]'
+                  : 'bg-neutral-50 hover:bg-neutral-100'
+              }`}
+            >
+              全部 ({nodes.length})
+            </button>
+            <button
+              type="button"
+              onClick={() => setTelemetryFilter('online')}
+              className={`px-2 py-0.5 border border-black font-bold text-[11px] flex items-center gap-1 ${
+                telemetryFilter === 'online'
+                  ? 'bg-emerald-300 text-emerald-950 shadow-[1px_1px_0px_#000]'
+                  : 'bg-neutral-50 hover:bg-neutral-100'
+              }`}
+            >
+              <span className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse inline-block" />
+              <span>仅在线 ({telemetryStats.onlineCount})</span>
+            </button>
+            <button
+              type="button"
+              onClick={() => setTelemetryFilter('offline')}
+              className={`px-2 py-0.5 border border-black font-bold text-[11px] flex items-center gap-1 ${
+                telemetryFilter === 'offline'
+                  ? 'bg-rose-300 text-rose-950 shadow-[1px_1px_0px_#000]'
+                  : 'bg-neutral-50 hover:bg-neutral-100'
+              }`}
+            >
+              <span className="w-2 h-2 rounded-full bg-rose-500 inline-block" />
+              <span>仅离线 ({telemetryStats.offlineCount})</span>
+            </button>
+            <button
+              type="button"
+              onClick={() => setTelemetryFilter('nosignal')}
+              className={`px-2 py-0.5 border border-black font-bold text-[11px] flex items-center gap-1 ${
+                telemetryFilter === 'nosignal'
+                  ? 'bg-neutral-300 text-black shadow-[1px_1px_0px_#000]'
+                  : 'bg-neutral-50 hover:bg-neutral-100'
+              }`}
+            >
+              <span className="w-2 h-2 rounded-full bg-neutral-400 inline-block" />
+              <span>未上报信号 ({telemetryStats.noSignalCount})</span>
+            </button>
+          </div>
+
+          <div className="text-[10px] text-neutral-500 font-mono">
+            * 点击表格中任意遥测徽章可展开完整健康体征与运行实例诊断
+          </div>
+        </div>
+      </div>
+
+      {/* 数据表格 */}
+      <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-x-auto">
+        <table className="w-full text-left text-xs border-collapse">
+          <thead>
+            <tr className="border-b-2 border-black bg-neutral-200 text-black select-none uppercase font-black tracking-wider">
+              <th className="px-4 py-3 border-r-2 border-black">节点唯一标识 (NODE_ID)</th>
+              <th className="px-4 py-3 border-r-2 border-black">节点名称 / 别名</th>
+              <th className="px-4 py-3 border-r-2 border-black">主机 IP & 物理地区</th>
+              <th className="px-4 py-3 border-r-2 border-black text-center">
+                <div className="flex items-center justify-center gap-1">
+                  <Radio size={12} />
+                  <span>实时遥测 (TELEMETRY)</span>
+                </div>
+              </th>
+              <th className="px-4 py-3 border-r-2 border-black text-center">调度启用</th>
+              <th className="px-4 py-3 border-r-2 border-black">备注说明</th>
+              <th className="px-4 py-3 text-right">管理操作</th>
+            </tr>
+          </thead>
+          <tbody className="divide-y-2 divide-neutral-200">
+            {loading && nodes.length === 0 ? (
+              <tr>
+                <td colSpan={7} className="px-4 py-12 text-center text-neutral-500 font-mono">
+                  <RefreshCw size={20} className="animate-spin inline-block mr-2" />
+                  正在加载集群节点档案库与遥测数据...
+                </td>
+              </tr>
+            ) : filteredNodes.length === 0 ? (
+              <tr>
+                <td colSpan={7} className="px-4 py-12 text-center text-neutral-500 font-mono">
+                  <AlertCircle size={20} className="inline-block mr-2 text-neutral-400" />
+                  {searchTerm || statusFilter !== 'all' || telemetryFilter !== 'all'
+                    ? '未找到符合条件的节点档案'
+                    : '暂无节点档案,请点击右上角 [登记新节点档案] 录入第一台机器'}
+                </td>
+              </tr>
+            ) : (
+              filteredNodes.map((node) => {
+                const summary = getNodeTelemetrySummary(node.node_id);
+
+                return (
+                  <tr key={node.node_id} className="hover:bg-neutral-50 transition">
+                    {/* NODE_ID */}
+                    <td className="px-4 py-3 border-r-2 border-neutral-200 whitespace-nowrap">
+                      <div className="flex items-center gap-1.5">
+                        <Server size={14} className="text-black shrink-0" />
+                        <span className="font-mono font-black text-black bg-neutral-100 px-1.5 py-0.5 border border-black shadow-[1px_1px_0px_#000]">
+                          {node.node_id}
+                        </span>
+                      </div>
+                    </td>
+
+                    {/* NAME */}
+                    <td className="px-4 py-3 border-r-2 border-neutral-200">
+                      <span className="font-bold text-black font-sans block">{node.name}</span>
+                      <span className="text-[10px] text-neutral-400 font-mono">
+                        登记于: <LocalTime date={node.created_at} />
+                      </span>
+                    </td>
+
+                    {/* IP & REGION */}
+                    <td className="px-4 py-3 border-r-2 border-neutral-200 whitespace-nowrap">
+                      <div className="flex flex-col">
+                        <span className="font-mono font-bold text-black text-[11px]">
+                          {node.ip_address || '-'}
+                        </span>
+                        <span className="text-[10px] text-neutral-500 flex items-center gap-1 mt-0.5">
+                          <Globe size={10} />
+                          <span>{node.region || '未指定地区'}</span>
+                        </span>
+                      </div>
+                    </td>
+
+                    {/* TELEMETRY COLUMN */}
+                    <td className="px-4 py-3 border-r-2 border-neutral-200 text-center whitespace-nowrap">
+                      {summary.isOnline ? (
+                        <button
+                          type="button"
+                          onClick={() => setSelectedTelemetryNode(node)}
+                          className="inline-flex items-center gap-1.5 px-2.5 py-1 bg-emerald-100 hover:bg-emerald-200 text-emerald-950 border border-black text-[11px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition cursor-pointer"
+                          title="点击查看此节点的实时遥测诊断明细"
+                        >
+                          <span className="relative flex h-2 w-2">
+                            <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
+                            <span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
+                          </span>
+                          <span>在线 ({summary.minAgeSec}s前)</span>
+                          {summary.roles.length > 0 && (
+                            <span className="text-[9px] px-1 bg-black text-white font-bold">
+                              {summary.roles.join('/')}
+                            </span>
+                          )}
+                        </button>
+                      ) : summary.hasReports ? (
+                        <button
+                          type="button"
+                          onClick={() => setSelectedTelemetryNode(node)}
+                          className="inline-flex items-center gap-1.5 px-2.5 py-1 bg-rose-100 hover:bg-rose-200 text-rose-950 border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition cursor-pointer"
+                          title="心跳已超过60s阈值,点击查看遥测诊断"
+                        >
+                          <span className="w-2 h-2 rounded-full bg-rose-600 inline-block" />
+                          <span>离线 ({formatAge(summary.minAgeSec)})</span>
+                        </button>
+                      ) : (
+                        <button
+                          type="button"
+                          onClick={() => setSelectedTelemetryNode(node)}
+                          className="inline-flex items-center gap-1.5 px-2 py-0.5 bg-neutral-100 hover:bg-neutral-200 text-neutral-600 border border-dashed border-neutral-400 text-[10px] font-bold active:translate-x-0.5 active:translate-y-0.5 transition cursor-pointer"
+                          title="暂未匹配到Redis心跳,点击查看遥测指引"
+                        >
+                          <span className="w-1.5 h-1.5 rounded-full bg-neutral-400 inline-block" />
+                          <span>未上报信号</span>
+                        </button>
+                      )}
+                    </td>
+
+                    {/* STATUS (SCHEDULING TOGGLE) */}
+                    <td className="px-4 py-3 border-r-2 border-neutral-200 text-center whitespace-nowrap">
+                      <button
+                        onClick={() => handleToggleStatus(node)}
+                        disabled={togglingNodeId === node.node_id}
+                        className={`px-2 py-0.5 border border-black font-bold text-[10px] shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition ${
+                          node.status === 1
+                            ? 'bg-emerald-200 text-emerald-950 hover:bg-emerald-300'
+                            : 'bg-neutral-200 text-neutral-700 hover:bg-neutral-300'
+                        }`}
+                        title="点击快速切换启用/停用状态"
+                      >
+                        {node.status === 1 ? '✓ 已启用' : '⊘ 已禁用'}
+                      </button>
+                    </td>
+
+                    {/* NOTES */}
+                    <td className="px-4 py-3 border-r-2 border-neutral-200 max-w-xs truncate text-[11px] text-neutral-600 font-sans">
+                      {node.notes || '-'}
+                    </td>
+
+                    {/* ACTIONS */}
+                    <td className="px-4 py-3 text-right whitespace-nowrap">
+                      <div className="flex items-center justify-end gap-1.5">
+                        <button
+                          type="button"
+                          onClick={() => setSelectedTelemetryNode(node)}
+                          className="px-2 py-1 bg-amber-100 hover:bg-amber-200 text-black border border-black text-[11px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1 uppercase"
+                          title="查看实时遥测与健康体征"
+                        >
+                          <Radio size={11} className="text-black" />
+                          <span>遥测</span>
+                        </button>
+
+                        <button
+                          type="button"
+                          onClick={() => onOpenEdit(node)}
+                          className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1 uppercase"
+                          title="编辑节点档案属性"
+                        >
+                          <Edit2 size={11} />
+                          <span>编辑</span>
+                        </button>
+
+                        <button
+                          type="button"
+                          onClick={() => handleDelete(node)}
+                          className="px-2 py-1 bg-rose-50 hover:bg-rose-100 text-rose-700 border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1 uppercase"
+                          title="注销此节点档案"
+                        >
+                          <Trash2 size={11} />
+                          <span>注销</span>
+                        </button>
+                      </div>
+                    </td>
+                  </tr>
+                );
+              })
+            )}
+          </tbody>
+        </table>
+      </div>
+
+      {/* 节点实时遥测详情弹窗 */}
+      <NodeTelemetryModal
+        isOpen={Boolean(selectedTelemetryNode)}
+        onClose={() => setSelectedTelemetryNode(null)}
+        node={selectedTelemetryNode}
+        runtimeNodes={runtimeNodes}
+        onRefreshAll={onRefresh}
+      />
+    </div>
+  );
+}

+ 14 - 0
src/components/admin/node-configurations/NodeClusterTelemetryBar.tsx

@@ -25,6 +25,8 @@ interface NodeClusterTelemetryBarProps {
   onRefresh: () => void;
   onInspectInstances?: (nodeId?: string, groupId?: string) => void;
   lastUpdatedTime?: string;
+  registeredNodeIds?: Set<string>;
+  onQuickRegisterNode?: (nodeId: string) => void;
 }
 
 export default function NodeClusterTelemetryBar({
@@ -35,6 +37,8 @@ export default function NodeClusterTelemetryBar({
   onRefresh,
   onInspectInstances,
   lastUpdatedTime,
+  registeredNodeIds,
+  onQuickRegisterNode,
 }: NodeClusterTelemetryBarProps) {
   const [collapsed, setCollapsed] = useState(false);
   const [inspectingPluginsNode, setInspectingPluginsNode] = useState<NodeRuntimeStatus | null>(null);
@@ -293,6 +297,16 @@ export default function NodeClusterTelemetryBar({
                           >
                             [ 插件清单 ]
                           </button>
+                          {registeredNodeIds && !registeredNodeIds.has(node.node_id) && onQuickRegisterNode && (
+                            <button
+                              type="button"
+                              onClick={() => onQuickRegisterNode(node.node_id)}
+                              className="px-2 py-0.5 bg-emerald-200 hover:bg-emerald-300 text-emerald-950 border border-black text-[10px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase"
+                              title="检测到此在线 Worker 尚未录入档案库,点击一键登记"
+                            >
+                              [ + 收录档案 ]
+                            </button>
+                          )}
                         </div>
                       </div>
                     </div>

+ 7 - 13
src/components/admin/node-configurations/NodeConfigCloneModal.tsx

@@ -9,6 +9,7 @@ import {
   NodeConfigurationItem,
 } from '@/types';
 import { nodeConfigService } from '@/lib/services/nodeConfigService';
+import RegisteredNodeSelect from '@/components/admin/node-configurations/RegisteredNodeSelect';
 
 interface NodeConfigCloneModalProps {
   isOpen: boolean;
@@ -160,21 +161,14 @@ export default function NodeConfigCloneModal({
           {/* Target Node & Identifier Inputs */}
           <div className="space-y-3">
             <div>
-              <label className="block text-[11px] font-bold text-black mb-1">
-                目标节点 ID (target node_id) <span className="text-rose-600 font-black">*</span>
-              </label>
-              <input
-                type="text"
-                required
-                autoFocus
+              <RegisteredNodeSelect
                 value={targetNodeId}
-                onChange={(e) => setTargetNodeId(e.target.value)}
-                placeholder="例如: node02, node-hk-01..."
-                className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                onChange={setTargetNodeId}
+                label="目标克隆节点 (TARGET NODE_ID)"
+                badgeText="严格单选"
+                placeholder="-- 选择要克隆部署的已注册节点 --"
+                required
               />
-              <span className="text-[10px] text-neutral-500 block mt-0.5">
-                指定要将此配置副本部署到的目标计算节点
-              </span>
             </div>
 
             <div>

+ 454 - 129
src/components/admin/node-configurations/NodeConfigCreateWizardModal.tsx

@@ -13,7 +13,12 @@ import {
 } from '@/types';
 import { providerService } from '@/lib/services/providerService';
 import { nodeConfigService } from '@/lib/services/nodeConfigService';
+import { accountService } from '@/lib/services/accountService';
+import { proxyService } from '@/lib/services/proxyService';
 import AppointmentTypeEditor from './AppointmentTypeEditor';
+import RegisteredNodeSelect from '@/components/admin/node-configurations/RegisteredNodeSelect';
+
+import { LOCAL_PROXY_POOLS, COMMON_WEBSITES } from './nodeConfigConstants';
 
 interface NodeConfigCreateWizardModalProps {
   isOpen: boolean;
@@ -34,13 +39,19 @@ export default function NodeConfigCreateWizardModal({
   const [loadingProviders, setLoadingProviders] = useState(false);
   const [submitting, setSubmitting] = useState(false);
 
+  // 数据库获取的账号池与代理池
+  const [accountPools, setAccountPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
+  const [cloudProxyPools, setCloudProxyPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
+  const [customBookerAccountPool, setCustomBookerAccountPool] = useState(false);
+  const [customSentinelAccountPool, setCustomSentinelAccountPool] = useState(false);
+
   // Step 1: Base & Identity
   const [nodeId, setNodeId] = useState('node01');
   const [identifier, setIdentifier] = useState('');
   const [website, setWebsite] = useState('');
   const [needAccount, setNeedAccount] = useState(1);
   const [needProxy, setNeedProxy] = useState(1);
-  const [proxyPoolStr, setProxyPoolStr] = useState('proxy-cheap');
+  const [proxyPoolStr, setProxyPoolStr] = useState('cloud:proxy-cheap');
   const [proxyCd, setProxyCd] = useState(300);
   const [sessionMaxLife, setSessionMaxLife] = useState(1800);
   const [activeTimeStart, setActiveTimeStart] = useState('00:00');
@@ -60,7 +71,7 @@ export default function NodeConfigCreateWizardModal({
   const [bookerAccountPoolId, setBookerAccountPoolId] = useState('');
   const [bookerTargetInstances, setBookerTargetInstances] = useState(1);
   const [bookerAccountCd, setBookerAccountCd] = useState(10800);
-  const [bookerCooldown, setBookerCooldown] = useState(300);
+  const [bookerCooldown, setBookerCooldown] = useState(30);
   const [bookerMaxBookings, setBookerMaxBookings] = useState(8);
 
   // Sentinel specifics
@@ -80,7 +91,8 @@ export default function NodeConfigCreateWizardModal({
     lib_path: 'plugins',
     plugin_name: '',
     plugin_bin: '',
-    plugin_proto: 'IVSPlg',
+    plugin_class: '',
+    plugin_proto: 'IPlugin',
   });
 
   // Appointment types & free config
@@ -91,16 +103,61 @@ export default function NodeConfigCreateWizardModal({
     if (isOpen) {
       setStep(1);
       fetchEnabledProviders();
+      fetchDbPools();
       resetForm();
     }
   }, [isOpen, entryType]);
 
+  const fetchDbPools = async () => {
+    try {
+      const [accRes, proxyRes] = await Promise.allSettled([
+        accountService.getPools(),
+        proxyService.getPools(),
+      ]);
+      if (accRes.status === 'fulfilled' && accRes.value?.data) {
+        setAccountPools(Array.isArray(accRes.value.data) ? accRes.value.data : []);
+      }
+      if (proxyRes.status === 'fulfilled' && proxyRes.value?.data) {
+        setCloudProxyPools(Array.isArray(proxyRes.value.data) ? proxyRes.value.data : []);
+      }
+    } catch (err) {
+      console.error('Failed to fetch pools from DB:', err);
+    }
+  };
+
+  const addProxyPoolTag = (tagToAdd: string) => {
+    if (!tagToAdd) return;
+    const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
+    if (!current.includes(tagToAdd)) {
+      current.push(tagToAdd);
+      setProxyPoolStr(current.join(', '));
+    }
+  };
+
+  const removeProxyPoolTag = (tagToRemove: string) => {
+    const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
+    const updated = current.filter((t) => t !== tagToRemove);
+    setProxyPoolStr(updated.join(', '));
+  };
+
+  // 仅筛选出支持当前 entryType 角色的服务商模板
+  const eligibleProviders = providers.filter(
+    (p) => p.role_templates && Boolean(p.role_templates[entryType])
+  );
+
   const fetchEnabledProviders = async () => {
     setLoadingProviders(true);
     try {
       const res = await providerService.getList({ enabled_only: true });
       if (res.code === 0 && res.data) {
-        setProviders(res.data);
+        const list = Array.isArray(res.data) ? res.data : [];
+        setProviders(list);
+        const matching = list.filter(
+          (p) => p.role_templates && Boolean(p.role_templates[entryType])
+        );
+        if (matching.length > 0 && !selectedProviderName) {
+          handleProviderSelect(matching[0].name, list, false);
+        }
       }
     } catch (e) {
       console.error('Failed to fetch providers:', e);
@@ -111,12 +168,12 @@ export default function NodeConfigCreateWizardModal({
 
   const resetForm = () => {
     setSelectedProviderName('');
-    setNodeId('node01');
+    setNodeId('');
     setIdentifier('');
     setWebsite('');
     setNeedAccount(1);
     setNeedProxy(1);
-    setProxyPoolStr('proxy-cheap');
+    setProxyPoolStr('');
     setProxyCd(300);
     setSessionMaxLife(1800);
     setActiveTimeStart('00:00');
@@ -136,11 +193,13 @@ export default function NodeConfigCreateWizardModal({
     setBookerAccountCd(10800);
     setBookerCooldown(300);
     setBookerMaxBookings(8);
+    setCustomBookerAccountPool(false);
 
     setSentinelAccountSource('built-in');
     setSentinelAccountPoolId('');
     setSentinelTargetInstances(1);
     setSentinelSignalTtl(30);
+    setCustomSentinelAccountPool(false);
 
     setQueryWaitMode('Random');
     setFixedWait(10);
@@ -151,16 +210,16 @@ export default function NodeConfigCreateWizardModal({
       lib_path: 'plugins',
       plugin_name: '',
       plugin_bin: '',
-      plugin_proto: 'IVSPlg',
+      plugin_proto: 'IPlugin',
     });
 
     setAppointmentTypes([]);
     setFreeConfigStr('{}');
   };
 
-  const handleProviderSelect = (providerName: string) => {
+  const handleProviderSelect = (providerName: string, providerList = providers, showToast = true) => {
     setSelectedProviderName(providerName);
-    const p = providers.find((item) => item.name === providerName);
+    const p = providerList.find((item) => item.name === providerName);
     if (!p) return;
 
     if (p.plugin_config) {
@@ -168,7 +227,8 @@ export default function NodeConfigCreateWizardModal({
         lib_path: p.plugin_config.lib_path || 'plugins',
         plugin_name: p.plugin_config.plugin_name || '',
         plugin_bin: p.plugin_config.plugin_bin || '',
-        plugin_proto: p.plugin_config.plugin_proto || 'IVSPlg',
+        plugin_class: p.plugin_config.plugin_class || '',
+        plugin_proto: p.plugin_config.plugin_proto || 'IPlugin',
       });
     }
 
@@ -194,7 +254,9 @@ export default function NodeConfigCreateWizardModal({
       }
     }
 
-    toast.success(`已从服务商模板 [${providerName}] 继承参数`);
+    if (showToast) {
+      toast.success(`已从服务商模板 [${providerName}] 继承参数与插件驱动`);
+    }
   };
 
   const buildPayload = (): Partial<NodeConfigurationItem> => {
@@ -273,8 +335,12 @@ export default function NodeConfigCreateWizardModal({
 
   const handleNext = () => {
     if (step === 1) {
+      if (!selectedProviderName) {
+        toast.error('新建任务必须选择一个服务商模板以继承配置与插件');
+        return;
+      }
       if (!nodeId.trim()) {
-        toast.error('节点 ID (node_id) 不能为空');
+        toast.error('请选择已注册的目标集群节点 (node_id)');
         return;
       }
       if (!identifier.trim()) {
@@ -364,34 +430,49 @@ export default function NodeConfigCreateWizardModal({
           {/* STEP 1 */}
           {step === 1 && (
             <div className="space-y-5">
-              {/* Provider Selection */}
+              {/* Provider Selection (Mandatory) */}
               <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
                 <div className="flex items-center justify-between border-b-2 border-black pb-1.5">
                   <div className="flex items-center gap-2">
                     <span className="w-2 h-2 bg-amber-300 border border-black inline-block" />
-                    <span className="font-black text-black uppercase">[ PROVIDER TEMPLATE // 选择预设服务商模板 ]</span>
+                    <span className="font-black text-black uppercase">[ PROVIDER TEMPLATE // 选择预设服务商模板 (必须继承) ]</span>
                   </div>
-                  <span className="text-[11px] text-neutral-500">选择后将自动继承默认配置</span>
+                  <span className="text-[11px] text-red-600 font-bold">* 必须选择服务商模板以继承参数与插件驱动</span>
                 </div>
 
                 <div className="grid grid-cols-1 md:grid-cols-2 gap-3 items-center">
                   <select
                     value={selectedProviderName}
                     onChange={(e) => handleProviderSelect(e.target.value)}
-                    disabled={loadingProviders}
+                    disabled={loadingProviders || eligibleProviders.length === 0}
                     className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
                   >
-                    <option value="">-- 手动配置 (不继承模板) --</option>
-                    {providers.map((p) => (
-                      <option key={p.id || p.name} value={p.name}>
-                        {p.name.toUpperCase()} (插件: {p.plugin_config?.plugin_name || '内置'})
-                      </option>
-                    ))}
+                    {eligibleProviders.length === 0 ? (
+                      <option value="">-- 无支持 [{entryType.toUpperCase()}] 角色的服务商模板 --</option>
+                    ) : (
+                      <option value="">-- 请选择要继承的服务商模板 (共 {eligibleProviders.length} 个支持 {entryType.toUpperCase()}) --</option>
+                    )}
+                    {eligibleProviders.map((p) => {
+                      const rolesStr = p.role_templates ? Object.keys(p.role_templates).join('/') : '';
+                      return (
+                        <option key={p.id || p.name} value={p.name}>
+                          {p.name.toUpperCase()} (插件: {p.plugin_config?.plugin_name || '内置'}, 支持角色: {rolesStr})
+                        </option>
+                      );
+                    })}
                   </select>
 
-                  {selectedProviderName && (
+                  {selectedProviderName ? (
                     <div className="text-[11px] font-black text-black bg-amber-300 border border-black px-2 py-1 shadow-[1px_1px_0px_#000] inline-block">
-                      ✓ 已继承 [{selectedProviderName.toUpperCase()}] 模板参数
+                      ✓ 已继承 [{selectedProviderName.toUpperCase()}] 模板参数 & 插件驱动 [{pluginConfig.plugin_name || '内置'}]
+                    </div>
+                  ) : eligibleProviders.length === 0 ? (
+                    <div className="text-[11px] font-bold text-rose-600 bg-rose-50 border border-rose-400 px-2 py-1">
+                      ⚠️ 暂无支持 [{entryType.toUpperCase()}] 的模板,请在「服务商模板」中开启此角色
+                    </div>
+                  ) : (
+                    <div className="text-[11px] font-bold text-rose-600 bg-rose-50 border border-rose-400 px-2 py-1">
+                      ⚠️ 新建 {entryType.toUpperCase()} 任务必须选择一个服务商模板
                     </div>
                   )}
                 </div>
@@ -406,15 +487,13 @@ export default function NodeConfigCreateWizardModal({
 
                 <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
                   <div>
-                    <label className="block text-[11px] font-bold text-black mb-1">
-                      目标节点唯一标识 (node_id) <span className="text-red-500">*</span>
-                    </label>
-                    <input
-                      type="text"
-                      placeholder="node01"
+                    <RegisteredNodeSelect
                       value={nodeId}
-                      onChange={(e) => setNodeId(e.target.value)}
-                      className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000] placeholder:text-neutral-400"
+                      onChange={setNodeId}
+                      label="目标集群节点 (NODE_ID)"
+                      badgeText="严格单选"
+                      placeholder="-- 请选择已注册的集群节点 --"
+                      required
                     />
                   </div>
 
@@ -431,15 +510,43 @@ export default function NodeConfigCreateWizardModal({
                     />
                   </div>
 
-                  <div className="md:col-span-2">
-                    <label className="block text-[11px] font-bold text-black mb-1">使馆/登录网址 (website)</label>
+                  <div className="md:col-span-2 space-y-1.5">
+                    <div className="flex justify-between items-center">
+                      <label className="block text-[11px] font-bold text-black">使馆/登录网址 (website)</label>
+                      <span className="text-[10px] text-neutral-500">支持直接输入或点击推荐使馆</span>
+                    </div>
                     <input
                       type="text"
+                      list="wizard-common-websites-list"
                       placeholder="https://visa.vfsglobal.com/..."
                       value={website}
                       onChange={(e) => setWebsite(e.target.value)}
                       className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000] placeholder:text-neutral-400"
                     />
+                    <datalist id="wizard-common-websites-list">
+                      {COMMON_WEBSITES.map((item) => (
+                        <option key={item.value} value={item.value}>
+                          {item.label}
+                        </option>
+                      ))}
+                    </datalist>
+                    <div className="flex flex-wrap items-center gap-1.5 pt-0.5">
+                      <span className="text-[10px] text-neutral-500 font-bold">推荐使馆:</span>
+                      {COMMON_WEBSITES.map((item) => (
+                        <button
+                          key={item.value}
+                          type="button"
+                          onClick={() => setWebsite(item.value)}
+                          className={`px-2 py-0.5 text-[10px] font-mono font-bold border transition ${
+                            website === item.value
+                              ? 'bg-amber-300 text-black border-black shadow-[1px_1px_0px_#000]'
+                              : 'bg-white text-neutral-700 border-neutral-300 hover:border-black hover:bg-neutral-100'
+                          }`}
+                        >
+                          {item.label}
+                        </button>
+                      ))}
+                    </div>
                   </div>
                 </div>
               </div>
@@ -501,78 +608,221 @@ export default function NodeConfigCreateWizardModal({
                   </div>
 
                   <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
+                    {/* Account Pool ID - dropdown from DB */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">使馆账号池 ID (account_pool_id)</label>
-                      <input
-                        type="text"
-                        value={bookerAccountPoolId}
-                        onChange={(e) => setBookerAccountPoolId(e.target.value)}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                      {customBookerAccountPool ? (
+                        <div className="flex gap-1">
+                          <input
+                            type="text"
+                            value={bookerAccountPoolId}
+                            onChange={(e) => setBookerAccountPoolId(e.target.value)}
+                            placeholder="输入自定义池 ID"
+                            className="flex-1 px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                          />
+                          <button
+                            type="button"
+                            onClick={() => { setCustomBookerAccountPool(false); setBookerAccountPoolId(''); }}
+                            className="px-2 py-1 bg-white hover:bg-neutral-200 border-2 border-black text-[10px] font-bold shadow-[1px_1px_0px_#000]"
+                            title="切换回下拉选择"
+                          >
+                            ✕
+                          </button>
+                        </div>
+                      ) : (
+                        <select
+                          value={bookerAccountPoolId}
+                          onChange={(e) => {
+                            if (e.target.value === '__CUSTOM__') {
+                              setCustomBookerAccountPool(true);
+                              setBookerAccountPoolId('');
+                            } else {
+                              setBookerAccountPoolId(e.target.value);
+                            }
+                          }}
+                          className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                        >
+                          <option value="">-- 请选择账号池 --</option>
+                          {accountPools.map((p) => (
+                            <option key={p.pool_name} value={p.pool_name}>
+                              {p.pool_name} ({p.total_count ?? 0} 个账号)
+                            </option>
+                          ))}
+                          <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
+                        </select>
+                      )}
                     </div>
+
+                    {/* Target Instances - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">目标并发实例 (target_instances)</label>
-                      <input
-                        type="number"
-                        min={1}
+                      <select
                         value={bookerTargetInstances}
                         onChange={(e) => setBookerTargetInstances(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20].map((v) => (
+                          <option key={v} value={v}>{v} 个实例{v === 1 ? ' (默认)' : ''}</option>
+                        ))}
+                      </select>
                     </div>
+
+                    {/* Account CD - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">账号冷却 (account_cd / 秒)</label>
-                      <input
-                        type="number"
+                      <select
                         value={bookerAccountCd}
                         onChange={(e) => setBookerAccountCd(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[
+                          { v: 1800, label: '30 分钟' },
+                          { v: 3600, label: '1 小时' },
+                          { v: 7200, label: '2 小时' },
+                          { v: 10800, label: '3 小时 (默认)' },
+                          { v: 14400, label: '4 小时' },
+                          { v: 21600, label: '6 小时' },
+                          { v: 43200, label: '12 小时' },
+                          { v: 86400, label: '24 小时' },
+                        ].map((opt) => (
+                          <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
+                        ))}
+                      </select>
                     </div>
+
+                    {/* Booking Cooldown - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">下单间隔冷却 (booking_cooldown / 秒)</label>
-                      <input
-                        type="number"
+                      <select
                         value={bookerCooldown}
                         onChange={(e) => setBookerCooldown(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[
+                          { v: 10, label: '10 秒' },
+                          { v: 30, label: '30 秒' },
+                          { v: 60, label: '1 分钟' },
+                          { v: 120, label: '2 分钟' },
+                          { v: 300, label: '5 分钟 (默认)' },
+                          { v: 600, label: '10 分钟' },
+                          { v: 900, label: '15 分钟' },
+                          { v: 1800, label: '30 分钟' },
+                        ].map((opt) => (
+                          <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
+                        ))}
+                      </select>
                     </div>
+
+                    {/* Max Bookings - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">单号最大占位次数</label>
-                      <input
-                        type="number"
+                      <select
                         value={bookerMaxBookings}
                         onChange={(e) => setBookerMaxBookings(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 30, 50].map((v) => (
+                          <option key={v} value={v}>{v} 次{v === 8 ? ' (默认)' : ''}</option>
+                        ))}
+                      </select>
                     </div>
+
+                    {/* Proxy CD - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">代理冷却时间 (proxy_cd / 秒)</label>
-                      <input
-                        type="number"
+                      <select
                         value={proxyCd}
                         onChange={(e) => setProxyCd(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[
+                          { v: 0, label: '无冷却' },
+                          { v: 60, label: '1 分钟' },
+                          { v: 120, label: '2 分钟' },
+                          { v: 180, label: '3 分钟' },
+                          { v: 300, label: '5 分钟 (默认)' },
+                          { v: 600, label: '10 分钟' },
+                          { v: 900, label: '15 分钟' },
+                          { v: 1800, label: '30 分钟' },
+                        ].map((opt) => (
+                          <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
+                        ))}
+                      </select>
                     </div>
+
+                    {/* Proxy Pool - tag-based multi-select from DB */}
                     <div className="md:col-span-2">
-                      <label className="block text-[11px] font-bold text-black mb-1">网络代理池标签列表 (proxy_pool, 逗号分隔)</label>
-                      <input
-                        type="text"
-                        value={proxyPoolStr}
-                        onChange={(e) => setProxyPoolStr(e.target.value)}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                      <label className="block text-[11px] font-bold text-black mb-1">网络代理池 (proxy_pool)</label>
+                      {/* Selected tags */}
+                      <div className="flex flex-wrap gap-1.5 mb-2 min-h-[28px] p-2 bg-white border-2 border-black shadow-[2px_2px_0px_#000]">
+                        {proxyPoolStr.split(',').map(s => s.trim()).filter(Boolean).length === 0 && (
+                          <span className="text-neutral-400 text-[10px] italic">尚未选择代理池...</span>
+                        )}
+                        {proxyPoolStr.split(',').map(s => s.trim()).filter(Boolean).map((tag) => (
+                          <span
+                            key={tag}
+                            className={`inline-flex items-center gap-1 px-2 py-0.5 border border-black text-[10px] font-bold shadow-[1px_1px_0px_#000] ${
+                              tag.startsWith('cloud:') ? 'bg-sky-200 text-sky-900' : 'bg-emerald-200 text-emerald-900'
+                            }`}
+                          >
+                            {tag.startsWith('cloud:') ? '☁' : '⊙'} {tag}
+                            <button
+                              type="button"
+                              onClick={() => removeProxyPoolTag(tag)}
+                              className="ml-0.5 hover:text-red-600 font-black"
+                            >
+                              ✕
+                            </button>
+                          </span>
+                        ))}
+                      </div>
+                      {/* Add tag dropdown */}
+                      <select
+                        value=""
+                        onChange={(e) => {
+                          if (e.target.value) addProxyPoolTag(e.target.value);
+                        }}
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        <option value="">+ 添加代理池标签...</option>
+                        <optgroup label="☁ 云端代理池 (cloud:)">
+                          {cloudProxyPools.map((p) => (
+                            <option key={`cloud:${p.pool_name}`} value={`cloud:${p.pool_name}`}>
+                              cloud:{p.pool_name} ({p.total_count ?? 0} 条代理)
+                            </option>
+                          ))}
+                        </optgroup>
+                        <optgroup label="⊙ 本地代理池 (local:)">
+                          {LOCAL_PROXY_POOLS.map((p) => (
+                            <option key={`local:${p.value}`} value={`local:${p.value}`}>
+                              local:{p.value} — {p.label}
+                            </option>
+                          ))}
+                        </optgroup>
+                      </select>
                     </div>
+
+                    {/* Session Max Life - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">Session 最长存活 (秒)</label>
-                      <input
-                        type="number"
+                      <select
                         value={sessionMaxLife}
                         onChange={(e) => setSessionMaxLife(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[
+                          { v: 300, label: '5 分钟' },
+                          { v: 600, label: '10 分钟' },
+                          { v: 900, label: '15 分钟' },
+                          { v: 1200, label: '20 分钟' },
+                          { v: 1800, label: '30 分钟 (默认)' },
+                          { v: 2700, label: '45 分钟' },
+                          { v: 3600, label: '1 小时' },
+                          { v: 7200, label: '2 小时' },
+                        ].map((opt) => (
+                          <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
+                        ))}
+                      </select>
                     </div>
                   </div>
                 </div>
@@ -587,41 +837,95 @@ export default function NodeConfigCreateWizardModal({
                   </div>
 
                   <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
+                    {/* Account Pool ID - dropdown from DB */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">使馆账号池 ID (account_pool_id)</label>
-                      <input
-                        type="text"
-                        value={sentinelAccountPoolId}
-                        onChange={(e) => setSentinelAccountPoolId(e.target.value)}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                      {customSentinelAccountPool ? (
+                        <div className="flex gap-1">
+                          <input
+                            type="text"
+                            value={sentinelAccountPoolId}
+                            onChange={(e) => setSentinelAccountPoolId(e.target.value)}
+                            placeholder="输入自定义池 ID"
+                            className="flex-1 px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                          />
+                          <button
+                            type="button"
+                            onClick={() => { setCustomSentinelAccountPool(false); setSentinelAccountPoolId(''); }}
+                            className="px-2 py-1 bg-white hover:bg-neutral-200 border-2 border-black text-[10px] font-bold shadow-[1px_1px_0px_#000]"
+                            title="切换回下拉选择"
+                          >
+                            ✕
+                          </button>
+                        </div>
+                      ) : (
+                        <select
+                          value={sentinelAccountPoolId}
+                          onChange={(e) => {
+                            if (e.target.value === '__CUSTOM__') {
+                              setCustomSentinelAccountPool(true);
+                              setSentinelAccountPoolId('');
+                            } else {
+                              setSentinelAccountPoolId(e.target.value);
+                            }
+                          }}
+                          className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                        >
+                          <option value="">-- 请选择账号池 --</option>
+                          {accountPools.map((p) => (
+                            <option key={p.pool_name} value={p.pool_name}>
+                              {p.pool_name} ({p.total_count ?? 0} 个账号)
+                            </option>
+                          ))}
+                          <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
+                        </select>
+                      )}
                     </div>
+
+                    {/* Target Instances - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">监控并发实例数</label>
-                      <input
-                        type="number"
-                        min={1}
+                      <select
                         value={sentinelTargetInstances}
                         onChange={(e) => setSentinelTargetInstances(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20].map((v) => (
+                          <option key={v} value={v}>{v} 个实例{v === 1 ? ' (默认)' : ''}</option>
+                        ))}
+                      </select>
                     </div>
+
+                    {/* Signal TTL - preset dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">放位信号 TTL 持续 (秒)</label>
-                      <input
-                        type="number"
+                      <select
                         value={sentinelSignalTtl}
                         onChange={(e) => setSentinelSignalTtl(Number(e.target.value))}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        {[
+                          { v: 10, label: '10 秒' },
+                          { v: 15, label: '15 秒' },
+                          { v: 20, label: '20 秒' },
+                          { v: 30, label: '30 秒 (默认)' },
+                          { v: 45, label: '45 秒' },
+                          { v: 60, label: '1 分钟' },
+                          { v: 90, label: '90 秒' },
+                          { v: 120, label: '2 分钟' },
+                        ].map((opt) => (
+                          <option key={opt.v} value={opt.v}>{opt.v}s — {opt.label}</option>
+                        ))}
+                      </select>
                     </div>
 
+                    {/* Query Wait Mode - dropdown */}
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">扫位轮询模式 (query_wait.mode)</label>
                       <select
                         value={queryWaitMode}
                         onChange={(e) => setQueryWaitMode(e.target.value as any)}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                        className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
                       >
                         <option value="Random">Random (随机等待)</option>
                         <option value="Fixed">Fixed (固定等待)</option>
@@ -631,32 +935,41 @@ export default function NodeConfigCreateWizardModal({
                     {queryWaitMode === 'Fixed' ? (
                       <div>
                         <label className="block text-[11px] font-bold text-black mb-1">固定等待 (秒)</label>
-                        <input
-                          type="number"
+                        <select
                           value={fixedWait}
                           onChange={(e) => setFixedWait(Number(e.target.value))}
-                          className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                        />
+                          className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                        >
+                          {[5, 10, 15, 20, 30, 45, 60, 90, 120, 180, 300].map((v) => (
+                            <option key={v} value={v}>{v}s{v === 10 ? ' (默认)' : ''}</option>
+                          ))}
+                        </select>
                       </div>
                     ) : (
                       <>
                         <div>
                           <label className="block text-[11px] font-bold text-black mb-1">随机最小等待 (秒)</label>
-                          <input
-                            type="number"
+                          <select
                             value={randomMin}
                             onChange={(e) => setRandomMin(Number(e.target.value))}
-                            className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                          />
+                            className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                          >
+                            {[10, 20, 30, 45, 60, 90, 120, 180, 300].map((v) => (
+                              <option key={v} value={v}>{v}s{v === 60 ? ' (默认)' : ''}</option>
+                            ))}
+                          </select>
                         </div>
                         <div>
                           <label className="block text-[11px] font-bold text-black mb-1">随机最大等待 (秒)</label>
-                          <input
-                            type="number"
+                          <select
                             value={randomMax}
                             onChange={(e) => setRandomMax(Number(e.target.value))}
-                            className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                          />
+                            className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                          >
+                            {[30, 60, 120, 180, 300, 450, 600, 900, 1200].map((v) => (
+                              <option key={v} value={v}>{v}s{v === 300 ? ' (默认)' : ''}</option>
+                            ))}
+                          </select>
                         </div>
                       </>
                     )}
@@ -710,42 +1023,50 @@ export default function NodeConfigCreateWizardModal({
                 onChange={setAppointmentTypes}
               />
 
-              {/* Plugin & Free Config */}
+              {/* Plugin (Inherited from Template, read-only) & Free Config */}
               <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
-                <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
-                  <span className="w-2 h-2 bg-black inline-block" />
-                  <span className="font-black text-black uppercase">[ EXTENSION // 插件与自由键值配置 ]</span>
+                <div className="flex items-center justify-between border-b-2 border-black pb-1.5">
+                  <div className="flex items-center gap-2">
+                    <span className="w-2 h-2 bg-black inline-block" />
+                    <span className="font-black text-black uppercase">[ PLUGIN DRIVER // 插件运行时 (已由模板绑定) ]</span>
+                  </div>
+                  <span className="text-[10px] text-emerald-800 bg-emerald-100 border border-emerald-500 px-1.5 py-0.5 font-bold">
+                    ✓ 自动从模板 [{selectedProviderName || '未选'}] 继承,无需手动配置
+                  </span>
                 </div>
 
-                <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
-                  <div>
-                    <label className="block text-[11px] font-bold text-black mb-1">插件名称 (plugin_name)</label>
-                    <input
-                      type="text"
-                      value={pluginConfig.plugin_name || ''}
-                      onChange={(e) => setPluginConfig({ ...pluginConfig, plugin_name: e.target.value })}
-                      className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                    />
+                {/* Readonly info bar */}
+                <div className="bg-white border-2 border-black p-3 shadow-[1px_1px_0px_#000] space-y-2">
+                  <div className="flex flex-wrap items-center justify-between gap-2">
+                    <div className="flex items-center gap-2">
+                      <span className="font-bold text-neutral-500 text-[11px]">绑定插件:</span>
+                      <span className="font-mono font-black text-black bg-amber-200 border border-black px-2 py-0.5 text-xs shadow-[1px_1px_0px_#000]">
+                        {pluginConfig.plugin_name || '默认内置驱动'}
+                      </span>
+                    </div>
+                    <div className="text-[11px] font-mono text-neutral-700">
+                      执行脚本: <code className="font-bold text-black bg-neutral-100 px-1 py-0.5 border border-neutral-300">{pluginConfig.plugin_bin || '(内置脚本)'}</code>
+                    </div>
                   </div>
-                  <div>
-                    <label className="block text-[11px] font-bold text-black mb-1">二进制脚本 (plugin_bin)</label>
-                    <input
-                      type="text"
-                      value={pluginConfig.plugin_bin || ''}
-                      onChange={(e) => setPluginConfig({ ...pluginConfig, plugin_bin: e.target.value })}
-                      className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                    />
+                  <div className="flex flex-wrap items-center justify-between text-[10px] text-neutral-500 border-t border-neutral-200 pt-1.5">
+                    <span>接口协议: <span className="font-mono font-bold text-neutral-700">{pluginConfig.plugin_proto || 'IPlugin'}</span></span>
+                    <span>加载目录: <span className="font-mono font-bold text-neutral-700">{pluginConfig.lib_path || 'plugins'}</span></span>
+                    {pluginConfig.plugin_class && (
+                      <span>入口类: <span className="font-mono font-bold text-neutral-700">{pluginConfig.plugin_class}</span></span>
+                    )}
                   </div>
                 </div>
 
-                <div>
+                {/* Free Config */}
+                <div className="pt-1">
                   <label className="block text-[11px] font-bold text-black mb-1">
-                    自定义扩展 JSON (free_config)
+                    自定义扩展 JSON (free_config, 可选)
                   </label>
                   <textarea
                     rows={3}
                     value={freeConfigStr}
                     onChange={(e) => setFreeConfigStr(e.target.value)}
+                    placeholder="{}"
                     className="w-full p-2.5 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-neutral-100 border-2 border-black shadow-[2px_2px_0px_#000]"
                   />
                 </div>
@@ -784,18 +1105,22 @@ export default function NodeConfigCreateWizardModal({
                 </div>
 
                 <div className="p-4 bg-neutral-100 border-2 border-black shadow-[2px_2px_0px_#000] space-y-2 text-xs">
-                  <div className="font-black text-black border-b-2 border-black pb-1 uppercase">[ 插件与继承模板 ]</div>
+                  <div className="font-black text-black border-b-2 border-black pb-1 uppercase">[ 插件运行时 (由模板锁定) ]</div>
                   <div className="flex justify-between">
                     <span className="text-neutral-600">继承模板:</span>
-                    <span className="font-bold text-black">{selectedProviderName || '无'}</span>
+                    <span className="font-bold text-black bg-amber-200 border border-black px-1.5">{selectedProviderName || '无'}</span>
+                  </div>
+                  <div className="flex justify-between">
+                    <span className="text-neutral-600">插件驱动:</span>
+                    <span className="font-bold text-black">{pluginConfig.plugin_name || '默认内置'}</span>
                   </div>
                   <div className="flex justify-between">
-                    <span className="text-neutral-600">插件名:</span>
-                    <span className="font-bold text-black">{pluginConfig.plugin_name || '默认'}</span>
+                    <span className="text-neutral-600">执行脚本:</span>
+                    <span className="font-mono font-bold text-black">{pluginConfig.plugin_bin || '(内置脚本)'}</span>
                   </div>
                   <div className="flex justify-between">
-                    <span className="text-neutral-600">脚本文件:</span>
-                    <span className="font-bold text-black">{pluginConfig.plugin_bin || '-'}</span>
+                    <span className="text-neutral-600">协议/目录:</span>
+                    <span className="font-mono text-neutral-600">{pluginConfig.plugin_proto || 'IPlugin'} / {pluginConfig.lib_path || 'plugins'}</span>
                   </div>
                 </div>
               </div>

+ 720 - 83
src/components/admin/node-configurations/NodeConfigEditModal.tsx

@@ -12,7 +12,28 @@ import {
   PluginConfig,
 } from '@/types';
 import { nodeConfigService } from '@/lib/services/nodeConfigService';
+import { accountService } from '@/lib/services/accountService';
+import { proxyService } from '@/lib/services/proxyService';
 import AppointmentTypeEditor from './AppointmentTypeEditor';
+import RegisteredNodeSelect from '@/components/admin/node-configurations/RegisteredNodeSelect';
+import {
+  LOCAL_PROXY_POOLS,
+  COMMON_WEBSITES,
+  PROXY_CD_PRESETS,
+  SESSION_MAX_LIFE_PRESETS,
+  BOOKER_TARGET_INSTANCES_PRESETS,
+  BOOKER_ACCOUNT_CD_PRESETS,
+  BOOKER_COOLDOWN_PRESETS,
+  BOOKER_MAX_BOOKINGS_PRESETS,
+  SENTINEL_TARGET_INSTANCES_PRESETS,
+  SENTINEL_SIGNAL_TTL_PRESETS,
+  FIXED_WAIT_PRESETS,
+  RANDOM_WAIT_PRESET_PAIRS,
+  RANDOM_MIN_PRESETS,
+  RANDOM_MAX_PRESETS,
+  LOGIN_INTERVAL_PRESETS,
+  ACTIVE_TIME_PRESETS,
+} from './nodeConfigConstants';
 
 interface NodeConfigEditModalProps {
   isOpen: boolean;
@@ -32,6 +53,13 @@ export default function NodeConfigEditModal({
   const [mode, setMode] = useState<'visual' | 'json'>('visual');
   const [saving, setSaving] = useState(false);
 
+  // DB pools
+  const [accountPools, setAccountPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
+  const [cloudProxyPools, setCloudProxyPools] = useState<{ pool_name: string; total_count?: number }[]>([]);
+  const [customBookerAccountPool, setCustomBookerAccountPool] = useState(false);
+  const [customSentinelAccountPool, setCustomSentinelAccountPool] = useState(false);
+  const [showRawProxyInput, setShowRawProxyInput] = useState(false);
+
   // Visual mode form fields
   const [nodeId, setNodeId] = useState('');
   const [website, setWebsite] = useState('');
@@ -74,6 +102,29 @@ export default function NodeConfigEditModal({
   // JSON mode payload
   const [rawJsonStr, setRawJsonStr] = useState('{\n  "set": {},\n  "clear": []\n}');
 
+  // Fetch account pools and proxy pools from DB
+  useEffect(() => {
+    if (isOpen) {
+      const fetchDbPools = async () => {
+        try {
+          const [accRes, proxyRes] = await Promise.allSettled([
+            accountService.getPools(),
+            proxyService.getPools(),
+          ]);
+          if (accRes.status === 'fulfilled' && accRes.value?.data) {
+            setAccountPools(Array.isArray(accRes.value.data) ? accRes.value.data : []);
+          }
+          if (proxyRes.status === 'fulfilled' && proxyRes.value?.data) {
+            setCloudProxyPools(Array.isArray(proxyRes.value.data) ? proxyRes.value.data : []);
+          }
+        } catch (err) {
+          console.error('Failed to fetch pools from DB:', err);
+        }
+      };
+      fetchDbPools();
+    }
+  }, [isOpen]);
+
   useEffect(() => {
     if (config) {
       setNodeId(config.node_id || '');
@@ -92,15 +143,19 @@ export default function NodeConfigEditModal({
         config.user_preferences ? JSON.stringify(config.user_preferences, null, 2) : '{}'
       );
 
+      const bPool = config.booker?.account_pool_id || '';
       setBookerAccountSource(config.booker?.account_source || 'built-in');
-      setBookerAccountPoolId(config.booker?.account_pool_id || '');
+      setBookerAccountPoolId(bPool);
+      setCustomBookerAccountPool(false);
       setBookerTargetInstances(config.booker?.target_instances !== undefined ? config.booker.target_instances : 1);
       setBookerAccountCd(config.booker?.account_cd !== undefined ? config.booker.account_cd : '');
       setBookerCooldown(config.booker?.booking_cooldown !== undefined ? config.booker.booking_cooldown : '');
       setBookerMaxBookings(config.booker?.max_bookings_per_account !== undefined ? config.booker.max_bookings_per_account : '');
 
+      const sPool = config.sentinel?.account_pool_id || '';
       setSentinelAccountSource(config.sentinel?.account_source || 'built-in');
-      setSentinelAccountPoolId(config.sentinel?.account_pool_id || '');
+      setSentinelAccountPoolId(sPool);
+      setCustomSentinelAccountPool(false);
       setSentinelTargetInstances(config.sentinel?.target_instances !== undefined ? config.sentinel.target_instances : 1);
       setSentinelSignalTtl(config.sentinel?.signal_ttl !== undefined ? config.sentinel.signal_ttl : '');
 
@@ -136,6 +191,21 @@ export default function NodeConfigEditModal({
 
   if (!isOpen || !config) return null;
 
+  const addProxyPoolTag = (tagToAdd: string) => {
+    if (!tagToAdd) return;
+    const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
+    if (!current.includes(tagToAdd)) {
+      current.push(tagToAdd);
+      setProxyPoolStr(current.join(', '));
+    }
+  };
+
+  const removeProxyPoolTag = (tagToRemove: string) => {
+    const current = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
+    const updated = current.filter((t) => t !== tagToRemove);
+    setProxyPoolStr(updated.join(', '));
+  };
+
   const calculateSparsePayload = (): SparseUpdatePayload => {
     const setObj: Record<string, any> = {};
     const clearArr: string[] = [];
@@ -157,8 +227,14 @@ export default function NodeConfigEditModal({
       setObj['session_max_life'] = Number(sessionMaxLife);
     }
 
-    if (activeTimeStart !== (config.active_time_start || '')) setObj['active_time_start'] = activeTimeStart;
-    if (activeTimeEnd !== (config.active_time_end || '')) setObj['active_time_end'] = activeTimeEnd;
+    if (activeTimeStart !== (config.active_time_start || '')) {
+      if (activeTimeStart === '') clearArr.push('active_time_start');
+      else setObj['active_time_start'] = activeTimeStart;
+    }
+    if (activeTimeEnd !== (config.active_time_end || '')) {
+      if (activeTimeEnd === '') clearArr.push('active_time_end');
+      else setObj['active_time_end'] = activeTimeEnd;
+    }
 
     const newProxyList = proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean);
     const oldProxyList = config.proxy_pool || [];
@@ -310,6 +386,29 @@ export default function NodeConfigEditModal({
     }
   };
 
+  // Helper badge component for preset option
+  const PresetChip = ({
+    active,
+    onClick,
+    children,
+  }: {
+    active: boolean;
+    onClick: () => void;
+    children: React.ReactNode;
+  }) => (
+    <button
+      type="button"
+      onClick={onClick}
+      className={`px-2 py-0.5 text-[10px] font-mono font-bold border transition shrink-0 ${
+        active
+          ? 'bg-amber-300 text-black border-black shadow-[1px_1px_0px_#000]'
+          : 'bg-white text-neutral-700 border-neutral-300 hover:border-black hover:bg-neutral-100 hover:text-black'
+      }`}
+    >
+      {children}
+    </button>
+  );
+
   return (
     <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-grayscale p-4 font-mono">
       <div className="bg-neutral-50 border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-4xl max-h-[92vh] flex flex-col overflow-hidden animate-in zoom-in-95 duration-150">
@@ -374,59 +473,270 @@ export default function NodeConfigEditModal({
 
                 <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
                   <div className="md:col-span-2">
-                    <label className="block text-[11px] font-bold text-black mb-1">
-                      目标计算节点 (node_id) <span className="text-rose-600 font-bold">*</span>
-                    </label>
-                    <input
-                      type="text"
-                      required
+                    <RegisteredNodeSelect
                       value={nodeId}
-                      onChange={(e) => setNodeId(e.target.value)}
-                      placeholder="default, node01, node02..."
-                      className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      onChange={setNodeId}
+                      label="目标计算节点 (NODE_ID)"
+                      badgeText="严格单选"
+                      placeholder="-- 请选择已注册的集群节点 --"
+                      required
                     />
                   </div>
 
-                  <div className="md:col-span-2">
-                    <label className="block text-[11px] font-bold text-black mb-1">使馆/登录网址 (website)</label>
+                  {/* Website with datalist and presets */}
+                  <div className="md:col-span-2 space-y-1.5">
+                    <div className="flex justify-between items-center">
+                      <label className="block text-[11px] font-bold text-black">使馆/登录网址 (website)</label>
+                      <span className="text-[10px] text-neutral-500">支持直接输入或点击下方预设</span>
+                    </div>
                     <input
                       type="text"
+                      list="edit-common-websites-list"
                       value={website}
                       onChange={(e) => setWebsite(e.target.value)}
                       placeholder="https://visa.vfsglobal.com/..."
                       className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                     />
+                    <datalist id="edit-common-websites-list">
+                      {COMMON_WEBSITES.map((item) => (
+                        <option key={item.value} value={item.value}>
+                          {item.label}
+                        </option>
+                      ))}
+                    </datalist>
+                    {/* Website Preset Chips */}
+                    <div className="flex flex-wrap items-center gap-1.5 pt-0.5">
+                      <span className="text-[10px] text-neutral-500 font-bold">推荐使馆:</span>
+                      {COMMON_WEBSITES.map((item) => (
+                        <PresetChip
+                          key={item.value}
+                          active={website === item.value}
+                          onClick={() => setWebsite(item.value)}
+                        >
+                          {item.label}
+                        </PresetChip>
+                      ))}
+                    </div>
                   </div>
 
-                  <div>
-                    <label className="block text-[11px] font-bold text-black mb-1">代理冷却时间 (proxy_cd / 秒)</label>
+                  {/* Proxy CD with presets */}
+                  <div className="space-y-1.5">
+                    <div className="flex justify-between items-center">
+                      <label className="block text-[11px] font-bold text-black">代理冷却时间 (proxy_cd / 秒)</label>
+                      <span className="text-[10px] text-neutral-500">{proxyCd === '' ? '未设置' : `${proxyCd}s`}</span>
+                    </div>
                     <input
                       type="number"
                       value={proxyCd}
                       onChange={(e) => setProxyCd(e.target.value === '' ? '' : Number(e.target.value))}
+                      placeholder="如 300"
                       className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                     />
+                    {/* Presets */}
+                    <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                      {PROXY_CD_PRESETS.map((p) => (
+                        <PresetChip
+                          key={p.v}
+                          active={proxyCd === p.v}
+                          onClick={() => setProxyCd(p.v)}
+                        >
+                          {p.label}
+                        </PresetChip>
+                      ))}
+                    </div>
                   </div>
 
-                  <div>
-                    <label className="block text-[11px] font-bold text-black mb-1">Session 最长存活时间 (秒)</label>
+                  {/* Session Max Life with presets */}
+                  <div className="space-y-1.5">
+                    <div className="flex justify-between items-center">
+                      <label className="block text-[11px] font-bold text-black">Session 最长存活时间 (秒)</label>
+                      <span className="text-[10px] text-neutral-500">{sessionMaxLife === '' ? '未设置' : `${sessionMaxLife}s`}</span>
+                    </div>
                     <input
                       type="number"
                       value={sessionMaxLife}
                       onChange={(e) => setSessionMaxLife(e.target.value === '' ? '' : Number(e.target.value))}
+                      placeholder="如 1800"
                       className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                     />
+                    {/* Presets */}
+                    <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                      {SESSION_MAX_LIFE_PRESETS.map((p) => (
+                        <PresetChip
+                          key={p.v}
+                          active={sessionMaxLife === p.v}
+                          onClick={() => setSessionMaxLife(p.v)}
+                        >
+                          {p.label}
+                        </PresetChip>
+                      ))}
+                    </div>
                   </div>
 
-                  <div className="md:col-span-2">
-                    <label className="block text-[11px] font-bold text-black mb-1">网络代理池标签列表 (proxy_pool, 逗号分隔)</label>
-                    <input
-                      type="text"
-                      value={proxyPoolStr}
-                      onChange={(e) => setProxyPoolStr(e.target.value)}
-                      placeholder="proxy-cheap, proxy-fast"
-                      className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                    />
+                  {/* Active Time Window with presets */}
+                  <div className="md:col-span-2 space-y-1.5 pt-1 border-t border-black/10">
+                    <div className="flex justify-between items-center">
+                      <label className="block text-[11px] font-bold text-black">每日生效时间窗口 (active_time_start ~ active_time_end)</label>
+                      <span className="text-[10px] text-neutral-500">留空为不限</span>
+                    </div>
+                    <div className="grid grid-cols-2 gap-2">
+                      <div>
+                        <input
+                          type="time"
+                          value={activeTimeStart}
+                          onChange={(e) => setActiveTimeStart(e.target.value)}
+                          className="w-full px-3 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[1px_1px_0px_#000]"
+                        />
+                      </div>
+                      <div>
+                        <input
+                          type="time"
+                          value={activeTimeEnd}
+                          onChange={(e) => setActiveTimeEnd(e.target.value)}
+                          className="w-full px-3 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[1px_1px_0px_#000]"
+                        />
+                      </div>
+                    </div>
+                    {/* Time presets */}
+                    <div className="flex flex-wrap items-center gap-1.5 pt-0.5">
+                      <span className="text-[10px] text-neutral-500 font-bold">常用时段:</span>
+                      {ACTIVE_TIME_PRESETS.map((t) => (
+                        <PresetChip
+                          key={t.label}
+                          active={activeTimeStart === t.start && activeTimeEnd === t.end}
+                          onClick={() => {
+                            setActiveTimeStart(t.start);
+                            setActiveTimeEnd(t.end);
+                          }}
+                        >
+                          {t.label}
+                        </PresetChip>
+                      ))}
+                      {(activeTimeStart || activeTimeEnd) && (
+                        <button
+                          type="button"
+                          onClick={() => {
+                            setActiveTimeStart('');
+                            setActiveTimeEnd('');
+                          }}
+                          className="px-2 py-0.5 text-[10px] font-mono font-bold text-red-600 border border-red-300 hover:bg-red-50 hover:border-red-600 transition"
+                        >
+                          [ 清空时段 ]
+                        </button>
+                      )}
+                    </div>
+                  </div>
+
+                  {/* Proxy Pool - tag multi-select and presets */}
+                  <div className="md:col-span-2 space-y-2 pt-1 border-t border-black/10">
+                    <div className="flex justify-between items-center">
+                      <label className="block text-[11px] font-bold text-black">网络代理池 (proxy_pool)</label>
+                      <button
+                        type="button"
+                        onClick={() => setShowRawProxyInput(!showRawProxyInput)}
+                        className="text-[10px] text-neutral-600 hover:text-black font-bold underline"
+                      >
+                        {showRawProxyInput ? '隐藏文本编辑' : '手动文本编辑'}
+                      </button>
+                    </div>
+
+                    {/* Selected tags */}
+                    <div className="flex flex-wrap gap-1.5 min-h-[34px] p-2 bg-white border-2 border-black shadow-[2px_2px_0px_#000]">
+                      {proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean).length === 0 && (
+                        <span className="text-neutral-400 text-[10px] italic">尚未选择代理池标签,请从下方快速选择或添加...</span>
+                      )}
+                      {proxyPoolStr.split(',').map((s) => s.trim()).filter(Boolean).map((tag) => (
+                        <span
+                          key={tag}
+                          className={`inline-flex items-center gap-1 px-2 py-0.5 border border-black text-[10px] font-bold shadow-[1px_1px_0px_#000] ${
+                            tag.startsWith('cloud:') ? 'bg-sky-200 text-sky-900' : 'bg-emerald-200 text-emerald-900'
+                          }`}
+                        >
+                          {tag.startsWith('cloud:') ? '☁' : '⊙'} {tag}
+                          <button
+                            type="button"
+                            onClick={() => removeProxyPoolTag(tag)}
+                            className="ml-0.5 hover:text-red-600 font-black"
+                            title="移除此标签"
+                          >
+                            ✕
+                          </button>
+                        </span>
+                      ))}
+                    </div>
+
+                    {/* Add tag dropdown */}
+                    <div className="grid grid-cols-1 md:grid-cols-2 gap-2">
+                      <select
+                        value=""
+                        onChange={(e) => {
+                          if (e.target.value) addProxyPoolTag(e.target.value);
+                        }}
+                        className="w-full px-3 py-1.5 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                      >
+                        <option value="">+ 下拉点选添加代理池...</option>
+                        {cloudProxyPools.length > 0 && (
+                          <optgroup label="☁ 云端代理池 (cloud:)">
+                            {cloudProxyPools.map((p) => (
+                              <option key={`cloud:${p.pool_name}`} value={`cloud:${p.pool_name}`}>
+                                cloud:{p.pool_name} ({p.total_count ?? 0} 条代理)
+                              </option>
+                            ))}
+                          </optgroup>
+                        )}
+                        <optgroup label="⊙ 本地代理池 (local:)">
+                          {LOCAL_PROXY_POOLS.map((p) => (
+                            <option key={`local:${p.value}`} value={`local:${p.value}`}>
+                              local:{p.value} — {p.label}
+                            </option>
+                          ))}
+                        </optgroup>
+                      </select>
+
+                      {/* Quick popular tags */}
+                      <div className="flex flex-wrap items-center gap-1">
+                        <span className="text-[10px] text-neutral-500 font-bold">快捷添加:</span>
+                        {[
+                          { tag: 'local_multi_pool', label: '🌐 全球混合' },
+                          { tag: 'local_cn', label: '🇨🇳 中国' },
+                          { tag: 'local_fr', label: '🇫🇷 法国' },
+                          { tag: 'local_de', label: '🇩🇪 德国' },
+                          { tag: 'local_gb', label: '🇬🇧 英国' },
+                        ].map((item) => {
+                          const isSelected = proxyPoolStr.split(',').map((s) => s.trim()).includes(item.tag);
+                          return (
+                            <button
+                              key={item.tag}
+                              type="button"
+                              onClick={() => {
+                                if (isSelected) removeProxyPoolTag(item.tag);
+                                else addProxyPoolTag(item.tag);
+                              }}
+                              className={`px-1.5 py-0.5 text-[10px] font-bold border transition ${
+                                isSelected
+                                  ? 'bg-emerald-300 border-black text-black shadow-[1px_1px_0px_#000]'
+                                  : 'bg-white border-neutral-300 text-neutral-700 hover:border-black hover:bg-neutral-100'
+                              }`}
+                            >
+                              {item.label}
+                            </button>
+                          );
+                        })}
+                      </div>
+                    </div>
+
+                    {showRawProxyInput && (
+                      <div className="space-y-1 pt-1">
+                        <label className="block text-[10px] text-neutral-500 font-bold">原始逗号字符串编辑 (proxy_pool)</label>
+                        <input
+                          type="text"
+                          value={proxyPoolStr}
+                          onChange={(e) => setProxyPoolStr(e.target.value)}
+                          placeholder="local_multi_pool, local_cn"
+                          className="w-full px-3 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                        />
+                      </div>
+                    )}
                   </div>
                 </div>
               </div>
@@ -440,17 +750,79 @@ export default function NodeConfigEditModal({
                   </div>
 
                   <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">使馆账号池 ID (account_pool_id)</label>
-                      <input
-                        type="text"
-                        value={bookerAccountPoolId}
-                        onChange={(e) => setBookerAccountPoolId(e.target.value)}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                    {/* Account Pool ID */}
+                    <div className="md:col-span-3 space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">使馆账号池 ID (account_pool_id)</label>
+                        <button
+                          type="button"
+                          onClick={() => {
+                            setCustomBookerAccountPool(!customBookerAccountPool);
+                            if (customBookerAccountPool) setBookerAccountPoolId('');
+                          }}
+                          className="text-[10px] text-neutral-600 hover:text-black font-bold underline"
+                        >
+                          {customBookerAccountPool ? '切换回选择现有池' : '✎ 手动输入池名称'}
+                        </button>
+                      </div>
+
+                      {customBookerAccountPool ? (
+                        <input
+                          type="text"
+                          value={bookerAccountPoolId}
+                          onChange={(e) => setBookerAccountPoolId(e.target.value)}
+                          placeholder="输入账号池 ID"
+                          className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                        />
+                      ) : (
+                        <select
+                          value={bookerAccountPoolId}
+                          onChange={(e) => {
+                            if (e.target.value === '__CUSTOM__') {
+                              setCustomBookerAccountPool(true);
+                              setBookerAccountPoolId('');
+                            } else {
+                              setBookerAccountPoolId(e.target.value);
+                            }
+                          }}
+                          className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                        >
+                          <option value="">-- 请选择已有账号池 --</option>
+                          {accountPools.map((p) => (
+                            <option key={p.pool_name} value={p.pool_name}>
+                              {p.pool_name} ({p.total_count ?? 0} 个账号)
+                            </option>
+                          ))}
+                          <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
+                        </select>
+                      )}
+
+                      {/* Quick pools list */}
+                      {accountPools.length > 0 && (
+                        <div className="flex flex-wrap items-center gap-1.5 pt-0.5">
+                          <span className="text-[10px] text-neutral-500 font-bold">已有账号池:</span>
+                          {accountPools.map((p) => (
+                            <PresetChip
+                              key={p.pool_name}
+                              active={bookerAccountPoolId === p.pool_name}
+                              onClick={() => {
+                                setCustomBookerAccountPool(false);
+                                setBookerAccountPoolId(p.pool_name);
+                              }}
+                            >
+                              {p.pool_name} ({p.total_count ?? 0})
+                            </PresetChip>
+                          ))}
+                        </div>
+                      )}
                     </div>
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">目标并发实例 (target_instances)</label>
+
+                    {/* Target Instances */}
+                    <div className="space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">目标并发实例 (target_instances)</label>
+                        <span className="text-[10px] text-neutral-500">{bookerTargetInstances || 1} 个</span>
+                      </div>
                       <input
                         type="number"
                         min={1}
@@ -458,33 +830,95 @@ export default function NodeConfigEditModal({
                         onChange={(e) => setBookerTargetInstances(e.target.value === '' ? '' : Number(e.target.value))}
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
+                      <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                        {BOOKER_TARGET_INSTANCES_PRESETS.map((v) => (
+                          <PresetChip
+                            key={v}
+                            active={Number(bookerTargetInstances) === v}
+                            onClick={() => setBookerTargetInstances(v)}
+                          >
+                            {v}{v === 1 ? ' (默认)' : ''}
+                          </PresetChip>
+                        ))}
+                      </div>
                     </div>
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">账号冷却 CD (account_cd / 秒)</label>
+
+                    {/* Account CD */}
+                    <div className="space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">账号冷却 CD (account_cd / 秒)</label>
+                        <span className="text-[10px] text-neutral-500">{bookerAccountCd === '' ? '未设置' : `${bookerAccountCd}s`}</span>
+                      </div>
                       <input
                         type="number"
                         value={bookerAccountCd}
                         onChange={(e) => setBookerAccountCd(e.target.value === '' ? '' : Number(e.target.value))}
+                        placeholder="如 10800"
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
+                      <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                        {BOOKER_ACCOUNT_CD_PRESETS.map((p) => (
+                          <PresetChip
+                            key={p.v}
+                            active={bookerAccountCd === p.v}
+                            onClick={() => setBookerAccountCd(p.v)}
+                          >
+                            {p.label}
+                          </PresetChip>
+                        ))}
+                      </div>
                     </div>
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">下单冷却 (booking_cooldown / 秒)</label>
+
+                    {/* Booking Cooldown */}
+                    <div className="space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">下单冷却 (booking_cooldown / 秒)</label>
+                        <span className="text-[10px] text-neutral-500">{bookerCooldown === '' ? '未设置' : `${bookerCooldown}s`}</span>
+                      </div>
                       <input
                         type="number"
                         value={bookerCooldown}
                         onChange={(e) => setBookerCooldown(e.target.value === '' ? '' : Number(e.target.value))}
+                        placeholder="如 300"
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
+                      <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                        {BOOKER_COOLDOWN_PRESETS.map((p) => (
+                          <PresetChip
+                            key={p.v}
+                            active={bookerCooldown === p.v}
+                            onClick={() => setBookerCooldown(p.v)}
+                          >
+                            {p.label}
+                          </PresetChip>
+                        ))}
+                      </div>
                     </div>
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">单号最大占位次数</label>
+
+                    {/* Max Bookings */}
+                    <div className="space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">单号最大占位次数</label>
+                        <span className="text-[10px] text-neutral-500">{bookerMaxBookings === '' ? '未设置' : `${bookerMaxBookings}次`}</span>
+                      </div>
                       <input
                         type="number"
                         value={bookerMaxBookings}
                         onChange={(e) => setBookerMaxBookings(e.target.value === '' ? '' : Number(e.target.value))}
+                        placeholder="如 8"
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
+                      <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                        {BOOKER_MAX_BOOKINGS_PRESETS.map((v) => (
+                          <PresetChip
+                            key={v}
+                            active={Number(bookerMaxBookings) === v}
+                            onClick={() => setBookerMaxBookings(v)}
+                          >
+                            {v}次{v === 8 ? ' (默认)' : ''}
+                          </PresetChip>
+                        ))}
+                      </div>
                     </div>
                   </div>
                 </div>
@@ -499,17 +933,79 @@ export default function NodeConfigEditModal({
                   </div>
 
                   <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">账号池 ID (account_pool_id)</label>
-                      <input
-                        type="text"
-                        value={sentinelAccountPoolId}
-                        onChange={(e) => setSentinelAccountPoolId(e.target.value)}
-                        className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                      />
+                    {/* Account Pool ID */}
+                    <div className="md:col-span-3 space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">账号池 ID (account_pool_id)</label>
+                        <button
+                          type="button"
+                          onClick={() => {
+                            setCustomSentinelAccountPool(!customSentinelAccountPool);
+                            if (customSentinelAccountPool) setSentinelAccountPoolId('');
+                          }}
+                          className="text-[10px] text-neutral-600 hover:text-black font-bold underline"
+                        >
+                          {customSentinelAccountPool ? '切换回选择现有池' : '✎ 手动输入池名称'}
+                        </button>
+                      </div>
+
+                      {customSentinelAccountPool ? (
+                        <input
+                          type="text"
+                          value={sentinelAccountPoolId}
+                          onChange={(e) => setSentinelAccountPoolId(e.target.value)}
+                          placeholder="输入账号池 ID"
+                          className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                        />
+                      ) : (
+                        <select
+                          value={sentinelAccountPoolId}
+                          onChange={(e) => {
+                            if (e.target.value === '__CUSTOM__') {
+                              setCustomSentinelAccountPool(true);
+                              setSentinelAccountPoolId('');
+                            } else {
+                              setSentinelAccountPoolId(e.target.value);
+                            }
+                          }}
+                          className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                        >
+                          <option value="">-- 请选择已有账号池 --</option>
+                          {accountPools.map((p) => (
+                            <option key={p.pool_name} value={p.pool_name}>
+                              {p.pool_name} ({p.total_count ?? 0} 个账号)
+                            </option>
+                          ))}
+                          <option value="__CUSTOM__">✎ 手动输入自定义池 ID...</option>
+                        </select>
+                      )}
+
+                      {/* Quick pools list */}
+                      {accountPools.length > 0 && (
+                        <div className="flex flex-wrap items-center gap-1.5 pt-0.5">
+                          <span className="text-[10px] text-neutral-500 font-bold">已有账号池:</span>
+                          {accountPools.map((p) => (
+                            <PresetChip
+                              key={p.pool_name}
+                              active={sentinelAccountPoolId === p.pool_name}
+                              onClick={() => {
+                                setCustomSentinelAccountPool(false);
+                                setSentinelAccountPoolId(p.pool_name);
+                              }}
+                            >
+                              {p.pool_name} ({p.total_count ?? 0})
+                            </PresetChip>
+                          ))}
+                        </div>
+                      )}
                     </div>
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">并发实例数 (target_instances)</label>
+
+                    {/* Target Instances */}
+                    <div className="space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">并发实例数 (target_instances)</label>
+                        <span className="text-[10px] text-neutral-500">{sentinelTargetInstances || 1} 个</span>
+                      </div>
                       <input
                         type="number"
                         min={1}
@@ -517,60 +1013,157 @@ export default function NodeConfigEditModal({
                         onChange={(e) => setSentinelTargetInstances(e.target.value === '' ? '' : Number(e.target.value))}
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
+                      <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                        {SENTINEL_TARGET_INSTANCES_PRESETS.map((v) => (
+                          <PresetChip
+                            key={v}
+                            active={Number(sentinelTargetInstances) === v}
+                            onClick={() => setSentinelTargetInstances(v)}
+                          >
+                            {v}{v === 1 ? ' (默认)' : ''}
+                          </PresetChip>
+                        ))}
+                      </div>
                     </div>
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">信号 TTL 持续 (秒)</label>
+
+                    {/* Signal TTL */}
+                    <div className="space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">信号 TTL 持续 (秒)</label>
+                        <span className="text-[10px] text-neutral-500">{sentinelSignalTtl === '' ? '未设置' : `${sentinelSignalTtl}s`}</span>
+                      </div>
                       <input
                         type="number"
                         value={sentinelSignalTtl}
                         onChange={(e) => setSentinelSignalTtl(e.target.value === '' ? '' : Number(e.target.value))}
+                        placeholder="如 30"
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
+                      <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                        {SENTINEL_SIGNAL_TTL_PRESETS.map((p) => (
+                          <PresetChip
+                            key={p.v}
+                            active={sentinelSignalTtl === p.v}
+                            onClick={() => setSentinelSignalTtl(p.v)}
+                          >
+                            {p.label}
+                          </PresetChip>
+                        ))}
+                      </div>
                     </div>
 
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">扫位轮询模式 (query_wait.mode)</label>
+                    {/* Wait Mode */}
+                    <div className="space-y-1.5">
+                      <label className="block text-[11px] font-bold text-black">扫位轮询模式 (query_wait.mode)</label>
                       <select
                         value={queryWaitMode}
                         onChange={(e) => setQueryWaitMode(e.target.value as any)}
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
                       >
-                        <option value="Random">Random (随机等待)</option>
-                        <option value="Fixed">Fixed (固定等待)</option>
+                        <option value="Random">Random (随机等待区间)</option>
+                        <option value="Fixed">Fixed (固定等待秒数)</option>
                       </select>
                     </div>
 
+                    {/* Query Wait details */}
                     {queryWaitMode === 'Fixed' ? (
-                      <div>
-                        <label className="block text-[11px] font-bold text-black mb-1">固定等待 (秒)</label>
+                      <div className="md:col-span-2 space-y-1.5">
+                        <div className="flex justify-between items-center">
+                          <label className="block text-[11px] font-bold text-black">固定等待 (秒)</label>
+                          <span className="text-[10px] text-neutral-500">{fixedWait === '' ? '未设置' : `${fixedWait}s`}</span>
+                        </div>
                         <input
                           type="number"
                           value={fixedWait}
                           onChange={(e) => setFixedWait(e.target.value === '' ? '' : Number(e.target.value))}
+                          placeholder="如 5"
                           className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                         />
+                        <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                          {FIXED_WAIT_PRESETS.map((p) => (
+                            <PresetChip
+                              key={p.v}
+                              active={fixedWait === p.v}
+                              onClick={() => setFixedWait(p.v)}
+                            >
+                              {p.label}
+                            </PresetChip>
+                          ))}
+                        </div>
                       </div>
                     ) : (
-                      <>
-                        <div>
-                          <label className="block text-[11px] font-bold text-black mb-1">随机最小等待 (秒)</label>
-                          <input
-                            type="number"
-                            value={randomMin}
-                            onChange={(e) => setRandomMin(e.target.value === '' ? '' : Number(e.target.value))}
-                            className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                          />
+                      <div className="md:col-span-3 space-y-2 pt-1 border-t border-black/10">
+                        {/* Recommended Random Pairs */}
+                        <div className="flex flex-wrap items-center gap-1.5">
+                          <span className="text-[10px] text-neutral-500 font-bold">推荐组合:</span>
+                          {RANDOM_WAIT_PRESET_PAIRS.map((pair) => (
+                            <PresetChip
+                              key={pair.label}
+                              active={Number(randomMin) === pair.min && Number(randomMax) === pair.max}
+                              onClick={() => {
+                                setRandomMin(pair.min);
+                                setRandomMax(pair.max);
+                              }}
+                            >
+                              {pair.label}
+                            </PresetChip>
+                          ))}
                         </div>
-                        <div>
-                          <label className="block text-[11px] font-bold text-black mb-1">随机最大等待 (秒)</label>
-                          <input
-                            type="number"
-                            value={randomMax}
-                            onChange={(e) => setRandomMax(e.target.value === '' ? '' : Number(e.target.value))}
-                            className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
-                          />
+
+                        <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+                          {/* Min */}
+                          <div className="space-y-1.5">
+                            <div className="flex justify-between items-center">
+                              <label className="block text-[11px] font-bold text-black">随机最小等待 (秒)</label>
+                              <span className="text-[10px] text-neutral-500">{randomMin === '' ? '未设置' : `${randomMin}s`}</span>
+                            </div>
+                            <input
+                              type="number"
+                              value={randomMin}
+                              onChange={(e) => setRandomMin(e.target.value === '' ? '' : Number(e.target.value))}
+                              placeholder="如 5"
+                              className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                            />
+                            <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                              {RANDOM_MIN_PRESETS.map((v) => (
+                                <PresetChip
+                                  key={v}
+                                  active={Number(randomMin) === v}
+                                  onClick={() => setRandomMin(v)}
+                                >
+                                  {v}s
+                                </PresetChip>
+                              ))}
+                            </div>
+                          </div>
+
+                          {/* Max */}
+                          <div className="space-y-1.5">
+                            <div className="flex justify-between items-center">
+                              <label className="block text-[11px] font-bold text-black">随机最大等待 (秒)</label>
+                              <span className="text-[10px] text-neutral-500">{randomMax === '' ? '未设置' : `${randomMax}s`}</span>
+                            </div>
+                            <input
+                              type="number"
+                              value={randomMax}
+                              onChange={(e) => setRandomMax(e.target.value === '' ? '' : Number(e.target.value))}
+                              placeholder="如 15"
+                              className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                            />
+                            <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                              {RANDOM_MAX_PRESETS.map((v) => (
+                                <PresetChip
+                                  key={v}
+                                  active={Number(randomMax) === v}
+                                  onClick={() => setRandomMax(v)}
+                                >
+                                  {v}s
+                                </PresetChip>
+                              ))}
+                            </div>
+                          </div>
                         </div>
-                      </>
+                      </div>
                     )}
                   </div>
                 </div>
@@ -591,27 +1184,48 @@ export default function NodeConfigEditModal({
                         type="text"
                         value={orderId}
                         onChange={(e) => setOrderId(e.target.value)}
+                        placeholder="如 ORDER-12345"
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
                     </div>
-                    <div>
-                      <label className="block text-[11px] font-bold text-black mb-1">登录重试间隔 (秒)</label>
+
+                    {/* Login Interval with presets */}
+                    <div className="space-y-1.5">
+                      <div className="flex justify-between items-center">
+                        <label className="block text-[11px] font-bold text-black">登录重试间隔 (秒)</label>
+                        <span className="text-[10px] text-neutral-500">{loginInterval === '' ? '未设置' : `${loginInterval}s`}</span>
+                      </div>
                       <input
                         type="number"
                         value={loginInterval}
                         onChange={(e) => setLoginInterval(e.target.value === '' ? '' : Number(e.target.value))}
+                        placeholder="如 1800"
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
+                      <div className="flex flex-wrap items-center gap-1 pt-0.5">
+                        {LOGIN_INTERVAL_PRESETS.map((p) => (
+                          <PresetChip
+                            key={p.v}
+                            active={loginInterval === p.v}
+                            onClick={() => setLoginInterval(p.v)}
+                          >
+                            {p.label}
+                          </PresetChip>
+                        ))}
+                      </div>
                     </div>
+
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">抢签账号 (username)</label>
                       <input
                         type="text"
                         value={accountUsername}
                         onChange={(e) => setAccountUsername(e.target.value)}
+                        placeholder="登录账号 / 邮箱"
                         className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
                       />
                     </div>
+
                     <div>
                       <label className="block text-[11px] font-bold text-black mb-1">抢签密码 (password)</label>
                       <input
@@ -627,7 +1241,30 @@ export default function NodeConfigEditModal({
                   <div className="pt-2 border-t border-black/20 space-y-1.5">
                     <div className="flex items-center justify-between">
                       <label className="block text-[11px] font-bold text-black">用户偏好 (user_preferences JSON)</label>
-                      <span className="text-[10px] text-neutral-500 font-mono">支持自定义键值与可变结构</span>
+                      <div className="flex items-center gap-1">
+                        <span className="text-[10px] text-neutral-500 mr-1">快速填充:</span>
+                        <button
+                          type="button"
+                          onClick={() => setUserPreferencesStr(JSON.stringify({ auto_confirm: true }, null, 2))}
+                          className="px-1.5 py-0.5 text-[10px] font-bold border border-black bg-white hover:bg-neutral-100"
+                        >
+                          默认模板
+                        </button>
+                        <button
+                          type="button"
+                          onClick={() => setUserPreferencesStr(JSON.stringify({ auto_confirm: true, urgent: true, vip_service: true }, null, 2))}
+                          className="px-1.5 py-0.5 text-[10px] font-bold border border-black bg-white hover:bg-neutral-100"
+                        >
+                          加急VIP模板
+                        </button>
+                        <button
+                          type="button"
+                          onClick={() => setUserPreferencesStr('{}')}
+                          className="px-1.5 py-0.5 text-[10px] font-bold border border-black bg-white hover:bg-neutral-100 text-neutral-600"
+                        >
+                          清空
+                        </button>
+                      </div>
                     </div>
                     <textarea
                       rows={3}

+ 535 - 0
src/components/admin/node-configurations/NodeTelemetryModal.tsx

@@ -0,0 +1,535 @@
+// src/components/admin/node-configurations/NodeTelemetryModal.tsx
+'use client';
+
+import React, { useState, useEffect, useCallback } from 'react';
+import {
+  Activity,
+  Radio,
+  Wifi,
+  WifiOff,
+  Server,
+  RefreshCw,
+  X,
+  CheckCircle2,
+  AlertTriangle,
+  Clock,
+  Layers,
+  Package,
+  Globe,
+  ShieldAlert,
+  Info,
+} from 'lucide-react';
+import { toast } from 'react-hot-toast';
+import { nodeConfigService } from '@/lib/services/nodeConfigService';
+import { ClusterNode, NodeRuntimeStatus } from '@/types';
+import LocalTime from '@/components/common/LocalTime';
+
+interface NodeTelemetryModalProps {
+  isOpen: boolean;
+  onClose: () => void;
+  node: ClusterNode | null;
+  runtimeNodes?: NodeRuntimeStatus[];
+  onRefreshAll?: () => void;
+}
+
+export default function NodeTelemetryModal({
+  isOpen,
+  onClose,
+  node,
+  runtimeNodes = [],
+  onRefreshAll,
+}: NodeTelemetryModalProps) {
+  const [localReports, setLocalReports] = useState<NodeRuntimeStatus[]>([]);
+  const [loading, setLoading] = useState(false);
+  const [lastRefreshedAt, setLastRefreshedAt] = useState<string>('');
+  const [autoRefresh, setAutoRefresh] = useState(true);
+
+  // 根据当前 node.node_id 筛选运行时上报
+  const nodeId = node?.node_id;
+
+  const fetchNodeTelemetry = useCallback(async () => {
+    if (!nodeId) return;
+    setLoading(true);
+    try {
+      const res = await nodeConfigService.getRuntimeStatus({ node_id: nodeId });
+      if (res.code === 0 && res.data) {
+        const matched = (res.data.nodes || []).filter((n) => n.node_id === nodeId);
+        setLocalReports(matched);
+        setLastRefreshedAt(res.data.timestamp || new Date().toLocaleTimeString());
+      }
+    } catch (e: any) {
+      console.error('Failed to fetch telemetry for node:', e);
+      toast.error('拉取节点实时遥测失败');
+    } finally {
+      setLoading(false);
+    }
+  }, [nodeId]);
+
+  // 当外部 runtimeNodes 变化或打开弹窗时同步
+  useEffect(() => {
+    if (!isOpen || !nodeId) return;
+    const initialMatched = runtimeNodes.filter((n) => n.node_id === nodeId);
+    setLocalReports(initialMatched);
+    fetchNodeTelemetry();
+  }, [isOpen, nodeId]);
+
+  // 自动轮询遥测(每 5 秒)
+  useEffect(() => {
+    if (!isOpen || !autoRefresh) return;
+    const interval = setInterval(() => {
+      fetchNodeTelemetry();
+    }, 5000);
+    return () => clearInterval(interval);
+  }, [isOpen, autoRefresh, fetchNodeTelemetry]);
+
+  if (!isOpen || !node) return null;
+
+  // 遥测计算
+  const hasReports = localReports.length > 0;
+  const isOnline = localReports.some((r) => r.is_online);
+  const minAgeSec = hasReports
+    ? Math.min(...localReports.map((r) => r.age_sec ?? 999999))
+    : 999999;
+  const latestReport = hasReports
+    ? localReports.reduce((prev, cur) => ((cur.age_sec ?? 999999) < (prev.age_sec ?? 999999) ? cur : prev))
+    : null;
+
+  // 聚合所有角色运行的组与任务
+  const allGroups = localReports.flatMap((r) =>
+    (r.groups || []).map((g) => ({ ...g, role: r.role }))
+  );
+  const totalTasks = allGroups.reduce((acc, g) => acc + (g.total_tasks || 0), 0);
+  const healthyTasks = allGroups.reduce((acc, g) => acc + (g.healthy_tasks || 0), 0);
+
+  // 聚合所有插件
+  const installedPluginsMap = new Map<string, any>();
+  localReports.forEach((r) => {
+    (r.installed_plugins || []).forEach((p) => {
+      if (!installedPluginsMap.has(p.name)) {
+        installedPluginsMap.set(p.name, p);
+      }
+    });
+  });
+  const installedPlugins = Array.from(installedPluginsMap.values());
+
+  const handleManualRefresh = async () => {
+    await fetchNodeTelemetry();
+    if (onRefreshAll) onRefreshAll();
+    toast.success('节点遥测已同步最新状态');
+  };
+
+  const formatAge = (sec: number) => {
+    if (sec < 60) return `${sec} 秒前`;
+    if (sec < 3600) return `${Math.floor(sec / 60)} 分钟前 (${sec}s)`;
+    return `${Math.floor(sec / 3600)} 小时前`;
+  };
+
+  return (
+    <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-mono">
+      <div className="bg-white border-4 border-black w-full max-w-4xl max-h-[92vh] flex flex-col shadow-[8px_8px_0px_#000] overflow-hidden">
+        {/* Modal Header */}
+        <div className="bg-neutral-200 border-b-2 border-black p-4 flex items-center justify-between select-none">
+          <div className="flex items-center gap-2.5">
+            <Radio size={20} className="text-black animate-pulse" />
+            <div>
+              <div className="flex items-center gap-2">
+                <span className="font-black text-sm uppercase tracking-wider text-black">
+                  [ 节点实时遥测监控 // NODE TELEMETRY DIAGNOSTIC ]
+                </span>
+                <span className="px-2 py-0.5 border border-black bg-white text-xs font-black">
+                  {node.node_id}
+                </span>
+              </div>
+              <p className="text-[11px] text-neutral-600 font-bold mt-0.5">
+                节点档案名称: <span className="text-black">{node.name}</span>
+                {node.ip_address && ` · IP: ${node.ip_address}`}
+                {node.region && ` · 机房: ${node.region}`}
+              </p>
+            </div>
+          </div>
+
+          <div className="flex items-center gap-2">
+            <button
+              type="button"
+              onClick={() => setAutoRefresh(!autoRefresh)}
+              className={`px-2.5 py-1 text-[11px] font-bold border border-black uppercase shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition ${
+                autoRefresh ? 'bg-emerald-300 text-emerald-950 font-black' : 'bg-neutral-100 text-neutral-600'
+              }`}
+            >
+              [ 自动轮询: {autoRefresh ? '开启 (5s)' : '暂停'} ]
+            </button>
+
+            <button
+              type="button"
+              onClick={handleManualRefresh}
+              disabled={loading}
+              className="p-1.5 border border-black bg-white hover:bg-neutral-100 shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+              title="立即拉取最新心跳"
+            >
+              <RefreshCw size={14} className={loading ? 'animate-spin' : ''} />
+            </button>
+
+            <button
+              type="button"
+              onClick={onClose}
+              className="p-1.5 border border-black bg-white hover:bg-neutral-100 shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+              title="关闭窗口"
+            >
+              <X size={14} />
+            </button>
+          </div>
+        </div>
+
+        {/* Modal Scrollable Body */}
+        <div className="p-5 overflow-y-auto space-y-5 text-xs flex-1">
+          {/* 1. 核心遥测生命体征看板 (Vitality Status Banner) */}
+          {isOnline ? (
+            <div className="p-4 bg-emerald-50 border-2 border-black shadow-[3px_3px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-4">
+              <div className="flex items-start gap-3">
+                <div className="w-9 h-9 border-2 border-black bg-emerald-300 flex items-center justify-center shrink-0 shadow-[2px_2px_0px_#000] mt-0.5">
+                  <Wifi size={18} className="text-black" />
+                </div>
+                <div>
+                  <div className="flex items-center gap-2">
+                    <span className="font-black text-sm uppercase text-emerald-950 flex items-center gap-1.5">
+                      <span className="w-2.5 h-2.5 rounded-full bg-emerald-500 animate-ping inline-block" />
+                      [ 节点实时在线 // ONLINE ]
+                    </span>
+                    <span className="px-2 py-0.5 border border-black bg-emerald-300 text-emerald-950 font-black text-[10px]">
+                      心跳正常 (NORMAL)
+                    </span>
+                  </div>
+                  <p className="text-emerald-900 font-bold mt-1 text-[11px]">
+                    最近一次心跳上报于: <strong>{latestReport?.collected_at || '刚才'}</strong> ({formatAge(minAgeSec)})
+                  </p>
+                  <p className="text-neutral-600 text-[10px] mt-0.5">
+                    监测通道: <code>vs:status:*:{node.node_id}</code> | 心跳保活阈值 60s 内持续刷新,节点处于可调度就绪状态。
+                  </p>
+                </div>
+              </div>
+
+              <div className="flex items-center gap-2 self-start md:self-auto shrink-0">
+                <div className="px-3 py-1.5 border border-black bg-white text-center shadow-[1px_1px_0px_#000]">
+                  <span className="text-[10px] text-neutral-500 block uppercase">活跃角色</span>
+                  <span className="font-black text-black text-xs">{localReports.length} 个角色运行中</span>
+                </div>
+                <div className="px-3 py-1.5 border border-black bg-white text-center shadow-[1px_1px_0px_#000]">
+                  <span className="text-[10px] text-neutral-500 block uppercase">活跃并发任务</span>
+                  <span className="font-black text-emerald-700 text-xs">
+                    {healthyTasks} / {totalTasks} 正常
+                  </span>
+                </div>
+              </div>
+            </div>
+          ) : hasReports ? (
+            <div className="p-4 bg-rose-50 border-2 border-black shadow-[3px_3px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-4">
+              <div className="flex items-start gap-3">
+                <div className="w-9 h-9 border-2 border-black bg-rose-300 flex items-center justify-center shrink-0 shadow-[2px_2px_0px_#000] mt-0.5">
+                  <WifiOff size={18} className="text-black" />
+                </div>
+                <div>
+                  <div className="flex items-center gap-2">
+                    <span className="font-black text-sm uppercase text-rose-950 flex items-center gap-1.5">
+                      <span className="w-2.5 h-2.5 rounded-full bg-rose-600 inline-block" />
+                      [ 节点心跳中断 // OFFLINE ]
+                    </span>
+                    <span className="px-2 py-0.5 border border-black bg-rose-300 text-rose-950 font-black text-[10px]">
+                      心跳超时 (&gt;60s)
+                    </span>
+                  </div>
+                  <p className="text-rose-900 font-bold mt-1 text-[11px]">
+                    该节点上一次心跳停留在: <strong>{latestReport?.collected_at || '未知'}</strong> ({formatAge(minAgeSec)})
+                  </p>
+                  <p className="text-neutral-600 text-[10px] mt-0.5">
+                    监测通道: <code>vs:status:*:{node.node_id}</code> | 超过离线阈值 60s 未收到心跳,系统已将该计算节点判定为离线。
+                  </p>
+                </div>
+              </div>
+
+              <div className="px-3 py-2 border border-black bg-white text-[11px] font-bold text-rose-800 shrink-0 self-start md:self-auto shadow-[1px_1px_0px_#000]">
+                ⚠️ 建议检查对应机器的 <code>main.py</code> 守护进程
+              </div>
+            </div>
+          ) : (
+            <div className="p-4 bg-neutral-100 border-2 border-black shadow-[3px_3px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-4">
+              <div className="flex items-start gap-3">
+                <div className="w-9 h-9 border-2 border-black bg-neutral-300 flex items-center justify-center shrink-0 shadow-[2px_2px_0px_#000] mt-0.5">
+                  <AlertTriangle size={18} className="text-black" />
+                </div>
+                <div>
+                  <div className="flex items-center gap-2">
+                    <span className="font-black text-sm uppercase text-neutral-900 flex items-center gap-1.5">
+                      <span className="w-2.5 h-2.5 rounded-full bg-neutral-400 inline-block" />
+                      [ 未检测到遥测信号 // NO SIGNAL ]
+                    </span>
+                    <span className="px-2 py-0.5 border border-black bg-neutral-300 text-black font-bold text-[10px]">
+                      暂无心跳数据
+                    </span>
+                  </div>
+                  <p className="text-neutral-700 font-bold mt-1 text-[11px]">
+                    Redis 中尚未匹配到键 <code>vs:status:*:{node.node_id}</code> 的上报数据。
+                  </p>
+                  <p className="text-neutral-500 text-[10px] mt-0.5">
+                    此节点已在数据库建档,若已部署机器,请确认运行参数中的 <code>NODE_ID={node.node_id}</code> 拼写完全一致。
+                  </p>
+                </div>
+              </div>
+            </div>
+          )}
+
+          {/* 2. 节点档案基本信息 (Node Profile & Identity) */}
+          <div className="bg-neutral-50 border-2 border-black p-4 shadow-[3px_3px_0px_#000] space-y-3">
+            <div className="flex items-center justify-between border-b-2 border-black pb-2">
+              <span className="font-black text-black uppercase text-xs flex items-center gap-1.5">
+                <Server size={14} />
+                <span>[ 节点基础档案与网络属性 // NODE PROFILE ]</span>
+              </span>
+              <span
+                className={`px-2 py-0.5 border border-black text-[10px] font-black uppercase ${
+                  node.status === 1 ? 'bg-emerald-200 text-emerald-950' : 'bg-neutral-200 text-neutral-700'
+                }`}
+              >
+                {node.status === 1 ? '✓ 系统调度中 (启用)' : '⊘ 已暂停调度 (禁用)'}
+              </span>
+            </div>
+
+            <div className="grid grid-cols-2 md:grid-cols-4 gap-3 text-xs">
+              <div className="p-2.5 bg-white border border-black shadow-[1px_1px_0px_#000]">
+                <span className="text-[10px] text-neutral-500 font-bold uppercase block">节点唯一标识</span>
+                <span className="font-mono font-black text-black text-xs block mt-0.5">{node.node_id}</span>
+              </div>
+              <div className="p-2.5 bg-white border border-black shadow-[1px_1px_0px_#000]">
+                <span className="text-[10px] text-neutral-500 font-bold uppercase block">主机 IP 地址</span>
+                <span className="font-mono font-black text-black text-xs block mt-0.5">
+                  {node.ip_address || '未填写 (内网/动态)'}
+                </span>
+              </div>
+              <div className="p-2.5 bg-white border border-black shadow-[1px_1px_0px_#000]">
+                <span className="text-[10px] text-neutral-500 font-bold uppercase block">物理地区 / 机房</span>
+                <span className="font-bold text-black text-xs block mt-0.5 flex items-center gap-1">
+                  <Globe size={11} className="text-neutral-500" />
+                  <span>{node.region || '未指定'}</span>
+                </span>
+              </div>
+              <div className="p-2.5 bg-white border border-black shadow-[1px_1px_0px_#000]">
+                <span className="text-[10px] text-neutral-500 font-bold uppercase block">建档登记时间</span>
+                <span className="font-mono text-neutral-700 text-xs block mt-0.5">
+                  <LocalTime date={node.created_at} />
+                </span>
+              </div>
+            </div>
+
+            {node.notes && (
+              <div className="p-2.5 bg-white border border-black text-neutral-700 text-[11px] shadow-[1px_1px_0px_#000]">
+                <span className="font-bold text-black">备注说明: </span>
+                <span>{node.notes}</span>
+              </div>
+            )}
+          </div>
+
+          {/* 3. 角色上报通道与生命周期 (Reporting Roles & Channels) */}
+          <div className="bg-neutral-50 border-2 border-black p-4 shadow-[3px_3px_0px_#000] space-y-3">
+            <div className="flex items-center justify-between border-b-2 border-black pb-2">
+              <span className="font-black text-black uppercase text-xs flex items-center gap-1.5">
+                <Activity size={14} />
+                <span>[ 角色运行时上报通道 // ROLE CHANNELS ({localReports.length}) ]</span>
+              </span>
+              <span className="text-[10px] text-neutral-500">
+                同步时间: {lastRefreshedAt || '刚才'}
+              </span>
+            </div>
+
+            {localReports.length === 0 ? (
+              <div className="p-4 border border-dashed border-neutral-400 bg-white text-center text-neutral-500">
+                暂无任何角色通道上报数据。运行 <code>python main.py &lt;role&gt;</code> 启动后将自动注册通道。
+              </div>
+            ) : (
+              <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+                {localReports.map((report, idx) => (
+                  <div
+                    key={idx}
+                    className={`p-3 bg-white border-2 border-black shadow-[2px_2px_0px_#000] space-y-2 ${
+                      report.is_online ? 'border-l-4 border-l-emerald-500' : 'border-l-4 border-l-rose-500'
+                    }`}
+                  >
+                    <div className="flex items-center justify-between">
+                      <div className="flex items-center gap-2">
+                        <span className="px-2 py-0.5 bg-black text-white font-black text-xs uppercase">
+                          {report.role}
+                        </span>
+                        <span className="text-[11px] font-mono text-neutral-500">
+                          vs:status:{report.role}:{report.node_id}
+                        </span>
+                      </div>
+
+                      {report.is_online ? (
+                        <span className="px-2 py-0.5 border border-black bg-emerald-200 text-emerald-950 font-black text-[10px]">
+                          ● 在线 ({report.age_sec}s前)
+                        </span>
+                      ) : (
+                        <span className="px-2 py-0.5 border border-black bg-rose-200 text-rose-950 font-bold text-[10px]">
+                          ■ 离线 ({report.age_sec}s前)
+                        </span>
+                      )}
+                    </div>
+
+                    <div className="flex items-center justify-between text-[11px] pt-1 border-t border-neutral-200">
+                      <span className="text-neutral-500">上报时间: {report.collected_at}</span>
+                      <span className="font-bold text-black">
+                        承载 {report.groups?.length || 0} 个任务组
+                      </span>
+                    </div>
+                  </div>
+                ))}
+              </div>
+            )}
+          </div>
+
+          {/* 4. 承载的任务组与实时并发遥测 (Running Groups & Instance Telemetry) */}
+          <div className="bg-neutral-50 border-2 border-black p-4 shadow-[3px_3px_0px_#000] space-y-3">
+            <div className="flex items-center justify-between border-b-2 border-black pb-2">
+              <span className="font-black text-black uppercase text-xs flex items-center gap-1.5">
+                <Layers size={14} />
+                <span>[ 承载任务组与并发实例 // ACTIVE GROUPS ({allGroups.length}) ]</span>
+              </span>
+              <span className="text-[10px] text-neutral-500">
+                并发健康度: {healthyTasks}/{totalTasks} 正常
+              </span>
+            </div>
+
+            {allGroups.length === 0 ? (
+              <div className="p-4 border border-dashed border-neutral-400 bg-white text-center text-neutral-500">
+                当前节点未承载任何处于活跃状态的任务组。
+              </div>
+            ) : (
+              <div className="space-y-2">
+                {allGroups.map((group, idx) => (
+                  <div
+                    key={idx}
+                    className="p-3 bg-white border border-black shadow-[1px_1px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-2"
+                  >
+                    <div>
+                      <div className="flex items-center gap-2">
+                        <span className="px-1.5 py-0.2 bg-neutral-200 border border-black font-black text-[10px] uppercase">
+                          {group.role}
+                        </span>
+                        <span className="font-mono font-black text-black text-xs">{group.group_id}</span>
+                        <span className="text-[11px] text-neutral-600 font-bold">
+                          [{group.plugin_name || '通用插件'}]
+                        </span>
+                      </div>
+                      <div className="text-[10px] text-neutral-500 mt-1">
+                        状态包装器: <code>{group.wrapper_state || 'RUNNING'}</code>
+                        {group.updated_at && ` | 更新于: ${group.updated_at}`}
+                      </div>
+                    </div>
+
+                    <div className="flex items-center gap-3 shrink-0">
+                      <div className="text-right">
+                        <span className="text-[10px] text-neutral-500 uppercase block">并发实例</span>
+                        <span className="font-black text-xs text-black">
+                          {group.healthy_tasks || 0} / {group.total_tasks || 0}
+                        </span>
+                      </div>
+                      <span
+                        className={`px-2 py-0.5 border border-black text-[10px] font-bold ${
+                          group.enable ? 'bg-emerald-100 text-emerald-900' : 'bg-neutral-100 text-neutral-600'
+                        }`}
+                      >
+                        {group.enable ? '启用中' : '待机中'}
+                      </span>
+                    </div>
+                  </div>
+                ))}
+              </div>
+            )}
+          </div>
+
+          {/* 5. 节点已装载插件列表 (Installed Plugins) */}
+          <div className="bg-neutral-50 border-2 border-black p-4 shadow-[3px_3px_0px_#000] space-y-3">
+            <div className="flex items-center justify-between border-b-2 border-black pb-2">
+              <span className="font-black text-black uppercase text-xs flex items-center gap-1.5">
+                <Package size={14} />
+                <span>[ 节点已装载插件清单 // INSTALLED PLUGINS ({installedPlugins.length}) ]</span>
+              </span>
+              <span className="text-[10px] text-neutral-500">
+                由 coordinate 本地加载汇报
+              </span>
+            </div>
+
+            {installedPlugins.length === 0 ? (
+              <div className="p-4 border border-dashed border-neutral-400 bg-white text-center text-neutral-500">
+                暂未从心跳中读取到已安装插件列表。
+              </div>
+            ) : (
+              <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2">
+                {installedPlugins.map((plugin, idx) => (
+                  <div
+                    key={idx}
+                    className="p-2.5 bg-white border border-black shadow-[1px_1px_0px_#000] space-y-1"
+                  >
+                    <div className="flex items-center justify-between">
+                      <span className="font-mono font-black text-black text-xs">{plugin.name}</span>
+                      <span className="px-1.5 py-0.2 bg-amber-300 border border-black font-black text-[9px]">
+                        v{plugin.version || '1.0.0'}
+                      </span>
+                    </div>
+                    {plugin.description && (
+                      <p className="text-[10px] text-neutral-600 line-clamp-2">{plugin.description}</p>
+                    )}
+                    {plugin.author && (
+                      <span className="text-[9px] text-neutral-400 block font-mono">
+                        Author: {plugin.author}
+                      </span>
+                    )}
+                  </div>
+                ))}
+              </div>
+            )}
+          </div>
+
+          {/* 6. 遥测排查与原理说明 (Diagnostic Specs) */}
+          <div className="p-3 bg-neutral-100 border border-black text-[10px] text-neutral-600 space-y-1">
+            <div className="font-bold text-black flex items-center gap-1">
+              <Info size={12} />
+              <span>[ 遥测保活与在线离线判定规范 ]</span>
+            </div>
+            <p>
+              • <strong>在线判定规则</strong>: Worker 节点定期在 Redis 写入 <code>vs:status:&#123;role&#125;:&#123;node_id&#125;</code>,包含最新采集时间戳。如果最近一次上报时间在 60 秒以内,系统判定为 <strong>[ 在线 / ONLINE ]</strong>,否则自动判定为 <strong>[ 离线 / OFFLINE ]</strong>。
+            </p>
+            <p>
+              • <strong>离线排查建议</strong>: 检查目标服务器是否已运行 <code>python main.py &lt;role&gt;</code>,或检查服务器与 Redis 之间的网络联通性。
+            </p>
+          </div>
+        </div>
+
+        {/* Modal Footer */}
+        <div className="bg-neutral-200 border-t-2 border-black p-3 px-5 flex items-center justify-between">
+          <div className="text-[10px] text-neutral-500 font-bold">
+            遥测键: <code>vs:status:*:{node.node_id}</code> | 心跳间隔: 60s
+          </div>
+
+          <div className="flex items-center gap-2">
+            <button
+              type="button"
+              onClick={handleManualRefresh}
+              disabled={loading}
+              className="px-3 py-1.5 border-2 border-black bg-white hover:bg-neutral-100 font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5"
+            >
+              <RefreshCw size={12} className={loading ? 'animate-spin' : ''} />
+              <span>刷新遥测</span>
+            </button>
+
+            <button
+              type="button"
+              onClick={onClose}
+              className="px-4 py-1.5 border-2 border-black bg-amber-300 hover:bg-amber-400 font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition uppercase"
+            >
+              [ 关闭 ]
+            </button>
+          </div>
+        </div>
+      </div>
+    </div>
+  );
+}

+ 408 - 103
src/components/admin/node-configurations/ProviderModal.tsx

@@ -4,8 +4,10 @@
 
 import React, { useState, useEffect } from 'react';
 import { toast } from 'react-hot-toast';
-import { ProviderItem, ProviderCreatePayload, ProviderUpdatePayload } from '@/types';
+import { Package, CheckCircle2, ChevronDown, Sparkles, RefreshCw } from 'lucide-react';
+import { ProviderItem, ProviderCreatePayload, ProviderUpdatePayload, PluginItem } from '@/types';
 import { providerService } from '@/lib/services/providerService';
+import { pluginService } from '@/lib/services/pluginService';
 
 interface ProviderModalProps {
   isOpen: boolean;
@@ -25,13 +27,29 @@ export default function ProviderModal({
   const [name, setName] = useState('');
   const [enabled, setEnabled] = useState(true);
 
-  // Plugin config
+  // Cloud Plugins Hub state
+  const [availablePlugins, setAvailablePlugins] = useState<PluginItem[]>([]);
+  const [selectedPluginId, setSelectedPluginId] = useState<string>('');
+  const [loadingPlugins, setLoadingPlugins] = useState(false);
+
+  // Plugin config (自动生成,只读)
   const [libPath, setLibPath] = useState('plugins');
   const [pluginName, setPluginName] = useState('');
   const [pluginBin, setPluginBin] = useState('');
-  const [pluginProto, setPluginProto] = useState('IVSPlg');
+  const [pluginClass, setPluginClass] = useState('');
+  const [pluginProto, setPluginProto] = useState('IPlugin');
+
+  // Supported roles state & Role templates
+  const [supportedRoles, setSupportedRoles] = useState<{
+    booker: boolean;
+    sentinel: boolean;
+    standalone: boolean;
+  }>({
+    booker: true,
+    sentinel: true,
+    standalone: false,
+  });
 
-  // Role templates
   const [activeRoleTab, setActiveRoleTab] = useState<'booker' | 'sentinel' | 'standalone'>('booker');
   const [bookerJson, setBookerJson] = useState('{\n  "proxy_cd": 300,\n  "session_max_life": 1800,\n  "booker.account_cd": 10800,\n  "booker.target_instances": 1\n}');
   const [sentinelJson, setSentinelJson] = useState('{\n  "sentinel.signal_ttl": 30,\n  "sentinel.query_wait.mode": "Random"\n}');
@@ -39,6 +57,34 @@ export default function ProviderModal({
 
   const [saving, setSaving] = useState(false);
 
+  // 加载云端插件中枢插件列表
+  useEffect(() => {
+    if (!isOpen) return;
+
+    let isMounted = true;
+    const fetchPlugins = async () => {
+      setLoadingPlugins(true);
+      try {
+        const res = await pluginService.getList({ page: 1, page_size: 100 });
+        const list = res?.data?.list || (Array.isArray(res?.data) ? res.data : []);
+        if (isMounted) {
+          setAvailablePlugins(Array.isArray(list) ? list : []);
+        }
+      } catch (e) {
+        console.error('Failed to load plugins:', e);
+        if (isMounted) setAvailablePlugins([]);
+      } finally {
+        if (isMounted) setLoadingPlugins(false);
+      }
+    };
+
+    fetchPlugins();
+
+    return () => {
+      isMounted = false;
+    };
+  }, [isOpen]);
+
   useEffect(() => {
     if (provider) {
       setName(provider.name || '');
@@ -48,31 +94,119 @@ export default function ProviderModal({
         setLibPath(provider.plugin_config.lib_path || 'plugins');
         setPluginName(provider.plugin_config.plugin_name || '');
         setPluginBin(provider.plugin_config.plugin_bin || '');
-        setPluginProto(provider.plugin_config.plugin_proto || 'IVSPlg');
+        setPluginClass((provider.plugin_config as any).plugin_class || (provider.plugin_config as any).class_name || '');
+        setPluginProto(provider.plugin_config.plugin_proto || 'IPlugin');
       } else {
         setLibPath('plugins');
         setPluginName('');
         setPluginBin('');
-        setPluginProto('IVSPlg');
+        setPluginClass('');
+        setPluginProto('IPlugin');
       }
 
       const rt = provider.role_templates || {};
-      setBookerJson(rt.booker ? JSON.stringify(rt.booker, null, 2) : '{}');
-      setSentinelJson(rt.sentinel ? JSON.stringify(rt.sentinel, null, 2) : '{}');
-      setStandaloneJson(rt.standalone ? JSON.stringify(rt.standalone, null, 2) : '{}');
+      const hasBooker = 'booker' in rt;
+      const hasSentinel = 'sentinel' in rt;
+      const hasStandalone = 'standalone' in rt;
+      const anyConfigured = hasBooker || hasSentinel || hasStandalone;
+
+      setSupportedRoles({
+        booker: anyConfigured ? hasBooker : true,
+        sentinel: anyConfigured ? hasSentinel : true,
+        standalone: anyConfigured ? hasStandalone : false,
+      });
+
+      setBookerJson(rt.booker ? JSON.stringify(rt.booker, null, 2) : '{\n  "proxy_cd": 300,\n  "session_max_life": 1800,\n  "booker.account_cd": 10800,\n  "booker.target_instances": 1\n}');
+      setSentinelJson(rt.sentinel ? JSON.stringify(rt.sentinel, null, 2) : '{\n  "sentinel.signal_ttl": 30,\n  "sentinel.query_wait.mode": "Random"\n}');
+      setStandaloneJson(rt.standalone ? JSON.stringify(rt.standalone, null, 2) : '{\n  "login_interval": 1800,\n  "session_max_life": 3600\n}');
+
+      if (hasBooker) setActiveRoleTab('booker');
+      else if (hasSentinel) setActiveRoleTab('sentinel');
+      else if (hasStandalone) setActiveRoleTab('standalone');
+      else setActiveRoleTab('booker');
     } else {
       setName('');
       setEnabled(true);
+      setSelectedPluginId('');
       setLibPath('plugins');
       setPluginName('');
       setPluginBin('');
-      setPluginProto('IVSPlg');
+      setPluginClass('');
+      setPluginProto('IPlugin');
+      setSupportedRoles({
+        booker: true,
+        sentinel: true,
+        standalone: false,
+      });
+      setActiveRoleTab('booker');
       setBookerJson('{\n  "proxy_cd": 300,\n  "session_max_life": 1800,\n  "booker.account_cd": 10800,\n  "booker.target_instances": 1\n}');
       setSentinelJson('{\n  "sentinel.signal_ttl": 30,\n  "sentinel.query_wait.mode": "Random"\n}');
       setStandaloneJson('{\n  "login_interval": 1800,\n  "session_max_life": 3600\n}');
     }
   }, [provider, isOpen]);
 
+  const toggleRoleSupport = (role: 'booker' | 'sentinel' | 'standalone') => {
+    const nextVal = !supportedRoles[role];
+    if (!nextVal) {
+      const remainingCount = Object.entries(supportedRoles).filter(
+        ([k, v]) => (k === role ? false : v)
+      ).length;
+      if (remainingCount === 0) {
+        toast.error('服务商模板必须至少支持一个角色');
+        return;
+      }
+    }
+    setSupportedRoles((prev) => ({ ...prev, [role]: nextVal }));
+    if (nextVal) {
+      setActiveRoleTab(role);
+    }
+  };
+
+  // 当已有 plugin_name 时,自动匹配高亮对应的云端插件
+  useEffect(() => {
+    if (availablePlugins.length > 0 && pluginName) {
+      const matched = availablePlugins.find(
+        (p) => p.name.toLowerCase() === pluginName.toLowerCase()
+      );
+      if (matched) {
+        setSelectedPluginId(String(matched.id));
+        if (!pluginClass && matched.class_name) {
+          setPluginClass(matched.class_name);
+        }
+      }
+    }
+  }, [availablePlugins, pluginName, pluginClass]);
+
+  // 从云端插件中选择并自动生成填充插件参数 (读取注册时保存的类名、文件名、协议名)
+  const handleSelectPlugin = (pluginIdStr: string) => {
+    setSelectedPluginId(pluginIdStr);
+    if (!pluginIdStr) {
+      setLibPath('plugins');
+      setPluginName('');
+      setPluginBin('');
+      setPluginClass('');
+      setPluginProto('IPlugin');
+      return;
+    }
+
+    const chosen = availablePlugins.find((p) => String(p.id) === pluginIdStr);
+    if (chosen) {
+      setLibPath('plugins');
+      setPluginName(chosen.name);
+      setPluginBin(chosen.filename || `${chosen.name}.py`);
+      setPluginClass(chosen.class_name || '');
+      setPluginProto(chosen.protocol || 'IPlugin');
+
+      // 若服务商唯一标识 name 尚未填写,智能推荐填入插件简名或插件名
+      if (!name && !isEdit) {
+        const cleanName = chosen.name.replace(/_plugin$/i, '');
+        setName(cleanName || chosen.name);
+      }
+
+      toast.success(`已绑定 [${chosen.display_name || chosen.name}] (类: ${chosen.class_name || '内置'})`);
+    }
+  };
+
   if (!isOpen) return null;
 
   const handleSubmit = async (e: React.FormEvent) => {
@@ -83,6 +217,11 @@ export default function ProviderModal({
       return;
     }
 
+    if (!pluginName.trim()) {
+      toast.error('请先从云端插件中枢选择关联插件');
+      return;
+    }
+
     let parsedBooker = {};
     let parsedSentinel = {};
     let parsedStandalone = {};
@@ -108,18 +247,25 @@ export default function ProviderModal({
       return;
     }
 
-    const pluginConfig = {
+    const pluginConfig: Record<string, any> = {
       lib_path: libPath.trim(),
       plugin_name: pluginName.trim(),
       plugin_bin: pluginBin.trim(),
-      plugin_proto: pluginProto.trim(),
+      plugin_proto: pluginProto.trim() || 'IPlugin',
     };
+    if (pluginClass.trim()) {
+      pluginConfig.plugin_class = pluginClass.trim();
+    }
 
-    const roleTemplates = {
-      booker: parsedBooker,
-      sentinel: parsedSentinel,
-      standalone: parsedStandalone,
-    };
+    const roleTemplates: Record<string, any> = {};
+    if (supportedRoles.booker) roleTemplates.booker = parsedBooker;
+    if (supportedRoles.sentinel) roleTemplates.sentinel = parsedSentinel;
+    if (supportedRoles.standalone) roleTemplates.standalone = parsedStandalone;
+
+    if (Object.keys(roleTemplates).length === 0) {
+      toast.error('服务商模板必须至少开启一个支持的角色 (Booker / Sentinel / Standalone)');
+      return;
+    }
 
     setSaving(true);
     try {
@@ -221,132 +367,291 @@ export default function ProviderModal({
 
           {/* Plugin Config */}
           <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
-            <div className="flex items-center gap-2 border-b-2 border-black pb-1.5">
-              <span className="w-2 h-2 bg-black inline-block" />
-              <span className="font-black text-black uppercase">[ 02 // 默认插件参数 (PLUGIN CONFIG) ]</span>
+            <div className="flex items-center justify-between border-b-2 border-black pb-2">
+              <div className="flex items-center gap-2">
+                <span className="w-2 h-2 bg-amber-400 inline-block border border-black" />
+                <span className="font-black text-black uppercase">[ 02 // 默认插件参数 (PLUGIN CONFIG) ]</span>
+              </div>
+              <span className="text-[10px] text-neutral-500 font-mono">从云端插件中枢选择一键生成</span>
             </div>
 
-            <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+            {/* 云端插件中枢联动选择器 */}
+            <div className="bg-amber-50/80 border-2 border-dashed border-black/70 p-3 space-y-2">
+              <div className="flex items-center justify-between">
+                <label className="text-[11px] font-black text-black flex items-center gap-1.5 uppercase">
+                  <Sparkles className="w-3.5 h-3.5 text-amber-600" />
+                  从云端插件中枢选择插件 (SELECT CLOUD PLUGIN)
+                </label>
+                {loadingPlugins && (
+                  <span className="text-[10px] text-neutral-500 flex items-center gap-1 font-mono">
+                    <RefreshCw className="w-3 h-3 animate-spin" /> 加载中...
+                  </span>
+                )}
+              </div>
+
+              <div className="flex gap-2">
+                <div className="relative flex-1">
+                  <select
+                    value={selectedPluginId}
+                    onChange={(e) => handleSelectPlugin(e.target.value)}
+                    disabled={loadingPlugins}
+                    className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-mono font-bold text-black outline-none shadow-[2px_2px_0px_#000] appearance-none pr-8 cursor-pointer disabled:bg-neutral-200"
+                  >
+                    <option value="">-- 请选择云端插件以自动生成参数 --</option>
+                    {availablePlugins.map((p) => (
+                      <option key={p.id} value={String(p.id)}>
+                        {p.display_name ? `${p.display_name} (${p.name})` : p.name}
+                        {p.class_name ? ` [类: ${p.class_name}]` : ''}
+                        {p.filename ? ` [文件: ${p.filename}]` : ''}
+                        {p.protocol ? ` (${p.protocol})` : ''}
+                      </option>
+                    ))}
+                  </select>
+                  <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2.5 text-black">
+                    <ChevronDown className="w-4 h-4" />
+                  </div>
+                </div>
+
+                {selectedPluginId && (
+                  <button
+                    type="button"
+                    onClick={() => handleSelectPlugin(selectedPluginId)}
+                    title="重新应用选中的插件参数"
+                    className="px-3 py-1.5 bg-black text-amber-300 border-2 border-black text-xs font-bold uppercase shadow-[2px_2px_0px_#000] hover:bg-neutral-800 transition active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1 whitespace-nowrap"
+                  >
+                    <Sparkles className="w-3.5 h-3.5" />
+                    重新生成
+                  </button>
+                )}
+              </div>
+
+              {selectedPluginId ? (
+                <div className="text-[11px] text-neutral-700 bg-white border border-neutral-300 px-2.5 py-1.5 flex items-center justify-between shadow-sm">
+                  {(() => {
+                    const cur = availablePlugins.find((p) => String(p.id) === selectedPluginId);
+                    if (!cur) return null;
+                    return (
+                      <>
+                        <span className="font-mono truncate">
+                          已绑定: <strong className="text-black">{cur.display_name || cur.name}</strong>
+                          {cur.class_name && <span className="ml-1 text-amber-800 font-bold">⚡ 类: {cur.class_name}</span>}
+                          <span className="ml-1 text-neutral-600">📄 文件: {cur.filename || `${cur.name}.py`}</span>
+                          <span className="ml-1 text-neutral-600">🔌 协议: {cur.protocol || 'IPlugin'}</span>
+                        </span>
+                        <span className="text-[10px] text-emerald-700 font-black bg-emerald-100 px-1.5 py-0.5 border border-emerald-400 shrink-0 ml-2">
+                          ✓ 参数已自动生成
+                        </span>
+                      </>
+                    );
+                  })()}
+                </div>
+              ) : (
+                <div className="text-[10px] text-neutral-500 italic">
+                  💡 必须且仅允许从上方云端插件中枢选择插件,系统将自动读取类名、文件名与协议并绑定,不可手动篡改。
+                </div>
+              )}
+            </div>
+
+            {/* 生成的 5 项参数 (只读展示,系统由所选插件自动生成) */}
+            <div className="grid grid-cols-1 md:grid-cols-3 gap-3 pt-1">
               <div>
-                <label className="block text-[11px] font-bold text-black mb-1">动态库目录 (lib_path)</label>
+                <label className="block text-[11px] font-bold text-neutral-700 mb-1 flex items-center justify-between">
+                  <span>动态库目录 (lib_path)</span>
+                  <span className="text-[10px] text-neutral-500 font-mono">[ 只读 ]</span>
+                </label>
                 <input
                   type="text"
                   placeholder="plugins"
                   value={libPath}
-                  onChange={(e) => setLibPath(e.target.value)}
-                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000] placeholder:text-neutral-400"
+                  readOnly
+                  tabIndex={-1}
+                  className="w-full px-3 py-2 border-2 border-black/40 bg-neutral-200/70 text-xs font-mono font-bold text-neutral-800 outline-none cursor-not-allowed select-all shadow-inner"
                 />
               </div>
               <div>
-                <label className="block text-[11px] font-bold text-black mb-1">插件模块名 (plugin_name)</label>
+                <label className="block text-[11px] font-bold text-neutral-700 mb-1 flex items-center justify-between">
+                  <span>插件模块名 (plugin_name)</span>
+                  <span className="text-[10px] text-neutral-500 font-mono">[ 只读 ]</span>
+                </label>
                 <input
                   type="text"
-                  placeholder="vfs_plugin"
+                  placeholder="-- 待选择插件生成 --"
                   value={pluginName}
-                  onChange={(e) => setPluginName(e.target.value)}
-                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000] placeholder:text-neutral-400"
+                  readOnly
+                  tabIndex={-1}
+                  className="w-full px-3 py-2 border-2 border-black/40 bg-neutral-200/70 text-xs font-mono font-bold text-neutral-800 outline-none cursor-not-allowed select-all shadow-inner"
                 />
               </div>
               <div>
-                <label className="block text-[11px] font-bold text-black mb-1">二进制脚本文件 (plugin_bin)</label>
+                <label className="block text-[11px] font-bold text-neutral-700 mb-1 flex items-center justify-between">
+                  <span>入口类名 (plugin_class)</span>
+                  <span className="text-[10px] text-neutral-500 font-mono">[ 只读 ]</span>
+                </label>
                 <input
                   type="text"
-                  placeholder="vfs_plugin.py"
-                  value={pluginBin}
-                  onChange={(e) => setPluginBin(e.target.value)}
-                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000] placeholder:text-neutral-400"
+                  placeholder="-- 待选择插件生成 --"
+                  value={pluginClass}
+                  readOnly
+                  tabIndex={-1}
+                  className="w-full px-3 py-2 border-2 border-black/40 bg-neutral-200/70 text-xs font-mono font-bold text-amber-900 outline-none cursor-not-allowed select-all shadow-inner"
                 />
               </div>
               <div>
-                <label className="block text-[11px] font-bold text-black mb-1">协议标识 (plugin_proto)</label>
+                <label className="block text-[11px] font-bold text-neutral-700 mb-1 flex items-center justify-between">
+                  <span>二进制脚本文件 (plugin_bin)</span>
+                  <span className="text-[10px] text-neutral-500 font-mono">[ 只读 ]</span>
+                </label>
                 <input
                   type="text"
-                  placeholder="IVSPlg"
-                  value={pluginProto}
-                  onChange={(e) => setPluginProto(e.target.value)}
-                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000] placeholder:text-neutral-400"
+                  placeholder="-- 待选择插件生成 --"
+                  value={pluginBin}
+                  readOnly
+                  tabIndex={-1}
+                  className="w-full px-3 py-2 border-2 border-black/40 bg-neutral-200/70 text-xs font-mono font-bold text-neutral-800 outline-none cursor-not-allowed select-all shadow-inner"
+                />
+              </div>
+              <div className="md:col-span-2">
+                <label className="block text-[11px] font-bold text-neutral-700 mb-1 flex items-center justify-between">
+                  <span>协议标识 (plugin_proto)</span>
+                  <span className="text-[10px] text-amber-700 font-mono font-bold">[ 统一 IPlugin ]</span>
+                </label>
+                <input
+                  type="text"
+                  placeholder="IPlugin"
+                  value={pluginProto || 'IPlugin'}
+                  readOnly
+                  tabIndex={-1}
+                  className="w-full px-3 py-2 border-2 border-black/40 bg-neutral-200/70 text-xs font-mono font-black text-neutral-800 outline-none cursor-not-allowed select-all shadow-inner"
                 />
               </div>
             </div>
           </div>
 
-          {/* Role Templates Tabs */}
+          {/* Role Templates & Capabilities */}
           <div className="border-2 border-black bg-neutral-100 p-4 shadow-[2px_2px_0px_#000] space-y-3">
             <div className="flex items-center justify-between border-b-2 border-black pb-1.5">
               <div className="flex items-center gap-2">
                 <span className="w-2 h-2 bg-black inline-block" />
-                <span className="font-black text-black uppercase">[ 03 // 角色配置模板平铺字典 (ROLE TEMPLATES) ]</span>
+                <span className="font-black text-black uppercase">[ 03 // 角色能力与配置模板 (SUPPORTED ROLES & TEMPLATES) ]</span>
+              </div>
+              <span className="text-[10px] text-neutral-500 font-mono">至少勾选一个支持的角色</span>
+            </div>
+
+            {/* Role Support Selector Cards */}
+            <div className="bg-white border-2 border-black p-2.5 shadow-[1px_1px_0px_#000] space-y-1.5">
+              <div className="flex items-center justify-between">
+                <span className="text-[11px] font-bold text-black uppercase">勾选该服务商支持的角色类型:</span>
+                <span className="text-[10px] text-neutral-500 font-mono">未勾选的角色将无法在对应任务中继承</span>
+              </div>
+              <div className="grid grid-cols-3 gap-2">
+                {[
+                  { key: 'booker' as const, label: 'BOOKER', desc: '占位调度角色' },
+                  { key: 'sentinel' as const, label: 'SENTINEL', desc: '扫位监控角色' },
+                  { key: 'standalone' as const, label: 'STANDALONE', desc: '独立单号任务' },
+                ].map((r) => {
+                  const active = supportedRoles[r.key];
+                  return (
+                    <button
+                      key={r.key}
+                      type="button"
+                      onClick={() => toggleRoleSupport(r.key)}
+                      className={`p-2 border-2 border-black text-left flex flex-col gap-0.5 transition ${
+                        active
+                          ? 'bg-amber-300 text-black shadow-[2px_2px_0px_#000]'
+                          : 'bg-neutral-100 text-neutral-500 border-neutral-300 hover:border-black'
+                      }`}
+                    >
+                      <div className="flex items-center justify-between">
+                        <span className="font-black text-xs">{r.label}</span>
+                        <span className={`text-[10px] font-bold px-1 border ${
+                          active ? 'bg-white border-black text-black' : 'border-transparent text-neutral-400'
+                        }`}>
+                          {active ? '✓ 支持' : '✕ 不支持'}
+                        </span>
+                      </div>
+                      <span className="text-[10px] opacity-80">{r.desc}</span>
+                    </button>
+                  );
+                })}
               </div>
-              <span className="text-[10px] text-neutral-500 font-mono">键支持点路径</span>
             </div>
 
             {/* Role Stepper / Tabs */}
             <div className="flex border-2 border-black bg-neutral-200 p-1 gap-1">
-              <button
-                type="button"
-                onClick={() => setActiveRoleTab('booker')}
-                className={`flex-1 py-1.5 text-xs font-mono uppercase transition border ${
-                  activeRoleTab === 'booker'
-                    ? 'bg-amber-300 text-black font-black border-black shadow-[1px_1px_0px_#000]'
-                    : 'bg-white text-neutral-700 font-bold border-transparent hover:bg-neutral-100'
-                }`}
-              >
-                [ BOOKER 模板 ]
-              </button>
-              <button
-                type="button"
-                onClick={() => setActiveRoleTab('sentinel')}
-                className={`flex-1 py-1.5 text-xs font-mono uppercase transition border ${
-                  activeRoleTab === 'sentinel'
-                    ? 'bg-amber-300 text-black font-black border-black shadow-[1px_1px_0px_#000]'
-                    : 'bg-white text-neutral-700 font-bold border-transparent hover:bg-neutral-100'
-                }`}
-              >
-                [ SENTINEL 模板 ]
-              </button>
-              <button
-                type="button"
-                onClick={() => setActiveRoleTab('standalone')}
-                className={`flex-1 py-1.5 text-xs font-mono uppercase transition border ${
-                  activeRoleTab === 'standalone'
-                    ? 'bg-amber-300 text-black font-black border-black shadow-[1px_1px_0px_#000]'
-                    : 'bg-white text-neutral-700 font-bold border-transparent hover:bg-neutral-100'
-                }`}
-              >
-                [ STANDALONE 模板 ]
-              </button>
+              {[
+                { key: 'booker' as const, label: 'BOOKER 模板' },
+                { key: 'sentinel' as const, label: 'SENTINEL 模板' },
+                { key: 'standalone' as const, label: 'STANDALONE 模板' },
+              ].map((t) => {
+                const isSelected = activeRoleTab === t.key;
+                const isSupported = supportedRoles[t.key];
+                return (
+                  <button
+                    key={t.key}
+                    type="button"
+                    onClick={() => setActiveRoleTab(t.key)}
+                    className={`flex-1 py-1.5 px-2 text-xs font-mono uppercase transition border flex items-center justify-center gap-1 ${
+                      isSelected
+                        ? 'bg-amber-300 text-black font-black border-black shadow-[1px_1px_0px_#000]'
+                        : 'bg-white text-neutral-700 font-bold border-transparent hover:bg-neutral-100'
+                    }`}
+                  >
+                    <span>{t.label}</span>
+                    <span className={`text-[10px] px-1 ${
+                      isSupported ? 'text-emerald-700 font-black' : 'text-neutral-400 font-normal line-through'
+                    }`}>
+                      {isSupported ? '✓' : '未启用'}
+                    </span>
+                  </button>
+                );
+              })}
             </div>
 
             {/* JSON Code Window */}
-            <div className="border-2 border-black shadow-[4px_4px_0px_#000]">
-              {activeRoleTab === 'booker' && (
-                <textarea
-                  rows={6}
-                  value={bookerJson}
-                  onChange={(e) => setBookerJson(e.target.value)}
-                  className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-amber-300 resize-y"
-                  placeholder="{}"
-                />
-              )}
-              {activeRoleTab === 'sentinel' && (
-                <textarea
-                  rows={6}
-                  value={sentinelJson}
-                  onChange={(e) => setSentinelJson(e.target.value)}
-                  className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-emerald-300 resize-y"
-                  placeholder="{}"
-                />
-              )}
-              {activeRoleTab === 'standalone' && (
-                <textarea
-                  rows={6}
-                  value={standaloneJson}
-                  onChange={(e) => setStandaloneJson(e.target.value)}
-                  className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-cyan-300 resize-y"
-                  placeholder="{}"
-                />
-              )}
-            </div>
+            {!supportedRoles[activeRoleTab] ? (
+              <div className="p-6 bg-neutral-100 border-2 border-black text-center space-y-2">
+                <div className="text-neutral-500 font-bold text-xs">
+                  当前服务商模板未开启对 <span className="text-black font-black uppercase">[{activeRoleTab}]</span> 角色的支持
+                </div>
+                <button
+                  type="button"
+                  onClick={() => toggleRoleSupport(activeRoleTab)}
+                  className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
+                >
+                  + 立即开启对 [{activeRoleTab.toUpperCase()}] 的支持并编辑模板
+                </button>
+              </div>
+            ) : (
+              <div className="border-2 border-black shadow-[4px_4px_0px_#000]">
+                {activeRoleTab === 'booker' && (
+                  <textarea
+                    rows={6}
+                    value={bookerJson}
+                    onChange={(e) => setBookerJson(e.target.value)}
+                    className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-amber-300 resize-y"
+                    placeholder="{}"
+                  />
+                )}
+                {activeRoleTab === 'sentinel' && (
+                  <textarea
+                    rows={6}
+                    value={sentinelJson}
+                    onChange={(e) => setSentinelJson(e.target.value)}
+                    className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-emerald-300 resize-y"
+                    placeholder="{}"
+                  />
+                )}
+                {activeRoleTab === 'standalone' && (
+                  <textarea
+                    rows={6}
+                    value={standaloneJson}
+                    onChange={(e) => setStandaloneJson(e.target.value)}
+                    className="w-full p-3 font-mono text-xs leading-relaxed outline-none bg-neutral-900 text-cyan-300 resize-y"
+                    placeholder="{}"
+                  />
+                )}
+              </div>
+            )}
           </div>
         </form>
 

+ 16 - 9
src/components/admin/node-configurations/ProviderTable.tsx

@@ -104,17 +104,24 @@ export default function ProviderTable({
                   <td className="p-3.5">
                     {roles.length > 0 ? (
                       <div className="flex flex-wrap gap-1">
-                        {roles.map((r) => (
-                          <span
-                            key={r}
-                            className="px-1.5 py-0.5 border border-black bg-white text-black font-bold uppercase text-[10px] shadow-[1px_1px_0px_#000]"
-                          >
-                            {r}
-                          </span>
-                        ))}
+                        {roles.map((r) => {
+                          let badgeStyle = 'bg-white text-black';
+                          if (r === 'booker') badgeStyle = 'bg-amber-300 text-black font-black';
+                          else if (r === 'sentinel') badgeStyle = 'bg-emerald-300 text-black font-black';
+                          else if (r === 'standalone') badgeStyle = 'bg-sky-200 text-sky-950 font-black';
+
+                          return (
+                            <span
+                              key={r}
+                              className={`px-1.5 py-0.5 border border-black uppercase text-[10px] shadow-[1px_1px_0px_#000] ${badgeStyle}`}
+                            >
+                              {r}
+                            </span>
+                          );
+                        })}
                       </div>
                     ) : (
-                      <span className="text-neutral-400 text-[11px]">未配置</span>
+                      <span className="text-rose-600 font-bold text-[11px]">[未开启任何角色]</span>
                     )}
                   </td>
 

+ 266 - 0
src/components/admin/node-configurations/RegisteredNodeSelect.tsx

@@ -0,0 +1,266 @@
+// src/components/admin/node-configurations/RegisteredNodeSelect.tsx
+'use client';
+
+import React, { useState, useEffect, useCallback } from 'react';
+import {
+  Server,
+  RefreshCw,
+  AlertTriangle,
+  CheckCircle2,
+  ChevronDown,
+  Radio,
+} from 'lucide-react';
+import { nodeConfigService } from '@/lib/services/nodeConfigService';
+import { ClusterNode, NodeRuntimeStatus } from '@/types';
+
+interface RegisteredNodeSelectProps {
+  value: string;
+  onChange: (value: string) => void;
+  label?: string;
+  badgeText?: string;
+  placeholder?: string;
+  helperText?: string;
+  required?: boolean;
+  disabled?: boolean;
+  runtimeNodes?: NodeRuntimeStatus[];
+}
+
+// 模块级缓存避免多个弹窗重复请求
+let cachedNodes: ClusterNode[] | null = null;
+let cachePromise: Promise<ClusterNode[]> | null = null;
+let cachedTelemetry: NodeRuntimeStatus[] | null = null;
+let telemetryPromise: Promise<NodeRuntimeStatus[]> | null = null;
+
+async function loadNodesCached(): Promise<ClusterNode[]> {
+  if (cachedNodes) return cachedNodes;
+  if (cachePromise) return cachePromise;
+
+  cachePromise = (async () => {
+    try {
+      const res = await nodeConfigService.listRegisteredNodes({ status: 1 });
+      const list = res?.data || [];
+      cachedNodes = Array.isArray(list) ? list : [];
+      return cachedNodes;
+    } catch (e) {
+      console.error('Failed to load registered cluster nodes:', e);
+      return [];
+    } finally {
+      cachePromise = null;
+    }
+  })();
+
+  return cachePromise;
+}
+
+async function loadTelemetryCached(): Promise<NodeRuntimeStatus[]> {
+  if (cachedTelemetry) return cachedTelemetry;
+  if (telemetryPromise) return telemetryPromise;
+
+  telemetryPromise = (async () => {
+    try {
+      const res = await nodeConfigService.getRuntimeStatus();
+      const list = res?.data?.nodes || [];
+      cachedTelemetry = Array.isArray(list) ? list : [];
+      return cachedTelemetry;
+    } catch {
+      return [];
+    } finally {
+      telemetryPromise = null;
+    }
+  })();
+
+  return telemetryPromise;
+}
+
+export function invalidateRegisteredNodesCache() {
+  cachedNodes = null;
+  cachedTelemetry = null;
+}
+
+export default function RegisteredNodeSelect({
+  value,
+  onChange,
+  label = '目标节点唯一标识 (NODE_ID)',
+  badgeText = '已注册节点',
+  placeholder = '-- 请选择已登记的集群节点 --',
+  helperText,
+  required = true,
+  disabled = false,
+  runtimeNodes: propRuntimeNodes,
+}: RegisteredNodeSelectProps) {
+  const [nodes, setNodes] = useState<ClusterNode[]>([]);
+  const [internalTelemetry, setInternalTelemetry] = useState<NodeRuntimeStatus[]>([]);
+  const [loading, setLoading] = useState(false);
+
+  const fetchNodesAndTelemetry = useCallback(async (force = false) => {
+    if (force) {
+      cachedNodes = null;
+      cachedTelemetry = null;
+    }
+    setLoading(true);
+    try {
+      const [list, telemetry] = await Promise.all([
+        loadNodesCached(),
+        propRuntimeNodes ? Promise.resolve(propRuntimeNodes) : loadTelemetryCached(),
+      ]);
+      setNodes(list);
+      setInternalTelemetry(telemetry);
+    } catch {
+      setNodes([]);
+      setInternalTelemetry([]);
+    } finally {
+      setLoading(false);
+    }
+  }, [propRuntimeNodes]);
+
+  useEffect(() => {
+    fetchNodesAndTelemetry();
+  }, [fetchNodesAndTelemetry]);
+
+  // 遥测生命体征计算
+  const activeTelemetry = propRuntimeNodes || internalTelemetry;
+  const getNodeVitality = (nodeId: string) => {
+    const reports = activeTelemetry.filter((r) => r.node_id === nodeId);
+    const hasReports = reports.length > 0;
+    const isOnline = reports.some((r) => r.is_online);
+    const minAgeSec = hasReports
+      ? Math.min(...reports.map((r) => r.age_sec ?? 999999))
+      : 999999;
+    return { hasReports, isOnline, minAgeSec };
+  };
+
+  const selectedNode = nodes.find((n) => n.node_id === value);
+  const isCustomUnregistered = Boolean(value && !selectedNode);
+
+  return (
+    <div className="space-y-1.5 font-mono">
+      {/* Label Bar */}
+      <div className="flex items-center justify-between">
+        <label className="text-xs font-black text-black uppercase flex items-center gap-1.5">
+          <Server size={13} className="text-black" />
+          <span>[ {label} ]</span>
+          {required && <span className="text-rose-600 font-bold">*</span>}
+        </label>
+
+        <div className="flex items-center gap-2">
+          {badgeText && (
+            <span className="text-[10px] font-bold px-1.5 py-0.5 bg-neutral-200 border border-black text-black">
+              {badgeText}
+            </span>
+          )}
+          <button
+            type="button"
+            onClick={() => fetchNodesAndTelemetry(true)}
+            disabled={loading || disabled}
+            title="刷新节点与遥测状态"
+            className="w-5 h-5 bg-white hover:bg-neutral-100 border border-black flex items-center justify-center text-black text-[10px] shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+          >
+            <RefreshCw size={10} className={loading ? 'animate-spin' : ''} />
+          </button>
+        </div>
+      </div>
+
+      {/* Select Dropdown */}
+      <div className="relative">
+        <select
+          value={value}
+          onChange={(e) => onChange(e.target.value)}
+          disabled={disabled || loading}
+          className={`w-full px-3 py-2 border-2 border-black bg-white text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000] cursor-pointer appearance-none ${
+            disabled ? 'opacity-60 cursor-not-allowed bg-neutral-100' : 'hover:border-black focus:bg-amber-50/50'
+          }`}
+        >
+          <option value="">{placeholder}</option>
+          {nodes.map((node) => {
+            const v = getNodeVitality(node.node_id);
+            const prefix = v.isOnline
+              ? `🟢 [在线 · ${v.minAgeSec}s前] `
+              : v.hasReports
+              ? `🔴 [离线超时] `
+              : `⚪ [未上报] `;
+
+            return (
+              <option key={node.node_id} value={node.node_id}>
+                {prefix}[{node.node_id}] {node.name}
+                {node.region ? ` · ${node.region}` : ''}
+                {node.ip_address ? ` (${node.ip_address})` : ''}
+              </option>
+            );
+          })}
+          {/* 若历史数据中有未注册的 node_id,追加展示该项避免丢值 */}
+          {isCustomUnregistered && (
+            <option value={value} disabled>
+              ⚠️ [未注册历史节点: {value}] (请重新选择已登记节点)
+            </option>
+          )}
+        </select>
+        <div className="absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-black">
+          <ChevronDown size={14} />
+        </div>
+      </div>
+
+      {/* Selected Node Card & Live Telemetry Pill */}
+      {selectedNode ? (
+        <div className="bg-amber-50 border border-black p-2.5 text-[11px] shadow-[1px_1px_0px_#000] space-y-1.5">
+          <div className="flex items-center justify-between">
+            <div className="flex items-center gap-1.5 font-bold text-black truncate">
+              <CheckCircle2 size={12} className="text-emerald-700 shrink-0" />
+              <span className="font-mono">
+                已选中节点: <strong>{selectedNode.name}</strong> ({selectedNode.node_id})
+              </span>
+            </div>
+            <span className="text-[10px] text-neutral-500 font-mono shrink-0 ml-2">
+              {selectedNode.region || '默认机房'} {selectedNode.ip_address ? `· ${selectedNode.ip_address}` : ''}
+            </span>
+          </div>
+
+          {/* Telemetry Status Diagnostic Badge */}
+          {(() => {
+            const v = getNodeVitality(selectedNode.node_id);
+            if (v.isOnline) {
+              return (
+                <div className="flex items-center gap-1.5 text-[10px] font-bold text-emerald-950 bg-emerald-100 border border-emerald-400 px-2 py-0.5">
+                  <span className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse shrink-0" />
+                  <span>
+                    遥测生命体征: <strong>实时在线</strong> (心跳 {v.minAgeSec}s前) · 节点就绪,可立即调度
+                  </span>
+                </div>
+              );
+            }
+            if (v.hasReports) {
+              return (
+                <div className="flex items-center gap-1.5 text-[10px] font-bold text-rose-950 bg-rose-100 border border-rose-400 px-2 py-0.5">
+                  <span className="w-2 h-2 rounded-full bg-rose-500 shrink-0" />
+                  <span>
+                    遥测状态警告: <strong>节点当前离线</strong> (&gt;60s未上报心跳) · 任务下发后需待 Worker 启动上线
+                  </span>
+                </div>
+              );
+            }
+            return (
+              <div className="flex items-center gap-1.5 text-[10px] text-neutral-700 bg-neutral-100 border border-neutral-300 px-2 py-0.5">
+                <span className="w-1.5 h-1.5 rounded-full bg-neutral-400 shrink-0" />
+                <span>
+                  遥测提示: 暂无心跳信号 · 请确保宿主机上已运行对应 NODE_ID 的工作节点进程
+                </span>
+              </div>
+            );
+          })()}
+        </div>
+      ) : isCustomUnregistered ? (
+        <div className="bg-rose-50 border border-rose-600 p-2 text-[11px] text-rose-800 flex items-center gap-1.5 shadow-[1px_1px_0px_#e11d48]">
+          <AlertTriangle size={13} className="shrink-0 text-rose-600" />
+          <span>
+            当前值 <code>{value}</code> 尚未在系统节点档案库中注册,请在上方重新选择已登记节点!
+          </span>
+        </div>
+      ) : nodes.length === 0 && !loading ? (
+        <div className="bg-neutral-100 border border-dashed border-neutral-400 p-2 text-[11px] text-neutral-600 flex items-center justify-between">
+          <span>暂无已启用的注册节点,请先在 <strong>[节点档案注册]</strong> Tab 登记新机器。</span>
+        </div>
+      ) : helperText ? (
+        <p className="text-[10px] text-neutral-500 font-mono">{helperText}</p>
+      ) : null}
+    </div>
+  );
+}

+ 378 - 0
src/components/admin/node-configurations/nodeConfigConstants.ts

@@ -0,0 +1,378 @@
+// src/components/admin/node-configurations/nodeConfigConstants.ts
+
+/**
+ * 常用使馆/登录中心网站列表
+ */
+export const COMMON_WEBSITES = [
+  { label: '🇫🇷 法国 (VFS Global)', value: 'https://visa.vfsglobal.com/chn/zh/fra' },
+  { label: '🇩🇪 德国 (VFS Global)', value: 'https://visa.vfsglobal.com/chn/zh/deu' },
+  { label: '🇮🇹 意大利 (VFS Global)', value: 'https://visa.vfsglobal.com/chn/zh/ita' },
+  { label: '🇬🇧 英国 (VFS Global)', value: 'https://visa.vfsglobal.com/chn/zh/gbr' },
+  { label: '🇳🇱 荷兰 (VFS Global)', value: 'https://visa.vfsglobal.com/chn/zh/nld' },
+  { label: '🇨🇭 瑞士 (TLScontact)', value: 'https://visas-ch.tlscontact.com' },
+  { label: '🇪🇸 西班牙 (BLS International)', value: 'https://china.blsspainvisa.com' },
+];
+
+/**
+ * 代理冷却时间 (proxy_cd / 秒) 预设
+ */
+export const PROXY_CD_PRESETS = [
+  { v: 0, label: '无冷却' },
+  { v: 60, label: '1 分钟' },
+  { v: 120, label: '2 分钟' },
+  { v: 180, label: '3 分钟' },
+  { v: 300, label: '5 分钟 (默认)' },
+  { v: 600, label: '10 分钟' },
+  { v: 900, label: '15 分钟' },
+  { v: 1800, label: '30 分钟' },
+];
+
+/**
+ * Session 最长存活时间 (session_max_life / 秒) 预设
+ */
+export const SESSION_MAX_LIFE_PRESETS = [
+  { v: 300, label: '5 分钟' },
+  { v: 600, label: '10 分钟' },
+  { v: 900, label: '15 分钟' },
+  { v: 1200, label: '20 分钟' },
+  { v: 1800, label: '30 分钟 (默认)' },
+  { v: 2700, label: '45 分钟' },
+  { v: 3600, label: '1 小时' },
+  { v: 7200, label: '2 小时' },
+];
+
+/**
+ * Booker 目标并发实例数预设
+ */
+export const BOOKER_TARGET_INSTANCES_PRESETS = [1, 2, 3, 5, 8, 10];
+
+/**
+ * Booker 账号冷却 (account_cd / 秒) 预设
+ */
+export const BOOKER_ACCOUNT_CD_PRESETS = [
+  { v: 0, label: '无冷却' },
+  { v: 60, label: '1 分钟' },
+  { v: 300, label: '5 分钟' },
+  { v: 600, label: '10 分钟' },
+  { v: 1800, label: '30 分钟' },
+  { v: 3600, label: '1 小时' },
+  { v: 10800, label: '3 小时 (默认)' },
+];
+
+/**
+ * Booker 下单冷却 (booking_cooldown / 秒) 预设
+ */
+export const BOOKER_COOLDOWN_PRESETS = [
+  { v: 10, label: '10 秒' },
+  { v: 30, label: '30 秒' },
+  { v: 60, label: '1 分钟' },
+  { v: 120, label: '2 分钟' },
+  { v: 300, label: '5 分钟 (默认)' },
+  { v: 600, label: '10 分钟' },
+  { v: 900, label: '15 分钟' },
+  { v: 1800, label: '30 分钟' },
+];
+
+/**
+ * Booker 单号最大占位次数预设
+ */
+export const BOOKER_MAX_BOOKINGS_PRESETS = [1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 30, 50];
+
+/**
+ * Sentinel 监控并发实例预设
+ */
+export const SENTINEL_TARGET_INSTANCES_PRESETS = [1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20];
+
+/**
+ * Sentinel 信号 TTL (signal_ttl / 秒) 预设
+ */
+export const SENTINEL_SIGNAL_TTL_PRESETS = [
+  { v: 10, label: '10 秒' },
+  { v: 20, label: '20 秒' },
+  { v: 30, label: '30 秒 (默认)' },
+  { v: 60, label: '1 分钟' },
+  { v: 120, label: '2 分钟' },
+  { v: 300, label: '5 分钟' },
+];
+
+/**
+ * Sentinel 固定等待 (fixed_wait / 秒) 预设
+ */
+export const FIXED_WAIT_PRESETS = [
+  { v: 2, label: '2 秒' },
+  { v: 3, label: '3 秒' },
+  { v: 5, label: '5 秒 (默认)' },
+  { v: 10, label: '10 秒' },
+  { v: 15, label: '15 秒' },
+  { v: 30, label: '30 秒' },
+];
+
+/**
+ * Sentinel 随机等待推荐区间组合
+ */
+export const RANDOM_WAIT_PRESET_PAIRS = [
+  { min: 3, max: 8, label: '3~8 秒 (高频抢位)' },
+  { min: 5, max: 15, label: '5~15 秒 (推荐标准)' },
+  { min: 10, max: 30, label: '10~30 秒 (稳健巡航)' },
+  { min: 15, max: 60, label: '15~60 秒 (防封宽松)' },
+];
+
+export const RANDOM_MIN_PRESETS = [1, 2, 3, 5, 8, 10, 15];
+export const RANDOM_MAX_PRESETS = [5, 8, 10, 15, 20, 30, 60];
+
+/**
+ * Standalone 登录重试间隔 (login_interval / 秒) 预设
+ */
+export const LOGIN_INTERVAL_PRESETS = [
+  { v: 60, label: '1 分钟' },
+  { v: 300, label: '5 分钟' },
+  { v: 600, label: '10 分钟' },
+  { v: 1800, label: '30 分钟 (默认)' },
+  { v: 3600, label: '1 小时' },
+];
+
+/**
+ * 活跃时间段预设
+ */
+export const ACTIVE_TIME_PRESETS = [
+  { start: '00:00', end: '23:59', label: '全天 24H (00:00-23:59)' },
+  { start: '08:00', end: '20:00', label: '白天工作时段 (08:00-20:00)' },
+  { start: '09:00', end: '18:00', label: '标准营业时段 (09:00-18:00)' },
+];
+
+/**
+ * 集群物理节点常用区域
+ */
+export const COMMON_NODE_REGIONS = [
+  { label: '中国香港 (cn-hongkong)', value: 'cn-hongkong' },
+  { label: '中国上海 (cn-shanghai)', value: 'cn-shanghai' },
+  { label: '中国北京 (cn-beijing)', value: 'cn-beijing' },
+  { label: '中国广州 (cn-guangzhou)', value: 'cn-guangzhou' },
+  { label: '新加坡 (ap-southeast-1)', value: 'ap-southeast-1' },
+  { label: '日本东京 (ap-northeast-1)', value: 'ap-northeast-1' },
+  { label: '德国法兰克福 (eu-central-1)', value: 'eu-central-1' },
+  { label: '法国巴黎 (eu-west-3)', value: 'eu-west-3' },
+  { label: '英国伦敦 (eu-west-2)', value: 'eu-west-2' },
+  { label: '美国西海岸 (us-west-1)', value: 'us-west-1' },
+];
+
+/**
+ * 本地代理池列表 (硬编码自 coordinate/config/proxies.yaml)
+ */
+export const LOCAL_PROXY_POOLS: { value: string; label: string }[] = [
+  { value: 'local_multi_pool', label: '🌐 全球混合池 (multi_pool)' },
+  // 亚洲
+  { value: 'local_ae', label: '🇦🇪 阿联酋 (AE)' },
+  { value: 'local_af', label: '🇦🇫 阿富汗 (AF)' },
+  { value: 'local_am', label: '🇦🇲 亚美尼亚 (AM)' },
+  { value: 'local_az', label: '🇦🇿 阿塞拜疆 (AZ)' },
+  { value: 'local_bd', label: '🇧🇩 孟加拉 (BD)' },
+  { value: 'local_bh', label: '🇧🇭 巴林 (BH)' },
+  { value: 'local_bn', label: '🇧🇳 文莱 (BN)' },
+  { value: 'local_bt', label: '🇧🇹 不丹 (BT)' },
+  { value: 'local_cn', label: '🇨🇳 中国 (CN)' },
+  { value: 'local_ge', label: '🇬🇪 格鲁吉亚 (GE)' },
+  { value: 'local_hk', label: '🇭🇰 香港 (HK)' },
+  { value: 'local_id', label: '🇮🇩 印尼 (ID)' },
+  { value: 'local_il', label: '🇮🇱 以色列 (IL)' },
+  { value: 'local_in', label: '🇮🇳 印度 (IN)' },
+  { value: 'local_iq', label: '🇮🇶 伊拉克 (IQ)' },
+  { value: 'local_ir', label: '🇮🇷 伊朗 (IR)' },
+  { value: 'local_jo', label: '🇯🇴 约旦 (JO)' },
+  { value: 'local_jp', label: '🇯🇵 日本 (JP)' },
+  { value: 'local_kh', label: '🇰🇭 柬埔寨 (KH)' },
+  { value: 'local_kr', label: '🇰🇷 韩国 (KR)' },
+  { value: 'local_kw', label: '🇰🇼 科威特 (KW)' },
+  { value: 'local_kz', label: '🇰🇿 哈萨克斯坦 (KZ)' },
+  { value: 'local_la', label: '🇱🇦 老挝 (LA)' },
+  { value: 'local_lb', label: '🇱🇧 黎巴嫩 (LB)' },
+  { value: 'local_lk', label: '🇱🇰 斯里兰卡 (LK)' },
+  { value: 'local_mm', label: '🇲🇲 缅甸 (MM)' },
+  { value: 'local_mn', label: '🇲🇳 蒙古 (MN)' },
+  { value: 'local_mo', label: '🇲🇴 澳门 (MO)' },
+  { value: 'local_mv', label: '🇲🇻 马尔代夫 (MV)' },
+  { value: 'local_my', label: '🇲🇾 马来西亚 (MY)' },
+  { value: 'local_np', label: '🇳🇵 尼泊尔 (NP)' },
+  { value: 'local_om', label: '🇴🇲 阿曼 (OM)' },
+  { value: 'local_ph', label: '🇵🇭 菲律宾 (PH)' },
+  { value: 'local_ps', label: '🇵🇸 巴勒斯坦 (PS)' },
+  { value: 'local_qa', label: '🇶🇦 卡塔尔 (QA)' },
+  { value: 'local_sa', label: '🇸🇦 沙特 (SA)' },
+  { value: 'local_sg', label: '🇸🇬 新加坡 (SG)' },
+  { value: 'local_sy', label: '🇸🇾 叙利亚 (SY)' },
+  { value: 'local_th', label: '🇹🇭 泰国 (TH)' },
+  { value: 'local_tj', label: '🇹🇯 塔吉克 (TJ)' },
+  { value: 'local_tl', label: '🇹🇱 东帝汶 (TL)' },
+  { value: 'local_tm', label: '🇹🇲 土库曼 (TM)' },
+  { value: 'local_tr', label: '🇹🇷 土耳其 (TR)' },
+  { value: 'local_tw', label: '🇹🇼 台湾 (TW)' },
+  { value: 'local_uz', label: '🇺🇿 乌兹别克 (UZ)' },
+  { value: 'local_vn', label: '🇻🇳 越南 (VN)' },
+  { value: 'local_ye', label: '🇾🇪 也门 (YE)' },
+  // 欧洲
+  { value: 'local_ad', label: '🇦🇩 安道尔 (AD)' },
+  { value: 'local_al', label: '🇦🇱 阿尔巴尼亚 (AL)' },
+  { value: 'local_at', label: '🇦🇹 奥地利 (AT)' },
+  { value: 'local_ax', label: '🇦🇽 奥兰群岛 (AX)' },
+  { value: 'local_ba', label: '🇧🇦 波黑 (BA)' },
+  { value: 'local_be', label: '🇧🇪 比利时 (BE)' },
+  { value: 'local_bg', label: '🇧🇬 保加利亚 (BG)' },
+  { value: 'local_by', label: '🇧🇾 白俄罗斯 (BY)' },
+  { value: 'local_ch', label: '🇨🇭 瑞士 (CH)' },
+  { value: 'local_cy', label: '🇨🇾 塞浦路斯 (CY)' },
+  { value: 'local_cz', label: '🇨🇿 捷克 (CZ)' },
+  { value: 'local_de', label: '🇩🇪 德国 (DE)' },
+  { value: 'local_dk', label: '🇩🇰 丹麦 (DK)' },
+  { value: 'local_ee', label: '🇪🇪 爱沙尼亚 (EE)' },
+  { value: 'local_es', label: '🇪🇸 西班牙 (ES)' },
+  { value: 'local_fi', label: '🇫🇮 芬兰 (FI)' },
+  { value: 'local_fo', label: '🇫🇴 法罗群岛 (FO)' },
+  { value: 'local_fr', label: '🇫🇷 法国 (FR)' },
+  { value: 'local_gb', label: '🇬🇧 英国 (GB)' },
+  { value: 'local_gg', label: '🇬🇬 根西 (GG)' },
+  { value: 'local_gi', label: '🇬🇮 直布罗陀 (GI)' },
+  { value: 'local_gl', label: '🇬🇱 格陵兰 (GL)' },
+  { value: 'local_gr', label: '🇬🇷 希腊 (GR)' },
+  { value: 'local_hr', label: '🇭🇷 克罗地亚 (HR)' },
+  { value: 'local_hu', label: '🇭🇺 匈牙利 (HU)' },
+  { value: 'local_ie', label: '🇮🇪 爱尔兰 (IE)' },
+  { value: 'local_im', label: '🇮🇲 马恩岛 (IM)' },
+  { value: 'local_is', label: '🇮🇸 冰岛 (IS)' },
+  { value: 'local_it', label: '🇮🇹 意大利 (IT)' },
+  { value: 'local_je', label: '🇯🇪 泽西 (JE)' },
+  { value: 'local_li', label: '🇱🇮 列支敦士登 (LI)' },
+  { value: 'local_lt', label: '🇱🇹 立陶宛 (LT)' },
+  { value: 'local_lu', label: '🇱🇺 卢森堡 (LU)' },
+  { value: 'local_lv', label: '🇱🇻 拉脱维亚 (LV)' },
+  { value: 'local_mc', label: '🇲🇨 摩纳哥 (MC)' },
+  { value: 'local_md', label: '🇲🇩 摩尔多瓦 (MD)' },
+  { value: 'local_me', label: '🇲🇪 黑山 (ME)' },
+  { value: 'local_mk', label: '🇲🇰 北马其顿 (MK)' },
+  { value: 'local_mt', label: '🇲🇹 马耳他 (MT)' },
+  { value: 'local_nl', label: '🇳🇱 荷兰 (NL)' },
+  { value: 'local_no', label: '🇳🇴 挪威 (NO)' },
+  { value: 'local_pl', label: '🇵🇱 波兰 (PL)' },
+  { value: 'local_pt', label: '🇵🇹 葡萄牙 (PT)' },
+  { value: 'local_ro', label: '🇷🇴 罗马尼亚 (RO)' },
+  { value: 'local_rs', label: '🇷🇸 塞尔维亚 (RS)' },
+  { value: 'local_ru', label: '🇷🇺 俄罗斯 (RU)' },
+  { value: 'local_se', label: '🇸🇪 瑞典 (SE)' },
+  { value: 'local_si', label: '🇸🇮 斯洛文尼亚 (SI)' },
+  { value: 'local_sk', label: '🇸🇰 斯洛伐克 (SK)' },
+  { value: 'local_sm', label: '🇸🇲 圣马力诺 (SM)' },
+  { value: 'local_ua', label: '🇺🇦 乌克兰 (UA)' },
+  { value: 'local_xk', label: '🇽🇰 科索沃 (XK)' },
+  // 非洲
+  { value: 'local_ag', label: '🇦🇬 安提瓜 (AG)' },
+  { value: 'local_ao', label: '🇦🇴 安哥拉 (AO)' },
+  { value: 'local_bf', label: '🇧🇫 布基纳法索 (BF)' },
+  { value: 'local_bi', label: '🇧🇮 布隆迪 (BI)' },
+  { value: 'local_bj', label: '🇧🇯 贝宁 (BJ)' },
+  { value: 'local_bw', label: '🇧🇼 博茨瓦纳 (BW)' },
+  { value: 'local_cd', label: '🇨🇩 刚果(金) (CD)' },
+  { value: 'local_cf', label: '🇨🇫 中非 (CF)' },
+  { value: 'local_cg', label: '🇨🇬 刚果(布) (CG)' },
+  { value: 'local_ci', label: '🇨🇮 科特迪瓦 (CI)' },
+  { value: 'local_cm', label: '🇨🇲 喀麦隆 (CM)' },
+  { value: 'local_cv', label: '🇨🇻 佛得角 (CV)' },
+  { value: 'local_dj', label: '🇩🇯 吉布提 (DJ)' },
+  { value: 'local_dz', label: '🇩🇿 阿尔及利亚 (DZ)' },
+  { value: 'local_eg', label: '🇪🇬 埃及 (EG)' },
+  { value: 'local_er', label: '🇪🇷 厄立特里亚 (ER)' },
+  { value: 'local_et', label: '🇪🇹 埃塞俄比亚 (ET)' },
+  { value: 'local_ga', label: '🇬🇦 加蓬 (GA)' },
+  { value: 'local_gh', label: '🇬🇭 加纳 (GH)' },
+  { value: 'local_gn', label: '🇬🇳 几内亚 (GN)' },
+  { value: 'local_gq', label: '🇬🇶 赤道几内亚 (GQ)' },
+  { value: 'local_gw', label: '🇬🇼 几内亚比绍 (GW)' },
+  { value: 'local_ke', label: '🇰🇪 肯尼亚 (KE)' },
+  { value: 'local_km', label: '🇰🇲 科摩罗 (KM)' },
+  { value: 'local_lr', label: '🇱🇷 利比里亚 (LR)' },
+  { value: 'local_ls', label: '🇱🇸 莱索托 (LS)' },
+  { value: 'local_ly', label: '🇱🇾 利比亚 (LY)' },
+  { value: 'local_ma', label: '🇲🇦 摩洛哥 (MA)' },
+  { value: 'local_mg', label: '🇲🇬 马达加斯加 (MG)' },
+  { value: 'local_ml', label: '🇲🇱 马里 (ML)' },
+  { value: 'local_mr', label: '🇲🇷 毛里塔尼亚 (MR)' },
+  { value: 'local_mu', label: '🇲🇺 毛里求斯 (MU)' },
+  { value: 'local_mw', label: '🇲🇼 马拉维 (MW)' },
+  { value: 'local_mz', label: '🇲🇿 莫桑比克 (MZ)' },
+  { value: 'local_na', label: '🇳🇦 纳米比亚 (NA)' },
+  { value: 'local_ne', label: '🇳🇪 尼日尔 (NE)' },
+  { value: 'local_ng', label: '🇳🇬 尼日利亚 (NG)' },
+  { value: 'local_rw', label: '🇷🇼 卢旺达 (RW)' },
+  { value: 'local_sd', label: '🇸🇩 苏丹 (SD)' },
+  { value: 'local_sl', label: '🇸🇱 塞拉利昂 (SL)' },
+  { value: 'local_sn', label: '🇸🇳 塞内加尔 (SN)' },
+  { value: 'local_so', label: '🇸🇴 索马里 (SO)' },
+  { value: 'local_ss', label: '🇸🇸 南苏丹 (SS)' },
+  { value: 'local_st', label: '🇸🇹 圣多美 (ST)' },
+  { value: 'local_sz', label: '🇸🇿 斯威士兰 (SZ)' },
+  { value: 'local_td', label: '🇹🇩 乍得 (TD)' },
+  { value: 'local_tg', label: '🇹🇬 多哥 (TG)' },
+  { value: 'local_tn', label: '🇹🇳 突尼斯 (TN)' },
+  { value: 'local_tz', label: '🇹🇿 坦桑尼亚 (TZ)' },
+  { value: 'local_ug', label: '🇺🇬 乌干达 (UG)' },
+  { value: 'local_za', label: '🇿🇦 南非 (ZA)' },
+  { value: 'local_zm', label: '🇿🇲 赞比亚 (ZM)' },
+  { value: 'local_zw', label: '🇿🇼 津巴布韦 (ZW)' },
+  // 北美 & 中美 & 加勒比
+  { value: 'local_as', label: '🇦🇸 美属萨摩亚 (AS)' },
+  { value: 'local_bb', label: '🇧🇧 巴巴多斯 (BB)' },
+  { value: 'local_bm', label: '🇧🇲 百慕大 (BM)' },
+  { value: 'local_bs', label: '🇧🇸 巴哈马 (BS)' },
+  { value: 'local_ca', label: '🇨🇦 加拿大 (CA)' },
+  { value: 'local_cr', label: '🇨🇷 哥斯达黎加 (CR)' },
+  { value: 'local_cu', label: '🇨🇺 古巴 (CU)' },
+  { value: 'local_cw', label: '🇨🇼 库拉索 (CW)' },
+  { value: 'local_do', label: '🇩🇴 多米尼加 (DO)' },
+  { value: 'local_gp', label: '🇬🇵 瓜德罗普 (GP)' },
+  { value: 'local_gt', label: '🇬🇹 危地马拉 (GT)' },
+  { value: 'local_gu', label: '🇬🇺 关岛 (GU)' },
+  { value: 'local_gy', label: '🇬🇾 圭亚那 (GY)' },
+  { value: 'local_hn', label: '🇭🇳 洪都拉斯 (HN)' },
+  { value: 'local_ht', label: '🇭🇹 海地 (HT)' },
+  { value: 'local_jm', label: '🇯🇲 牙买加 (JM)' },
+  { value: 'local_mh', label: '🇲🇭 马绍尔群岛 (MH)' },
+  { value: 'local_mp', label: '🇲🇵 北马里亚纳 (MP)' },
+  { value: 'local_mq', label: '🇲🇶 马提尼克 (MQ)' },
+  { value: 'local_mx', label: '🇲🇽 墨西哥 (MX)' },
+  { value: 'local_ni', label: '🇳🇮 尼加拉瓜 (NI)' },
+  { value: 'local_pa', label: '🇵🇦 巴拿马 (PA)' },
+  { value: 'local_pm', label: '🇵🇲 圣皮埃尔 (PM)' },
+  { value: 'local_pr', label: '🇵🇷 波多黎各 (PR)' },
+  { value: 'local_pw', label: '🇵🇼 帕劳 (PW)' },
+  { value: 'local_sx', label: '🇸🇽 圣马丁 (SX)' },
+  { value: 'local_sv', label: '🇸🇻 萨尔瓦多 (SV)' },
+  { value: 'local_tc', label: '🇹🇨 特克斯和凯科斯 (TC)' },
+  { value: 'local_tt', label: '🇹🇹 特立尼达 (TT)' },
+  { value: 'local_us', label: '🇺🇸 美国 (US)' },
+  // 南美
+  { value: 'local_ar', label: '🇦🇷 阿根廷 (AR)' },
+  { value: 'local_bo', label: '🇧🇴 玻利维亚 (BO)' },
+  { value: 'local_br', label: '🇧🇷 巴西 (BR)' },
+  { value: 'local_cl', label: '🇨🇱 智利 (CL)' },
+  { value: 'local_co', label: '🇨🇴 哥伦比亚 (CO)' },
+  { value: 'local_ec', label: '🇪🇨 厄瓜多尔 (EC)' },
+  { value: 'local_gf', label: '🇬🇫 法属圭亚那 (GF)' },
+  { value: 'local_pe', label: '🇵🇪 秘鲁 (PE)' },
+  { value: 'local_py', label: '🇵🇾 巴拉圭 (PY)' },
+  { value: 'local_sr', label: '🇸🇷 苏里南 (SR)' },
+  { value: 'local_uy', label: '🇺🇾 乌拉圭 (UY)' },
+  { value: 'local_ve', label: '🇻🇪 委内瑞拉 (VE)' },
+  // 大洋洲 & 太平洋
+  { value: 'local_au', label: '🇦🇺 澳大利亚 (AU)' },
+  { value: 'local_fj', label: '🇫🇯 斐济 (FJ)' },
+  { value: 'local_fm', label: '🇫🇲 密克罗尼西亚 (FM)' },
+  { value: 'local_nc', label: '🇳🇨 新喀里多尼亚 (NC)' },
+  { value: 'local_nf', label: '🇳🇫 诺福克岛 (NF)' },
+  { value: 'local_nz', label: '🇳🇿 新西兰 (NZ)' },
+  { value: 'local_pf', label: '🇵🇫 法属波利尼西亚 (PF)' },
+  { value: 'local_pg', label: '🇵🇬 巴布亚新几内亚 (PG)' },
+  { value: 'local_re', label: '🇷🇪 留尼汪 (RE)' },
+  { value: 'local_sb', label: '🇸🇧 所罗门群岛 (SB)' },
+  { value: 'local_tk', label: '🇹🇰 托克劳 (TK)' },
+  { value: 'local_vu', label: '🇻🇺 瓦努阿图 (VU)' },
+  { value: 'local_wf', label: '🇼🇫 瓦利斯和富图纳 (WF)' },
+  { value: 'local_yt', label: '🇾🇹 马约特 (YT)' },
+];

+ 104 - 0
src/components/admin/orders/OrderDetailDrawer.tsx

@@ -19,6 +19,8 @@ import {
   FileSpreadsheet,
   XCircle,
   Loader2,
+  Coins,
+  CheckCircle2,
 } from 'lucide-react';
 import LocalTime from '@/components/common/LocalTime';
 import { getPaymentProviderIcon } from '@/components/admin/payments/paymentIcons';
@@ -63,6 +65,7 @@ interface OrderDetailDrawerProps {
   onCancelOrder?: (orderId: string) => void;
   onAdjustPrice?: (order: any) => void;
   onCheckPayments?: (order: any) => void;
+  onMarkCompleted?: (orderId: string) => void;
 }
 
 export default function OrderDetailDrawer({
@@ -74,6 +77,7 @@ export default function OrderDetailDrawer({
   onCancelOrder,
   onAdjustPrice,
   onCheckPayments,
+  onMarkCompleted,
 }: OrderDetailDrawerProps) {
   const handleCancelClick = (orderId: string) => {
     if (onCancel) onCancel(orderId);
@@ -373,6 +377,106 @@ export default function OrderDetailDrawer({
             </div>
           </div>
 
+          {/* Section 1.5: 渠道归属与合伙分润结算 */}
+          <div className="bg-white border-2 border-black shadow-[3px_3px_0px_#000]">
+            <div className="bg-neutral-100 px-4 py-2 border-b-2 border-black flex items-center justify-between text-xs font-black uppercase text-black">
+              <div className="flex items-center gap-1.5">
+                <Coins size={14} />
+                <span>[ 02 // 渠道归属与财务分润结算 ]</span>
+              </div>
+              <div className="flex items-center gap-2">
+                {onEdit && (
+                  <button
+                    onClick={() => onEdit(order)}
+                    className="px-2 py-0.5 bg-amber-300 hover:bg-amber-400 border border-black text-[10px] font-bold shadow-[1px_1px_0px_#000] flex items-center gap-1 transition active:translate-x-0.5 active:translate-y-0.5"
+                    title="配置业务合作渠道、销售对接人及中介机构"
+                  >
+                    <Edit size={10} />
+                    <span>配置渠道/对接人</span>
+                  </button>
+                )}
+                <span className="text-[10px] font-mono px-1.5 py-0.5 bg-neutral-200 border border-black text-black">
+                  {order.settlement_status === 'settled' ? '已完成期末结清' : order.settlement_status === 'risk_period' ? 'T+7风险隔离中' : order.settlement_status === 'eligible' ? '待账期分润' : '履约未结算'}
+                </span>
+              </div>
+            </div>
+
+            <div className="p-4 space-y-3 text-xs">
+              <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+                <div className="border-b border-dashed border-neutral-300 pb-1.5">
+                  <span className="text-[10px] text-neutral-500 font-bold uppercase block">业务渠道类型</span>
+                  <div className="font-bold text-black flex items-center gap-1.5 mt-0.5">
+                    {order.channel_type === 'agency' ? (
+                      <span className="px-1.5 py-0.2 bg-purple-100 text-purple-900 border border-black font-bold text-[10px]">
+                        中介同行渠道单
+                      </span>
+                    ) : order.channel_type === 'website' ? (
+                      <span className="px-1.5 py-0.2 bg-neutral-100 text-neutral-800 border border-black font-bold text-[10px]">
+                        官网公海单 (双方平分)
+                      </span>
+                    ) : (
+                      <span className="px-1.5 py-0.2 bg-amber-100 text-amber-900 border border-black font-bold text-[10px]">
+                        社交自收直客单 (包干提成)
+                      </span>
+                    )}
+                  </div>
+                </div>
+
+                <div className="border-b border-dashed border-neutral-300 pb-1.5">
+                  <span className="text-[10px] text-neutral-500 font-bold uppercase block">40% 销售提成归属人</span>
+                  <span className="font-bold text-black font-mono">
+                    {order.handler_id || (order.channel_type === 'website' ? '无 (甲乙合伙平分)' : '未指派')}
+                  </span>
+                </div>
+
+                {order.channel_type === 'agency' && (
+                  <div className="border-b border-dashed border-neutral-300 pb-1.5">
+                    <span className="text-[10px] text-neutral-500 font-bold uppercase block">合作中介机构 ID</span>
+                    <span className="font-bold text-black font-mono">{order.agency_id || '-'}</span>
+                  </div>
+                )}
+
+                <div className="border-b border-dashed border-neutral-300 pb-1.5">
+                  <span className="text-[10px] text-neutral-500 font-bold uppercase block">20% 技术分成归属</span>
+                  <span className="font-bold text-neutral-600 text-[11px]">
+                    依据商品插件管理者自动结算
+                  </span>
+                </div>
+
+                <div className="border-b border-dashed border-neutral-300 pb-1.5">
+                  <span className="text-[10px] text-neutral-500 font-bold uppercase block">履约出签时间</span>
+                  <span className="font-bold text-black">
+                    {order.completed_at ? <LocalTime date={order.completed_at} /> : '尚未出签/未标记'}
+                  </span>
+                </div>
+
+                <div className="border-b border-dashed border-neutral-300 pb-1.5">
+                  <span className="text-[10px] text-neutral-500 font-bold uppercase block">风险期解除时间</span>
+                  <span className="font-bold text-black">
+                    {order.risk_cleared_at ? <LocalTime date={order.risk_cleared_at} /> : '-'}
+                  </span>
+                </div>
+              </div>
+
+              {/* 履约操作按键 */}
+              {onMarkCompleted && (order.settlement_status === 'unsettled' || !order.settlement_status) && (
+                <div className="pt-2 border-t border-neutral-200 flex items-center justify-between">
+                  <div className="text-[11px] text-neutral-500">
+                    出签后请及时标记完成,系统将自动进入 T+7 天公账定金风险期。
+                  </div>
+                  <button
+                    type="button"
+                    onClick={() => onMarkCompleted(order.id)}
+                    className="flex items-center gap-1.5 px-3 py-1.5 bg-emerald-300 hover:bg-emerald-400 text-black border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase"
+                  >
+                    <CheckCircle2 size={13} />
+                    <span>[ 标记履约出签完成 ]</span>
+                  </button>
+                </div>
+              )}
+            </div>
+          </div>
+
           {/* Section 2: Form & Application Parameters */}
           <div className="bg-white border-2 border-black shadow-[3px_3px_0px_#000]">
             <div className="bg-neutral-100 px-4 py-2 border-b-2 border-black flex items-center justify-between text-xs font-black uppercase text-black">

+ 263 - 56
src/components/admin/orders/OrderEditModal.tsx

@@ -1,56 +1,109 @@
 'use client';
 
 import { useState, useEffect } from 'react';
-import { X, Save, Loader2, AlertTriangle } from 'lucide-react';
+import { X, Save, Loader2, AlertTriangle, Users, Building2, Globe, Sliders } from 'lucide-react';
 import { toast } from 'react-hot-toast';
 import JsonEditor from '@/components/common/JsonEditor';
-import { OrderDetail } from '@/types';
+import AdminUserSelect from '@/components/common/AdminUserSelect';
+import { settlementService } from '@/lib/services';
+import { OrderDetail, VasAgency } from '@/types';
 
 interface OrderEditModalProps {
   isOpen: boolean;
   onClose: () => void;
-  order: OrderDetail | null;
+  order: (OrderDetail & { channel_type?: string; handler_id?: string; agency_id?: string }) | null;
   onSubmit: (orderId: string, data: any) => Promise<void>;
 }
 
 export default function OrderEditModal({ isOpen, onClose, order, onSubmit }: OrderEditModalProps) {
   const [loading, setLoading] = useState(false);
+  const [channelType, setChannelType] = useState<'direct' | 'agency' | 'website'>('direct');
+  const [handlerId, setHandlerId] = useState<string>('');
+  const [agencyId, setAgencyId] = useState<string>('');
+  const [agencies, setAgencies] = useState<VasAgency[]>([]);
+  const [loadingAgencies, setLoadingAgencies] = useState(false);
   const [userInputsJson, setUserInputsJson] = useState('');
+  const [activeTab, setActiveTab] = useState<'channel' | 'params'>('channel');
 
+  // 加载中介列表
+  useEffect(() => {
+    async function loadAgencies() {
+      setLoadingAgencies(true);
+      try {
+        const res = await settlementService.listAgencies({ active_only: true });
+        const list = res?.data?.items || res?.data || [];
+        setAgencies(Array.isArray(list) ? list : []);
+      } catch {
+        setAgencies([]);
+      } finally {
+        setLoadingAgencies(false);
+      }
+    }
+    if (isOpen) {
+      loadAgencies();
+    }
+  }, [isOpen]);
+
+  // 回填初始订单数据
   useEffect(() => {
     if (isOpen && order) {
+      const currentChannel = (order.channel_type as 'direct' | 'agency' | 'website') || 'direct';
+      setChannelType(currentChannel);
+      setHandlerId(order.handler_id || '');
+      setAgencyId(order.agency_id || '');
+
       const inputs = order.user_inputs || {};
       setUserInputsJson(JSON.stringify(inputs, null, 2));
+      setActiveTab('channel');
     }
   }, [isOpen, order]);
 
+  // 切换中介时自动联动默认对接人
+  const handleAgencyChange = (selectedId: string) => {
+    setAgencyId(selectedId);
+    if (selectedId) {
+      const match = agencies.find((a) => a.id === selectedId);
+      if (match && match.owner_id && !handlerId) {
+        setHandlerId(match.owner_id);
+      }
+    }
+  };
+
   const handleSubmit = async () => {
-    setLoading(true);
-    try {
-      let parsedInputs = {};
+    if (!order?.id) {
+      toast.error('未获取到有效的订单编号');
+      return;
+    }
+
+    if (channelType === 'agency' && !agencyId) {
+      toast.error('中介同行渠道单必须绑定合作中介机构');
+      return;
+    }
+
+    let parsedInputs = {};
+    if (userInputsJson.trim()) {
       try {
         parsedInputs = JSON.parse(userInputsJson);
       } catch (e) {
-        toast.error("JSON 格式语法错误,请检查");
-        setLoading(false);
+        toast.error('申报参数 JSON 语法错误,请检查格式');
         return;
       }
+    }
 
+    setLoading(true);
+    try {
       const updateData = {
+        channel_type: channelType,
+        agency_id: channelType === 'agency' ? agencyId.trim() || null : null,
+        handler_id: channelType === 'website' ? (handlerId.trim() || null) : (handlerId.trim() || null),
         user_inputs: parsedInputs,
       };
 
-      if (!order?.id) {
-        toast.error('未获取到有效的订单编号');
-        setLoading(false);
-        return;
-      }
-
       await onSubmit(order.id, updateData);
-      toast.success('订单参数更新成功');
+      toast.success('订单配置更新成功');
       onClose();
     } catch (error) {
-      // ignore
+      // 父级或全局拦截器已处理错误提示
     } finally {
       setLoading(false);
     }
@@ -61,60 +114,214 @@ export default function OrderEditModal({ isOpen, onClose, order, onSubmit }: Ord
   return (
     <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-grayscale p-4 font-mono">
       <div className="bg-neutral-50 border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-2xl overflow-hidden flex flex-col max-h-[90vh] animate-in zoom-in-95 duration-200">
-
+        
         {/* Header */}
-        <div className="px-5 py-3.5 border-b-2 border-black flex justify-between items-center bg-neutral-200 text-black select-none">
-          <div className="flex items-center gap-2 text-xs font-bold uppercase tracking-wider">
+        <div className="px-5 py-3 border-b-2 border-black flex justify-between items-center bg-neutral-200 text-black select-none">
+          <div className="flex items-center gap-2 text-xs font-black uppercase tracking-wider">
             <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
-            <span>[ EDIT ORDER PARAMS // #{order.id} ]</span>
+            <span>[ CONFIGURE ORDER // #{order.id} ]</span>
           </div>
-          <button onClick={onClose} className="w-6 h-6 bg-white hover:bg-amber-300 border border-black flex items-center justify-center font-bold text-xs transition">
+          <button
+            onClick={onClose}
+            className="w-6 h-6 bg-white hover:bg-amber-300 border border-black flex items-center justify-center font-bold text-xs transition"
+          >
             ✕
           </button>
         </div>
 
-        {/* Content */}
-        <div className="p-6 overflow-y-auto flex-1 space-y-4 bg-white">
-
-          <div className="bg-amber-50 border-2 border-black p-3 text-xs shadow-[2px_2px_0px_#000]">
-            <div className="font-bold flex items-center gap-1.5 text-black uppercase mb-1">
-              <AlertTriangle size={14} />
-              <span>[ 重要操作提示 ]</span>
-            </div>
-            <p className="text-neutral-700 font-sans">
-              修改申报参数后,若关联的自动化抢约任务处于重试或待命中,系统将自动使用新参数重新调度。
-            </p>
-          </div>
-
-          <div className="space-y-1">
-            <JsonEditor
-              label="申报参数 JSON (USER_INPUTS)"
-              value={userInputsJson}
-              onChange={setUserInputsJson}
-              height="h-64"
-              placeholder="{}"
-            />
-          </div>
-
-        </div>
-
-        {/* Footer */}
-        <div className="px-5 py-3 border-t-2 border-black bg-neutral-100 flex justify-end gap-3">
+        {/* Tab Switcher */}
+        <div className="flex border-b-2 border-black bg-neutral-100 text-xs font-bold">
           <button
-            onClick={onClose}
-            className="px-4 py-2 border-2 border-black bg-white hover:bg-neutral-200 text-black text-xs font-bold shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase"
+            type="button"
+            onClick={() => setActiveTab('channel')}
+            className={`flex-1 py-2.5 px-4 flex items-center justify-center gap-2 border-r-2 border-black transition ${
+              activeTab === 'channel' ? 'bg-white text-black border-b-2 border-b-white -mb-[2px] z-10' : 'bg-neutral-200 text-neutral-600 hover:bg-neutral-100'
+            }`}
           >
-            [ 取消 ]
+            <Sliders size={14} />
+            <span>渠道与销售提成人配置</span>
           </button>
           <button
-            onClick={handleSubmit}
-            disabled={loading}
-            className="px-6 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-black shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 uppercase disabled:opacity-50"
+            type="button"
+            onClick={() => setActiveTab('params')}
+            className={`flex-1 py-2.5 px-4 flex items-center justify-center gap-2 transition ${
+              activeTab === 'params' ? 'bg-white text-black border-b-2 border-b-white -mb-[2px] z-10' : 'bg-neutral-200 text-neutral-600 hover:bg-neutral-100'
+            }`}
           >
-            {loading && <Loader2 size={14} className="animate-spin" />}
-            <span>[ 确认修改生效 ]</span>
+            <AlertTriangle size={14} />
+            <span>申报参数 (USER_INPUTS)</span>
           </button>
         </div>
+
+        {/* Modal Body */}
+        <div className="p-6 overflow-y-auto flex-1 space-y-5 bg-white">
+          {activeTab === 'channel' ? (
+            <div className="space-y-5">
+              {/* 渠道类型选择 */}
+              <div>
+                <label className="text-xs font-black text-black uppercase block mb-2">
+                  [ 1. 选择业务合作渠道 (CHANNEL_TYPE) ] <span className="text-rose-600">*</span>
+                </label>
+                <div className="grid grid-cols-1 sm:grid-cols-3 gap-2.5">
+                  {/* Direct */}
+                  <div
+                    onClick={() => setChannelType('direct')}
+                    className={`p-3 border-2 cursor-pointer transition select-none ${
+                      channelType === 'direct'
+                        ? 'border-black bg-amber-100 shadow-[3px_3px_0px_#000]'
+                        : 'border-neutral-300 bg-neutral-50 hover:border-black'
+                    }`}
+                  >
+                    <div className="flex items-center gap-1.5 mb-1 font-black text-xs text-black uppercase">
+                      <Users size={15} />
+                      <span>社交自收直客</span>
+                    </div>
+                    <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
+                      团队自引流直客,独享<strong>40%销售提成</strong>。
+                    </p>
+                  </div>
+
+                  {/* Agency */}
+                  <div
+                    onClick={() => setChannelType('agency')}
+                    className={`p-3 border-2 cursor-pointer transition select-none ${
+                      channelType === 'agency'
+                        ? 'border-black bg-purple-100 shadow-[3px_3px_0px_#000]'
+                        : 'border-neutral-300 bg-neutral-50 hover:border-black'
+                    }`}
+                  >
+                    <div className="flex items-center gap-1.5 mb-1 font-black text-xs text-purple-950 uppercase">
+                      <Building2 size={15} />
+                      <span>中介同行渠道</span>
+                    </div>
+                    <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
+                      合作同行中介,受<strong>专属协议底价</strong>约束。
+                    </p>
+                  </div>
+
+                  {/* Website */}
+                  <div
+                    onClick={() => setChannelType('website')}
+                    className={`p-3 border-2 cursor-pointer transition select-none ${
+                      channelType === 'website'
+                        ? 'border-black bg-neutral-200 shadow-[3px_3px_0px_#000]'
+                        : 'border-neutral-300 bg-neutral-50 hover:border-black'
+                    }`}
+                  >
+                    <div className="flex items-center gap-1.5 mb-1 font-black text-xs text-black uppercase">
+                      <Globe size={15} />
+                      <span>官网公海单</span>
+                    </div>
+                    <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
+                      公海自然流量,40%提成由合伙双方(各20%)平分。
+                    </p>
+                  </div>
+                </div>
+              </div>
+
+              {/* Agency 绑定 */}
+              {channelType === 'agency' && (
+                <div className="p-3.5 bg-purple-50/60 border-2 border-purple-900 shadow-[3px_3px_0px_#581c87] space-y-2">
+                  <div className="flex items-center justify-between">
+                    <label className="text-xs font-black text-purple-950 uppercase block">
+                      [ 2. 绑定合作中介同行机构 (AGENCY_ID) ] <span className="text-rose-600">*</span>
+                    </label>
+                    <span className="text-[10px] text-purple-700 font-mono">
+                      {loadingAgencies ? '加载机构中...' : `共 ${agencies.length} 家中介`}
+                    </span>
+                  </div>
+
+                  <select
+                    value={agencyId}
+                    onChange={(e) => handleAgencyChange(e.target.value)}
+                    className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-mono font-bold focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000] text-black cursor-pointer"
+                  >
+                    <option value="">-- 请选择合作中介机构档案 --</option>
+                    {agencies.map((agency) => (
+                      <option key={agency.id} value={agency.id}>
+                        {agency.name} ({agency.code || agency.id}) - 底价 ¥{(agency.min_floor_price / 100).toFixed(2)} - 拓展人: {agency.owner_id || '无'}
+                      </option>
+                    ))}
+                  </select>
+                  <p className="text-[10px] text-purple-800 font-sans">
+                    💡 提示:中介渠道必须关联中介档案,该中介拓展人自动享有对应40%提成权益。
+                  </p>
+                </div>
+              )}
+
+              {/* 40% 提成人选择 (使用 AdminUserSelect) */}
+              <div className="border-t-2 border-dashed border-neutral-300 pt-4">
+                <AdminUserSelect
+                  value={handlerId}
+                  onChange={setHandlerId}
+                  label="40% 销售包干提成归属人 (HANDLER_ID)"
+                  badgeText="系统管理员账户"
+                  placeholder="选择系统管理员作为提成人"
+                  helperText={
+                    channelType === 'website'
+                      ? '官网公海单通常留空(由甲乙合伙人平分),如指定专人对接可在此选择管理员'
+                      : '该管理员账户将在财务周期结算中享受该笔订单的40%销售提成'
+                  }
+                />
+              </div>
+
+              {/* 补充说明: 技术分成 */}
+              <div className="p-3 bg-neutral-100 border-2 border-neutral-300 text-[11px] text-neutral-600 space-y-1">
+                <span className="font-bold text-neutral-800 block uppercase">
+                  ℹ️ 关于 20% 技术版权分成 (DEVELOPER_ID)
+                </span>
+                <p>
+                  全站订单已与商品处理插件解耦:技术分成无需在订单层面配置,财务引擎将在期末结算时,根据订单所购买商品所绑定的<strong>云端插件及其开发者管理者账户</strong>自动核算归属。
+                </p>
+              </div>
+            </div>
+          ) : (
+            <div className="space-y-4">
+              <div className="bg-amber-50 border-2 border-black p-3 text-xs shadow-[2px_2px_0px_#000]">
+                <div className="font-bold flex items-center gap-1.5 text-black uppercase mb-1">
+                  <AlertTriangle size={14} />
+                  <span>[ 重要操作提示 ]</span>
+                </div>
+                <p className="text-neutral-700 font-sans">
+                  修改申报参数后,若关联的自动化抢约任务处于重试或待命中,系统将自动使用新参数重新调度。
+                </p>
+              </div>
+
+              <div className="space-y-1">
+                <JsonEditor
+                  label="申报参数 JSON (USER_INPUTS)"
+                  value={userInputsJson}
+                  onChange={setUserInputsJson}
+                  height="h-64"
+                  placeholder="{}"
+                />
+              </div>
+            </div>
+          )}
+        </div>
+
+        {/* Footer */}
+        <div className="px-5 py-3 border-t-2 border-black bg-neutral-100 flex justify-between items-center">
+          <span className="text-[10px] text-neutral-500 font-mono">
+            {activeTab === 'channel' ? '渠道/对接人配置模式' : '底层申报入参编辑模式'}
+          </span>
+          <div className="flex items-center gap-3">
+            <button
+              onClick={onClose}
+              className="px-4 py-2 border-2 border-black bg-white hover:bg-neutral-200 text-black text-xs font-bold shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase"
+            >
+              [ 取消 ]
+            </button>
+            <button
+              onClick={handleSubmit}
+              disabled={loading}
+              className="px-6 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-black shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 uppercase disabled:opacity-50"
+            >
+              {loading && <Loader2 size={14} className="animate-spin" />}
+              <span>[ 保存配置并生效 ]</span>
+            </button>
+          </div>
+        </div>
       </div>
     </div>
   );

+ 46 - 2
src/components/admin/orders/OrderFilterBar.tsx

@@ -7,6 +7,10 @@ export type OrderStatusFilter = 'all' | 'pending' | 'paid' | 'cancelled' | 'fail
 interface OrderFilterBarProps {
   currentStatus: OrderStatusFilter;
   onStatusChange: (status: OrderStatusFilter) => void;
+  channelFilter?: string;
+  onChannelChange?: (channel: string) => void;
+  settlementFilter?: string;
+  onSettlementChange?: (settlement: string) => void;
   keyword: string;
   onKeywordChange: (kw: string) => void;
   onSearch: () => void;
@@ -20,6 +24,10 @@ interface OrderFilterBarProps {
 export default function OrderFilterBar({
   currentStatus,
   onStatusChange,
+  channelFilter = 'all',
+  onChannelChange,
+  settlementFilter = 'all',
+  onSettlementChange,
   keyword,
   onKeywordChange,
   onSearch,
@@ -88,12 +96,48 @@ export default function OrderFilterBar({
         </div>
       </div>
 
+      {/* 中排:渠道与结算状态多维筛选 */}
+      <div className="flex flex-wrap items-center gap-3 pt-2 border-t-2 border-dashed border-neutral-300">
+        {onChannelChange && (
+          <div className="flex items-center gap-1.5 text-xs font-bold">
+            <span className="text-neutral-500 uppercase tracking-tight">[ 渠道来源 ]:</span>
+            <select
+              value={channelFilter}
+              onChange={(e) => onChannelChange(e.target.value)}
+              className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black cursor-pointer"
+            >
+              <option value="all">全部渠道 (ALL)</option>
+              <option value="direct">社交自收直客 (40%对接人)</option>
+              <option value="agency">中介渠道单 (40%拓展人)</option>
+              <option value="website">官网公海单 (甲乙平分)</option>
+            </select>
+          </div>
+        )}
+
+        {onSettlementChange && (
+          <div className="flex items-center gap-1.5 text-xs font-bold">
+            <span className="text-neutral-500 uppercase tracking-tight">[ 结算状态 ]:</span>
+            <select
+              value={settlementFilter}
+              onChange={(e) => onSettlementChange(e.target.value)}
+              className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black cursor-pointer"
+            >
+              <option value="all">全部结算状态 (ALL)</option>
+              <option value="unsettled">未结算 (履约中)</option>
+              <option value="risk_period">T+7退款风险期</option>
+              <option value="eligible">可结算 (待期末分润)</option>
+              <option value="settled">已结算归档</option>
+            </select>
+          </div>
+        )}
+      </div>
+
       {/* 下排:搜索框与刷新 */}
-      <div className="flex flex-col sm:flex-row items-center gap-2.5 pt-2 border-t-2 border-dashed border-neutral-300">
+      <div className="flex flex-col sm:flex-row items-center gap-2.5 pt-2 border-t border-neutral-200">
         <div className="relative flex-1 w-full">
           <input
             type="text"
-            placeholder="搜索订单号 / 邮箱 / 姓名 / 商品名称 / 用户 ID..."
+            placeholder="搜索订单号 / 邮箱 / 姓名 / 渠道 / 对接人 / 商品名称..."
             value={keyword}
             onChange={(e) => onKeywordChange(e.target.value)}
             onKeyDown={handleKeyDown}

+ 113 - 14
src/components/admin/orders/OrderTable.tsx

@@ -28,6 +28,7 @@ interface OrderTableProps {
   onEdit: (order: OrderDetail) => void;
   onCheckPayments: (order: OrderDetail) => void;
   onAdjustPrice: (order: OrderDetail) => void;
+  onMarkCompleted?: (orderId: string) => void;
 }
 
 export default function OrderTable({
@@ -38,6 +39,7 @@ export default function OrderTable({
   onEdit,
   onCheckPayments,
   onAdjustPrice,
+  onMarkCompleted,
 }: OrderTableProps) {
   const [copiedId, setCopiedId] = useState<string | null>(null);
 
@@ -74,12 +76,17 @@ export default function OrderTable({
     switch (s) {
       case 'paid':
       case 'succeeded':
-      case 'completed':
         return (
           <span className="px-2 py-0.5 bg-amber-300 text-black border border-black font-mono font-black text-[10px] uppercase shadow-[1px_1px_0px_#000]">
             ★ 已支付 // PAID
           </span>
         );
+      case 'completed':
+        return (
+          <span className="px-2 py-0.5 bg-emerald-300 text-black border border-black font-mono font-black text-[10px] uppercase shadow-[1px_1px_0px_#000]">
+            ✔ 履约完成
+          </span>
+        );
       case 'pending':
         return (
           <span className="px-2 py-0.5 bg-neutral-100 text-black border border-black font-mono font-bold text-[10px] uppercase">
@@ -107,6 +114,76 @@ export default function OrderTable({
     }
   };
 
+  const getChannelBadge = (order: ExtendedOrderDetail) => {
+    const channel = order.channel_type || 'direct';
+    if (channel === 'agency') {
+      return (
+        <div className="flex flex-col">
+          <span className="px-1.5 py-0.5 bg-purple-100 text-purple-900 border border-black font-mono font-bold text-[9px] uppercase w-fit">
+            [ 中介渠道 ]
+          </span>
+          <span className="text-[10px] text-neutral-600 truncate max-w-[130px] font-mono mt-0.5">
+            拓展: {order.handler_id || '未绑定'}
+          </span>
+        </div>
+      );
+    }
+    if (channel === 'website') {
+      return (
+        <div className="flex flex-col">
+          <span className="px-1.5 py-0.5 bg-neutral-100 text-neutral-700 border border-black font-mono font-bold text-[9px] uppercase w-fit">
+            [ 官网公海 ]
+          </span>
+          <span className="text-[10px] text-neutral-500 font-mono mt-0.5">
+            双方平分
+          </span>
+        </div>
+      );
+    }
+    // 默认 direct
+    return (
+      <div className="flex flex-col">
+        <span className="px-1.5 py-0.5 bg-amber-100 text-amber-900 border border-black font-mono font-bold text-[9px] uppercase w-fit">
+          [ 社交直客 ]
+        </span>
+        <span className="text-[10px] text-neutral-600 truncate max-w-[130px] font-mono mt-0.5">
+          对接: {order.handler_id || '未指定'}
+        </span>
+      </div>
+    );
+  };
+
+  const getSettlementBadge = (status?: string) => {
+    const s = (status || 'unsettled').toLowerCase();
+    switch (s) {
+      case 'risk_period':
+        return (
+          <span className="px-1.5 py-0.5 bg-amber-200 text-black border border-black font-mono font-bold text-[9px] uppercase">
+            ⏳ T+7风险期
+          </span>
+        );
+      case 'eligible':
+        return (
+          <span className="px-1.5 py-0.5 bg-emerald-200 text-emerald-950 border border-black font-mono font-bold text-[9px] uppercase">
+            ⚡ 待分润
+          </span>
+        );
+      case 'settled':
+        return (
+          <span className="px-1.5 py-0.5 bg-black text-white border border-black font-mono font-bold text-[9px] uppercase">
+            ✓ 已结清
+          </span>
+        );
+      case 'unsettled':
+      default:
+        return (
+          <span className="px-1.5 py-0.5 bg-neutral-100 text-neutral-600 border border-black font-mono text-[9px] uppercase">
+            未结算
+          </span>
+        );
+    }
+  };
+
   const canCancel = (status: string) => {
     const s = (status || '').toLowerCase();
     return s !== 'cancelled' && s !== 'completed' && s !== 'failed';
@@ -149,6 +226,9 @@ export default function OrderTable({
               <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
                 [ 订单流水号 / 创建时间 ]
               </th>
+              <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                [ 渠道归属 / 对接人 ]
+              </th>
               <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
                 [ 申请商品 / 目的地 ]
               </th>
@@ -159,7 +239,7 @@ export default function OrderTable({
                 [ 结算应付 ]
               </th>
               <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
-                [ 工单状态 ]
+                [ 订单与结算状态 ]
               </th>
               <th className="px-4 py-3 text-right text-xs font-black text-black uppercase tracking-wider">
                 [ 调度操作 ]
@@ -169,6 +249,7 @@ export default function OrderTable({
           <tbody className="bg-white divide-y border-t-2 border-black">
             {orders.map((order) => {
               const isPending = (order.status || '').toLowerCase() === 'pending';
+              const canMarkDone = onMarkCompleted && (order.status === 'paid' || order.status === 'succeeded' || order.status === 'completed') && (order.settlement_status === 'unsettled' || !order.settlement_status);
 
               return (
                 <tr
@@ -200,13 +281,18 @@ export default function OrderTable({
                     </div>
                   </td>
 
-                  {/* Column 2: Product */}
+                  {/* Column 2: Channel & Handler */}
+                  <td className="px-4 py-3.5 whitespace-nowrap">
+                    {getChannelBadge(order)}
+                  </td>
+
+                  {/* Column 3: Product */}
                   <td className="px-4 py-3.5">
-                    <div className="max-w-[200px] min-w-0">
+                    <div className="max-w-[180px] min-w-0">
                       <span className="text-xs font-black text-black block truncate font-sans">
                         {order.product_name || order.product_title || '默认服务套餐'}
                       </span>
-                      <span className="text-[10px] text-neutral-500 block">
+                      <span className="text-[10px] text-neutral-500 block truncate">
                         {order.user_inputs && Object.keys(order.user_inputs).length > 0
                           ? `已登记 ${Object.keys(order.user_inputs).length} 项申报参数`
                           : '基础申请'}
@@ -214,31 +300,44 @@ export default function OrderTable({
                     </div>
                   </td>
 
-                  {/* Column 3: Customer */}
+                  {/* Column 4: Customer */}
                   <td className="px-4 py-3.5">
                     <div className="min-w-0 flex flex-col font-sans">
-                      <span className="text-xs font-bold text-black truncate max-w-[160px]">
+                      <span className="text-xs font-bold text-black truncate max-w-[140px]">
                         {order.user_name || order.applicant_name || '未填写姓名'}
                       </span>
-                      <span className="text-[10px] text-neutral-500 font-mono truncate max-w-[160px]">
+                      <span className="text-[10px] text-neutral-500 font-mono truncate max-w-[140px]">
                         {order.user_email || (order.user_id ? `ID: ${order.user_id.slice(0, 8)}...` : '-')}
                       </span>
                     </div>
                   </td>
 
-                  {/* Column 4: Price */}
+                  {/* Column 5: Price */}
                   <td className="px-4 py-3.5 whitespace-nowrap">
                     {renderPrice(order)}
                   </td>
 
-                  {/* Column 5: Status */}
+                  {/* Column 6: Status & Settlement */}
                   <td className="px-4 py-3.5 whitespace-nowrap">
-                    {getStatusBadge(order.status)}
+                    <div className="flex flex-col gap-1 items-start">
+                      {getStatusBadge(order.status)}
+                      {getSettlementBadge(order.settlement_status)}
+                    </div>
                   </td>
 
-                  {/* Column 6: Actions */}
+                  {/* Column 7: Actions */}
                   <td className="px-4 py-3.5 text-right whitespace-nowrap">
                     <div className="flex items-center justify-end gap-1.5" onClick={(e) => e.stopPropagation()}>
+                      {canMarkDone && (
+                        <button
+                          onClick={() => onMarkCompleted?.(order.id)}
+                          className="px-2 py-1 bg-emerald-200 hover:bg-emerald-300 text-emerald-950 border border-black text-[11px] font-black shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
+                          title="出签履约完成,开启T+7风险期"
+                        >
+                          履约
+                        </button>
+                      )}
+
                       <button
                         onClick={() => onCheckPayments(order)}
                         className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
@@ -260,9 +359,9 @@ export default function OrderTable({
                       <button
                         onClick={() => onEdit(order)}
                         className="px-2 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
-                        title="编辑表单参数"
+                        title="配置渠道来源、对接人及申报参数"
                       >
-                        编辑
+                        配置
                       </button>
 
                       <button

+ 7 - 0
src/components/admin/payments/ProviderModal.tsx

@@ -36,6 +36,13 @@ const PAYMENT_PRESETS = [
     currency: 'CNY',
     icon: DEFAULT_PAYMENT_ICONS.alipay,
   },
+  {
+    name: 'creem',
+    title: 'Creem (AI Agent Payment)',
+    channel: 'online_link',
+    currency: 'USD',
+    icon: DEFAULT_PAYMENT_ICONS.creem,
+  },
   {
     name: 'stripe',
     title: 'Stripe 国际信用卡',

+ 4 - 1
src/components/admin/payments/paymentIcons.ts

@@ -7,7 +7,8 @@ export const DEFAULT_PAYMENT_ICONS: Record<string, string> = {
   paypal: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='22' fill='%23003087'/%3E%3Cpath fill='%230079C1' d='M35 78l8-51h18c7.5 0 13 4 11.5 13-1.8 10.5-8.5 16-16.5 16h-5.5L47 78H35z'/%3E%3Cpath fill='%2300457C' d='M44 78l4-25h8c8 0 14.7-5.5 16.5-16 .3-1.8.3-3.4 0-4.8C71 31 69 30 65 30H43l-8 51h9v-3z' opacity='.2'/%3E%3Cpath fill='%23002C6C' d='M43 75l5.5-35h12c7.5 0 13 4 11.5 13-1.8 10.5-8.5 16-16.5 16h-5.5L47 87h-4l3.5-12h-3.5z'/%3E%3C/svg%3E",
   usdt_trc20: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='22' fill='%2326A17B'/%3E%3Cpath fill='%23ffffff' d='M55.5 48.2c-.4 0-2.8.2-5.5.2-2.4 0-4.7-.1-5.5-.2v-7.8h21.8V31H33.7v9.4h21.8v7.8c-10.7.5-18.7 2.3-18.7 4.6s8 4.1 18.7 4.6v17.4h9.1V57.4c10.6-.5 18.7-2.3 18.7-4.6-.1-2.3-8.1-4.1-18.8-4.6zm0 7.4v-.1c-.4 0-2.8.2-5.5.2-2.4 0-4.7-.1-5.5-.2v.1c-9.1-.4-15.6-1.8-15.6-3.4s6.5-3 15.6-3.4v6.8zm9.1-3.4c0 1.6-6.5 3-15.6 3.4v-6.8c9.1.4 15.6 1.8 15.6 3.4z'/%3E%3C/svg%3E",
   usdt: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='22' fill='%2326A17B'/%3E%3Cpath fill='%23ffffff' d='M55.5 48.2c-.4 0-2.8.2-5.5.2-2.4 0-4.7-.1-5.5-.2v-7.8h21.8V31H33.7v9.4h21.8v7.8c-10.7.5-18.7 2.3-18.7 4.6s8 4.1 18.7 4.6v17.4h9.1V57.4c10.6-.5 18.7-2.3 18.7-4.6-.1-2.3-8.1-4.1-18.8-4.6zm0 7.4v-.1c-.4 0-2.8.2-5.5.2-2.4 0-4.7-.1-5.5-.2v.1c-9.1-.4-15.6-1.8-15.6-3.4s6.5-3 15.6-3.4v6.8zm9.1-3.4c0 1.6-6.5 3-15.6 3.4v-6.8c9.1.4 15.6 1.8 15.6 3.4z'/%3E%3C/svg%3E",
-  bank_transfer: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='22' fill='%23334155'/%3E%3Cpath fill='%23ffffff' d='M50 20L20 35v5h60v-5L50 20zm-24 25h8v24h-8V45zm16 0h8v24h-8V45zm16 0h8v24h-8V45zm16 0h8v24h-8V45zM16 73v7h68v-7H16z'/%3E%3C/svg%3E"
+  bank_transfer: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='22' fill='%23334155'/%3E%3Cpath fill='%23ffffff' d='M50 20L20 35v5h60v-5L50 20zm-24 25h8v24h-8V45zm16 0h8v24h-8V45zm16 0h8v24h-8V45zm16 0h8v24h-8V45zM16 73v7h68v-7H16z'/%3E%3C/svg%3E",
+  creem: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='22' fill='%23FFBE98' stroke='%23000000' stroke-width='3'/%3E%3Cpath fill='%2318181b' d='M68 35c-4-5-10-8-18-8-14 0-25 11-25 25s11 25 25 25c8 0 14-3 18-8l-8-6c-2 3-6 5-10 5-9 0-16-7-16-16s7-16 16-16c4 0 8 2 10 5l8-6z'/%3E%3C/svg%3E"
 };
 
 /**
@@ -20,6 +21,7 @@ export function getPaymentProviderIcon(name?: string, icon?: string): string {
       const code = (name || '').toLowerCase();
       if (code.includes('wechat') || code.includes('wx')) return DEFAULT_PAYMENT_ICONS.wechat;
       if (code.includes('ali')) return DEFAULT_PAYMENT_ICONS.alipay;
+      if (code.includes('creem')) return DEFAULT_PAYMENT_ICONS.creem;
       if (code.includes('stripe')) return DEFAULT_PAYMENT_ICONS.stripe;
       if (code.includes('paypal')) return DEFAULT_PAYMENT_ICONS.paypal;
       if (code.includes('usdt') || code.includes('tether')) return DEFAULT_PAYMENT_ICONS.usdt;
@@ -31,6 +33,7 @@ export function getPaymentProviderIcon(name?: string, icon?: string): string {
   const code = (name || '').toLowerCase();
   if (code.includes('wechat') || code.includes('wx')) return DEFAULT_PAYMENT_ICONS.wechat;
   if (code.includes('ali')) return DEFAULT_PAYMENT_ICONS.alipay;
+  if (code.includes('creem')) return DEFAULT_PAYMENT_ICONS.creem;
   if (code.includes('stripe')) return DEFAULT_PAYMENT_ICONS.stripe;
   if (code.includes('paypal')) return DEFAULT_PAYMENT_ICONS.paypal;
   if (code.includes('usdt') || code.includes('tether')) return DEFAULT_PAYMENT_ICONS.usdt;

+ 49 - 2
src/components/admin/plugins/PluginDetailDrawer.tsx

@@ -18,6 +18,8 @@ import {
   Calendar,
   Layers,
   ArrowUpRight,
+  User,
+  Edit2,
 } from 'lucide-react';
 import { pluginService } from '@/lib/services/pluginService';
 import { toast } from 'react-hot-toast';
@@ -27,17 +29,21 @@ import { PluginDetail, PluginVersionItem } from '@/types';
 interface PluginDetailDrawerProps {
   isOpen: boolean;
   pluginId: number | null;
+  refreshKey?: number;
   onClose: () => void;
   onRefreshList: () => void;
   onOpenPublishVersion: (detail: PluginDetail) => void;
+  onOpenEdit?: (detail: PluginDetail) => void;
 }
 
 export default function PluginDetailDrawer({
   isOpen,
   pluginId,
+  refreshKey,
   onClose,
   onRefreshList,
   onOpenPublishVersion,
+  onOpenEdit,
 }: PluginDetailDrawerProps) {
   const [detail, setDetail] = useState<PluginDetail | null>(null);
   const [loading, setLoading] = useState(false);
@@ -68,7 +74,7 @@ export default function PluginDetailDrawer({
     } else {
       setDetail(null);
     }
-  }, [isOpen, pluginId, fetchDetail]);
+  }, [isOpen, pluginId, refreshKey, fetchDetail]);
 
   if (!isOpen) return null;
 
@@ -196,14 +202,55 @@ export default function PluginDetailDrawer({
                         {detail.latest_version ? `v${detail.latest_version}` : '未指定'}
                       </span>
                     </div>
+                    <div>
+                      <span className="text-[10px] text-neutral-500 font-bold uppercase block">入口类名 (Class):</span>
+                      <span className="font-mono font-bold text-amber-700">{detail.class_name || '-'}</span>
+                    </div>
+                    <div>
+                      <span className="text-[10px] text-neutral-500 font-bold uppercase block">脚本文件名 (Bin):</span>
+                      <span className="font-mono font-bold text-black">{detail.filename || `${detail.name}.py`}</span>
+                    </div>
+                    <div>
+                      <span className="text-[10px] text-neutral-500 font-bold uppercase block">协议标识 (Protocol):</span>
+                      <span className="font-mono font-black text-black">{detail.protocol || 'IPlugin'}</span>
+                    </div>
                     <div>
                       <span className="text-[10px] text-neutral-500 font-bold uppercase block">发布总版本数:</span>
                       <span className="font-mono font-bold text-black">{detail.versions?.length || 0} 个</span>
                     </div>
-                    <div>
+                    <div className="col-span-2">
                       <span className="text-[10px] text-neutral-500 font-bold uppercase block">最后更新:</span>
                       <span className="font-mono text-black">{detail.updated_at || '-'}</span>
                     </div>
+
+                    <div className="col-span-2 pt-2.5 border-t border-dashed border-neutral-300 flex items-center justify-between">
+                      <div>
+                        <span className="text-[10px] text-neutral-500 font-bold uppercase flex items-center gap-1">
+                          <User size={11} className="text-black" />
+                          <span>开发管理者 ID (享有 20% 技术分成):</span>
+                        </span>
+                        <div className="mt-0.5">
+                          {detail.developer_id ? (
+                            <span className="inline-flex items-center gap-1 px-2 py-0.5 bg-blue-50 border border-black text-black font-mono font-bold text-xs shadow-[1px_1px_0px_#000]">
+                              {detail.developer_id}
+                            </span>
+                          ) : (
+                            <span className="text-neutral-400 italic font-sans text-xs">未设置 (暂无独立技术分成)</span>
+                          )}
+                        </div>
+                      </div>
+                      {onOpenEdit && (
+                        <button
+                          type="button"
+                          onClick={() => onOpenEdit(detail)}
+                          className="px-2.5 py-1 bg-white hover:bg-amber-300 border border-black font-black uppercase text-[10px] shadow-[1px_1px_0px_#000] flex items-center gap-1 active:translate-x-0.5 active:translate-y-0.5 transition shrink-0"
+                          title="修改开发管理者配置"
+                        >
+                          <Edit2 size={10} />
+                          <span>[ 设置/修改开发者 ]</span>
+                        </button>
+                      )}
+                    </div>
                   </div>
                 </div>
 

+ 64 - 2
src/components/admin/plugins/PluginEditModal.tsx

@@ -2,9 +2,10 @@
 'use client';
 
 import { useState, useEffect } from 'react';
-import { X, Edit2, Loader2, AlertCircle, Check } from 'lucide-react';
+import { X, Edit2, Loader2, AlertCircle, Check, User } from 'lucide-react';
 import { pluginService } from '@/lib/services/pluginService';
 import { PluginItem } from '@/types';
+import AdminUserSelect from '@/components/common/AdminUserSelect';
 
 interface PluginEditModalProps {
   isOpen: boolean;
@@ -20,7 +21,11 @@ export default function PluginEditModal({
   onSuccess,
 }: PluginEditModalProps) {
   const [displayName, setDisplayName] = useState('');
+  const [filename, setFilename] = useState('');
+  const [className, setClassName] = useState('');
+  const [protocol, setProtocol] = useState('IPlugin');
   const [description, setDescription] = useState('');
+  const [developerId, setDeveloperId] = useState('');
   const [status, setStatus] = useState(1);
   const [loading, setLoading] = useState(false);
   const [errorMsg, setErrorMsg] = useState('');
@@ -28,7 +33,11 @@ export default function PluginEditModal({
   useEffect(() => {
     if (isOpen && plugin) {
       setDisplayName(plugin.display_name || '');
+      setFilename(plugin.filename || `${plugin.name}.py`);
+      setClassName(plugin.class_name || '');
+      setProtocol(plugin.protocol || 'IPlugin');
       setDescription(plugin.description || '');
+      setDeveloperId(plugin.developer_id || '');
       setStatus(plugin.status ?? 1);
       setErrorMsg('');
     }
@@ -44,7 +53,11 @@ export default function PluginEditModal({
     try {
       const res = await pluginService.update(plugin.id, {
         display_name: displayName.trim(),
+        filename: filename.trim(),
+        class_name: className.trim(),
+        protocol: protocol.trim() || 'IPlugin',
         description: description.trim(),
+        developer_id: developerId.trim() || '',
         status,
       });
 
@@ -112,12 +125,52 @@ export default function PluginEditModal({
             />
           </div>
 
+          {/* 类名、文件名、协议标识 */}
+          <div className="grid grid-cols-1 md:grid-cols-3 gap-2.5">
+            <div className="space-y-1">
+              <label className="font-bold uppercase text-black block text-[11px]">
+                入口类名 (Class)
+              </label>
+              <input
+                type="text"
+                value={className}
+                onChange={(e) => setClassName(e.target.value)}
+                placeholder="例如: VFSPlugin"
+                className="w-full px-2.5 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+              />
+            </div>
+            <div className="space-y-1">
+              <label className="font-bold uppercase text-black block text-[11px]">
+                脚本文件名 (File)
+              </label>
+              <input
+                type="text"
+                value={filename}
+                onChange={(e) => setFilename(e.target.value)}
+                placeholder="例如: vfs_plugin.py"
+                className="w-full px-2.5 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+              />
+            </div>
+            <div className="space-y-1">
+              <label className="font-bold uppercase text-black block text-[11px]">
+                协议标识 (Protocol)
+              </label>
+              <input
+                type="text"
+                value={protocol}
+                onChange={(e) => setProtocol(e.target.value)}
+                placeholder="IPlugin"
+                className="w-full px-2.5 py-1.5 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono font-black text-black outline-none shadow-[2px_2px_0px_#000]"
+              />
+            </div>
+          </div>
+
           <div className="space-y-1">
             <label className="font-bold uppercase text-black block">
               功能描述
             </label>
             <textarea
-              rows={3}
+              rows={2}
               value={description}
               onChange={(e) => setDescription(e.target.value)}
               placeholder="功能描述说明"
@@ -125,6 +178,15 @@ export default function PluginEditModal({
             />
           </div>
 
+          <AdminUserSelect
+            label="插件开发管理者 (技术分成归属)"
+            badgeText="享有 20% 技术分成"
+            value={developerId}
+            onChange={setDeveloperId}
+            placeholder="选择管理员账户或输入用户ID"
+            helperText="合作开发者均为系统管理员身份。关联此插件商品的订单履约后,财务分润结算将自动核算 20% 技术分成归属。"
+          />
+
           <div className="space-y-1">
             <label className="font-bold uppercase text-black block">
               启用状态

+ 107 - 4
src/components/admin/plugins/PluginPublishModal.tsx

@@ -11,9 +11,11 @@ import {
   AlertCircle,
   Loader2,
   Sparkles,
+  User,
 } from 'lucide-react';
 import { pluginService } from '@/lib/services/pluginService';
 import { PluginItem } from '@/types';
+import AdminUserSelect from '@/components/common/AdminUserSelect';
 
 interface PluginPublishModalProps {
   isOpen: boolean;
@@ -35,8 +37,12 @@ export default function PluginPublishModal({
   // 表单字段
   const [name, setName] = useState('');
   const [displayName, setDisplayName] = useState('');
+  const [filename, setFilename] = useState('');
+  const [className, setClassName] = useState('');
+  const [protocol, setProtocol] = useState('IPlugin');
   const [version, setVersion] = useState('');
   const [description, setDescription] = useState('');
+  const [developerId, setDeveloperId] = useState('');
   const [changelog, setChangelog] = useState('');
   const [setAsLatest, setSetAsLatest] = useState(true);
 
@@ -47,21 +53,36 @@ export default function PluginPublishModal({
 
   const isNewPlugin = !initialPlugin;
 
+  const deriveClassName = (str: string) => {
+    if (!str) return '';
+    const clean = str.replace(/[^a-zA-Z0-9_]/g, '');
+    const parts = clean.split('_').filter(Boolean);
+    return parts.map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join('');
+  };
+
   useEffect(() => {
     if (isOpen) {
       setErrorMsg('');
       if (initialPlugin) {
         setName(initialPlugin.name);
         setDisplayName(initialPlugin.display_name || '');
+        setFilename(initialPlugin.filename || `${initialPlugin.name}.py`);
+        setClassName(initialPlugin.class_name || deriveClassName(initialPlugin.name));
+        setProtocol(initialPlugin.protocol || 'IPlugin');
         setDescription(initialPlugin.description || '');
+        setDeveloperId(initialPlugin.developer_id || '');
         setVersion('');
         setChangelog('');
         setSetAsLatest(true);
       } else {
         setName('');
         setDisplayName('');
+        setFilename('');
+        setClassName('');
+        setProtocol('IPlugin');
         setVersion('1.0.0');
         setDescription('');
+        setDeveloperId('');
         setChangelog('首发版本上线');
         setSetAsLatest(true);
       }
@@ -74,6 +95,16 @@ export default function PluginPublishModal({
 
   if (!isOpen) return null;
 
+  const handleNameChange = (val: string) => {
+    setName(val);
+    if (!filename || filename === `${name}.py`) {
+      setFilename(val ? `${val}.py` : '');
+    }
+    if (!className || className === deriveClassName(name)) {
+      setClassName(deriveClassName(val));
+    }
+  };
+
   const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
     const file = e.target.files?.[0];
     if (file) {
@@ -82,6 +113,9 @@ export default function PluginPublishModal({
         return;
       }
       setSelectedFile(file);
+      if (!filename) {
+        setFilename(file.name);
+      }
       setErrorMsg('');
     }
   };
@@ -112,13 +146,21 @@ export default function PluginPublishModal({
     setLoading(true);
 
     try {
+      const finalFilename = filename.trim() || (selectedFile ? selectedFile.name : `${name.trim()}.py`);
+      const finalClassName = className.trim() || deriveClassName(name.trim());
+      const finalProtocol = protocol.trim() || 'IPlugin';
+
       if (sourceType === 'file' && selectedFile) {
         const formData = new FormData();
         formData.append('file', selectedFile);
         formData.append('name', name.trim());
         formData.append('version', version.trim());
+        formData.append('filename', finalFilename);
+        formData.append('class_name', finalClassName);
+        formData.append('protocol', finalProtocol);
         if (displayName.trim()) formData.append('display_name', displayName.trim());
         if (description.trim()) formData.append('description', description.trim());
+        if (developerId.trim()) formData.append('developer_id', developerId.trim());
         if (changelog.trim()) formData.append('changelog', changelog.trim());
         formData.append('set_as_latest', String(setAsLatest));
         await pluginService.publish(formData);
@@ -126,10 +168,14 @@ export default function PluginPublishModal({
         await pluginService.publish({
           name: name.trim(),
           version: version.trim(),
+          filename: finalFilename,
+          class_name: finalClassName,
+          protocol: finalProtocol,
           download_url: downloadUrl.trim(),
           sha256: sha256.trim() || undefined,
           display_name: displayName.trim() || undefined,
           description: description.trim() || undefined,
+          developer_id: developerId.trim() || undefined,
           changelog: changelog.trim() || undefined,
           set_as_latest: setAsLatest,
         });
@@ -188,11 +234,11 @@ export default function PluginPublishModal({
                   type="text"
                   disabled={!isNewPlugin}
                   value={name}
-                  onChange={(e) => setName(e.target.value)}
-                  placeholder="例如: fr_tls_contact_bot"
+                  onChange={(e) => handleNameChange(e.target.value)}
+                  placeholder="例如: vfs_plugin"
                   className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-mono text-black outline-none disabled:bg-neutral-200 shadow-[2px_2px_0px_#000]"
                 />
-                <p className="text-[10px] text-neutral-500">仅允许字母、数字和下划线</p>
+                <p className="text-[10px] text-neutral-500">用于模块寻址,仅限字母数字下划线</p>
               </div>
 
               <div className="space-y-1">
@@ -203,12 +249,60 @@ export default function PluginPublishModal({
                   type="text"
                   value={displayName}
                   onChange={(e) => setDisplayName(e.target.value)}
-                  placeholder="例如: 法国 TLS 自动化抢约插件"
+                  placeholder="例如: VFS 全球签证预约插件"
                   className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-sans text-black outline-none shadow-[2px_2px_0px_#000]"
                 />
               </div>
             </div>
 
+            {/* 新增: 入口类名、脚本文件名、协议名 */}
+            <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
+              <div className="space-y-1">
+                <label className="font-bold uppercase text-black block flex items-center justify-between">
+                  <span>入口类名 (Class Name)</span>
+                  <span className="text-[10px] text-neutral-500 font-mono">*</span>
+                </label>
+                <input
+                  type="text"
+                  value={className}
+                  onChange={(e) => setClassName(e.target.value)}
+                  placeholder="例如: VFSPlugin"
+                  className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-mono font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                />
+                <p className="text-[10px] text-neutral-500">Python 类入口名称</p>
+              </div>
+
+              <div className="space-y-1">
+                <label className="font-bold uppercase text-black block flex items-center justify-between">
+                  <span>脚本文件名 (Filename)</span>
+                  <span className="text-[10px] text-neutral-500 font-mono">*</span>
+                </label>
+                <input
+                  type="text"
+                  value={filename}
+                  onChange={(e) => setFilename(e.target.value)}
+                  placeholder="例如: vfs_plugin.py"
+                  className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-mono font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                />
+                <p className="text-[10px] text-neutral-500">执行二进制/脚本名</p>
+              </div>
+
+              <div className="space-y-1">
+                <label className="font-bold uppercase text-black block flex items-center justify-between">
+                  <span>插件协议 (Protocol)</span>
+                  <span className="text-[10px] text-amber-700 font-mono font-bold">[IPlugin]</span>
+                </label>
+                <input
+                  type="text"
+                  value={protocol}
+                  onChange={(e) => setProtocol(e.target.value)}
+                  placeholder="IPlugin"
+                  className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-mono font-black text-black outline-none shadow-[2px_2px_0px_#000]"
+                />
+                <p className="text-[10px] text-neutral-500">统一实现协议规范</p>
+              </div>
+            </div>
+
             <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
               <div className="space-y-1">
                 <label className="font-bold uppercase text-black block">
@@ -236,6 +330,15 @@ export default function PluginPublishModal({
                 />
               </div>
             </div>
+
+            <AdminUserSelect
+              label="插件开发管理者 (技术分成归属)"
+              badgeText="享有 20% 技术分成"
+              value={developerId}
+              onChange={setDeveloperId}
+              placeholder="选择管理员账户或输入用户ID"
+              helperText="合作开发者均为系统管理员身份。关联此插件的订单结算时,将自动核算该开发者享受 20% 技术版权分成。"
+            />
           </div>
 
           {/* 代码文件/URL 分发来源 */}

+ 40 - 1
src/components/admin/plugins/PluginTable.tsx

@@ -11,6 +11,7 @@ import {
   XCircle,
   Calendar,
   Layers,
+  User,
 } from 'lucide-react';
 import { PluginItem } from '@/types';
 
@@ -64,6 +65,7 @@ export default function PluginTable({
             <thead className="bg-neutral-100 text-xs font-black text-black uppercase">
               <tr>
                 <th className="px-4 py-3">[ 插件标识 / 展示名称 ]</th>
+                <th className="px-4 py-3">[ 开发管理者 (20%分成) ]</th>
                 <th className="px-4 py-3">[ 最新稳定版本 ]</th>
                 <th className="px-4 py-3">[ 运行状态 ]</th>
                 <th className="px-4 py-3">[ 更新发布时间 ]</th>
@@ -86,8 +88,21 @@ export default function PluginTable({
                             <span>{plugin.display_name || plugin.name}</span>
                           </div>
                           <div className="font-mono text-[10px] text-neutral-500 mt-0.5">{plugin.name}</div>
+                          <div className="font-mono text-[10px] text-neutral-600 mt-1 flex flex-wrap gap-1 items-center">
+                            <span className="bg-neutral-100 border border-neutral-300 px-1 py-0.5">
+                              📄 {plugin.filename || `${plugin.name}.py`}
+                            </span>
+                            {plugin.class_name && (
+                              <span className="bg-amber-100 text-black border border-black/30 px-1 py-0.5 font-bold">
+                                ⚡ {plugin.class_name}
+                              </span>
+                            )}
+                            <span className="bg-neutral-200 text-neutral-700 px-1 py-0.5">
+                              {plugin.protocol || 'IPlugin'}
+                            </span>
+                          </div>
                           {plugin.description && (
-                            <p className="text-[10px] text-neutral-500 truncate mt-0.5" title={plugin.description}>
+                            <p className="text-[10px] text-neutral-500 truncate mt-1" title={plugin.description}>
                               {plugin.description}
                             </p>
                           )}
@@ -95,6 +110,30 @@ export default function PluginTable({
                       </div>
                     </td>
 
+                    {/* Developer */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      {plugin.developer_id ? (
+                        <div className="flex items-center gap-1.5">
+                          <span className="inline-flex items-center gap-1 px-2 py-0.5 bg-blue-50 border border-black text-[11px] font-mono font-bold text-black shadow-[1px_1px_0px_#000]">
+                            <User size={11} className="text-black" />
+                            {plugin.developer_id}
+                          </span>
+                          <span className="text-[10px] bg-amber-200 text-black px-1 border border-black font-mono font-bold">
+                            20%
+                          </span>
+                        </div>
+                      ) : (
+                        <button
+                          type="button"
+                          onClick={() => onOpenEdit(plugin)}
+                          className="inline-flex items-center gap-1 text-[10px] text-neutral-500 hover:text-black border border-dashed border-neutral-400 px-1.5 py-0.5 hover:bg-amber-100 transition"
+                          title="点击设置插件开发者ID"
+                        >
+                          <Plus size={10} /> 未设置开发者
+                        </button>
+                      )}
+                    </td>
+
                     {/* Latest Version */}
                     <td className="px-4 py-3.5 whitespace-nowrap">
                       {plugin.latest_version ? (

+ 55 - 11
src/components/admin/products/ProductDetailDrawer.tsx

@@ -24,13 +24,16 @@ import {
   Layers,
   Sparkles,
   Loader2,
-  AlertCircle
+  AlertCircle,
+  BookOpen,
+  Trash2,
 } from 'lucide-react';
 import { toast } from 'react-hot-toast';
 import LocalTime from '@/components/common/LocalTime';
 import JsonEditor from '@/components/common/JsonEditor';
 import { Product, SchemaItem, ProductRouting } from '@/types';
 import { productService } from '@/lib/services';
+import ProductTutorialBanner from '@/components/common/ProductTutorialBanner';
 
 interface ProductDetailDrawerProps {
   isOpen: boolean;
@@ -43,6 +46,7 @@ interface ProductDetailDrawerProps {
   onManageRouting?: (product: Product) => void;
   onOpenSchemaManager?: () => void;
   onManageSchemas?: () => void;
+  onDelete?: (product: Product) => void;
 }
 
 export default function ProductDetailDrawer({
@@ -56,6 +60,7 @@ export default function ProductDetailDrawer({
   onManageRouting,
   onOpenSchemaManager,
   onManageSchemas,
+  onDelete,
 }: ProductDetailDrawerProps) {
   const handleRoutingClick = (p: Product) => {
     if (onManageRouting) onManageRouting(p);
@@ -369,6 +374,33 @@ export default function ProductDetailDrawer({
                     </div>
                   )}
                 </div>
+
+                {/* 04 教程与操作指引概览卡片 */}
+                <div className="bg-neutral-50 border-2 border-black p-4 shadow-[2px_2px_0px_#000] space-y-2">
+                  <div className="flex items-center justify-between border-b-2 border-black pb-2">
+                    <span className="text-xs font-black uppercase text-black flex items-center gap-1.5">
+                      <BookOpen size={14} />
+                      <span>[ 04 // 购买前教程与操作指引 ]</span>
+                    </span>
+                    <button
+                      onClick={() => onEdit(product)}
+                      className="text-[10px] font-bold text-black hover:underline uppercase"
+                    >
+                      [ 编辑教程 → ]
+                    </button>
+                  </div>
+
+                  {product.extra_fields?.tutorial?.enabled ? (
+                    <ProductTutorialBanner
+                      tutorial={product.extra_fields.tutorial}
+                      productTitle={product.title}
+                    />
+                  ) : (
+                    <div className="p-3 bg-white border border-dashed border-neutral-300 text-center text-neutral-500">
+                      未为此商品启用使用教程。如需指引用户注册账号或准备材料,可在编辑弹窗中开启。
+                    </div>
+                  )}
+                </div>
               </div>
             )}
 
@@ -473,16 +505,28 @@ export default function ProductDetailDrawer({
           </div>
 
           {/* Footer */}
-          <div className="px-5 py-3 border-t-2 border-black bg-neutral-200 flex items-center justify-between shrink-0">
-            <button
-              onClick={handleToggle}
-              disabled={toggling}
-              className={`px-3 py-1.5 border-2 border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 ${
-                isEnabled ? 'bg-neutral-100 hover:bg-neutral-300 text-black' : 'bg-amber-300 hover:bg-amber-400 text-black'
-              }`}
-            >
-              {toggling ? '...' : isEnabled ? '[ 下架商品 ]' : '[ 立即上架 ]'}
-            </button>
+          <div className="px-5 py-3 border-t-2 border-black bg-neutral-200 flex flex-wrap items-center justify-between gap-2 shrink-0">
+            <div className="flex items-center gap-2">
+              <button
+                onClick={handleToggle}
+                disabled={toggling}
+                className={`px-3 py-1.5 border-2 border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 ${
+                  isEnabled ? 'bg-neutral-100 hover:bg-neutral-300 text-black' : 'bg-amber-300 hover:bg-amber-400 text-black'
+                }`}
+              >
+                {toggling ? '...' : isEnabled ? '[ 下架商品 ]' : '[ 立即上架 ]'}
+              </button>
+
+              {onDelete && (
+                <button
+                  onClick={() => onDelete(product)}
+                  className="px-3 py-1.5 bg-rose-100 hover:bg-rose-200 text-rose-800 border-2 border-black text-xs font-bold uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1"
+                >
+                  <Trash2 size={13} />
+                  <span>[ 删除商品 ]</span>
+                </button>
+              )}
+            </div>
 
             <div className="flex items-center gap-2">
               <button

+ 21 - 3
src/components/admin/products/ProductList.tsx

@@ -11,7 +11,8 @@ import {
   MapPin,
   FileJson,
   Layers,
-  AlertCircle
+  AlertCircle,
+  Trash2,
 } from 'lucide-react';
 import { Product, SchemaItem } from '@/types';
 
@@ -23,6 +24,7 @@ interface ProductListProps {
   onEdit: (product: Product) => void;
   onManageRouting: (product: Product) => void;
   onToggleStatus: (product: Product) => Promise<void>;
+  onDelete?: (product: Product) => void;
 }
 
 export default function ProductList({
@@ -33,6 +35,7 @@ export default function ProductList({
   onEdit,
   onManageRouting,
   onToggleStatus,
+  onDelete,
 }: ProductListProps) {
   const [togglingId, setTogglingId] = useState<number | null>(null);
 
@@ -118,8 +121,13 @@ export default function ProductList({
                               {product.description}
                             </div>
                           )}
-                          <div className="text-[10px] text-neutral-400 font-mono mt-0.5">
-                            PROVIDER: <span className="font-bold text-black">{product.provider || 'TROOV'}</span>
+                          <div className="text-[10px] text-neutral-400 font-mono mt-0.5 flex items-center gap-1.5">
+                            <span>PROVIDER: <strong className="text-black">{product.provider || 'TROOV'}</strong></span>
+                            {product.extra_fields?.tutorial?.enabled && (
+                              <span className="px-1 py-0.2 bg-sky-200 border border-black text-[9px] font-black uppercase text-sky-950">
+                                📖 附带教程
+                              </span>
+                            )}
                           </div>
                         </div>
                       </div>
@@ -196,6 +204,16 @@ export default function ProductList({
                         >
                           编辑
                         </button>
+                        {onDelete && (
+                          <button
+                            onClick={() => onDelete(product)}
+                            className="px-2 py-1 bg-rose-100 hover:bg-rose-200 text-rose-800 border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase flex items-center gap-1"
+                            title="删除商品"
+                          >
+                            <Trash2 size={11} />
+                            <span>删除</span>
+                          </button>
+                        )}
                       </div>
                     </td>
                   </tr>

+ 844 - 17
src/components/admin/products/ProductModal.tsx

@@ -1,3 +1,4 @@
+// src/components/admin/products/ProductModal.tsx
 'use client';
 
 import { useState, useEffect, useMemo } from 'react';
@@ -15,11 +16,19 @@ import {
   Tag,
   Layers,
   ArrowRight,
-  Info
+  Info,
+  BookOpen,
+  ExternalLink,
+  Plus,
+  Trash2,
+  HelpCircle,
+  Compass,
 } from 'lucide-react';
-import { SchemaItem } from '@/types';
+import { SchemaItem, ProductTutorialConfig, TutorialStep, ProductCardConfig } from '@/types';
 import { toast } from 'react-hot-toast';
 import { productService } from '@/lib/services';
+import ProductTutorialBanner from '@/components/common/ProductTutorialBanner';
+import ServicePoster from '@/components/services/ServicePoster';
 
 interface ProductModalProps {
   isOpen: boolean;
@@ -54,6 +63,86 @@ const VISA_OPTIONS = [
   { label: '电子签证', value: 'e-Visa', desc: '在线电子直签' },
 ];
 
+const TUTORIAL_TEMPLATES = [
+  {
+    name: 'VFS 官方账号与邮箱激活模版 (复合型)',
+    config: {
+      enabled: true,
+      display_type: 'both' as const,
+      button_text: '📖 查看 VFS 账号准备教程',
+      link_url: 'https://welcome.vfsglobal.com/',
+      link_text: 'VFS 官网注册通道 ↗',
+      modal_title: 'VFS 官方预约账号注册与授权使用指南',
+      badge_text: '申请人必读',
+      summary: '本服务由自动化脚本登录 VFS 官方系统代刷名额,需要您自备一个已激活的有效官网账号。',
+      content: '【安全与风控注意事项】\n1. 账号密码由脚本单次会话加载,全程采用 AES-256 加密传输。\n2. 任务执行期间请勿在个人手机或浏览器中频繁登录该账号,以防触发 VFS 官方 IP 临时风控锁定。',
+      steps: [
+        {
+          step_no: 1,
+          title: '前往对应国家 VFS 官网注册账号',
+          desc: '进入对应使领馆官方 VFS 页面,点击 "Create an account",密码需包含大小写字母、数字及特殊符号。',
+        },
+        {
+          step_no: 2,
+          title: '查收激活邮件完成邮箱认证',
+          desc: '注册后必须在 24 小时内登录您填写的邮箱,点击激活邮件中的链接,并成功登录一次官网。',
+        },
+        {
+          step_no: 3,
+          title: '在下方表单中填入账号与密码',
+          desc: '请确保在申报表单中输入的账号与密码完全准确无误,以便脚本自动代填与抢位。',
+        },
+      ],
+    },
+  },
+  {
+    name: '美签 CGI / usvisascheduling 与 DS-160 指引',
+    config: {
+      enabled: true,
+      display_type: 'both' as const,
+      button_text: '📖 查看美签账号与 DS-160 填报指引',
+      link_url: 'https://www.usvisascheduling.com/',
+      link_text: '美签官方预约系统 ↗',
+      modal_title: '美签系统预约账号与 DS-160 编码填写指引',
+      badge_text: '美签必备',
+      summary: '请确保您的 DS-160 申请表已生成有效条形码(以 AA00 开头),且已在官方预约平台完成缴费绑定。',
+      content: '【填报要点】\n1. DS-160 编号必须与使领馆预约系统内绑定的完全一致,否则递签中心将无法核验入场。\n2. 若设置了安全问题,请在表单备注中提供,以确保跨设备登录时能够通过验证。',
+      steps: [
+        {
+          step_no: 1,
+          title: '完成并取得 DS-160 确认页编号',
+          desc: '登录 CEAC 网站完成填写,获得以 "AA" 开头的 10 位确认条形码编号。',
+        },
+        {
+          step_no: 2,
+          title: '确认预约系统账号已完成缴费',
+          desc: '登录 usvisascheduling / cgifederal 系统,确认预约申请已创建且签证费收据已激活。',
+        },
+        {
+          step_no: 3,
+          title: '提供登录凭据与安全问题',
+          desc: '在下方申报清单中如实填写登录账号、密码及设置的安全问题答案。',
+        },
+      ],
+    },
+  },
+  {
+    name: '纯外部知识库 / 飞书 / 语雀文档超链接模版',
+    config: {
+      enabled: true,
+      display_type: 'link' as const,
+      button_text: '🔗 查看官方图文使用指南',
+      link_url: 'https://www.yuque.com/',
+      link_text: '打开官方图文文档 ↗',
+      modal_title: '申请人使用与材料准备指引',
+      badge_text: '图文教程',
+      summary: '购买前请先阅读官方在线知识库文档,了解详细资料要求。',
+      content: '',
+      steps: [],
+    },
+  },
+];
+
 export default function ProductModal({
   isOpen,
   onClose,
@@ -80,6 +169,36 @@ export default function ProductModal({
     schema_id: 0,
   });
 
+  // 使用教程配置状态
+  const [tutorialConfig, setTutorialConfig] = useState<ProductTutorialConfig>({
+    enabled: false,
+    display_type: 'both',
+    button_text: '📖 查看账号准备与使用教程',
+    link_url: '',
+    link_text: '打开官方图文文档 ↗',
+    modal_title: '',
+    badge_text: '申请人必读指引',
+    summary: '',
+    content: '',
+    steps: [],
+  });
+
+  // 前台卡片包装与海报定制状态
+  const [cardConfig, setCardConfig] = useState<ProductCardConfig>({
+    banner_url: '',
+    poster_title: '',
+    poster_highlight: '',
+    poster_sub: '',
+    poster_tag: '',
+    poster_accent_color: '#2563eb',
+    official_tag: '官方直连',
+    status_tag: 'New',
+    pill_text: '',
+    sales_text: '',
+    buy_button_text: '立即购买',
+    sublink_text: '查阅服务细则 →',
+  });
+
   useEffect(() => {
     if (isOpen) {
       fetchSchemas();
@@ -112,6 +231,69 @@ export default function ProductModal({
           enabled: product.enabled !== undefined ? Number(product.enabled) : 1,
           schema_id: product.schema_id || 0,
         });
+
+        if (product.extra_fields?.tutorial) {
+          const t = product.extra_fields.tutorial;
+          setTutorialConfig({
+            enabled: Boolean(t.enabled),
+            display_type: t.display_type || 'both',
+            button_text: t.button_text || '📖 查看账号准备与使用教程',
+            link_url: t.link_url || '',
+            link_text: t.link_text || '打开官方图文文档 ↗',
+            modal_title: t.modal_title || '',
+            badge_text: t.badge_text || '申请人必读指引',
+            summary: t.summary || '',
+            content: t.content || '',
+            steps: Array.isArray(t.steps) ? t.steps : [],
+          });
+        } else {
+          setTutorialConfig({
+            enabled: false,
+            display_type: 'both',
+            button_text: '📖 查看账号准备与使用教程',
+            link_url: '',
+            link_text: '打开官方图文文档 ↗',
+            modal_title: '',
+            badge_text: '申请人必读指引',
+            summary: '',
+            content: '',
+            steps: [],
+          });
+        }
+
+        if (product.extra_fields?.card_config) {
+          const c = product.extra_fields.card_config;
+          setCardConfig({
+            banner_url: c.banner_url || '',
+            poster_title: c.poster_title || '',
+            poster_highlight: c.poster_highlight || '',
+            poster_sub: c.poster_sub || '',
+            poster_tag: c.poster_tag || '',
+            poster_accent_color: c.poster_accent_color || '#2563eb',
+            official_tag: c.official_tag !== undefined ? c.official_tag : '官方直连',
+            status_tag: c.status_tag !== undefined ? c.status_tag : 'New',
+            pill_text: c.pill_text || '',
+            sales_text: c.sales_text || '',
+            buy_button_text: c.buy_button_text || '立即购买',
+            sublink_text: c.sublink_text || '查阅服务细则 →',
+          });
+        } else {
+          setCardConfig({
+            banner_url: '',
+            poster_title: '',
+            poster_highlight: '',
+            poster_sub: '',
+            poster_tag: '',
+            poster_accent_color: '#2563eb',
+            official_tag: '官方直连',
+            status_tag: 'New',
+            pill_text: '',
+            sales_text: '',
+            buy_button_text: '立即购买',
+            sublink_text: '查阅服务细则 →',
+          });
+        }
+
         if (product.schema_id) {
           fetchSchemaDetail(product.schema_id);
         } else {
@@ -131,6 +313,32 @@ export default function ProductModal({
           enabled: 1,
           schema_id: 0,
         });
+        setTutorialConfig({
+          enabled: false,
+          display_type: 'both',
+          button_text: '📖 查看账号准备与使用教程',
+          link_url: '',
+          link_text: '打开官方图文文档 ↗',
+          modal_title: '',
+          badge_text: '申请人必读指引',
+          summary: '',
+          content: '',
+          steps: [],
+        });
+        setCardConfig({
+          banner_url: '',
+          poster_title: '',
+          poster_highlight: '',
+          poster_sub: '',
+          poster_tag: '',
+          poster_accent_color: '#2563eb',
+          official_tag: '官方直连',
+          status_tag: 'New',
+          pill_text: '',
+          sales_text: '',
+          buy_button_text: '立即购买',
+          sublink_text: '查阅服务细则 →',
+        });
         setSelectedSchemaDetail(null);
       }
     }
@@ -157,6 +365,46 @@ export default function ProductModal({
     fetchSchemaDetail(newSchemaId);
   };
 
+  const handleAddStep = () => {
+    setTutorialConfig((prev) => ({
+      ...prev,
+      steps: [
+        ...(prev.steps || []),
+        {
+          step_no: (prev.steps?.length || 0) + 1,
+          title: `步骤 ${(prev.steps?.length || 0) + 1}`,
+          desc: '',
+        },
+      ],
+    }));
+  };
+
+  const handleRemoveStep = (index: number) => {
+    setTutorialConfig((prev) => {
+      const nextSteps = [...(prev.steps || [])];
+      nextSteps.splice(index, 1);
+      return {
+        ...prev,
+        steps: nextSteps.map((s, idx) => ({ ...s, step_no: idx + 1 })),
+      };
+    });
+  };
+
+  const handleUpdateStep = (index: number, field: 'title' | 'desc', val: string) => {
+    setTutorialConfig((prev) => {
+      const nextSteps = [...(prev.steps || [])];
+      if (nextSteps[index]) {
+        nextSteps[index] = { ...nextSteps[index], [field]: val };
+      }
+      return { ...prev, steps: nextSteps };
+    });
+  };
+
+  const handleApplyTutorialTemplate = (tpl: (typeof TUTORIAL_TEMPLATES)[0]) => {
+    setTutorialConfig({ ...tpl.config });
+    toast.success(`已应用模版: ${tpl.name}`);
+  };
+
   const handleSubmit = async (e: React.FormEvent) => {
     e.preventDefault();
     if (!form.title.trim()) return toast.error('请输入商品标题');
@@ -170,6 +418,11 @@ export default function ProductModal({
         recommend_score: Number(form.recommend_score) || 0,
         enabled: Number(form.enabled),
         schema_id: form.schema_id > 0 ? Number(form.schema_id) : null,
+        extra_fields: {
+          ...(product?.extra_fields || {}),
+          tutorial: tutorialConfig.enabled ? tutorialConfig : null,
+          card_config: cardConfig,
+        },
       };
 
       if (product?.id) {
@@ -352,22 +605,22 @@ export default function ProductModal({
               </div>
             </div>
 
-            {/* 3. 定价与排序权重卡片 */}
+            {/* 3. 定价与运营权重 */}
             <div className="bg-neutral-50 border-2 border-black p-4 shadow-[2px_2px_0px_#000] space-y-3">
               <span className="text-[10px] font-black uppercase text-black block border-b-2 border-black pb-1">
-                [ 03 // 价格与上架状态 ]
+                [ 03 // 服务费定价与权重管理 ]
               </span>
 
-              <div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
+              <div className="grid grid-cols-1 sm:grid-cols-4 gap-3">
                 <div className="space-y-1">
                   <label className="font-bold text-black uppercase block">
-                    标准单价 (元) <span className="text-black">*</span>
+                    标准服务费 (元) <span className="text-black">*</span>
                   </label>
                   <input
                     type="number"
-                    required
                     min="0"
                     step="0.01"
+                    required
                     className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-mono font-bold text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
                     value={form.price_amount}
                     onChange={(e) => setForm({ ...form, price_amount: Number(e.target.value) })}
@@ -375,28 +628,25 @@ export default function ProductModal({
                 </div>
                 <div className="space-y-1">
                   <label className="font-bold text-black uppercase block">
-                    结算货币
+                    结算币种
                   </label>
                   <select
-                    className="w-full border-2 border-black bg-white px-2 py-2 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
+                    className="w-full border-2 border-black bg-white px-2 py-2 text-xs font-mono font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
                     value={form.price_currency}
                     onChange={(e) => setForm({ ...form, price_currency: e.target.value })}
                   >
-                    <option value="CNY">CNY (人民币)</option>
-                    <option value="EUR">EUR (欧元)</option>
-                    <option value="USD">USD (美元)</option>
-                    <option value="GBP">GBP (英镑)</option>
+                    <option value="CNY">CNY (人民币 ¥)</option>
+                    <option value="USD">USD (美元 $)</option>
+                    <option value="EUR">EUR (欧元 €)</option>
+                    <option value="GBP">GBP (英镑 £)</option>
                   </select>
                 </div>
                 <div className="space-y-1">
                   <label className="font-bold text-black uppercase block">
-                    推荐权重 (Score)
+                    推荐权重 (越高越靠前)
                   </label>
                   <input
                     type="number"
-                    min="0"
-                    step="1"
-                    placeholder="0"
                     className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-mono font-bold text-black focus:bg-amber-50 outline-none shadow-[2px_2px_0px_#000]"
                     value={form.recommend_score || 0}
                     onChange={(e) => setForm({ ...form, recommend_score: Number(e.target.value) })}
@@ -527,6 +777,583 @@ export default function ProductModal({
               )}
             </div>
 
+            {/* 5. 用户使用教程与操作指引配置 (新特性) */}
+            <div className="bg-sky-50 border-2 border-black p-4 shadow-[2px_2px_0px_#000] space-y-3.5">
+              <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-2">
+                <div className="flex items-center gap-2">
+                  <BookOpen size={16} className="text-black" />
+                  <span className="font-black text-black text-xs uppercase">
+                    [ 05 // 用户使用教程与操作指引配置 (可选) ]
+                  </span>
+                </div>
+                <label className="flex items-center gap-2 cursor-pointer font-bold text-xs select-none">
+                  <input
+                    type="checkbox"
+                    checked={tutorialConfig.enabled}
+                    onChange={(e) =>
+                      setTutorialConfig((prev) => ({ ...prev, enabled: e.target.checked }))
+                    }
+                    className="w-4 h-4 accent-amber-400 cursor-pointer"
+                  />
+                  <span>为此商品开启购买前使用教程</span>
+                </label>
+              </div>
+
+              {tutorialConfig.enabled ? (
+                <div className="space-y-4">
+                  {/* 快捷模板一键套用 */}
+                  <div className="p-2.5 bg-white border border-black shadow-[1px_1px_0px_#000] space-y-1.5">
+                    <span className="text-[10px] font-bold text-neutral-500 uppercase block font-mono">
+                      ⚡️ 常用教程模板快速套用:
+                    </span>
+                    <div className="flex flex-wrap gap-2">
+                      {TUTORIAL_TEMPLATES.map((tpl, idx) => (
+                        <button
+                          key={idx}
+                          type="button"
+                          onClick={() => handleApplyTutorialTemplate(tpl)}
+                          className="px-2.5 py-1 bg-neutral-100 hover:bg-amber-300 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+                        >
+                          {tpl.name}
+                        </button>
+                      ))}
+                    </div>
+                  </div>
+
+                  {/* 形式多种选择 (Display Type) */}
+                  <div className="space-y-1.5">
+                    <label className="font-bold text-black uppercase block">
+                      教程展现形式 (支持弹窗对话框、超链接及多种组合) <span className="text-rose-600">*</span>
+                    </label>
+                    <div className="grid grid-cols-2 sm:grid-cols-4 gap-2">
+                      {[
+                        {
+                          type: 'both',
+                          label: '⚡️ 弹窗 + 外部超链接 (推荐)',
+                          desc: '既可弹窗看步骤,又可点外链跳文档',
+                        },
+                        {
+                          type: 'modal',
+                          label: '💬 弹出对话框类型 (Modal)',
+                          desc: '点击按钮弹出详细操作步骤对话框',
+                        },
+                        {
+                          type: 'link',
+                          label: '🔗 外部超链接类型 (Link)',
+                          desc: '直接在新标签页跳转飞书/语雀/Wiki',
+                        },
+                        {
+                          type: 'embedded',
+                          label: '📑 页面内嵌展开卡片 (Embedded)',
+                          desc: '直接在下单页面上方以卡片形式展开',
+                        },
+                      ].map((item) => {
+                        const isSelected = tutorialConfig.display_type === item.type;
+                        return (
+                          <div
+                            key={item.type}
+                            onClick={() =>
+                              setTutorialConfig((prev) => ({
+                                ...prev,
+                                display_type: item.type as any,
+                              }))
+                            }
+                            className={`p-2.5 border-2 border-black cursor-pointer text-left transition select-none ${
+                              isSelected
+                                ? 'bg-amber-300 shadow-[2px_2px_0px_#000]'
+                                : 'bg-white hover:bg-neutral-100 shadow-[1px_1px_0px_#000]'
+                            }`}
+                          >
+                            <div className="text-xs font-black text-black">{item.label}</div>
+                            <div className="text-[10px] text-neutral-600 font-sans mt-0.5">
+                              {item.desc}
+                            </div>
+                          </div>
+                        );
+                      })}
+                    </div>
+                  </div>
+
+                  {/* 基础文案配置 */}
+                  <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+                    <div className="space-y-1">
+                      <label className="font-bold text-black uppercase block">
+                        触发按钮文案 (前台按钮文字)
+                      </label>
+                      <input
+                        type="text"
+                        placeholder="如: 📖 查看 VFS 账号准备教程"
+                        className="w-full border-2 border-black bg-white px-3 py-1.5 text-xs text-black outline-none shadow-[2px_2px_0px_#000]"
+                        value={tutorialConfig.button_text}
+                        onChange={(e) =>
+                          setTutorialConfig((prev) => ({ ...prev, button_text: e.target.value }))
+                        }
+                      />
+                    </div>
+                    <div className="space-y-1">
+                      <label className="font-bold text-black uppercase block">
+                        教程弹窗大标题
+                      </label>
+                      <input
+                        type="text"
+                        placeholder="如: VFS 官方预约账号注册与授权使用指南"
+                        className="w-full border-2 border-black bg-white px-3 py-1.5 text-xs text-black outline-none shadow-[2px_2px_0px_#000]"
+                        value={tutorialConfig.modal_title}
+                        onChange={(e) =>
+                          setTutorialConfig((prev) => ({ ...prev, modal_title: e.target.value }))
+                        }
+                      />
+                    </div>
+                  </div>
+
+                  {/* 超链接配置 (当选中 link / both / embedded 时) */}
+                  {(tutorialConfig.display_type === 'link' ||
+                    tutorialConfig.display_type === 'both' ||
+                    tutorialConfig.display_type === 'embedded') && (
+                    <div className="grid grid-cols-1 sm:grid-cols-3 gap-3 p-3 bg-white border border-black shadow-[1px_1px_0px_#000]">
+                      <div className="sm:col-span-2 space-y-1">
+                        <label className="font-bold text-black uppercase block flex items-center gap-1">
+                          <ExternalLink size={12} />
+                          <span>外部图文教程 / 文档超链接 URL</span>
+                        </label>
+                        <input
+                          type="url"
+                          placeholder="如: https://your-wiki-feishu.com/guide/vfs-account"
+                          className="w-full border-2 border-black bg-white px-3 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                          value={tutorialConfig.link_url}
+                          onChange={(e) =>
+                            setTutorialConfig((prev) => ({ ...prev, link_url: e.target.value }))
+                          }
+                        />
+                      </div>
+                      <div className="space-y-1">
+                        <label className="font-bold text-black uppercase block">
+                          超链接按钮文字
+                        </label>
+                        <input
+                          type="text"
+                          placeholder="如: 打开官方图文文档 ↗"
+                          className="w-full border-2 border-black bg-white px-3 py-1.5 text-xs text-black outline-none shadow-[2px_2px_0px_#000]"
+                          value={tutorialConfig.link_text}
+                          onChange={(e) =>
+                            setTutorialConfig((prev) => ({ ...prev, link_text: e.target.value }))
+                          }
+                        />
+                      </div>
+                    </div>
+                  )}
+
+                  {/* 核心摘要与准备说明 */}
+                  <div className="space-y-1">
+                    <label className="font-bold text-black uppercase block">
+                      核心摘要 / 账号准备提示 (在弹窗顶部或内嵌卡片展示)
+                    </label>
+                    <textarea
+                      rows={2}
+                      placeholder="如: 本服务由自动化脚本登录 VFS 官方系统代刷名额,需要您自备一个已激活的有效官网账号。"
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-sans text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={tutorialConfig.summary}
+                      onChange={(e) =>
+                        setTutorialConfig((prev) => ({ ...prev, summary: e.target.value }))
+                      }
+                    />
+                  </div>
+
+                  {/* 步骤清单配置 (Steps List) */}
+                  <div className="space-y-2">
+                    <div className="flex items-center justify-between">
+                      <label className="font-bold text-black uppercase block">
+                        分步操作指导 ({tutorialConfig.steps?.length || 0} 个步骤)
+                      </label>
+                      <button
+                        type="button"
+                        onClick={handleAddStep}
+                        className="px-2.5 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-xs font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1"
+                      >
+                        <Plus size={12} />
+                        <span>新增步骤</span>
+                      </button>
+                    </div>
+
+                    {tutorialConfig.steps && tutorialConfig.steps.length > 0 ? (
+                      <div className="space-y-2">
+                        {tutorialConfig.steps.map((step, idx) => (
+                          <div
+                            key={idx}
+                            className="bg-white border-2 border-black p-3 shadow-[1px_1px_0px_#000] space-y-2"
+                          >
+                            <div className="flex items-center justify-between gap-2">
+                              <div className="flex items-center gap-2 flex-1">
+                                <span className="w-5 h-5 bg-black text-white text-xs font-black flex items-center justify-center shrink-0">
+                                  {step.step_no}
+                                </span>
+                                <input
+                                  type="text"
+                                  placeholder="步骤标题 (如: 官网注册账号并完成激活)"
+                                  className="w-full border border-black px-2 py-1 text-xs font-bold text-black outline-none focus:bg-amber-50"
+                                  value={step.title}
+                                  onChange={(e) => handleUpdateStep(idx, 'title', e.target.value)}
+                                />
+                              </div>
+                              <button
+                                type="button"
+                                onClick={() => handleRemoveStep(idx)}
+                                className="p-1 text-rose-700 hover:bg-rose-100 border border-black shadow-[1px_1px_0px_#000] transition"
+                                title="删除该步骤"
+                              >
+                                <Trash2 size={12} />
+                              </button>
+                            </div>
+                            <textarea
+                              rows={2}
+                              placeholder="步骤详细描述、注意事项或入口说明..."
+                              className="w-full border border-neutral-300 px-2 py-1 text-xs font-sans text-neutral-800 outline-none focus:border-black"
+                              value={step.desc}
+                              onChange={(e) => handleUpdateStep(idx, 'desc', e.target.value)}
+                            />
+                          </div>
+                        ))}
+                      </div>
+                    ) : (
+                      <div className="p-3 border border-dashed border-sky-300 bg-white text-center text-neutral-500 text-[11px]">
+                        暂无分步步骤。若只需纯外链或大段文本说明,可不添加步骤;若需分步图解,可点击上方「新增步骤」或直接套用模板。
+                      </div>
+                    )}
+                  </div>
+
+                  {/* 详细长文本 / FAQ 补充 */}
+                  <div className="space-y-1">
+                    <label className="font-bold text-black uppercase block">
+                      常见疑问解答 (FAQ) 或详细补充长文本
+                    </label>
+                    <textarea
+                      rows={3}
+                      placeholder="如: 安全提示、防风控策略、验证码接收说明等详细事项..."
+                      className="w-full border-2 border-black bg-white px-3 py-2 text-xs font-sans text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={tutorialConfig.content}
+                      onChange={(e) =>
+                        setTutorialConfig((prev) => ({ ...prev, content: e.target.value }))
+                      }
+                    />
+                  </div>
+
+                  {/* 实时效果预览 (Live Preview) */}
+                  <div className="pt-2 border-t-2 border-black space-y-1.5">
+                    <span className="text-[10px] font-black text-black uppercase block">
+                      [ 实时效果预览 (前台用户所见样式) ]:
+                    </span>
+                    <ProductTutorialBanner
+                      tutorial={tutorialConfig}
+                      productTitle={form.title || '法国申根签证预约加急服务'}
+                    />
+                  </div>
+                </div>
+              ) : (
+                <p className="text-[11px] text-neutral-600 font-sans">
+                  勾选后可为此商品配置专门的<strong>使用指南、账号准备指引或外部文档超链接</strong>。用户在下单填表前即可查阅,防止因账号信息缺失导致工单失败。
+                </p>
+              )}
+            </div>
+
+            {/* === 06. 前台展示卡片包装与海报定制 === */}
+            <div className="bg-neutral-50 border-2 border-black p-4 space-y-4 shadow-[3px_3px_0px_#000]">
+              <div className="flex items-center justify-between border-b-2 border-black pb-2">
+                <div className="flex items-center gap-2">
+                  <span className="w-2.5 h-2.5 bg-black" />
+                  <span className="text-xs font-black uppercase text-black">
+                    [ 06 // 前台展示卡片包装与海报定制 (Showcase Card & Poster) ]
+                  </span>
+                </div>
+                <span className="text-[10px] font-mono text-neutral-500 uppercase">
+                  MATCH /SERVICES DARK CARD
+                </span>
+              </div>
+
+              <p className="text-[11px] text-neutral-600 font-sans">
+                定制商品在前台服务列表(/services)横向画幅卡片中的专属视觉海报、活动标贴、行动胶囊文案与销售库存统计。
+              </p>
+
+              {/* 1. 海报画幅 (16:9 Poster) */}
+              <div className="p-3.5 bg-white border-2 border-black shadow-[2px_2px_0px_#000] space-y-3">
+                <div className="flex items-center justify-between border-b border-neutral-200 pb-1.5">
+                  <span className="text-[11px] font-black uppercase text-black flex items-center gap-1.5">
+                    <Sparkles size={12} className="text-amber-500" />
+                    <span>左侧 16:9 视觉海报参数</span>
+                  </span>
+                  <span className="text-[10px] text-neutral-400 font-mono">留空则自动根据国家与签证类型智能生成</span>
+                </div>
+
+                <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+                  <div className="space-y-1 md:col-span-2">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      自定义海报大图 URL (可选,填入后将覆盖默认 3D 海报)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="https://... 或图床外链图片地址"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.banner_url || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, banner_url: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      海报主标题 (大字,如: FRANCE, USA, GPT Plus)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder={form.country ? form.country.toUpperCase() : '例如: FRANCE'}
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.poster_title || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, poster_title: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      海报亮色重点词 (如: Schengen 4M, Plus 4M, FAST-PASS)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="例如: Schengen 4M"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.poster_highlight || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, poster_highlight: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      海报副标题说明 (如: 申根短期签证官方代抢, 学生认证账号)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="例如: 申根短期签证官方加急预约"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.poster_sub || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, poster_sub: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      海报顶部微标 (如: VFS 官方通道, SUZHE AI)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="例如: VFS 官方通道"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.poster_tag || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, poster_tag: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1 md:col-span-2">
+                    <label className="text-[11px] font-bold text-black uppercase block">
+                      海报高亮强调色
+                    </label>
+                    <div className="flex flex-wrap items-center gap-2">
+                      {[
+                        { label: '科技湛蓝', color: '#2563eb' },
+                        { label: '极客翡翠', color: '#10b981' },
+                        { label: '尊贵金橙', color: '#d97706' },
+                        { label: '热烈绯红', color: '#dc2626' },
+                        { label: '高级橙红', color: '#ea580c' },
+                        { label: '神秘幻紫', color: '#7c3aed' },
+                      ].map((c) => (
+                        <button
+                          key={c.color}
+                          type="button"
+                          onClick={() => setCardConfig((prev) => ({ ...prev, poster_accent_color: c.color }))}
+                          className={`px-2.5 py-1 text-[11px] font-bold border border-black flex items-center gap-1.5 shadow-[1px_1px_0px_#000] ${
+                            cardConfig.poster_accent_color === c.color ? 'ring-2 ring-black font-black bg-neutral-100' : 'bg-white'
+                          }`}
+                        >
+                          <span className="w-2.5 h-2.5 rounded-full" style={{ backgroundColor: c.color }} />
+                          <span>{c.label}</span>
+                        </button>
+                      ))}
+                      <input
+                        type="color"
+                        value={cardConfig.poster_accent_color || '#2563eb'}
+                        onChange={(e) => setCardConfig((prev) => ({ ...prev, poster_accent_color: e.target.value }))}
+                        className="w-7 h-7 border border-black cursor-pointer p-0"
+                        title="自定义颜色"
+                      />
+                    </div>
+                  </div>
+                </div>
+              </div>
+
+              {/* 2. 中栏与右栏专属文案定制 */}
+              <div className="p-3.5 bg-white border-2 border-black shadow-[2px_2px_0px_#000] space-y-3">
+                <span className="text-[11px] font-black uppercase text-black flex items-center gap-1.5 border-b border-neutral-200 pb-1.5">
+                  <Tag size={12} className="text-emerald-600" />
+                  <span>中栏标贴、胶囊按键与右侧行动文案</span>
+                </span>
+
+                <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      活动/通道标贴 (青色微斜标签,如: 官方活动、官方直连、特惠直供)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="默认: 官方直连"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.official_tag || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, official_tag: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      状态徽标 (天蓝角标,如: New、Hot、限时可约)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="默认: New"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.status_tag || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, status_tag: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      辅助细线胶囊文案 (如: 无法完成绑卡?、查看办理教程与指引)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="留空则自动显示教程标题或全额退款保障"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.pill_text || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, pill_text: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      底部销售/库存描述 (如: 仅剩 5 件 · 已售 77、实时监控中 · 已售 120)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="留空则根据商品推荐分自动生成"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.sales_text || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, sales_text: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      右侧购买按键文案 (如: 立即购买、立即申请、立即抢位)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="默认: 立即购买"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.buy_button_text || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, buy_button_text: e.target.value }))}
+                    />
+                  </div>
+
+                  <div className="space-y-1">
+                    <label className="text-[11px] font-bold text-black uppercase">
+                      底部次级细字链接 (如: 已购买? 去激活 →、查阅服务细则 →)
+                    </label>
+                    <input
+                      type="text"
+                      placeholder="默认: 查阅服务细则 →"
+                      className="w-full border-2 border-black bg-white px-2.5 py-1.5 text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+                      value={cardConfig.sublink_text || ''}
+                      onChange={(e) => setCardConfig((prev) => ({ ...prev, sublink_text: e.target.value }))}
+                    />
+                  </div>
+                </div>
+              </div>
+
+              {/* 3. 实时前台卡片效果预览 (Live Preview) */}
+              <div className="pt-2 border-t-2 border-black space-y-2">
+                <span className="text-[10px] font-black text-black uppercase flex items-center gap-1.5">
+                  <Sparkles size={12} className="text-amber-500" />
+                  <span>[ 实时效果预览 (前台用户所见样式) ]:</span>
+                </span>
+
+                <div className="p-4 bg-neutral-100 border-2 border-black shadow-[4px_4px_0px_#000]">
+                  <div className="bg-white border-2 border-black p-4 sm:p-5 shadow-[4px_4px_0px_#000] flex flex-col md:flex-row items-stretch md:items-center justify-between gap-4">
+                    <ServicePoster
+                      product={{
+                        ...form,
+                        id: product?.id || 999,
+                        extra_fields: { card_config: cardConfig },
+                      } as any}
+                    />
+
+                    <div className="flex-1 min-w-0 flex flex-col justify-between py-0.5 space-y-2">
+                      <div className="flex items-center gap-2 text-xs font-mono font-bold tracking-wider">
+                        <span className="w-2.5 h-2.5 bg-emerald-400 border border-black inline-block shadow-[1px_1px_0px_#000]" />
+                        <span className="uppercase bg-neutral-100 border border-black px-1.5 py-0.5 text-black font-black text-[10px] shadow-[1px_1px_0px_#000]">
+                          {(form.country || 'FRANCE').toUpperCase()} // {form.provider || 'VFS'}
+                        </span>
+                      </div>
+
+                      <div className="flex flex-wrap items-center gap-2">
+                        <h3 className="text-base font-black text-black tracking-tight font-sans">
+                          {form.title || '法国短期申根签证专属代抢通道'}
+                        </h3>
+                        {cardConfig.official_tag && (
+                          <span className="bg-teal-100 text-teal-900 border border-black px-1.5 py-0.2 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
+                            {cardConfig.official_tag}
+                          </span>
+                        )}
+                        {cardConfig.status_tag && (
+                          <span className="bg-amber-300 text-black border border-black px-1.5 py-0.2 text-[10px] font-mono font-black shadow-[1px_1px_0px_#000] uppercase">
+                            {cardConfig.status_tag}
+                          </span>
+                        )}
+                      </div>
+
+                      <p className="text-neutral-600 text-xs line-clamp-2 leading-relaxed">
+                        {form.description || '官方直连极速通道,分布式集群 24 小时毫秒级抢位,预约失败无条件全额退款。'}
+                      </p>
+
+                      <div>
+                        <span className="inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 text-black border-2 border-black font-mono text-xs font-bold shadow-[2px_2px_0px_#000]">
+                          [ {cardConfig.pill_text || (tutorialConfig.enabled ? (tutorialConfig.modal_title || '查看办理教程与材料指引') : '7×24H 官方代抢 · 失败全额退款')} → ]
+                        </span>
+                      </div>
+
+                      <div className="text-neutral-500 text-[11px] font-mono pt-1 border-t border-neutral-200">
+                        <strong className="text-neutral-800 font-bold">
+                          {cardConfig.sales_text || '实时监控中 · 已售 88'}
+                        </strong>
+                      </div>
+                    </div>
+
+                    <div className="md:w-40 shrink-0 flex flex-row md:flex-col items-center md:items-end justify-between md:justify-center gap-2 pt-3 md:pt-0 border-t-2 border-neutral-200 md:border-t-0 md:border-l-2 md:border-neutral-200 md:pl-4">
+                      <div className="font-mono text-left md:text-right">
+                        <div className="text-[9px] font-bold text-neutral-500 uppercase">FEE</div>
+                        <div className="flex items-baseline justify-end gap-0.5">
+                          <span className="text-sm font-bold text-black font-mono">¥</span>
+                          <span className="text-2xl font-black text-black font-mono tracking-tight">{Number(form.price_amount).toLocaleString()}</span>
+                        </div>
+                      </div>
+
+                      <span className="px-4 py-2 bg-amber-300 text-black border-2 border-black font-black font-mono text-xs shadow-[2px_2px_0px_#000] uppercase">
+                        [ {cardConfig.buy_button_text || '立即购买'} ]
+                      </span>
+
+                      <span className="text-[10px] font-mono font-bold text-neutral-600 underline underline-offset-2">
+                        {cardConfig.sublink_text || '查阅服务细则 →'}
+                      </span>
+                    </div>
+                  </div>
+                </div>
+              </div>
+            </div>
+
           </form>
         </div>
 

+ 425 - 0
src/components/admin/settlement/AgenciesTab.tsx

@@ -0,0 +1,425 @@
+// src/components/admin/settlement/AgenciesTab.tsx
+'use client';
+
+import { useState, useEffect } from 'react';
+import { Plus, Edit2, Building2, Check, X, RefreshCw, UserCheck, ShieldAlert } from 'lucide-react';
+import { settlementService } from '@/lib/services';
+import { VasAgency, VasAgencyCreatePayload, VasAgencyUpdatePayload } from '@/types';
+import { toast } from 'react-hot-toast';
+import LocalTime from '@/components/common/LocalTime';
+import AdminUserSelect from '@/components/common/AdminUserSelect';
+
+export default function AgenciesTab() {
+  const [agencies, setAgencies] = useState<VasAgency[]>([]);
+  const [loading, setLoading] = useState(false);
+  const [isModalOpen, setIsModalOpen] = useState(false);
+  const [editingAgency, setEditingAgency] = useState<VasAgency | null>(null);
+
+  // Form State
+  const [name, setName] = useState('');
+  const [contactName, setContactName] = useState('');
+  const [contactPhone, setContactPhone] = useState('');
+  const [ownerId, setOwnerId] = useState('');
+  const [minFloorPriceYuan, setMinFloorPriceYuan] = useState('0');
+  const [status, setStatus] = useState<number>(1);
+  const [notes, setNotes] = useState('');
+  const [submitting, setSubmitting] = useState(false);
+
+  const fetchAgencies = async () => {
+    setLoading(true);
+    try {
+      const res = await settlementService.listAgencies({ page: 0, size: 100 });
+      const items = res?.data?.items || res?.data || [];
+      setAgencies(Array.isArray(items) ? items : []);
+    } catch {
+      toast.error('加载中介机构列表失败');
+    } finally {
+      setLoading(false);
+    }
+  };
+
+  useEffect(() => {
+    fetchAgencies();
+  }, []);
+
+  const openCreateModal = () => {
+    setEditingAgency(null);
+    setName('');
+    setContactName('');
+    setContactPhone('');
+    setOwnerId('');
+    setMinFloorPriceYuan('0');
+    setStatus(1);
+    setNotes('');
+    setIsModalOpen(true);
+  };
+
+  const openEditModal = (agency: VasAgency) => {
+    setEditingAgency(agency);
+    setName(agency.name);
+    setContactName(agency.contact_name || '');
+    setContactPhone(agency.contact_phone || '');
+    setOwnerId(agency.owner_id);
+    setMinFloorPriceYuan((agency.min_floor_price / 100).toFixed(2));
+    setStatus(agency.status);
+    setNotes(agency.notes || '');
+    setIsModalOpen(true);
+  };
+
+  const handleSubmit = async (e: React.FormEvent) => {
+    e.preventDefault();
+    if (!name.trim()) return toast.error('请输入中介机构名称');
+    if (!ownerId.trim()) return toast.error('请输入专属拓展维系人ID (拿40%提成)');
+
+    const floorPriceCents = Math.round(Number(minFloorPriceYuan || 0) * 100);
+    if (isNaN(floorPriceCents) || floorPriceCents < 0) {
+      return toast.error('请输入有效的最低协议结算底价');
+    }
+
+    setSubmitting(true);
+    try {
+      if (editingAgency) {
+        const payload: VasAgencyUpdatePayload = {
+          name: name.trim(),
+          contact_name: contactName.trim() || undefined,
+          contact_phone: contactPhone.trim() || undefined,
+          owner_id: ownerId.trim(),
+          min_floor_price: floorPriceCents,
+          status,
+          notes: notes.trim() || undefined,
+        };
+        await settlementService.updateAgency(editingAgency.id, payload);
+        toast.success(`中介档案 [${name}] 更新成功`);
+      } else {
+        const payload: VasAgencyCreatePayload = {
+          name: name.trim(),
+          contact_name: contactName.trim() || undefined,
+          contact_phone: contactPhone.trim() || undefined,
+          owner_id: ownerId.trim(),
+          min_floor_price: floorPriceCents,
+          notes: notes.trim() || undefined,
+        };
+        await settlementService.createAgency(payload);
+        toast.success(`合作中介 [${name}] 登记成功`);
+      }
+      setIsModalOpen(false);
+      fetchAgencies();
+    } catch (err: any) {
+      toast.error('保存失败: ' + (err.response?.data?.message || err.message));
+    } finally {
+      setSubmitting(false);
+    }
+  };
+
+  return (
+    <div className="space-y-6 font-mono">
+      {/* 顶部操作与说明 */}
+      <div className="bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-4">
+        <div>
+          <div className="flex items-center gap-2">
+            <Building2 size={18} className="text-black" />
+            <h2 className="text-sm font-black uppercase text-black">
+              [ COOPERATIVE AGENCIES // 合作中介渠道档案与协议底价 ]
+            </h2>
+          </div>
+          <p className="text-[11px] text-neutral-600 font-sans mt-1">
+            中介渠道单采用<strong>内部最低底价(批发价)</strong>结算,公账统收无二次返佣;每单 <strong>40% 销售提成</strong>由该中介的专属拓展对接人个人独占,并对录入准确性负全责。
+          </p>
+        </div>
+
+        <div className="flex items-center gap-2 shrink-0">
+          <button
+            onClick={fetchAgencies}
+            disabled={loading}
+            className="px-3 py-1.5 bg-neutral-100 hover:bg-neutral-200 border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] flex items-center gap-1 active:translate-x-0.5 active:translate-y-0.5 uppercase"
+          >
+            <RefreshCw size={13} className={loading ? 'animate-spin' : ''} />
+            <span>[ 刷新 ]</span>
+          </button>
+          <button
+            onClick={openCreateModal}
+            className="px-4 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] flex items-center gap-1.5 active:translate-x-0.5 active:translate-y-0.5 uppercase"
+          >
+            <Plus size={14} />
+            <span>[ 登记新中介机构 ]</span>
+          </button>
+        </div>
+      </div>
+
+      {/* 中介列表表格 */}
+      <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
+        <div className="overflow-x-auto">
+          <table className="min-w-full divide-y-2 divide-black text-left">
+            <thead className="bg-neutral-100 border-b-2 border-black">
+              <tr>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 机构标识 / 名称 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 专属拓展维系人 (40%提成) ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 协议最低结算底价 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 业务联系人 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 合作备注 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 合作状态 ]
+                </th>
+                <th className="px-4 py-3 text-right text-xs font-black text-black uppercase tracking-wider">
+                  [ 操作 ]
+                </th>
+              </tr>
+            </thead>
+            <tbody className="bg-white divide-y border-t-2 border-black">
+              {agencies.length === 0 ? (
+                <tr>
+                  <td colSpan={7} className="px-4 py-12 text-center text-neutral-400 text-xs">
+                    {loading ? '[ 正在读取合作中介档案... ]' : '[ 暂未登记合作中介,点击右上角新建 ]'}
+                  </td>
+                </tr>
+              ) : (
+                agencies.map((agency) => (
+                  <tr key={agency.id} className="hover:bg-amber-50/60 transition">
+                    {/* Name */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="flex flex-col">
+                        <span className="text-xs font-black text-black font-sans">
+                          {agency.name}
+                        </span>
+                        <span className="text-[10px] text-neutral-400 font-mono">
+                          ID: {agency.id}
+                        </span>
+                      </div>
+                    </td>
+
+                    {/* Owner */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="flex items-center gap-1.5">
+                        <UserCheck size={13} className="text-purple-700" />
+                        <span className="text-xs font-black text-black font-mono">
+                          {agency.owner_id}
+                        </span>
+                      </div>
+                      <span className="text-[9px] text-purple-700 font-bold block mt-0.5">
+                        (该中介订单独占 40% 提成)
+                      </span>
+                    </td>
+
+                    {/* Floor Price */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="flex flex-col">
+                        <span className="text-xs font-black text-rose-600 font-mono">
+                          ¥{(agency.min_floor_price / 100).toFixed(2)}
+                        </span>
+                        <span className="text-[9px] text-neutral-400">
+                          低于此价阻断录单
+                        </span>
+                      </div>
+                    </td>
+
+                    {/* Contact */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="text-xs font-sans text-black">
+                        {agency.contact_name || '-'}
+                      </div>
+                      <div className="text-[10px] text-neutral-500 font-mono">
+                        {agency.contact_phone || '-'}
+                      </div>
+                    </td>
+
+                    {/* Notes */}
+                    <td className="px-4 py-3.5 max-w-[200px]">
+                      <span className="text-xs text-neutral-600 font-sans truncate block">
+                        {agency.notes || '-'}
+                      </span>
+                    </td>
+
+                    {/* Status */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      {agency.status === 1 ? (
+                        <span className="px-2 py-0.5 bg-emerald-100 text-emerald-800 border border-black font-bold text-[10px]">
+                          ✓ 合作中
+                        </span>
+                      ) : (
+                        <span className="px-2 py-0.5 bg-neutral-200 text-neutral-600 border border-black text-[10px]">
+                          ⊘ 已暂停
+                        </span>
+                      )}
+                    </td>
+
+                    {/* Action */}
+                    <td className="px-4 py-3.5 text-right whitespace-nowrap">
+                      <button
+                        onClick={() => openEditModal(agency)}
+                        className="px-2.5 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 inline-flex items-center gap-1 uppercase"
+                      >
+                        <Edit2 size={11} />
+                        <span>编辑底价</span>
+                      </button>
+                    </td>
+                  </tr>
+                ))
+              )}
+            </tbody>
+          </table>
+        </div>
+      </div>
+
+      {/* 新增/编辑弹窗 */}
+      {isModalOpen && (
+        <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-grayscale">
+          <div className="bg-white border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-xl overflow-hidden animate-in fade-in zoom-in-95 duration-100">
+            {/* Header */}
+            <div className="bg-neutral-200 px-5 py-3 border-b-2 border-black flex items-center justify-between">
+              <div className="flex items-center gap-2">
+                <Building2 size={16} className="text-black" />
+                <h3 className="text-xs font-black uppercase text-black">
+                  [ {editingAgency ? 'EDIT AGENCY // 编辑中介协议档案' : 'CREATE AGENCY // 登记合作中介'} ]
+                </h3>
+              </div>
+              <button
+                onClick={() => setIsModalOpen(false)}
+                className="w-6 h-6 border border-black bg-white hover:bg-rose-100 flex items-center justify-center text-xs font-black shadow-[1px_1px_0px_#000]"
+              >
+                ✕
+              </button>
+            </div>
+
+            {/* Form */}
+            <form onSubmit={handleSubmit} className="p-5 space-y-4 text-xs">
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 中介机构名称 / 旅行社名称 ] <span className="text-rose-600">*</span>
+                </label>
+                <input
+                  type="text"
+                  required
+                  value={name}
+                  onChange={(e) => setName(e.target.value)}
+                  placeholder="例如: 环球行天下国际旅行社"
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              {/* 专属拓展维系人与最低底价 */}
+              <div className="space-y-4">
+                <div>
+                  <AdminUserSelect
+                    value={ownerId}
+                    onChange={setOwnerId}
+                    label="专属拓展维系人 (OWNER_ID)"
+                    badgeText="系统管理员"
+                    placeholder="选择系统管理员作为拓展维系人"
+                    helperText="该中介每笔订单 40% 销售提成归此人账户"
+                    required
+                  />
+                </div>
+
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 最低协议结算底价 (元) ] <span className="text-rose-600">*</span>
+                  </label>
+                  <div className="relative">
+                    <span className="absolute left-2.5 top-2 font-bold text-xs">¥</span>
+                    <input
+                      type="number"
+                      step="0.01"
+                      required
+                      value={minFloorPriceYuan}
+                      onChange={(e) => setMinFloorPriceYuan(e.target.value)}
+                      placeholder="0.00"
+                      className="w-full pl-7 pr-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                    />
+                  </div>
+                  <span className="text-[10px] text-neutral-500 font-mono mt-1 block">
+                    录单价格低于此底价抛出异常阻断
+                  </span>
+                </div>
+              </div>
+
+              <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 机构联系人姓名 ]
+                  </label>
+                  <input
+                    type="text"
+                    value={contactName}
+                    onChange={(e) => setContactName(e.target.value)}
+                    placeholder="联系人姓名"
+                    className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  />
+                </div>
+
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 机构联系电话 / 微信 ]
+                  </label>
+                  <input
+                    type="text"
+                    value={contactPhone}
+                    onChange={(e) => setContactPhone(e.target.value)}
+                    placeholder="手机号或微信号"
+                    className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  />
+                </div>
+              </div>
+
+              {editingAgency && (
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 合作状态 ]
+                  </label>
+                  <select
+                    value={status}
+                    onChange={(e) => setStatus(Number(e.target.value))}
+                    className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  >
+                    <option value={1}>1: 正常合作启用中</option>
+                    <option value={0}>0: 暂停合作 (禁用录单)</option>
+                  </select>
+                </div>
+              )}
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 协议与合作备注 ]
+                </label>
+                <textarea
+                  rows={2}
+                  value={notes}
+                  onChange={(e) => setNotes(e.target.value)}
+                  placeholder="结算周期约定、账单格式或特殊注意事项..."
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              {/* Footer */}
+              <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex items-center justify-end gap-2">
+                <button
+                  type="button"
+                  onClick={() => setIsModalOpen(false)}
+                  className="px-4 py-2 bg-neutral-100 hover:bg-neutral-200 border-2 border-black font-bold text-xs uppercase"
+                >
+                  [ 取消 ]
+                </button>
+                <button
+                  type="submit"
+                  disabled={submitting}
+                  className="px-5 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase disabled:opacity-50"
+                >
+                  {submitting ? '[ 提交中... ]' : editingAgency ? '[ 保存更新 ]' : '[ 确认登记 ]'}
+                </button>
+              </div>
+            </form>
+          </div>
+        </div>
+      )}
+    </div>
+  );
+}

+ 466 - 0
src/components/admin/settlement/CostRecordsTab.tsx

@@ -0,0 +1,466 @@
+// src/components/admin/settlement/CostRecordsTab.tsx
+'use client';
+
+import { useState, useEffect } from 'react';
+import {
+  Plus,
+  RefreshCw,
+  Server,
+  Network,
+  Cpu,
+  Smartphone,
+  Receipt,
+  ExternalLink,
+  DollarSign,
+  Filter,
+} from 'lucide-react';
+import { settlementService } from '@/lib/services';
+import {
+  VasCostRecord,
+  VasCostCreatePayload,
+  CostCategory,
+  COST_CATEGORY_LABELS,
+} from '@/types';
+import { toast } from 'react-hot-toast';
+import LocalTime from '@/components/common/LocalTime';
+
+export default function CostRecordsTab() {
+  const [costs, setCosts] = useState<VasCostRecord[]>([]);
+  const [loading, setLoading] = useState(false);
+  const [summary, setSummary] = useState<Record<string, number>>({});
+  const [categoryFilter, setCategoryFilter] = useState<string>('all');
+  const [isModalOpen, setIsModalOpen] = useState(false);
+
+  // Form State
+  const [category, setCategory] = useState<CostCategory>('vps');
+  const [amountYuan, setAmountYuan] = useState('');
+  const [description, setDescription] = useState('');
+  const [voucherUrl, setVoucherUrl] = useState('');
+  const [paidAt, setPaidAt] = useState('');
+  const [submitting, setSubmitting] = useState(false);
+
+  const fetchCosts = async () => {
+    setLoading(true);
+    try {
+      const params: any = { page: 0, size: 100 };
+      if (categoryFilter !== 'all') {
+        params.category = categoryFilter;
+      }
+      const res = await settlementService.listCosts(params);
+      const items = res?.data?.items || res?.data || [];
+      setCosts(Array.isArray(items) ? items : []);
+
+      // 统计当期耗材 (按最近30天)
+      const now = new Date();
+      const thirtyDaysAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
+      try {
+        const sumRes = await settlementService.getCostsSummary(
+          thirtyDaysAgo.toISOString(),
+          now.toISOString()
+        );
+        setSummary(sumRes?.data || {});
+      } catch {
+        // silent
+      }
+    } catch {
+      toast.error('获取运行耗材支出流水失败');
+    } finally {
+      setLoading(false);
+    }
+  };
+
+  useEffect(() => {
+    fetchCosts();
+  }, [categoryFilter]);
+
+  const openCreateModal = () => {
+    setCategory('vps');
+    setAmountYuan('');
+    setDescription('');
+    setVoucherUrl('');
+    setPaidAt(new Date().toISOString().slice(0, 16));
+    setIsModalOpen(true);
+  };
+
+  const handleSubmit = async (e: React.FormEvent) => {
+    e.preventDefault();
+    const amountCents = Math.round(Number(amountYuan || 0) * 100);
+    if (isNaN(amountCents) || amountCents <= 0) {
+      return toast.error('请输入有效的支出金额 (大于0)');
+    }
+
+    setSubmitting(true);
+    try {
+      const payload: VasCostCreatePayload = {
+        category,
+        amount: amountCents,
+        description: description.trim() || undefined,
+        voucher_url: voucherUrl.trim() || undefined,
+        paid_at: paidAt ? new Date(paidAt).toISOString() : undefined,
+      };
+      await settlementService.createCost(payload);
+      toast.success('耗材成本记录已录入');
+      setIsModalOpen(false);
+      fetchCosts();
+    } catch (err: any) {
+      toast.error('录入失败: ' + (err.response?.data?.message || err.message));
+    } finally {
+      setSubmitting(false);
+    }
+  };
+
+  const getCategoryIcon = (cat: string) => {
+    switch (cat) {
+      case 'vps':
+        return <Server size={14} className="text-blue-600" />;
+      case 'proxy_ip':
+        return <Network size={14} className="text-purple-600" />;
+      case 'captcha_api':
+        return <Cpu size={14} className="text-amber-600" />;
+      case 'sms_api':
+        return <Smartphone size={14} className="text-emerald-600" />;
+      default:
+        return <Receipt size={14} className="text-neutral-600" />;
+    }
+  };
+
+  return (
+    <div className="space-y-6 font-mono">
+      {/* 顶部说明与分类汇总卡 */}
+      <div className="grid grid-cols-2 sm:grid-cols-5 gap-3">
+        <div className="bg-white border-2 border-black p-3.5 shadow-[3px_3px_0px_#000]">
+          <div className="flex items-center justify-between text-neutral-500 mb-1">
+            <span className="text-[10px] font-black uppercase">海外 VPS 服务器</span>
+            <Server size={14} className="text-blue-600" />
+          </div>
+          <div className="text-base font-black text-black">
+            ¥{((summary.vps || 0) / 100).toFixed(2)}
+          </div>
+          <span className="text-[9px] text-neutral-400">抢号节点实例月租</span>
+        </div>
+
+        <div className="bg-white border-2 border-black p-3.5 shadow-[3px_3px_0px_#000]">
+          <div className="flex items-center justify-between text-neutral-500 mb-1">
+            <span className="text-[10px] font-black uppercase">高匿代理 IP 池</span>
+            <Network size={14} className="text-purple-600" />
+          </div>
+          <div className="text-base font-black text-black">
+            ¥{((summary.proxy_ip || 0) / 100).toFixed(2)}
+          </div>
+          <span className="text-[9px] text-neutral-400">住宅轮换代理流量</span>
+        </div>
+
+        <div className="bg-white border-2 border-black p-3.5 shadow-[3px_3px_0px_#000]">
+          <div className="flex items-center justify-between text-neutral-500 mb-1">
+            <span className="text-[10px] font-black uppercase">自动打码平台</span>
+            <Cpu size={14} className="text-amber-600" />
+          </div>
+          <div className="text-base font-black text-black">
+            ¥{((summary.captcha_api || 0) / 100).toFixed(2)}
+          </div>
+          <span className="text-[9px] text-neutral-400">2Captcha/YesCaptcha</span>
+        </div>
+
+        <div className="bg-white border-2 border-black p-3.5 shadow-[3px_3px_0px_#000]">
+          <div className="flex items-center justify-between text-neutral-500 mb-1">
+            <span className="text-[10px] font-black uppercase">短信接码平台</span>
+            <Smartphone size={14} className="text-emerald-600" />
+          </div>
+          <div className="text-base font-black text-black">
+            ¥{((summary.sms_api || 0) / 100).toFixed(2)}
+          </div>
+          <span className="text-[9px] text-neutral-400">海外虚拟号接码充值</span>
+        </div>
+
+        <div className="bg-amber-100 border-2 border-black p-3.5 shadow-[3px_3px_0px_#000] col-span-2 sm:col-span-1">
+          <div className="flex items-center justify-between text-neutral-600 mb-1">
+            <span className="text-[10px] font-black uppercase">本期耗材总计</span>
+            <Receipt size={14} className="text-black" />
+          </div>
+          <div className="text-base font-black text-black">
+            ¥
+            {(
+              Object.values(summary).reduce((acc, v) => acc + (Number(v) || 0), 0) / 100
+            ).toFixed(2)}
+          </div>
+          <span className="text-[9px] text-neutral-600 font-bold">全单自动公摊</span>
+        </div>
+      </div>
+
+      {/* 筛选与操作栏 */}
+      <div className="bg-white border-2 border-black p-4 shadow-[4px_4px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-3">
+        <div className="flex items-center gap-2">
+          <Filter size={14} className="text-black" />
+          <span className="text-xs font-bold text-black uppercase">[ 类别筛选 ]:</span>
+          <select
+            value={categoryFilter}
+            onChange={(e) => setCategoryFilter(e.target.value)}
+            className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black cursor-pointer"
+          >
+            <option value="all">全部耗材类别 (ALL)</option>
+            <option value="vps">海外 VPS 服务器</option>
+            <option value="proxy_ip">高匿代理 IP 池</option>
+            <option value="captcha_api">自动打码平台 API</option>
+            <option value="sms_api">短信接码平台 API</option>
+            <option value="other">其他杂项支出</option>
+          </select>
+        </div>
+
+        <div className="flex items-center gap-2">
+          <button
+            onClick={fetchCosts}
+            disabled={loading}
+            className="px-3 py-1.5 bg-neutral-100 hover:bg-neutral-200 border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] flex items-center gap-1 active:translate-x-0.5 active:translate-y-0.5 uppercase"
+          >
+            <RefreshCw size={13} className={loading ? 'animate-spin' : ''} />
+            <span>[ 刷新 ]</span>
+          </button>
+          <button
+            onClick={openCreateModal}
+            className="px-4 py-1.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] flex items-center gap-1.5 active:translate-x-0.5 active:translate-y-0.5 uppercase"
+          >
+            <Plus size={14} />
+            <span>[ 录入新耗材支出 ]</span>
+          </button>
+        </div>
+      </div>
+
+      {/* 耗材支出流水表格 */}
+      <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
+        <div className="overflow-x-auto">
+          <table className="min-w-full divide-y-2 divide-black text-left">
+            <thead className="bg-neutral-100 border-b-2 border-black">
+              <tr>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 耗材类别 / 流水 ID ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 支出金额 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 支出说明 / 充值用途 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 实际发生时间 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 绑定的结算账期 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 扣款凭证截图 ]
+                </th>
+                <th className="px-4 py-3 text-right text-xs font-black text-black uppercase tracking-wider">
+                  [ 录入人 ]
+                </th>
+              </tr>
+            </thead>
+            <tbody className="bg-white divide-y border-t-2 border-black">
+              {costs.length === 0 ? (
+                <tr>
+                  <td colSpan={7} className="px-4 py-12 text-center text-neutral-400 text-xs">
+                    {loading ? '[ 正在读取耗材成本台账... ]' : '[ 暂无耗材支出记录,点击右上角录入 ]'}
+                  </td>
+                </tr>
+              ) : (
+                costs.map((cost) => (
+                  <tr key={cost.id} className="hover:bg-amber-50/60 transition">
+                    {/* Category */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="flex items-center gap-2">
+                        {getCategoryIcon(cost.category)}
+                        <span className="text-xs font-black text-black">
+                          {COST_CATEGORY_LABELS[cost.category as CostCategory] || cost.category}
+                        </span>
+                      </div>
+                      <span className="text-[10px] text-neutral-400 font-mono mt-0.5 block">
+                        REC #{cost.id}
+                      </span>
+                    </td>
+
+                    {/* Amount */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <span className="text-xs font-black text-rose-600 font-mono">
+                        -¥{(cost.amount / 100).toFixed(2)}
+                      </span>
+                      <span className="text-[9px] text-neutral-400 block uppercase">
+                        {cost.currency}
+                      </span>
+                    </td>
+
+                    {/* Description */}
+                    <td className="px-4 py-3.5 max-w-[220px]">
+                      <span className="text-xs text-neutral-800 font-sans block truncate">
+                        {cost.description || '无附加说明'}
+                      </span>
+                    </td>
+
+                    {/* Paid At */}
+                    <td className="px-4 py-3.5 whitespace-nowrap text-xs text-neutral-700">
+                      <LocalTime date={cost.paid_at} />
+                    </td>
+
+                    {/* Period ID */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      {cost.period_id ? (
+                        <span className="px-1.5 py-0.5 bg-black text-white border border-black font-mono font-bold text-[10px]">
+                          {cost.period_id} (已平账)
+                        </span>
+                      ) : (
+                        <span className="px-1.5 py-0.5 bg-neutral-100 text-neutral-500 border border-black font-mono text-[10px]">
+                          待账期归集均摊
+                        </span>
+                      )}
+                    </td>
+
+                    {/* Voucher */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      {cost.voucher_url ? (
+                        <a
+                          href={cost.voucher_url}
+                          target="_blank"
+                          rel="noreferrer"
+                          className="px-2 py-0.5 bg-white hover:bg-amber-300 text-black border border-black text-[10px] font-bold shadow-[1px_1px_0px_#000] inline-flex items-center gap-1"
+                        >
+                          <span>查看凭证</span>
+                          <ExternalLink size={10} />
+                        </a>
+                      ) : (
+                        <span className="text-neutral-400 text-[10px]">-</span>
+                      )}
+                    </td>
+
+                    {/* Created by */}
+                    <td className="px-4 py-3.5 text-right whitespace-nowrap">
+                      <span className="text-xs font-bold text-black font-mono">
+                        {cost.created_by}
+                      </span>
+                    </td>
+                  </tr>
+                ))
+              )}
+            </tbody>
+          </table>
+        </div>
+      </div>
+
+      {/* 录入耗材弹窗 */}
+      {isModalOpen && (
+        <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-grayscale">
+          <div className="bg-white border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100">
+            {/* Header */}
+            <div className="bg-neutral-200 px-5 py-3 border-b-2 border-black flex items-center justify-between">
+              <div className="flex items-center gap-2">
+                <Receipt size={16} className="text-black" />
+                <h3 className="text-xs font-black uppercase text-black">
+                  [ RECORD COST // 录入运行耗材支出 ]
+                </h3>
+              </div>
+              <button
+                onClick={() => setIsModalOpen(false)}
+                className="w-6 h-6 border border-black bg-white hover:bg-rose-100 flex items-center justify-center text-xs font-black shadow-[1px_1px_0px_#000]"
+              >
+                ✕
+              </button>
+            </div>
+
+            {/* Form */}
+            <form onSubmit={handleSubmit} className="p-5 space-y-4 text-xs">
+              <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 耗材类别 ] <span className="text-rose-600">*</span>
+                  </label>
+                  <select
+                    value={category}
+                    onChange={(e) => setCategory(e.target.value as CostCategory)}
+                    className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  >
+                    <option value="vps">海外 VPS 服务器</option>
+                    <option value="proxy_ip">高匿代理 IP 池</option>
+                    <option value="captcha_api">自动打码平台 API</option>
+                    <option value="sms_api">短信接码平台 API</option>
+                    <option value="other">其他杂项支出</option>
+                  </select>
+                </div>
+
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 支出金额 (元) ] <span className="text-rose-600">*</span>
+                  </label>
+                  <div className="relative">
+                    <span className="absolute left-2.5 top-2 font-bold">¥</span>
+                    <input
+                      type="number"
+                      step="0.01"
+                      required
+                      value={amountYuan}
+                      onChange={(e) => setAmountYuan(e.target.value)}
+                      placeholder="0.00"
+                      className="w-full pl-7 pr-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                    />
+                  </div>
+                </div>
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 实际扣款 / 充值发生时间 ]
+                </label>
+                <input
+                  type="datetime-local"
+                  value={paidAt}
+                  onChange={(e) => setPaidAt(e.target.value)}
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 支出用途 / 充值订单说明 ]
+                </label>
+                <input
+                  type="text"
+                  value={description}
+                  onChange={(e) => setDescription(e.target.value)}
+                  placeholder="例如: 9月份德国法兰克福代理IP池扩容50G流量"
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 扣款凭证或发票截图 URL ]
+                </label>
+                <input
+                  type="url"
+                  value={voucherUrl}
+                  onChange={(e) => setVoucherUrl(e.target.value)}
+                  placeholder="https://..."
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              {/* Footer */}
+              <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex items-center justify-end gap-2">
+                <button
+                  type="button"
+                  onClick={() => setIsModalOpen(false)}
+                  className="px-4 py-2 bg-neutral-100 hover:bg-neutral-200 border-2 border-black font-bold text-xs uppercase"
+                >
+                  [ 取消 ]
+                </button>
+                <button
+                  type="submit"
+                  disabled={submitting}
+                  className="px-5 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase disabled:opacity-50"
+                >
+                  {submitting ? '[ 正在录入... ]' : '[ 确认录入支出 ]'}
+                </button>
+              </div>
+            </form>
+          </div>
+        </div>
+      )}
+    </div>
+  );
+}

+ 363 - 0
src/components/admin/settlement/FaultCompensationsTab.tsx

@@ -0,0 +1,363 @@
+// src/components/admin/settlement/FaultCompensationsTab.tsx
+'use client';
+
+import { useState, useEffect } from 'react';
+import {
+  AlertTriangle,
+  Plus,
+  RefreshCw,
+  UserX,
+  FileText,
+  ShieldCheck,
+  CheckCircle,
+} from 'lucide-react';
+import { settlementService } from '@/lib/services';
+import { VasFaultRecord, VasFaultCreatePayload } from '@/types';
+import { toast } from 'react-hot-toast';
+import LocalTime from '@/components/common/LocalTime';
+
+export default function FaultCompensationsTab() {
+  const [faults, setFaults] = useState<VasFaultRecord[]>([]);
+  const [loading, setLoading] = useState(false);
+  const [isModalOpen, setIsModalOpen] = useState(false);
+
+  // Form State
+  const [orderId, setOrderId] = useState('');
+  const [liableUserId, setLiableUserId] = useState('');
+  const [penaltyYuan, setPenaltyYuan] = useState('');
+  const [reason, setReason] = useState('');
+  const [notes, setNotes] = useState('');
+  const [submitting, setSubmitting] = useState(false);
+
+  const fetchFaults = async () => {
+    setLoading(true);
+    try {
+      const res = await settlementService.listFaults({ page: 0, size: 100 });
+      const items = res?.data?.items || res?.data || [];
+      setFaults(Array.isArray(items) ? items : []);
+    } catch {
+      toast.error('加载过错赔偿记录失败');
+    } finally {
+      setLoading(false);
+    }
+  };
+
+  useEffect(() => {
+    fetchFaults();
+  }, []);
+
+  const openCreateModal = () => {
+    setOrderId('');
+    setLiableUserId('');
+    setPenaltyYuan('');
+    setReason('');
+    setNotes('');
+    setIsModalOpen(true);
+  };
+
+  const handleSubmit = async (e: React.FormEvent) => {
+    e.preventDefault();
+    if (!orderId.trim()) return toast.error('请输入关联订单ID');
+    if (!liableUserId.trim()) return toast.error('请输入过失责任人用户ID');
+    if (!reason.trim()) return toast.error('请输入录错原因');
+
+    const penaltyCents = Math.round(Number(penaltyYuan || 0) * 100);
+    if (isNaN(penaltyCents) || penaltyCents <= 0) {
+      return toast.error('请输入有效的个人赔偿/罚款金额');
+    }
+
+    setSubmitting(true);
+    try {
+      const payload: VasFaultCreatePayload = {
+        order_id: orderId.trim(),
+        liable_user_id: liableUserId.trim(),
+        penalty_amount: penaltyCents,
+        reason: reason.trim(),
+        notes: notes.trim() || undefined,
+      };
+      await settlementService.createFault(payload);
+      toast.success('过失赔偿罚单已登记,将在账期结算时从该人提成中全额扣减');
+      setIsModalOpen(false);
+      fetchFaults();
+    } catch (err: any) {
+      toast.error('登记失败: ' + (err.response?.data?.message || err.message));
+    } finally {
+      setSubmitting(false);
+    }
+  };
+
+  return (
+    <div className="space-y-6 font-mono">
+      {/* 顶部操作与包干赔偿规则看板 */}
+      <div className="bg-rose-50 border-2 border-black p-5 shadow-[4px_4px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-4">
+        <div>
+          <div className="flex items-center gap-2">
+            <AlertTriangle size={18} className="text-rose-600" />
+            <h2 className="text-sm font-black uppercase text-black">
+              [ FAULT COMPENSATIONS // 个人录错惩罚与全额冲销台账 ]
+            </h2>
+          </div>
+          <p className="text-[11px] text-neutral-700 font-sans mt-1">
+            <strong>核心制度约束</strong>:无论是自收直客还是中介渠道,接单人独占该单 40% 销售包干提成,必须对信息准确性负全责;
+            凡因护照号、姓名拼音录错导致的废单损失,<strong>全额从该责任人当期销售提成中扣减,严禁动用公款或计入公共成本</strong>。
+          </p>
+        </div>
+
+        <div className="flex items-center gap-2 shrink-0">
+          <button
+            onClick={fetchFaults}
+            disabled={loading}
+            className="px-3 py-1.5 bg-white hover:bg-neutral-100 border-2 border-black text-xs font-bold shadow-[2px_2px_0px_#000] flex items-center gap-1 active:translate-x-0.5 active:translate-y-0.5 uppercase"
+          >
+            <RefreshCw size={13} className={loading ? 'animate-spin' : ''} />
+            <span>[ 刷新 ]</span>
+          </button>
+          <button
+            onClick={openCreateModal}
+            className="px-4 py-1.5 bg-rose-200 hover:bg-rose-300 text-rose-950 border-2 border-black text-xs font-black shadow-[2px_2px_0px_#000] flex items-center gap-1.5 active:translate-x-0.5 active:translate-y-0.5 uppercase"
+          >
+            <Plus size={14} />
+            <span>[ 登记个人录错事件 ]</span>
+          </button>
+        </div>
+      </div>
+
+      {/* 赔偿记录表格 */}
+      <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
+        <div className="overflow-x-auto">
+          <table className="min-w-full divide-y-2 divide-black text-left">
+            <thead className="bg-neutral-100 border-b-2 border-black">
+              <tr>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 罚单编号 / 关联订单号 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 过失责任人 (从其40%提成扣减) ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 个人全额承担扣款金额 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 录错原因与失误细节 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 冲销扣款状态 ]
+                </th>
+                <th className="px-4 py-3 text-xs font-black text-black uppercase tracking-wider">
+                  [ 抵扣结算账期 ]
+                </th>
+                <th className="px-4 py-3 text-right text-xs font-black text-black uppercase tracking-wider">
+                  [ 登记时间 ]
+                </th>
+              </tr>
+            </thead>
+            <tbody className="bg-white divide-y border-t-2 border-black">
+              {faults.length === 0 ? (
+                <tr>
+                  <td colSpan={7} className="px-4 py-12 text-center text-neutral-400 text-xs">
+                    {loading ? '[ 正在读取录错过失罚单... ]' : '[ 暂无个人录错记录,团队零失误运行中 ]'}
+                  </td>
+                </tr>
+              ) : (
+                faults.map((fault) => (
+                  <tr key={fault.id} className="hover:bg-rose-50/50 transition">
+                    {/* ID */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="flex flex-col">
+                        <span className="text-xs font-black text-black font-mono">
+                          FAULT #{fault.id}
+                        </span>
+                        <span className="text-[10px] text-neutral-500 font-mono mt-0.5">
+                          单号: #{fault.order_id}
+                        </span>
+                      </div>
+                    </td>
+
+                    {/* Liable User */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="flex items-center gap-1.5">
+                        <UserX size={13} className="text-rose-600" />
+                        <span className="text-xs font-black text-rose-800 font-mono">
+                          {fault.liable_user_id}
+                        </span>
+                      </div>
+                      <span className="text-[9px] text-neutral-500 mt-0.5 block">
+                        从该人销售提成全额扣减
+                      </span>
+                    </td>
+
+                    {/* Penalty */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <span className="text-xs font-black text-rose-600 font-mono">
+                        -¥{(fault.penalty_amount / 100).toFixed(2)}
+                      </span>
+                    </td>
+
+                    {/* Reason */}
+                    <td className="px-4 py-3.5 max-w-[240px]">
+                      <div className="text-xs font-bold text-black font-sans">
+                        {fault.reason}
+                      </div>
+                      {fault.notes && (
+                        <div className="text-[10px] text-neutral-500 font-sans truncate">
+                          {fault.notes}
+                        </div>
+                      )}
+                    </td>
+
+                    {/* Status */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      {fault.deducted_status === 1 ? (
+                        <span className="px-2 py-0.5 bg-black text-white border border-black font-mono font-bold text-[10px]">
+                          ✓ 已从提成扣除
+                        </span>
+                      ) : (
+                        <span className="px-2 py-0.5 bg-amber-200 text-black border border-black font-mono font-bold text-[10px]">
+                          ⏳ 待期末冲销
+                        </span>
+                      )}
+                    </td>
+
+                    {/* Period */}
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <span className="text-xs font-mono font-bold text-neutral-700">
+                        {fault.period_id || '待分配账期'}
+                      </span>
+                    </td>
+
+                    {/* Created at */}
+                    <td className="px-4 py-3.5 text-right whitespace-nowrap text-xs text-neutral-500">
+                      <LocalTime date={fault.created_at} />
+                    </td>
+                  </tr>
+                ))
+              )}
+            </tbody>
+          </table>
+        </div>
+      </div>
+
+      {/* 登记录错弹窗 */}
+      {isModalOpen && (
+        <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-grayscale">
+          <div className="bg-white border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100">
+            {/* Header */}
+            <div className="bg-rose-100 px-5 py-3 border-b-2 border-black flex items-center justify-between">
+              <div className="flex items-center gap-2">
+                <AlertTriangle size={16} className="text-rose-700" />
+                <h3 className="text-xs font-black uppercase text-black">
+                  [ REPORT FAULT // 登记录错过失与赔偿损失 ]
+                </h3>
+              </div>
+              <button
+                onClick={() => setIsModalOpen(false)}
+                className="w-6 h-6 border border-black bg-white hover:bg-rose-100 flex items-center justify-center text-xs font-black shadow-[1px_1px_0px_#000]"
+              >
+                ✕
+              </button>
+            </div>
+
+            {/* Form */}
+            <form onSubmit={handleSubmit} className="p-5 space-y-4 text-xs">
+              <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 关联订单流水号 ] <span className="text-rose-600">*</span>
+                  </label>
+                  <input
+                    type="text"
+                    required
+                    value={orderId}
+                    onChange={(e) => setOrderId(e.target.value)}
+                    placeholder="输入订单单号"
+                    className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  />
+                </div>
+
+                <div>
+                  <label className="font-black text-black uppercase block mb-1">
+                    [ 过失责任人 ID ] <span className="text-rose-600">*</span>
+                  </label>
+                  <input
+                    type="text"
+                    required
+                    value={liableUserId}
+                    onChange={(e) => setLiableUserId(e.target.value)}
+                    placeholder="该单负责接单录入人ID"
+                    className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  />
+                </div>
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 应由个人全额承担的废单赔偿损失 (元) ] <span className="text-rose-600">*</span>
+                </label>
+                <div className="relative">
+                  <span className="absolute left-2.5 top-2 font-bold text-rose-600">¥</span>
+                  <input
+                    type="number"
+                    step="0.01"
+                    required
+                    value={penaltyYuan}
+                    onChange={(e) => setPenaltyYuan(e.target.value)}
+                    placeholder="0.00"
+                    className="w-full pl-7 pr-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold text-rose-600 focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                  />
+                </div>
+                <span className="text-[10px] text-neutral-500 font-mono mt-0.5 block">
+                  此损失将从责任人当期 40% 销售提成中扣除,绝不动用合伙公款。
+                </span>
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 录错原因与失误原因描述 ] <span className="text-rose-600">*</span>
+                </label>
+                <input
+                  type="text"
+                  required
+                  value={reason}
+                  onChange={(e) => setReason(e.target.value)}
+                  placeholder="例如: 护照号末尾数字录反导致使馆出签作废"
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 事故补充说明 / 客户协商说明 ]
+                </label>
+                <textarea
+                  rows={2}
+                  value={notes}
+                  onChange={(e) => setNotes(e.target.value)}
+                  placeholder="已向客户致歉并补录新单重新抢号..."
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              {/* Footer */}
+              <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex items-center justify-end gap-2">
+                <button
+                  type="button"
+                  onClick={() => setIsModalOpen(false)}
+                  className="px-4 py-2 bg-neutral-100 hover:bg-neutral-200 border-2 border-black font-bold text-xs uppercase"
+                >
+                  [ 取消 ]
+                </button>
+                <button
+                  type="submit"
+                  disabled={submitting}
+                  className="px-5 py-2 bg-rose-200 hover:bg-rose-300 text-rose-950 border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase disabled:opacity-50"
+                >
+                  {submitting ? '[ 登记中... ]' : '[ 确认登记罚单 ]'}
+                </button>
+              </div>
+            </form>
+          </div>
+        </div>
+      )}
+    </div>
+  );
+}

+ 750 - 0
src/components/admin/settlement/SettlementEngineTab.tsx

@@ -0,0 +1,750 @@
+// src/components/admin/settlement/SettlementEngineTab.tsx
+'use client';
+
+import { useState, useEffect } from 'react';
+import {
+  Calculator,
+  Play,
+  CheckCircle,
+  FileSpreadsheet,
+  Calendar,
+  Users,
+  ShieldAlert,
+  ArrowRight,
+  Receipt,
+  Download,
+  Eye,
+  RefreshCw,
+  Settings2,
+  ChevronDown,
+  ChevronUp,
+  Check,
+} from 'lucide-react';
+import { settlementService } from '@/lib/services';
+import {
+  SettlementPeriod,
+  SettlementPreviewRequest,
+  SettlementConfirmRequest,
+  SettlementPreviewResponse,
+  SettlementOrderDetail,
+} from '@/types';
+import { toast } from 'react-hot-toast';
+import { retroConfirm } from '@/lib/dialog';
+import SettlementPeriodDetailModal from './SettlementPeriodDetailModal';
+import LocalTime from '@/components/common/LocalTime';
+import AdminUserSelect from '@/components/common/AdminUserSelect';
+
+export default function SettlementEngineTab() {
+  // Preset State: 'current_month' | 'last_month' | 'custom'
+  const [activePreset, setActivePreset] = useState<'current_month' | 'last_month' | 'custom'>('current_month');
+
+  // Dates
+  const [startDate, setStartDate] = useState('');
+  const [endDate, setEndDate] = useState('');
+
+  // Partner Accounts (Persisted in localStorage with sensible defaults)
+  const [partnerAId, setPartnerAId] = useState('partner_a');
+  const [partnerBId, setPartnerBId] = useState('partner_b');
+  const [showAccountConfig, setShowAccountConfig] = useState(false);
+
+  // Preview State
+  const [previewLoading, setPreviewLoading] = useState(false);
+  const [previewResult, setPreviewResult] = useState<SettlementPreviewResponse | null>(null);
+  const [showOrderDetails, setShowOrderDetails] = useState(false);
+
+  // Confirm Modal State
+  const [isConfirmModalOpen, setIsConfirmModalOpen] = useState(false);
+  const [periodId, setPeriodId] = useState('');
+  const [periodName, setPeriodName] = useState('');
+  const [notes, setNotes] = useState('');
+  const [confirming, setConfirming] = useState(false);
+
+  // Past Periods
+  const [periods, setPeriods] = useState<SettlementPeriod[]>([]);
+  const [loadingPeriods, setLoadingPeriods] = useState(false);
+  const [selectedPeriod, setSelectedPeriod] = useState<SettlementPeriod | null>(null);
+  const [isDetailModalOpen, setIsDetailModalOpen] = useState(false);
+
+  // Initialize dates and saved partner accounts
+  useEffect(() => {
+    // 1. 读取保存的合伙人账户绑定,若未配置则使用默认值
+    const savedA = localStorage.getItem('settlement_partner_a');
+    const savedB = localStorage.getItem('settlement_partner_b');
+    if (savedA) setPartnerAId(savedA);
+    if (savedB) setPartnerBId(savedB);
+
+    // 2. 默认选择当月月结
+    handlePresetCurrentMonth();
+    fetchPeriods();
+  }, []);
+
+  const handlePresetCurrentMonth = () => {
+    setActivePreset('current_month');
+    const now = new Date();
+    const year = now.getFullYear();
+    const month = String(now.getMonth() + 1).padStart(2, '0');
+    setStartDate(`${year}-${month}-01T00:00`);
+    setEndDate(now.toISOString().slice(0, 16));
+    setPeriodId(`${year}-${month}`);
+    setPeriodName(`${year}年${Number(month)}月度财务结算`);
+  };
+
+  const handlePresetLastMonth = () => {
+    setActivePreset('last_month');
+    const now = new Date();
+    const firstDayPrevMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
+    const lastDayPrevMonth = new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59);
+    const year = firstDayPrevMonth.getFullYear();
+    const month = String(firstDayPrevMonth.getMonth() + 1).padStart(2, '0');
+    setStartDate(`${year}-${month}-01T00:00`);
+    setEndDate(lastDayPrevMonth.toISOString().slice(0, 16));
+    setPeriodId(`${year}-${month}`);
+    setPeriodName(`${year}年${Number(month)}月度财务结算`);
+  };
+
+  const handleSaveAccountConfig = (e: React.FormEvent) => {
+    e.preventDefault();
+    if (!partnerAId.trim() || !partnerBId.trim()) {
+      return toast.error('合伙人甲方与乙方标识不能为空');
+    }
+    localStorage.setItem('settlement_partner_a', partnerAId.trim());
+    localStorage.setItem('settlement_partner_b', partnerBId.trim());
+    toast.success('合伙分润账户配置已保存');
+    setShowAccountConfig(false);
+  };
+
+  const fetchPeriods = async () => {
+    setLoadingPeriods(true);
+    try {
+      const res = await settlementService.listPeriods({ page: 0, size: 50 });
+      const items = res?.data?.items || res?.data || [];
+      setPeriods(Array.isArray(items) ? items : []);
+    } catch {
+      toast.error('获取历史结算账期列表失败');
+    } finally {
+      setLoadingPeriods(false);
+    }
+  };
+
+  const handleCalculatePreview = async (e: React.FormEvent) => {
+    e.preventDefault();
+    if (!startDate || !endDate) return toast.error('请选择账期起止时间');
+
+    setPreviewLoading(true);
+    try {
+      const payload: SettlementPreviewRequest = {
+        start_date: new Date(startDate).toISOString(),
+        end_date: new Date(endDate).toISOString(),
+        partner_a_id: partnerAId.trim() || 'partner_a',
+        partner_b_id: partnerBId.trim() || 'partner_b',
+      };
+      const res = await settlementService.previewSettlement(payload);
+      const data = res?.data || res;
+      setPreviewResult(data);
+      if (data.total_orders === 0) {
+        toast('当前选定日期区间内暂无已履约且满 T+7 风险期的可结算订单', { icon: 'ℹ️' });
+      } else {
+        toast.success(`试算完成!汇总待结算订单 ${data.total_orders} 笔`);
+      }
+    } catch (err: any) {
+      toast.error('试算分润失败: ' + (err.response?.data?.message || err.message));
+    } finally {
+      setPreviewLoading(false);
+    }
+  };
+
+  const handleOpenConfirmModal = () => {
+    if (!previewResult) return;
+    setIsConfirmModalOpen(true);
+  };
+
+  const handleConfirmSettlement = async (e: React.FormEvent) => {
+    e.preventDefault();
+    if (!periodId.trim()) return toast.error('请输入账期ID (如 2026-10)');
+    if (!periodName.trim()) return toast.error('请输入账期显示名称');
+
+    const ok = await retroConfirm({
+      title: '[ CONFIRM // 正式固化结算账期 ]',
+      message: `确定要固化账期 [${periodName}] 吗?确认后涉及的 ${previewResult?.total_orders} 笔订单将置为已结清状态(settled),快照将永久不可篡改。`,
+      type: 'warning',
+      confirmText: '[ 确认冻结归档 ]',
+    });
+    if (!ok) return;
+
+    setConfirming(true);
+    try {
+      const payload: SettlementConfirmRequest = {
+        start_date: new Date(startDate).toISOString(),
+        end_date: new Date(endDate).toISOString(),
+        partner_a_id: partnerAId.trim(),
+        partner_b_id: partnerBId.trim(),
+        period_id: periodId.trim(),
+        period_name: periodName.trim(),
+        notes: notes.trim() || undefined,
+      };
+
+      await settlementService.confirmSettlement(payload);
+      toast.success(`账期 [${periodName}] 已成功固化并写入不可篡改对账快照!`);
+      setIsConfirmModalOpen(false);
+      setPreviewResult(null);
+      fetchPeriods();
+    } catch (err: any) {
+      toast.error('固化结算单失败: ' + (err.response?.data?.message || err.message));
+    } finally {
+      setConfirming(false);
+    }
+  };
+
+  const handleViewArchivedPeriod = (p: SettlementPeriod) => {
+    setSelectedPeriod(p);
+    setIsDetailModalOpen(true);
+  };
+
+  return (
+    <div className="space-y-6 font-mono">
+      {/* 结算试算配置面板 */}
+      <form onSubmit={handleCalculatePreview} className="bg-white border-2 border-black p-5 shadow-[4px_4px_0px_#000] space-y-4">
+        <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3 border-b-2 border-black pb-3">
+          <div className="flex items-center gap-2">
+            <Calculator size={18} className="text-black" />
+            <h2 className="text-sm font-black uppercase text-black">
+              [ SETTLEMENT ENGINE // 账期分润清算引擎与试算预览 ]
+            </h2>
+          </div>
+          <span className="text-[10px] text-neutral-500 font-bold uppercase">
+            规则:40%合伙分红 + 40%销售提成(包干) + 20%技术版权 - 公摊耗材
+          </span>
+        </div>
+
+        {/* 快捷账期预设 & 核心日期选择 */}
+        <div className="space-y-3">
+          <div className="flex flex-wrap items-center gap-2 text-xs">
+            <span className="font-black text-neutral-600 uppercase text-[11px]">[ 快捷结算周期: ]</span>
+            <button
+              type="button"
+              onClick={handlePresetCurrentMonth}
+              className={`px-3 py-1 border-2 border-black font-bold uppercase transition shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 ${
+                activePreset === 'current_month'
+                  ? 'bg-amber-300 text-black'
+                  : 'bg-neutral-100 hover:bg-neutral-200 text-neutral-700'
+              }`}
+            >
+              📅 本月至今 (默认)
+            </button>
+            <button
+              type="button"
+              onClick={handlePresetLastMonth}
+              className={`px-3 py-1 border-2 border-black font-bold uppercase transition shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 ${
+                activePreset === 'last_month'
+                  ? 'bg-amber-300 text-black'
+                  : 'bg-neutral-100 hover:bg-neutral-200 text-neutral-700'
+              }`}
+            >
+              📅 上月整月
+            </button>
+            {activePreset === 'custom' && (
+              <span className="px-2 py-0.5 bg-neutral-200 border border-black text-[10px] font-bold text-neutral-600">
+                自定义起止时间
+              </span>
+            )}
+          </div>
+
+          <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 text-xs items-end">
+            <div>
+              <label className="font-black text-black uppercase block mb-1">
+                [ 账期起始时间 ] <span className="text-rose-600">*</span>
+              </label>
+              <input
+                type="datetime-local"
+                required
+                value={startDate}
+                onChange={(e) => {
+                  setStartDate(e.target.value);
+                  setActivePreset('custom');
+                }}
+                className="w-full px-2.5 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+              />
+            </div>
+
+            <div>
+              <label className="font-black text-black uppercase block mb-1">
+                [ 账期结束时间 ] <span className="text-rose-600">*</span>
+              </label>
+              <input
+                type="datetime-local"
+                required
+                value={endDate}
+                onChange={(e) => {
+                  setEndDate(e.target.value);
+                  setActivePreset('custom');
+                }}
+                className="w-full px-2.5 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+              />
+            </div>
+
+            <div className="flex items-center">
+              <button
+                type="submit"
+                disabled={previewLoading}
+                className="w-full py-2.5 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase flex items-center justify-center gap-2 shrink-0 disabled:opacity-50"
+              >
+                <Play size={14} className={previewLoading ? 'animate-spin' : ''} />
+                <span>{previewLoading ? '[ 正在执行分润试算... ]' : '[ 开始期末分润试算 (PREVIEW) ]'}</span>
+              </button>
+            </div>
+          </div>
+        </div>
+
+        {/* 分润账户绑定状态条 (折叠式配置) */}
+        <div className="bg-neutral-50 border border-neutral-300 p-2.5 text-xs flex flex-wrap items-center justify-between gap-2">
+          <div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-neutral-600">
+            <span className="font-bold text-black flex items-center gap-1">
+              <Users size={13} className="text-neutral-700" />
+              结算分成归属规则:
+            </span>
+            <span>
+              甲方合伙分红(20%): <strong className="text-black font-mono">{partnerAId}</strong>
+            </span>
+            <span>
+              乙方合伙分红(20%): <strong className="text-black font-mono">{partnerBId}</strong>
+            </span>
+            <span>
+              技术版权(20%): <strong className="text-emerald-700 font-bold">按订单商品插件开发管理者自动归属</strong>
+            </span>
+            <span className="text-neutral-400">| 销售提成(40%): 各订单独立对接人</span>
+          </div>
+
+          <button
+            type="button"
+            onClick={() => setShowAccountConfig(!showAccountConfig)}
+            className="px-2.5 py-1 bg-white hover:bg-neutral-100 border border-black font-bold text-[11px] flex items-center gap-1 shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5"
+          >
+            <Settings2 size={12} />
+            <span>{showAccountConfig ? '[ 收起配置 ▲ ]' : '[ ⚙️ 配置合伙账户 ]'}</span>
+          </button>
+        </div>
+
+        {/* 折叠的合伙人账户配置表单 */}
+        {showAccountConfig && (
+          <div className="p-4 bg-amber-50 border-2 border-black space-y-3 animate-in fade-in slide-in-from-top-2 duration-150">
+            <div className="flex items-center justify-between">
+              <div className="flex items-center gap-2">
+                <Settings2 size={15} className="text-black" />
+                <span className="font-black text-xs uppercase text-black">
+                  [ 合伙人甲乙双方账户配置与本地固化 ]
+                </span>
+              </div>
+              <span className="text-[10px] text-neutral-500">
+                配置将保存在本地浏览器中,试算与结算时自动生效
+              </span>
+            </div>
+
+            <div className="grid grid-cols-1 sm:grid-cols-2 gap-4 text-xs">
+              <AdminUserSelect
+                label="甲方合伙人账户"
+                badgeText="享有 20% 运营合伙分成"
+                required
+                value={partnerAId}
+                onChange={setPartnerAId}
+                placeholder="选择甲方管理员账户或输入ID"
+                helperText="合作者均为系统管理员身份。享有当期合伙人资金池 50%(全单总利润 20%)分润打款。"
+              />
+
+              <AdminUserSelect
+                label="乙方合伙人账户"
+                badgeText="享有 20% 运营合伙分成"
+                required
+                value={partnerBId}
+                onChange={setPartnerBId}
+                placeholder="选择乙方管理员账户或输入ID"
+                helperText="合作者均为系统管理员身份。享有当期合伙人资金池 50%(全单总利润 20%)分润打款。"
+              />
+            </div>
+
+            <div className="p-2.5 bg-neutral-100 border border-black text-[11px] text-neutral-600 font-sans">
+              ℹ️ <strong>技术分成自动归属说明</strong>:每一个商品 (Product) 均绑定了底层履约插件,插件由管理者开发。结算引擎在试算时会顺着 <code>订单 -&gt; 商品 -&gt; 插件 -&gt; 插件开发管理者</code> 链路自动将对应订单的 20% 技术版权费打款给对应的技术管理者,支持不同商品/插件由不同技术人员独立分润。
+            </div>
+
+            <div className="flex items-center justify-end gap-2 pt-1">
+              <button
+                type="button"
+                onClick={handleSaveAccountConfig}
+                className="px-4 py-1.5 bg-black text-white hover:bg-neutral-800 border-2 border-black font-bold text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 flex items-center gap-1.5 uppercase"
+              >
+                <Check size={12} className="text-emerald-400" />
+                <span>保存合伙账户配置</span>
+              </button>
+            </div>
+          </div>
+        )}
+      </form>
+
+      {/* 试算结果展示区 */}
+      {previewResult && (
+        <div className="space-y-5 animate-in fade-in zoom-in-95 duration-150">
+          {/* 1. KPI Cards */}
+          <div className="grid grid-cols-2 sm:grid-cols-5 gap-3">
+            <div className="bg-white border-2 border-black p-4 shadow-[3px_3px_0px_#000]">
+              <span className="text-[10px] text-neutral-500 uppercase font-black block">合格订单总数</span>
+              <div className="text-xl font-black text-black mt-1">
+                {previewResult.total_orders} 笔
+              </div>
+              <span className="text-[9px] text-emerald-700 font-bold block mt-0.5">已过退款风险期</span>
+            </div>
+
+            <div className="bg-white border-2 border-black p-4 shadow-[3px_3px_0px_#000]">
+              <span className="text-[10px] text-neutral-500 uppercase font-black block">订单实收总营业额</span>
+              <div className="text-xl font-black text-black mt-1">
+                ¥{(previewResult.total_revenue / 100).toFixed(2)}
+              </div>
+              <span className="text-[9px] text-neutral-400 block mt-0.5">合伙公账统一收入</span>
+            </div>
+
+            <div className="bg-white border-2 border-black p-4 shadow-[3px_3px_0px_#000]">
+              <span className="text-[10px] text-neutral-500 uppercase font-black block">当期公共耗材支出</span>
+              <div className="text-xl font-black text-rose-600 mt-1">
+                -¥{(previewResult.total_cost / 100).toFixed(2)}
+              </div>
+              <span className="text-[9px] text-neutral-400 block mt-0.5">VPS+代理IP+打码API</span>
+            </div>
+
+            <div className="bg-white border-2 border-black p-4 shadow-[3px_3px_0px_#000]">
+              <span className="text-[10px] text-neutral-500 uppercase font-black block">单均公摊耗材成本</span>
+              <div className="text-xl font-black text-amber-700 mt-1">
+                ¥{(previewResult.avg_cost / 100).toFixed(2)}
+              </div>
+              <span className="text-[9px] text-neutral-400 block mt-0.5">每单均摊成本</span>
+            </div>
+
+            <div className="bg-amber-100 border-2 border-black p-4 shadow-[3px_3px_0px_#000] col-span-2 sm:col-span-1">
+              <span className="text-[10px] text-neutral-600 uppercase font-black block">全平台可分配净毛利</span>
+              <div className="text-xl font-black text-black mt-1">
+                ¥{(previewResult.net_profit / 100).toFixed(2)}
+              </div>
+              <span className="text-[9px] text-neutral-700 font-bold block mt-0.5">实收 - 耗材</span>
+            </div>
+          </div>
+
+          {/* 2. Payout Table: 分润打款清单 */}
+          <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
+            <div className="bg-neutral-200 px-5 py-3 border-b-2 border-black flex items-center justify-between">
+              <div className="flex items-center gap-2">
+                <Users size={16} className="text-black" />
+                <h3 className="text-xs font-black uppercase text-black">
+                  [ PAYOUT SUMMARY // 4方分润打款与冲销清算总表 ]
+                </h3>
+              </div>
+              <span className="text-[10px] text-neutral-600 font-mono">
+                公账统支 | 个人过错全额抵扣提成
+              </span>
+            </div>
+
+            <div className="overflow-x-auto">
+              <table className="min-w-full divide-y-2 divide-black text-left text-xs">
+                <thead className="bg-neutral-100 border-b-2 border-black">
+                  <tr>
+                    <th className="px-4 py-3 font-black text-black uppercase">[ 分润归属人 ID ]</th>
+                    <th className="px-4 py-3 font-black text-black uppercase">[ 参与角色与分成逻辑 ]</th>
+                    <th className="px-4 py-3 font-black text-black uppercase">[ 理论应得分润金额 ]</th>
+                    <th className="px-4 py-3 font-black text-black uppercase">[ 录错过失冲销抵扣 ]</th>
+                    <th className="px-4 py-3 font-black text-black uppercase bg-amber-100">[ 实际最终到手打款 (NET) ]</th>
+                  </tr>
+                </thead>
+                <tbody className="bg-white divide-y border-t-2 border-black">
+                  {previewResult.payout_summary.map((p, idx) => {
+                    let roleBadge = '销售/经办提成 (40%)';
+                    let roleBadgeClass = 'bg-purple-100 text-purple-900 border-purple-300';
+
+                    if (p.user_id === partnerAId || p.role_description.includes('甲方')) {
+                      roleBadge = '甲方合伙分红 (20%)';
+                      roleBadgeClass = 'bg-blue-100 text-blue-900 border-blue-400';
+                    } else if (p.user_id === partnerBId || p.role_description.includes('乙方')) {
+                      roleBadge = '乙方合伙分红 (20%)';
+                      roleBadgeClass = 'bg-amber-100 text-amber-900 border-amber-400';
+                    } else if (p.role_description.includes('技术') || p.user_id.includes('dev') || p.user_id.includes('plugin')) {
+                      roleBadge = '技术版权分成 (20% 插件开发)';
+                      roleBadgeClass = 'bg-emerald-100 text-emerald-900 border-emerald-400';
+                    }
+
+                    return (
+                      <tr key={idx} className="hover:bg-amber-50/50">
+                        <td className="px-4 py-3 font-mono">
+                          <div className="flex flex-col sm:flex-row sm:items-center gap-1.5">
+                            <span className="font-black text-black">{p.user_id}</span>
+                            <span className={`px-1.5 py-0.5 text-[10px] font-bold border rounded w-fit ${roleBadgeClass}`}>
+                              {roleBadge}
+                            </span>
+                          </div>
+                        </td>
+                        <td className="px-4 py-3 text-neutral-800 font-sans text-xs">
+                          {p.role_description}
+                        </td>
+                        <td className="px-4 py-3 font-bold font-mono">
+                          ¥{(p.gross_amount / 100).toFixed(2)}
+                        </td>
+                        <td className="px-4 py-3 font-bold font-mono text-rose-600">
+                          {p.fault_penalty > 0 ? `-¥${(p.fault_penalty / 100).toFixed(2)}` : '¥0.00'}
+                        </td>
+                        <td className="px-4 py-3 font-black font-mono text-emerald-800 bg-amber-50 text-sm">
+                          ¥{(p.net_payout / 100).toFixed(2)}
+                        </td>
+                      </tr>
+                    );
+                  })}
+                </tbody>
+              </table>
+            </div>
+
+            {/* 固化操作栏 */}
+            <div className="p-4 bg-neutral-100 border-t-2 border-black flex flex-col sm:flex-row sm:items-center justify-between gap-3">
+              <div className="text-[11px] text-neutral-600 font-sans">
+                确认无误后,点击右侧按钮冻结为不可篡改历史账期,系统将自动把相应订单标记为 <strong>已结算 (settled)</strong>。
+              </div>
+              <button
+                type="button"
+                onClick={handleOpenConfirmModal}
+                className="px-6 py-2.5 bg-black text-white hover:bg-neutral-800 border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase flex items-center justify-center gap-1.5 shrink-0"
+              >
+                <CheckCircle size={14} className="text-emerald-400" />
+                <span>[ 正式签署并冻结账期 (CONFIRM SNAPSHOT) ]</span>
+              </button>
+            </div>
+          </div>
+
+          {/* 3. 订单级利润透视表 (可展开) */}
+          <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
+            <div
+              onClick={() => setShowOrderDetails(!showOrderDetails)}
+              className="bg-neutral-100 px-5 py-3 border-b-2 border-black flex items-center justify-between cursor-pointer select-none hover:bg-neutral-200 transition"
+            >
+              <div className="flex items-center gap-2">
+                <FileSpreadsheet size={16} className="text-black" />
+                <h3 className="text-xs font-black uppercase text-black">
+                  [ ORDER BREAKDOWN // 订单级利润与分成透视明细 ({previewResult.details.length} 笔) ]
+                </h3>
+              </div>
+              <span className="text-xs font-bold text-neutral-600">
+                {showOrderDetails ? '[ 收起明细 ▲ ]' : '[ 展开明细 ▼ ]'}
+              </span>
+            </div>
+
+            {showOrderDetails && (
+              <div className="overflow-x-auto max-h-[400px]">
+                <table className="min-w-full divide-y-2 divide-black text-left text-xs font-mono">
+                  <thead className="bg-neutral-50 border-b border-black sticky top-0 z-10">
+                    <tr>
+                      <th className="px-3 py-2 font-bold">[ 订单流水号 ]</th>
+                      <th className="px-3 py-2 font-bold">[ 渠道 ]</th>
+                      <th className="px-3 py-2 font-bold">[ 对接人 ]</th>
+                      <th className="px-3 py-2 font-bold">[ 实收金额 ]</th>
+                      <th className="px-3 py-2 font-bold">[ 单均耗材 ]</th>
+                      <th className="px-3 py-2 font-bold">[ 单笔净利 ]</th>
+                      <th className="px-3 py-2 font-bold text-blue-700">[ 技术20% ]</th>
+                      <th className="px-3 py-2 font-bold text-purple-700">[ 销售40% ]</th>
+                      <th className="px-3 py-2 font-bold text-amber-700">[ 甲方分红 ]</th>
+                      <th className="px-3 py-2 font-bold text-amber-700">[ 乙方分红 ]</th>
+                    </tr>
+                  </thead>
+                  <tbody className="bg-white divide-y border-neutral-200">
+                    {previewResult.details.map((d) => (
+                      <tr key={d.order_id} className="hover:bg-amber-50/50">
+                        <td className="px-3 py-2 font-bold">#{d.order_id}</td>
+                        <td className="px-3 py-2">
+                          <span className="px-1 py-0.2 bg-neutral-100 border border-black text-[10px]">
+                            {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
+                          </span>
+                        </td>
+                        <td className="px-3 py-2 text-neutral-600">{d.handler_id || '-'}</td>
+                        <td className="px-3 py-2 font-bold">¥{(d.order_amount / 100).toFixed(2)}</td>
+                        <td className="px-3 py-2 text-rose-600">-¥{(d.avg_cost / 100).toFixed(2)}</td>
+                        <td className="px-3 py-2 font-black text-black">¥{(d.net_profit / 100).toFixed(2)}</td>
+                        <td className="px-3 py-2 text-blue-700">¥{(d.tech_fee / 100).toFixed(2)}</td>
+                        <td className="px-3 py-2 text-purple-700">¥{(d.sales_fee / 100).toFixed(2)}</td>
+                        <td className="px-3 py-2 text-amber-700">¥{(d.partner_a_amount / 100).toFixed(2)}</td>
+                        <td className="px-3 py-2 text-amber-700">¥{(d.partner_b_amount / 100).toFixed(2)}</td>
+                      </tr>
+                    ))}
+                  </tbody>
+                </table>
+              </div>
+            )}
+          </div>
+        </div>
+      )}
+
+      {/* 历史固化结算对账单列表 */}
+      <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
+        <div className="bg-neutral-100 px-5 py-3 border-b-2 border-black flex items-center justify-between">
+          <div className="flex items-center gap-2">
+            <Receipt size={16} className="text-black" />
+            <h3 className="text-xs font-black uppercase text-black">
+              [ SETTLEMENT ARCHIVES // 已固化历史结算对账快照 ]
+            </h3>
+          </div>
+          <button
+            onClick={fetchPeriods}
+            disabled={loadingPeriods}
+            className="px-2.5 py-1 bg-white hover:bg-neutral-200 border border-black text-[10px] font-bold shadow-[1px_1px_0px_#000] flex items-center gap-1"
+          >
+            <RefreshCw size={11} className={loadingPeriods ? 'animate-spin' : ''} />
+            <span>刷新历史</span>
+          </button>
+        </div>
+
+        <div className="overflow-x-auto">
+          <table className="min-w-full divide-y-2 divide-black text-left text-xs font-mono">
+            <thead className="bg-neutral-50 border-b-2 border-black">
+              <tr>
+                <th className="px-4 py-3 font-black text-black uppercase">[ 账期标识 / 名称 ]</th>
+                <th className="px-4 py-3 font-black text-black uppercase">[ 结算日期区间 ]</th>
+                <th className="px-4 py-3 font-black text-black uppercase">[ 订单量 ]</th>
+                <th className="px-4 py-3 font-black text-black uppercase">[ 实收营业额 ]</th>
+                <th className="px-4 py-3 font-black text-black uppercase">[ 公共耗材成本 ]</th>
+                <th className="px-4 py-3 font-black text-black uppercase">[ 净毛利 ]</th>
+                <th className="px-4 py-3 font-black text-black uppercase">[ 状态 ]</th>
+                <th className="px-4 py-3 text-right font-black text-black uppercase">[ 操作 ]</th>
+              </tr>
+            </thead>
+            <tbody className="bg-white divide-y border-t-2 border-black">
+              {periods.length === 0 ? (
+                <tr>
+                  <td colSpan={8} className="px-4 py-10 text-center text-neutral-400 text-xs">
+                    {loadingPeriods ? '[ 正在读取历史结算账期... ]' : '[ 暂无已归档结算账期 ]'}
+                  </td>
+                </tr>
+              ) : (
+                periods.map((p) => (
+                  <tr key={p.id} className="hover:bg-amber-50/50">
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <div className="font-black text-black">{p.name}</div>
+                      <div className="text-[10px] text-neutral-400 font-mono">ID: {p.id}</div>
+                    </td>
+                    <td className="px-4 py-3.5 whitespace-nowrap text-neutral-700 text-[11px]">
+                      <LocalTime date={p.start_date} /> ~ <LocalTime date={p.end_date} />
+                    </td>
+                    <td className="px-4 py-3.5 whitespace-nowrap font-bold text-black">
+                      {p.total_orders} 笔
+                    </td>
+                    <td className="px-4 py-3.5 whitespace-nowrap font-bold text-black">
+                      ¥{(p.total_revenue / 100).toFixed(2)}
+                    </td>
+                    <td className="px-4 py-3.5 whitespace-nowrap font-bold text-rose-600">
+                      -¥{(p.total_cost / 100).toFixed(2)}
+                    </td>
+                    <td className="px-4 py-3.5 whitespace-nowrap font-black text-emerald-700">
+                      ¥{(p.net_profit / 100).toFixed(2)}
+                    </td>
+                    <td className="px-4 py-3.5 whitespace-nowrap">
+                      <span className="px-2 py-0.5 bg-black text-white border border-black font-mono font-bold text-[10px]">
+                        ✓ {p.status === 'confirmed' ? '已确认归档' : p.status}
+                      </span>
+                    </td>
+                    <td className="px-4 py-3.5 text-right whitespace-nowrap">
+                      <button
+                        onClick={() => handleViewArchivedPeriod(p)}
+                        className="px-2.5 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-[11px] font-bold shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 inline-flex items-center gap-1 uppercase"
+                      >
+                        <Eye size={11} />
+                        <span>查阅对账快照</span>
+                      </button>
+                    </td>
+                  </tr>
+                ))
+              )}
+            </tbody>
+          </table>
+        </div>
+      </div>
+
+      {/* 确认固化弹窗 */}
+      {isConfirmModalOpen && (
+        <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-grayscale font-mono">
+          <div className="bg-white border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-md overflow-hidden animate-in fade-in zoom-in-95 duration-100">
+            <div className="bg-neutral-200 px-5 py-3 border-b-2 border-black flex items-center justify-between">
+              <h3 className="text-xs font-black uppercase text-black">
+                [ CONFIRM SETTLEMENT // 签署并冻结结算账期 ]
+              </h3>
+              <button
+                onClick={() => setIsConfirmModalOpen(false)}
+                className="w-6 h-6 border border-black bg-white hover:bg-rose-100 flex items-center justify-center text-xs font-black shadow-[1px_1px_0px_#000]"
+              >
+                ✕
+              </button>
+            </div>
+
+            <form onSubmit={handleConfirmSettlement} className="p-5 space-y-4 text-xs">
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 账期唯一标识 ID ] <span className="text-rose-600">*</span>
+                </label>
+                <input
+                  type="text"
+                  required
+                  value={periodId}
+                  onChange={(e) => setPeriodId(e.target.value)}
+                  placeholder="例如: 2026-10"
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 账期显示名称 ] <span className="text-rose-600">*</span>
+                </label>
+                <input
+                  type="text"
+                  required
+                  value={periodName}
+                  onChange={(e) => setPeriodName(e.target.value)}
+                  placeholder="例如: 2026年10月度财务月结"
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              <div>
+                <label className="font-black text-black uppercase block mb-1">
+                  [ 签署备注 / 公账打款说明 ]
+                </label>
+                <textarea
+                  rows={2}
+                  value={notes}
+                  onChange={(e) => setNotes(e.target.value)}
+                  placeholder="甲乙双方已核对无误,公账已执行银行打款..."
+                  className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono focus:bg-white outline-none shadow-[2px_2px_0px_#000]"
+                />
+              </div>
+
+              <div className="p-3 bg-amber-50 border border-black text-[11px] font-sans text-neutral-700">
+                <strong>注意</strong>:冻结后系统将锁定这 <strong>{previewResult?.total_orders}</strong> 笔订单状态为已结清,无法在此区间二次重复结算。
+              </div>
+
+              <div className="pt-3 border-t-2 border-dashed border-neutral-300 flex items-center justify-end gap-2">
+                <button
+                  type="button"
+                  onClick={() => setIsConfirmModalOpen(false)}
+                  className="px-4 py-2 bg-neutral-100 hover:bg-neutral-200 border-2 border-black font-bold text-xs uppercase"
+                >
+                  [ 取消 ]
+                </button>
+                <button
+                  type="submit"
+                  disabled={confirming}
+                  className="px-5 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 uppercase disabled:opacity-50"
+                >
+                  {confirming ? '[ 正在固化... ]' : '[ 确认并冻结归档 ]'}
+                </button>
+              </div>
+            </form>
+          </div>
+        </div>
+      )}
+
+      {/* 历史快照详情 Modal */}
+      <SettlementPeriodDetailModal
+        isOpen={isDetailModalOpen}
+        onClose={() => setIsDetailModalOpen(false)}
+        period={selectedPeriod}
+      />
+    </div>
+  );
+}

+ 207 - 0
src/components/admin/settlement/SettlementPeriodDetailModal.tsx

@@ -0,0 +1,207 @@
+// src/components/admin/settlement/SettlementPeriodDetailModal.tsx
+'use client';
+
+import { useState, useEffect } from 'react';
+import { SettlementPeriod, SettlementOrderDetail } from '@/types';
+import { settlementService } from '@/lib/services';
+import { X, Receipt, CheckCircle, ExternalLink, Download } from 'lucide-react';
+import LocalTime from '@/components/common/LocalTime';
+import { toast } from 'react-hot-toast';
+
+interface Props {
+  isOpen: boolean;
+  onClose: () => void;
+  period: SettlementPeriod | null;
+}
+
+export default function SettlementPeriodDetailModal({ isOpen, onClose, period }: Props) {
+  const [details, setDetails] = useState<SettlementOrderDetail[]>([]);
+  const [loading, setLoading] = useState(false);
+
+  useEffect(() => {
+    if (isOpen && period) {
+      fetchDetails(period.id);
+    } else {
+      setDetails([]);
+    }
+  }, [isOpen, period]);
+
+  const fetchDetails = async (periodId: string) => {
+    setLoading(true);
+    try {
+      const res = await settlementService.getPeriodDetails(periodId, { page: 0, size: 200 });
+      const items = res?.data?.items || res?.data || [];
+      setDetails(Array.isArray(items) ? items : []);
+    } catch {
+      toast.error('加载账期明细快照失败');
+    } finally {
+      setLoading(false);
+    }
+  };
+
+  if (!isOpen || !period) return null;
+
+  const summary = period.summary_data || {};
+  const payouts = summary.payout_summary || [];
+
+  return (
+    <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-grayscale font-mono">
+      <div className="bg-white border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-4xl max-h-[90vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-100">
+        {/* Header */}
+        <div className="bg-neutral-200 px-5 py-3 border-b-2 border-black flex items-center justify-between shrink-0">
+          <div className="flex items-center gap-2">
+            <Receipt size={16} className="text-black" />
+            <h3 className="text-xs font-black uppercase text-black">
+              [ ARCHIVED STATEMENT // 历史固化结算对账单快照: {period.name} ]
+            </h3>
+          </div>
+          <button
+            onClick={onClose}
+            className="w-6 h-6 border border-black bg-white hover:bg-rose-100 flex items-center justify-center text-xs font-black shadow-[1px_1px_0px_#000]"
+          >
+            ✕
+          </button>
+        </div>
+
+        {/* Scrollable Content */}
+        <div className="flex-1 overflow-y-auto p-5 space-y-5 bg-neutral-50">
+          {/* KPI Banner */}
+          <div className="bg-white border-2 border-black p-4 shadow-[3px_3px_0px_#000] grid grid-cols-2 sm:grid-cols-5 gap-3 text-center">
+            <div className="border-r-2 border-dashed border-neutral-300 pr-2">
+              <span className="text-[10px] text-neutral-500 font-bold block">账期编号</span>
+              <span className="text-xs font-black text-black">{period.id}</span>
+            </div>
+            <div className="border-r-2 border-dashed border-neutral-300 pr-2">
+              <span className="text-[10px] text-neutral-500 font-bold block">结算订单总数</span>
+              <span className="text-sm font-black text-black">{period.total_orders} 笔</span>
+            </div>
+            <div className="border-r-2 border-dashed border-neutral-300 pr-2">
+              <span className="text-[10px] text-neutral-500 font-bold block">实收总营业额</span>
+              <span className="text-sm font-black text-black">¥{(period.total_revenue / 100).toFixed(2)}</span>
+            </div>
+            <div className="border-r-2 border-dashed border-neutral-300 pr-2">
+              <span className="text-[10px] text-neutral-500 font-bold block">单均耗材成本</span>
+              <span className="text-sm font-black text-rose-600">¥{(period.avg_cost / 100).toFixed(2)}</span>
+            </div>
+            <div>
+              <span className="text-[10px] text-neutral-500 font-bold block">平台净毛利</span>
+              <span className="text-sm font-black text-emerald-700">¥{(period.net_profit / 100).toFixed(2)}</span>
+            </div>
+          </div>
+
+          {/* 打款清单 */}
+          {payouts.length > 0 && (
+            <div className="bg-white border-2 border-black shadow-[3px_3px_0px_#000] overflow-hidden">
+              <div className="bg-neutral-100 px-4 py-2 border-b-2 border-black text-xs font-black uppercase text-black">
+                [ 1. 最终签署打款分配清单 ]
+              </div>
+              <div className="overflow-x-auto">
+                <table className="min-w-full divide-y border-black text-left text-xs">
+                  <thead className="bg-neutral-50 border-b border-black">
+                    <tr>
+                      <th className="px-3 py-2 font-bold text-neutral-600">[ 参与方 ID ]</th>
+                      <th className="px-3 py-2 font-bold text-neutral-600">[ 角色分润类型 ]</th>
+                      <th className="px-3 py-2 font-bold text-neutral-600">[ 应得分润金额 ]</th>
+                      <th className="px-3 py-2 font-bold text-neutral-600">[ 过失录错冲销扣除 ]</th>
+                      <th className="px-3 py-2 font-black text-black">[ 实际最终到手转账 ]</th>
+                    </tr>
+                  </thead>
+                  <tbody className="divide-y border-neutral-200">
+                    {payouts.map((p: any, idx: number) => {
+                      let roleBadgeClass = 'bg-purple-100 text-purple-900 border-purple-300';
+                      if (p.role_description?.includes('甲方') || p.user_id?.includes('partner_a')) {
+                        roleBadgeClass = 'bg-blue-100 text-blue-900 border-blue-400';
+                      } else if (p.role_description?.includes('乙方') || p.user_id?.includes('partner_b')) {
+                        roleBadgeClass = 'bg-amber-100 text-amber-900 border-amber-400';
+                      } else if (p.role_description?.includes('技术') || p.user_id?.includes('developer')) {
+                        roleBadgeClass = 'bg-emerald-100 text-emerald-900 border-emerald-400';
+                      }
+
+                      return (
+                        <tr key={idx} className="hover:bg-neutral-50">
+                          <td className="px-3 py-2 font-mono">
+                            <span className="font-black text-black mr-1.5">{p.user_id}</span>
+                            <span className={`px-1.5 py-0.5 text-[9px] font-bold border rounded ${roleBadgeClass}`}>
+                              {p.role_description?.split(' ')[0] || '分润方'}
+                            </span>
+                          </td>
+                          <td className="px-3 py-2 text-neutral-700 font-sans">{p.role_description}</td>
+                          <td className="px-3 py-2 font-bold">¥{(p.gross_amount / 100).toFixed(2)}</td>
+                          <td className="px-3 py-2 text-rose-600 font-bold">
+                            {p.fault_penalty > 0 ? `-¥${(p.fault_penalty / 100).toFixed(2)}` : '¥0.00'}
+                          </td>
+                          <td className="px-3 py-2 font-black text-emerald-700 bg-amber-50/50">
+                            ¥{(p.net_payout / 100).toFixed(2)}
+                          </td>
+                        </tr>
+                      );
+                    })}
+                  </tbody>
+                </table>
+              </div>
+            </div>
+          )}
+
+          {/* 订单明细表格 */}
+          <div className="bg-white border-2 border-black shadow-[3px_3px_0px_#000] overflow-hidden">
+            <div className="bg-neutral-100 px-4 py-2 border-b-2 border-black text-xs font-black uppercase text-black flex items-center justify-between">
+              <span>[ 2. 订单级利润拆解快照 (共 {details.length} 笔) ]</span>
+              {loading && <span className="text-[10px] text-neutral-500 font-normal">加载中...</span>}
+            </div>
+            <div className="overflow-x-auto max-h-[360px]">
+              <table className="min-w-full divide-y border-black text-left text-xs font-mono">
+                <thead className="bg-neutral-50 border-b border-black sticky top-0 z-10">
+                  <tr>
+                    <th className="px-3 py-2 font-bold">[ 订单号 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 渠道 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 对接人 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 实收金额 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 单均耗材 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 单笔净利 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 技术20% ]</th>
+                    <th className="px-3 py-2 font-bold">[ 销售40% ]</th>
+                    <th className="px-3 py-2 font-bold">[ 甲方分红 ]</th>
+                    <th className="px-3 py-2 font-bold">[ 乙方分红 ]</th>
+                  </tr>
+                </thead>
+                <tbody className="divide-y border-neutral-200">
+                  {details.map((d) => (
+                    <tr key={d.order_id} className="hover:bg-neutral-50">
+                      <td className="px-3 py-1.5 font-bold">#{d.order_id}</td>
+                      <td className="px-3 py-1.5">
+                        <span className="px-1 py-0.2 bg-neutral-100 border border-black text-[10px]">
+                          {d.channel_type === 'agency' ? '中介' : d.channel_type === 'website' ? '公海' : '直客'}
+                        </span>
+                      </td>
+                      <td className="px-3 py-1.5 text-neutral-600">{d.handler_id || '-'}</td>
+                      <td className="px-3 py-1.5 font-bold">¥{(d.order_amount / 100).toFixed(2)}</td>
+                      <td className="px-3 py-1.5 text-rose-600">-¥{(d.avg_cost / 100).toFixed(2)}</td>
+                      <td className="px-3 py-1.5 font-black text-black">¥{(d.net_profit / 100).toFixed(2)}</td>
+                      <td className="px-3 py-1.5 text-blue-700">¥{(d.tech_fee / 100).toFixed(2)}</td>
+                      <td className="px-3 py-1.5 text-purple-700">¥{(d.sales_fee / 100).toFixed(2)}</td>
+                      <td className="px-3 py-1.5 text-amber-700">¥{(d.partner_a_amount / 100).toFixed(2)}</td>
+                      <td className="px-3 py-1.5 text-amber-700">¥{(d.partner_b_amount / 100).toFixed(2)}</td>
+                    </tr>
+                  ))}
+                </tbody>
+              </table>
+            </div>
+          </div>
+        </div>
+
+        {/* Footer */}
+        <div className="bg-white p-3 border-t-2 border-black flex items-center justify-between shrink-0">
+          <div className="text-[11px] text-neutral-500 font-mono">
+            确认人: {period.confirmed_by || '系统'} | 确认时间: <LocalTime date={period.confirmed_at || period.created_at} />
+          </div>
+          <button
+            onClick={onClose}
+            className="px-4 py-1.5 bg-black text-white hover:bg-neutral-800 border-2 border-black text-xs font-bold uppercase shadow-[2px_2px_0px_#000]"
+          >
+            [ 关闭窗口 ]
+          </button>
+        </div>
+      </div>
+    </div>
+  );
+}

+ 207 - 0
src/components/common/AdminUserSelect.tsx

@@ -0,0 +1,207 @@
+// src/components/common/AdminUserSelect.tsx
+'use client';
+
+import React, { useState, useEffect } from 'react';
+import { User, ShieldCheck, RefreshCw, Edit3, ListFilter, Check } from 'lucide-react';
+import { userService } from '@/lib/services/userService';
+
+export interface AdminAccount {
+  id: string;
+  nickname?: string;
+  email?: string;
+  phone?: string;
+  role?: string;
+}
+
+interface AdminUserSelectProps {
+  value: string;
+  onChange: (value: string) => void;
+  label?: string;
+  badgeText?: string;
+  placeholder?: string;
+  helperText?: string;
+  required?: boolean;
+  disabled?: boolean;
+}
+
+// Module-level cache to prevent repeated API calls across sibling components
+let cachedAdmins: AdminAccount[] | null = null;
+let cachePromise: Promise<AdminAccount[]> | null = null;
+
+async function loadAdminsOnce(): Promise<AdminAccount[]> {
+  if (cachedAdmins) return cachedAdmins;
+  if (cachePromise) return cachePromise;
+
+  cachePromise = (async () => {
+    try {
+      const res = await userService.getAdmins();
+      const list = res?.data || res || [];
+      cachedAdmins = Array.isArray(list) ? list : [];
+      return cachedAdmins;
+    } catch (e) {
+      console.error('Failed to load admin list', e);
+      return [];
+    } finally {
+      cachePromise = null;
+    }
+  })();
+
+  return cachePromise;
+}
+
+export default function AdminUserSelect({
+  value,
+  onChange,
+  label,
+  badgeText,
+  placeholder = '选择系统管理员账户',
+  helperText,
+  required = false,
+  disabled = false,
+}: AdminUserSelectProps) {
+  const [admins, setAdmins] = useState<AdminAccount[]>(cachedAdmins || []);
+  const [loading, setLoading] = useState(false);
+  const [isManualMode, setIsManualMode] = useState(false);
+
+  const fetchList = async (force = false) => {
+    setLoading(true);
+    if (force) cachedAdmins = null;
+    const list = await loadAdminsOnce();
+    setAdmins(list);
+    setLoading(false);
+  };
+
+  useEffect(() => {
+    fetchList();
+  }, []);
+
+  const selectedAdmin = admins.find((a) => a.id === value);
+
+  return (
+    <div className="space-y-1 font-mono text-xs">
+      {(label || badgeText) && (
+        <div className="flex items-center justify-between">
+          {label && (
+            <label className="font-black text-black uppercase flex items-center gap-1.5">
+              <ShieldCheck size={13} className="text-black" />
+              <span>{label}</span>
+              {required && <span className="text-rose-600">*</span>}
+            </label>
+          )}
+          <div className="flex items-center gap-1.5 ml-auto">
+            {badgeText && (
+              <span className="text-[10px] text-amber-900 bg-amber-200 border border-black px-1 font-bold">
+                {badgeText}
+              </span>
+            )}
+            <button
+              type="button"
+              onClick={() => setIsManualMode(!isManualMode)}
+              className="text-[10px] text-neutral-600 hover:text-black hover:underline flex items-center gap-0.5 ml-1"
+              title={isManualMode ? '切换为下拉选择已注册管理员' : '手动输入自定义标识'}
+            >
+              {isManualMode ? (
+                <>
+                  <ListFilter size={10} />
+                  <span>[下拉选择]</span>
+                </>
+              ) : (
+                <>
+                  <Edit3 size={10} />
+                  <span>[手动输入]</span>
+                </>
+              )}
+            </button>
+            <button
+              type="button"
+              onClick={() => fetchList(true)}
+              className="p-0.5 text-neutral-500 hover:text-black"
+              title="刷新管理员列表"
+            >
+              <RefreshCw size={10} className={loading ? 'animate-spin' : ''} />
+            </button>
+          </div>
+        </div>
+      )}
+
+      {isManualMode ? (
+        <div className="relative">
+          <input
+            type="text"
+            required={required}
+            disabled={disabled}
+            value={value}
+            onChange={(e) => onChange(e.target.value)}
+            placeholder={placeholder || '输入管理员/合作者账户ID'}
+            className="w-full px-3 py-2 border-2 border-black bg-neutral-50 focus:bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000]"
+          />
+        </div>
+      ) : (
+        <div className="space-y-1.5">
+          <div className="relative">
+            <select
+              value={value || ''}
+              required={required}
+              disabled={disabled || loading}
+              onChange={(e) => onChange(e.target.value)}
+              className="w-full px-3 py-2 border-2 border-black bg-white text-xs font-mono text-black outline-none shadow-[2px_2px_0px_#000] cursor-pointer appearance-none pr-8"
+            >
+              <option value="">-- [ 暂不指定 / 清空 ] --</option>
+              {admins.map((u) => {
+                const displayName = u.nickname ? `${u.nickname} (${u.email || u.id})` : (u.email || u.id);
+                return (
+                  <option key={u.id} value={u.id}>
+                    👤 {displayName} — [ID: {u.id}]
+                  </option>
+                );
+              })}
+            </select>
+            <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2.5 text-black">
+              ▼
+            </div>
+          </div>
+
+          {/* 当已选中管理员时的信息卡片 */}
+          {selectedAdmin && (
+            <div className="p-2 bg-blue-50 border border-black flex items-center justify-between text-[11px] shadow-[1px_1px_0px_#000]">
+              <div className="flex items-center gap-2">
+                <div className="w-5 h-5 bg-blue-600 text-white rounded-none flex items-center justify-center font-bold text-[10px]">
+                  ADM
+                </div>
+                <div>
+                  <span className="font-bold text-black font-sans">
+                    {selectedAdmin.nickname || '系统管理员'}
+                  </span>
+                  <span className="text-neutral-500 font-mono ml-1.5 text-[10px]">
+                    {selectedAdmin.email ? `<${selectedAdmin.email}>` : ''}
+                  </span>
+                </div>
+              </div>
+              <span className="font-mono font-bold text-[10px] text-blue-900 bg-blue-100 px-1 border border-blue-300">
+                ID: {selectedAdmin.id}
+              </span>
+            </div>
+          )}
+
+          {/* 若当前 value 不在管理员列表中但有值(比如手动写入或历史配置) */}
+          {!selectedAdmin && value && (
+            <div className="p-1.5 bg-neutral-100 border border-neutral-300 flex items-center justify-between text-[10px] text-neutral-600">
+              <span>当前绑定自定义ID: <strong className="font-mono text-black">{value}</strong></span>
+              <button
+                type="button"
+                onClick={() => onChange('')}
+                className="text-rose-600 hover:underline"
+              >
+                [ 清除 ]
+              </button>
+            </div>
+          )}
+        </div>
+      )}
+
+      {helperText && (
+        <p className="text-[10px] text-neutral-500 font-sans">{helperText}</p>
+      )}
+    </div>
+  );
+}

+ 292 - 0
src/components/common/ProductTutorialBanner.tsx

@@ -0,0 +1,292 @@
+// src/components/common/ProductTutorialBanner.tsx
+'use client';
+
+import React, { useState } from 'react';
+import {
+  BookOpen,
+  ExternalLink,
+  HelpCircle,
+  X,
+  ChevronDown,
+  ChevronUp,
+  Sparkles,
+  Info,
+  CheckCircle2,
+  AlertTriangle,
+  FileText,
+  Compass,
+} from 'lucide-react';
+import { ProductTutorialConfig } from '@/types';
+
+interface ProductTutorialBannerProps {
+  tutorial?: ProductTutorialConfig | null;
+  productTitle?: string;
+  className?: string;
+  defaultOpenModal?: boolean;
+  onCloseModal?: () => void;
+  hideBanner?: boolean;
+}
+
+export default function ProductTutorialBanner({
+  tutorial,
+  productTitle,
+  className = '',
+  defaultOpenModal = false,
+  onCloseModal,
+  hideBanner = false,
+}: ProductTutorialBannerProps) {
+  const [isModalOpen, setIsModalOpen] = useState(defaultOpenModal);
+  const [isEmbeddedExpanded, setIsEmbeddedExpanded] = useState(true);
+
+  React.useEffect(() => {
+    setIsModalOpen(defaultOpenModal);
+  }, [defaultOpenModal]);
+
+  const handleCloseModal = () => {
+    setIsModalOpen(false);
+    if (onCloseModal) onCloseModal();
+  };
+
+  if (!tutorial || !tutorial.enabled) return null;
+
+  const displayType = tutorial.display_type || 'modal';
+  const modalTitle = tutorial.modal_title || '商品使用教程与资料准备指引';
+  const badgeText = tutorial.badge_text || '申请人必读指引';
+  const buttonText = tutorial.button_text || '📖 查看使用教程与账号准备说明';
+  const linkText = tutorial.link_text || '打开完整图文文档 ↗';
+  const linkUrl = tutorial.link_url?.trim();
+  const summary = tutorial.summary?.trim();
+  const content = tutorial.content?.trim();
+  const steps = tutorial.steps || [];
+
+  return (
+    <div className={`font-mono ${className}`}>
+      {/* 1. 页面常驻横幅 / 引导卡片 */}
+      {!hideBanner && (
+        <div className="bg-sky-50 border-2 border-black p-4 sm:p-5 shadow-[4px_4px_0px_#000] space-y-3">
+        {/* 顶部标题与形态切换区 */}
+        <div className="flex flex-wrap items-center justify-between gap-2 border-b-2 border-black pb-2.5">
+          <div className="flex items-center gap-2">
+            <div className="w-6 h-6 bg-sky-300 border border-black flex items-center justify-center font-black shadow-[1px_1px_0px_#000]">
+              <Compass size={14} className="text-black" />
+            </div>
+            <span className="font-black text-black text-xs sm:text-sm uppercase tracking-wide">
+              [ {modalTitle} ]
+            </span>
+            <span className="px-1.5 py-0.2 bg-amber-300 border border-black text-[10px] font-black uppercase text-black">
+              ★ {badgeText}
+            </span>
+          </div>
+
+          {/* 右侧动作按钮区 (根据 display_type 展示多种形式) */}
+          <div className="flex items-center gap-2">
+            {/* 弹窗按钮 (用于 modal / both / embedded) */}
+            {(displayType === 'modal' || displayType === 'both' || displayType === 'embedded') && (
+              <button
+                type="button"
+                onClick={() => setIsModalOpen(true)}
+                className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5"
+              >
+                <BookOpen size={12} />
+                <span>{buttonText}</span>
+              </button>
+            )}
+
+            {/* 外部超链接按钮 (用于 link / both / embedded) */}
+            {linkUrl && (displayType === 'link' || displayType === 'both' || displayType === 'embedded') && (
+              <a
+                href={linkUrl}
+                target="_blank"
+                rel="noopener noreferrer"
+                className="px-3 py-1 bg-white hover:bg-neutral-100 text-black border border-black text-xs font-black uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center gap-1.5"
+                title="在新窗口打开外部详细图文教程"
+              >
+                <ExternalLink size={12} />
+                <span>{linkText}</span>
+              </a>
+            )}
+
+            {/* 内嵌模式下的折叠展开按键 */}
+            {displayType === 'embedded' && (
+              <button
+                type="button"
+                onClick={() => setIsEmbeddedExpanded(!isEmbeddedExpanded)}
+                className="p-1 bg-white hover:bg-neutral-100 border border-black text-xs font-bold shadow-[1px_1px_0px_#000]"
+                title={isEmbeddedExpanded ? '折叠步骤' : '展开步骤'}
+              >
+                {isEmbeddedExpanded ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
+              </button>
+            )}
+          </div>
+        </div>
+
+        {/* 摘要提示文案 */}
+        {summary && (
+          <div className="flex items-start gap-2 text-xs text-neutral-800 font-sans leading-relaxed">
+            <Info size={14} className="text-sky-700 shrink-0 mt-0.5" />
+            <p className="font-medium">{summary}</p>
+          </div>
+        )}
+
+        {/* 2. 内嵌步骤卡片 (仅当 display_type 为 embedded 且展开时显示) */}
+        {displayType === 'embedded' && isEmbeddedExpanded && steps.length > 0 && (
+          <div className="pt-2 border-t border-dashed border-sky-300 space-y-2">
+            <span className="text-[10px] font-bold text-neutral-500 uppercase block font-mono">
+              [ 核心准备三步法 / QUICK STEPS ]:
+            </span>
+            <div className="grid grid-cols-1 sm:grid-cols-3 gap-2.5">
+              {steps.map((step, idx) => (
+                <div
+                  key={idx}
+                  className="bg-white border border-black p-2.5 shadow-[1px_1px_0px_#000] space-y-1"
+                >
+                  <div className="flex items-center gap-1.5 font-mono">
+                    <span className="w-4 h-4 bg-black text-white text-[10px] font-black flex items-center justify-center">
+                      {step.step_no || idx + 1}
+                    </span>
+                    <span className="text-xs font-black text-black truncate">{step.title}</span>
+                  </div>
+                  <p className="text-[11px] text-neutral-600 font-sans leading-snug line-clamp-3">
+                    {step.desc}
+                  </p>
+                </div>
+              ))}
+            </div>
+          </div>
+        )}
+      </div>
+      )}
+
+      {/* 3. 弹出对话框模式 (Tutorial Modal Dialog) */}
+      {isModalOpen && (
+        <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-mono animate-in fade-in duration-150">
+          <div className="bg-neutral-50 border-4 border-black w-full max-w-2xl max-h-[88vh] flex flex-col shadow-[8px_8px_0px_#000] overflow-hidden">
+            {/* Modal Header */}
+            <div className="bg-neutral-200 border-b-2 border-black p-4 flex items-center justify-between select-none">
+              <div className="flex items-center gap-2">
+                <div className="w-6 h-6 bg-amber-300 border border-black flex items-center justify-center font-black shadow-[1px_1px_0px_#000]">
+                  <BookOpen size={14} className="text-black" />
+                </div>
+                <div>
+                  <h3 className="font-black text-black text-sm uppercase tracking-wide">
+                    {modalTitle}
+                  </h3>
+                  {productTitle && (
+                    <p className="text-[10px] text-neutral-500 font-bold font-sans">
+                      适用商品: {productTitle}
+                    </p>
+                  )}
+                </div>
+              </div>
+
+              <button
+                type="button"
+                onClick={handleCloseModal}
+                className="w-7 h-7 bg-white hover:bg-neutral-100 border border-black flex items-center justify-center font-bold text-xs shadow-[1px_1px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+              >
+                <X size={14} />
+              </button>
+            </div>
+
+            {/* Modal Scrollable Body */}
+            <div className="p-5 overflow-y-auto space-y-4 text-xs flex-1 bg-white">
+              {/* 核心摘要警示条 */}
+              {summary && (
+                <div className="bg-amber-50 border-2 border-black p-3.5 shadow-[2px_2px_0px_#000] flex items-start gap-2.5">
+                  <AlertTriangle size={16} className="text-amber-800 shrink-0 mt-0.5" />
+                  <div>
+                    <span className="font-black text-black uppercase text-[11px] block">
+                      [ 核心填报与账号要求说明 ]
+                    </span>
+                    <p className="text-neutral-800 font-sans text-xs mt-0.5 leading-relaxed font-medium">
+                      {summary}
+                    </p>
+                  </div>
+                </div>
+              )}
+
+              {/* 步骤列表展示 */}
+              {steps.length > 0 && (
+                <div className="space-y-3">
+                  <span className="font-black text-black uppercase text-xs block border-b-2 border-black pb-1">
+                    [ 操作指南与准备步骤 // STEP-BY-STEP GUIDE ({steps.length}) ]
+                  </span>
+                  <div className="space-y-2.5">
+                    {steps.map((step, idx) => (
+                      <div
+                        key={idx}
+                        className="bg-neutral-50 border-2 border-black p-3 shadow-[2px_2px_0px_#000] flex items-start gap-3"
+                      >
+                        <div className="w-6 h-6 bg-black text-white font-black text-xs flex items-center justify-center shrink-0 mt-0.5">
+                          {String(step.step_no || idx + 1).padStart(2, '0')}
+                        </div>
+                        <div className="space-y-1">
+                          <h4 className="font-black text-black text-xs font-sans uppercase">
+                            {step.title}
+                          </h4>
+                          <p className="text-neutral-700 font-sans text-xs leading-relaxed">
+                            {step.desc}
+                          </p>
+                        </div>
+                      </div>
+                    ))}
+                  </div>
+                </div>
+              )}
+
+              {/* 详细长文本补充内容 */}
+              {content && (
+                <div className="bg-neutral-50 border-2 border-black p-4 shadow-[2px_2px_0px_#000] space-y-2">
+                  <span className="font-black text-black uppercase text-xs block border-b border-neutral-300 pb-1 flex items-center gap-1.5">
+                    <FileText size={13} />
+                    <span>[ 详细说明与常见疑问 FAQ ]</span>
+                  </span>
+                  <div className="text-neutral-800 font-sans text-xs leading-relaxed whitespace-pre-wrap">
+                    {content}
+                  </div>
+                </div>
+              )}
+
+              {/* 外部文档推荐 */}
+              {linkUrl && (
+                <div className="bg-sky-50 border-2 border-black p-3.5 shadow-[2px_2px_0px_#000] flex flex-col sm:flex-row sm:items-center justify-between gap-3">
+                  <div>
+                    <span className="font-black text-black uppercase text-xs block">
+                      官方在线图文知识库 / 视频文档
+                    </span>
+                    <p className="text-[11px] text-neutral-600 font-sans mt-0.5">
+                      支持在电脑或手机浏览器中完整查阅带图截屏与更详细的说明
+                    </p>
+                  </div>
+                  <a
+                    href={linkUrl}
+                    target="_blank"
+                    rel="noopener noreferrer"
+                    className="px-4 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition flex items-center justify-center gap-1.5 shrink-0"
+                  >
+                    <span>{linkText}</span>
+                    <ExternalLink size={13} />
+                  </a>
+                </div>
+              )}
+            </div>
+
+            {/* Modal Footer */}
+            <div className="bg-neutral-200 border-t-2 border-black p-3.5 px-5 flex items-center justify-between">
+              <span className="text-[10px] text-neutral-600 font-bold">
+                * 建议仔细核对账号密码,以确保自动化工单能顺畅通过官网风控验证
+              </span>
+              <button
+                type="button"
+                onClick={handleCloseModal}
+                className="px-4 py-1.5 bg-black hover:bg-neutral-800 text-white font-black text-xs uppercase shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 transition"
+              >
+                [ 我已阅读并了解 ]
+              </button>
+            </div>
+          </div>
+        </div>
+      )}
+    </div>
+  );
+}

+ 315 - 0
src/components/services/ServicePoster.tsx

@@ -0,0 +1,315 @@
+// src/components/services/ServicePoster.tsx
+'use client';
+
+import React from 'react';
+import { Product } from '@/types';
+import { Plane, ShieldCheck, Compass, Globe2, Sparkles } from 'lucide-react';
+
+interface ServicePosterProps {
+  product: Product;
+  className?: string;
+}
+
+export default function ServicePoster({ product, className = '' }: ServicePosterProps) {
+  // 如果商品配置了自定义海报图,优先展示
+  const cardConfig = product.extra_fields?.card_config;
+  const customBanner = cardConfig?.banner_url || product.extra_fields?.banner_url || product.extra_fields?.banner_image;
+
+  if (customBanner) {
+    return (
+      <div className={`relative w-full lg:w-[280px] xl:w-[320px] aspect-[16/9] shrink-0 overflow-hidden bg-neutral-100 border-2 border-black shadow-[3px_3px_0px_#000] ${className}`}>
+        {/* eslint-disable-next-line @next/next/no-img-element */}
+        <img
+          src={customBanner}
+          alt={product.title}
+          className="w-full h-full object-cover"
+        />
+        <div className="absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent pointer-events-none" />
+        <div className="absolute bottom-2 left-2.5 right-2.5 flex items-center justify-between text-[10px] text-white font-mono">
+          <span className="font-bold tracking-wider bg-black/75 px-1.5 py-0.5 border border-white/40">{cardConfig?.poster_title || product.country}</span>
+          <span className="font-bold bg-amber-300 text-black px-1.5 py-0.5 border border-black shadow-[1px_1px_0px_#000]">{product.provider || 'VAS'}</span>
+        </div>
+      </div>
+    );
+  }
+
+  // 根据国家和类型生成极具辨识度的 3D 视觉海报
+  const countryLower = (product.country || '').toLowerCase();
+  const visaType = product.visa_type || 'Tourist';
+
+  // 国家专属视觉主题
+  const getTheme = () => {
+    if (countryLower.includes('france') || countryLower.includes('法国')) {
+      return {
+        brand: 'FRANCE VISA',
+        mainTitle: 'FRANCE',
+        highlightTitle: 'Schengen 4M',
+        sub: '申根短期签证官方代抢',
+        accentColor: '#2563eb', // blue
+        accentTag: 'VFS 官方通道',
+        flagColors: ['#002654', '#ffffff', '#ed2939'],
+        watermark: 'france.vfs.vas',
+        symbolType: 'schengen',
+      };
+    }
+    if (countryLower.includes('united states') || countryLower.includes('usa') || countryLower.includes('us') || countryLower.includes('美国')) {
+      return {
+        brand: 'US VISA',
+        mainTitle: 'USA B1/B2',
+        highlightTitle: 'FAST-PASS',
+        sub: '美签免面签 / 加急代刷',
+        accentColor: '#dc2626', // red
+        accentTag: 'CGI / AIS 直连',
+        flagColors: ['#b22234', '#ffffff', '#3c3b6e'],
+        watermark: 'us-visa.vas.ai',
+        symbolType: 'us',
+      };
+    }
+    if (countryLower.includes('united kingdom') || countryLower.includes('uk') || countryLower.includes('英国')) {
+      return {
+        brand: 'UK VISA',
+        mainTitle: 'UK VISITOR',
+        highlightTitle: 'STANDARD',
+        sub: '英签访问 / 留学快速预约',
+        accentColor: '#b91c1c',
+        accentTag: 'TLS Contact 通道',
+        flagColors: ['#012169', '#ffffff', '#c8102e'],
+        watermark: 'ukvi.official.vas',
+        symbolType: 'uk',
+      };
+    }
+    if (countryLower.includes('germany') || countryLower.includes('德国')) {
+      return {
+        brand: 'GERMANY VISA',
+        mainTitle: 'GERMANY',
+        highlightTitle: 'National / Term',
+        sub: '德国大使馆预约加急',
+        accentColor: '#d97706', // amber/gold
+        accentTag: 'Termin 直连',
+        flagColors: ['#000000', '#dd0000', '#ffcc00'],
+        watermark: 'germany.termin.vas',
+        symbolType: 'germany',
+      };
+    }
+    if (countryLower.includes('italy') || countryLower.includes('意大利')) {
+      return {
+        brand: 'ITALY VISA',
+        mainTitle: 'ITALIA',
+        highlightTitle: 'Turismo 90D',
+        sub: '意签快捷办理与刷位',
+        accentColor: '#059669', // green
+        accentTag: 'VFS 申根通道',
+        flagColors: ['#009246', '#ffffff', '#ce2b37'],
+        watermark: 'italy.schengen.vas',
+        symbolType: 'italy',
+      };
+    }
+    if (countryLower.includes('spain') || countryLower.includes('西班牙')) {
+      return {
+        brand: 'SPAIN VISA',
+        mainTitle: 'SPAIN',
+        highlightTitle: 'BLS Priority',
+        sub: '西班牙旅游/商务代抢',
+        accentColor: '#ea580c', // orange/crimson
+        accentTag: 'BLS 官方直连',
+        flagColors: ['#aa151b', '#f1bf00', '#aa151b'],
+        watermark: 'spain.bls.vas',
+        symbolType: 'spain',
+      };
+    }
+    if (countryLower.includes('denmark') || countryLower.includes('丹麦')) {
+      return {
+        brand: 'DENMARK VISA',
+        mainTitle: 'DENMARK',
+        highlightTitle: 'Schengen Plus',
+        sub: '丹麦申根加急代抢',
+        accentColor: '#dc2626',
+        accentTag: 'VFS 官方通道',
+        flagColors: ['#c8102e', '#ffffff'],
+        watermark: 'denmark.vfs.vas',
+        symbolType: 'schengen',
+      };
+    }
+    if (countryLower.includes('netherlands') || countryLower.includes('荷兰') || countryLower.includes('holland')) {
+      return {
+        brand: 'NETHERLANDS VISA',
+        mainTitle: 'HOLLAND',
+        highlightTitle: 'Schengen 90D',
+        sub: '荷兰申根极速代抢',
+        accentColor: '#ea580c', // Dutch orange
+        accentTag: 'VFS 官方通道',
+        flagColors: ['#ae1c28', '#ffffff', '#21468b'],
+        watermark: 'netherlands.vfs.vas',
+        symbolType: 'schengen',
+      };
+    }
+    if (countryLower.includes('greece') || countryLower.includes('希腊')) {
+      return {
+        brand: 'GREECE VISA',
+        mainTitle: 'GREECE',
+        highlightTitle: 'Priority Slot',
+        sub: '希腊官方预约通道',
+        accentColor: '#0284c7', // Aegean cyan
+        accentTag: '官方通道直连',
+        flagColors: ['#0d5eaf', '#ffffff'],
+        watermark: 'greece.schengen.vas',
+        symbolType: 'schengen',
+      };
+    }
+    if (countryLower.includes('japan') || countryLower.includes('日本')) {
+      return {
+        brand: 'JAPAN VISA',
+        mainTitle: 'JAPAN',
+        highlightTitle: 'e-VISA Fast',
+        sub: '日本单次 / 多次加急',
+        accentColor: '#e11d48', // rose
+        accentTag: 'eVisa 官方通道',
+        flagColors: ['#ffffff', '#bc002d'],
+        watermark: 'japan.evisa.vas',
+        symbolType: 'japan',
+      };
+    }
+
+    // Default global
+    return {
+      brand: 'GLOBAL VISA',
+      mainTitle: (product.country || 'GLOBAL').toUpperCase(),
+      highlightTitle: `${visaType.toUpperCase()} PASS`,
+      sub: `${product.country} 官方加急预约`,
+      accentColor: '#0284c7', // sky
+      accentTag: `${product.provider || 'OFFICIAL'} 直连`,
+      flagColors: ['#0284c7', '#38bdf8'],
+      watermark: 'vas.global.ai',
+      symbolType: 'global',
+    };
+  };
+
+  const baseTheme = getTheme();
+  const theme = {
+    ...baseTheme,
+    brand: cardConfig?.poster_tag || baseTheme.brand,
+    mainTitle: cardConfig?.poster_title || baseTheme.mainTitle,
+    highlightTitle: cardConfig?.poster_highlight || baseTheme.highlightTitle,
+    sub: cardConfig?.poster_sub || baseTheme.sub,
+    accentColor: cardConfig?.poster_accent_color || baseTheme.accentColor,
+  };
+
+  return (
+    <div
+      className={`relative w-full lg:w-[280px] xl:w-[320px] aspect-[16/9] shrink-0 overflow-hidden bg-gradient-to-br from-[#fafaf9] via-[#ffffff] to-[#f5f5f4] border-2 border-black shadow-[3px_3px_0px_#000] select-none flex flex-col justify-between p-3.5 sm:p-4 ${className}`}
+    >
+      {/* 顶部微型品牌标 */}
+      <div className="flex items-center justify-between z-10 font-mono">
+        <span className="text-[10px] font-black tracking-widest text-black uppercase bg-neutral-100 border border-black px-1.5 py-0.5 shadow-[1px_1px_0px_#000]">
+          {theme.brand}
+        </span>
+        <span className="text-[10px] font-black px-1.5 py-0.5 border border-black bg-amber-300 text-black shadow-[1px_1px_0px_#000]">
+          {theme.accentTag}
+        </span>
+      </div>
+
+      {/* 主体文字排版与右侧 3D 拟真徽章 */}
+      <div className="flex items-center justify-between gap-2 my-auto z-10">
+        {/* 左侧大字 */}
+        <div className="space-y-0.5">
+          <div className="text-xl sm:text-2xl font-black text-black tracking-tighter leading-tight font-sans">
+            {theme.mainTitle}
+          </div>
+          <div
+            className="text-lg sm:text-xl font-black tracking-tight leading-none"
+            style={{ color: theme.accentColor }}
+          >
+            {theme.highlightTitle}
+          </div>
+          <div className="text-[10px] font-bold text-neutral-600 pt-0.5 tracking-tight font-mono">
+            {theme.sub}
+          </div>
+        </div>
+
+        {/* 右侧 3D 视觉元素 */}
+        <div className="relative shrink-0 w-20 h-20 sm:w-24 sm:h-24 flex items-center justify-center">
+          {/* 背景环境光晕 */}
+          <div
+            className="absolute inset-0 rounded-full blur-xl opacity-30 transform scale-90"
+            style={{ backgroundColor: theme.accentColor }}
+          />
+
+          {/* 3D 徽章图形 */}
+          <div className="relative z-10 transform hover:scale-105 transition-transform duration-300 drop-shadow-[0_12px_12px_rgba(0,0,0,0.18)]">
+            {theme.symbolType === 'schengen' && (
+              <svg viewBox="0 0 100 100" className="w-16 h-16 sm:w-20 sm:h-20">
+                <circle cx="50" cy="50" r="42" fill="url(#blueGrad)" stroke="#1e40af" strokeWidth="2" />
+                <circle cx="50" cy="50" r="35" fill="none" stroke="#60a5fa" strokeWidth="1" strokeDasharray="3 3" />
+                <path d="M50 18 L53 28 L63 28 L55 34 L58 44 L50 38 L42 44 L45 34 L37 28 L47 28 Z" fill="#fbbf24" />
+                <path d="M30 55 C30 45, 70 45, 70 55 C70 68, 50 82, 50 82 C50 82, 30 68, 30 55 Z" fill="#ffffff" opacity="0.9" />
+                <text x="50" y="65" textAnchor="middle" fontSize="11" fontWeight="900" fill="#1e3a8a">EU</text>
+                <defs>
+                  <linearGradient id="blueGrad" x1="0%" y1="0%" x2="100%" y2="100%">
+                    <stop offset="0%" stopColor="#3b82f6" />
+                    <stop offset="100%" stopColor="#1d4ed8" />
+                  </linearGradient>
+                </defs>
+              </svg>
+            )}
+
+            {theme.symbolType === 'us' && (
+              <svg viewBox="0 0 100 100" className="w-16 h-16 sm:w-20 sm:h-20">
+                <path d="M50 12 L85 24 C85 55, 68 80, 50 88 C32 80, 15 55, 15 24 Z" fill="url(#usGrad)" stroke="#991b1b" strokeWidth="2" />
+                <path d="M50 20 L78 30 C78 54, 64 74, 50 80 C36 74, 22 54, 22 30 Z" fill="#1e293b" />
+                <circle cx="50" cy="46" r="16" fill="#dc2626" />
+                <path d="M50 34 L53 43 L62 43 L55 49 L57 58 L50 52 L43 58 L45 49 L38 43 L47 43 Z" fill="#ffffff" />
+                <defs>
+                  <linearGradient id="usGrad" x1="0%" y1="0%" x2="100%" y2="100%">
+                    <stop offset="0%" stopColor="#ef4444" />
+                    <stop offset="100%" stopColor="#991b1b" />
+                  </linearGradient>
+                </defs>
+              </svg>
+            )}
+
+            {theme.symbolType === 'uk' && (
+              <svg viewBox="0 0 100 100" className="w-16 h-16 sm:w-20 sm:h-20">
+                <rect x="18" y="22" width="64" height="56" rx="10" fill="url(#ukGrad)" stroke="#1e293b" strokeWidth="2" />
+                <path d="M28 32 L36 46 L50 34 L64 46 L72 32 L68 62 L32 62 Z" fill="#fbbf24" stroke="#d97706" strokeWidth="1" />
+                <circle cx="36" cy="62" r="3" fill="#ffffff" />
+                <circle cx="50" cy="62" r="3" fill="#ffffff" />
+                <circle cx="64" cy="62" r="3" fill="#ffffff" />
+                <text x="50" y="74" textAnchor="middle" fontSize="8" fontWeight="bold" fill="#ffffff" letterSpacing="1">UKVI</text>
+                <defs>
+                  <linearGradient id="ukGrad" x1="0%" y1="0%" x2="100%" y2="100%">
+                    <stop offset="0%" stopColor="#1e3a8a" />
+                    <stop offset="100%" stopColor="#0f172a" />
+                  </linearGradient>
+                </defs>
+              </svg>
+            )}
+
+            {(theme.symbolType === 'germany' || theme.symbolType === 'italy' || theme.symbolType === 'spain' || theme.symbolType === 'japan' || theme.symbolType === 'global') && (
+              <svg viewBox="0 0 100 100" className="w-16 h-16 sm:w-20 sm:h-20">
+                <circle cx="50" cy="50" r="42" fill="url(#metalGrad)" stroke="#334155" strokeWidth="2" />
+                <circle cx="50" cy="50" r="34" fill="#0f172a" />
+                {/* 3D 飞行光环与指南针 */}
+                <ellipse cx="50" cy="50" rx="30" ry="14" fill="none" stroke={theme.accentColor} strokeWidth="2.5" transform="rotate(-30 50 50)" />
+                <circle cx="50" cy="50" r="9" fill={theme.accentColor} opacity="0.9" />
+                <path d="M50 32 L53 45 L66 50 L53 55 L50 68 L47 55 L34 50 L47 45 Z" fill="#ffffff" />
+                <defs>
+                  <linearGradient id="metalGrad" x1="0%" y1="0%" x2="100%" y2="100%">
+                    <stop offset="0%" stopColor="#cbd5e1" />
+                    <stop offset="50%" stopColor="#64748b" />
+                    <stop offset="100%" stopColor="#334155" />
+                  </linearGradient>
+                </defs>
+              </svg>
+            )}
+          </div>
+        </div>
+      </div>
+
+      {/* 底部微信息与水印 */}
+      <div className="flex items-center justify-between text-[9px] font-mono text-neutral-500 z-10 pt-1 border-t border-neutral-300">
+        <span className="truncate font-bold">官方通道直连 · 失败全退</span>
+        <span className="font-bold text-black">{theme.watermark}</span>
+      </div>
+    </div>
+  );
+}

+ 8 - 0
src/lib/services/accountService.ts

@@ -28,6 +28,14 @@ export interface AccountUpdatePayload {
 }
 
 export const accountService = {
+  /**
+   * 获取所有使馆账号池列表
+   */
+  async getPools() {
+    const res = await api.get('/api/account/pools');
+    return res.data;
+  },
+
   /**
    * 分页查询账号列表
    */

+ 1 - 0
src/lib/services/index.ts

@@ -14,3 +14,4 @@ export * from './statsService';
 export * from './pluginService';
 export * from './nodeConfigService';
 export * from './providerService';
+export * from './settlementService';

+ 59 - 0
src/lib/services/nodeConfigService.ts

@@ -162,5 +162,64 @@ export const nodeConfigService = {
     const res = await api.get('/api/node-configurations/runtime-status', { params });
     return res.data;
   },
+
+  // ==================== 节点档案注册 API ====================
+  /**
+   * 获取已注册集群节点档案列表
+   */
+  async listRegisteredNodes(params?: {
+    status?: number;
+    keyword?: string;
+  }): Promise<{
+    code: number;
+    message: string;
+    data: import('@/types').ClusterNode[];
+  }> {
+    const res = await api.get('/api/node-configurations/nodes/list', { params });
+    return res.data;
+  },
+
+  /**
+   * 登记新集群节点档案
+   */
+  async createRegisteredNode(payload: import('@/types').ClusterNodeCreatePayload): Promise<{
+    code: number;
+    message: string;
+    data: import('@/types').ClusterNode;
+  }> {
+    const res = await api.post('/api/node-configurations/nodes/create', payload);
+    return res.data;
+  },
+
+  /**
+   * 更新已注册集群节点档案
+   */
+  async updateRegisteredNode(
+    nodeId: string,
+    payload: import('@/types').ClusterNodeUpdatePayload
+  ): Promise<{
+    code: number;
+    message: string;
+    data: import('@/types').ClusterNode;
+  }> {
+    const res = await api.post('/api/node-configurations/nodes/update', payload, {
+      params: { node_id: nodeId },
+    });
+    return res.data;
+  },
+
+  /**
+   * 注销集群节点档案
+   */
+  async deleteRegisteredNode(nodeId: string): Promise<{
+    code: number;
+    message: string;
+    data: boolean;
+  }> {
+    const res = await api.post('/api/node-configurations/nodes/delete', null, {
+      params: { node_id: nodeId },
+    });
+    return res.data;
+  },
 };
 

+ 42 - 3
src/lib/services/orderService.ts

@@ -8,6 +8,9 @@ export interface OrderListParams {
   size?: number;
   keyword?: string;
   status?: string;
+  channel_type?: 'direct' | 'agency' | 'website' | string;
+  handler_id?: string;
+  settlement_status?: 'unsettled' | 'risk_period' | 'eligible' | 'settled' | string;
   [key: string]: any;
 }
 
@@ -47,13 +50,30 @@ export const orderService = {
   },
 
   /**
-   * 管理员后台直接创建订单
+   * 管理员后台直接创建订单 (支持渠道/中介/对接人/自定义价格)
    */
-  async createByAdmin(payload: Record<string, any>) {
+  async createByAdmin(payload: {
+    product_id: number;
+    user_inputs: Record<string, any>;
+    channel_type?: 'direct' | 'agency' | 'website' | string;
+    agency_id?: string | null;
+    handler_id?: string | null;
+    final_amount?: number | null;
+  }) {
     const res = await api.post('/api/vas/order/create_by_admin', payload);
     return res.data;
   },
 
+  /**
+   * 标记订单履约出签完成,开启退款风险期(如T+7)
+   */
+  async markCompleted(orderId: string | number, riskDays: number = 7) {
+    const res = await api.post('/api/vas/order/mark_completed', null, {
+      params: { order_id: orderId, risk_days: riskDays },
+    });
+    return res.data;
+  },
+
   /**
    * 取消订单
    */
@@ -84,11 +104,30 @@ export const orderService = {
     return res.data;
   },
 
+  /**
+   * 管理员配置与更新订单属性 (渠道/对接人/中介/申报参数/状态)
+   */
+  async updateOrder(
+    orderId: string | number,
+    payload: {
+      channel_type?: 'direct' | 'agency' | 'website';
+      agency_id?: string | null;
+      handler_id?: string | null;
+      status?: string;
+      user_inputs?: Record<string, any>;
+    }
+  ) {
+    const res = await api.post('/api/vas/order/update', payload, {
+      params: { order_id: orderId },
+    });
+    return res.data;
+  },
+
   /**
    * 后台调整订单价格 (优惠 / 减免 / 附加费)
    */
   async adjustPrice(orderId: string | number, payload: Record<string, any>) {
-    const res = await api.post('/api/vas/order/adjust_price', payload, {
+    const res = await api.post('/api/vas/order/adjust-price', payload, {
       params: { order_id: orderId },
     });
     return res.data;

+ 1 - 1
src/lib/services/productService.ts

@@ -62,7 +62,7 @@ export const productService = {
    */
   async delete(productId: number) {
     const res = await api.delete('/api/vas/product/delete', {
-      params: { product_id: productId },
+      params: { id: productId, product_id: productId },
     });
     return res.data;
   },

+ 8 - 0
src/lib/services/proxyService.ts

@@ -32,6 +32,14 @@ export interface ProxyUpdatePayload {
 }
 
 export const proxyService = {
+  /**
+   * 获取所有云端代理池列表
+   */
+  async getPools() {
+    const res = await api.get('/api/proxy/pools');
+    return res.data;
+  },
+
   /**
    * 分页查询代理节点列表
    */

+ 151 - 0
src/lib/services/settlementService.ts

@@ -0,0 +1,151 @@
+// src/lib/services/settlementService.ts
+
+import api from '@/lib/api';
+import {
+  VasAgency,
+  VasAgencyCreatePayload,
+  VasAgencyUpdatePayload,
+  VasCostRecord,
+  VasCostCreatePayload,
+  VasFaultRecord,
+  VasFaultCreatePayload,
+  SettlementPeriod,
+  SettlementPreviewRequest,
+  SettlementConfirmRequest,
+  SettlementPreviewResponse,
+  SettlementOrderDetail,
+} from '@/types';
+
+export interface AgencyListParams {
+  page?: number;
+  size?: number;
+  active_only?: boolean;
+}
+
+export interface CostListParams {
+  period_id?: string;
+  category?: string;
+  start_date?: string;
+  end_date?: string;
+  page?: number;
+  size?: number;
+}
+
+export interface FaultListParams {
+  user_id?: string;
+  deducted_status?: number;
+  page?: number;
+  size?: number;
+}
+
+export const settlementService = {
+  // ===================== 合作中介机构 =====================
+  /**
+   * 查询中介机构列表
+   */
+  async listAgencies(params?: AgencyListParams) {
+    const res = await api.get('/api/vas/agency/list', { params });
+    return res.data;
+  },
+
+  /**
+   * 获取中介机构详情
+   */
+  async getAgency(agencyId: string) {
+    const res = await api.get(`/api/vas/agency/${agencyId}`);
+    return res.data;
+  },
+
+  /**
+   * 登记/创建中介机构
+   */
+  async createAgency(payload: VasAgencyCreatePayload) {
+    const res = await api.post('/api/vas/agency/create', payload);
+    return res.data;
+  },
+
+  /**
+   * 更新中介信息或协议底价
+   */
+  async updateAgency(agencyId: string, payload: VasAgencyUpdatePayload) {
+    const res = await api.put(`/api/vas/agency/${agencyId}`, payload);
+    return res.data;
+  },
+
+  // ===================== 运行耗材成本 =====================
+  /**
+   * 查询耗材支出流水
+   */
+  async listCosts(params?: CostListParams) {
+    const res = await api.get('/api/vas/cost/list', { params });
+    return res.data;
+  },
+
+  /**
+   * 录入新的耗材支出
+   */
+  async createCost(payload: VasCostCreatePayload) {
+    const res = await api.post('/api/vas/cost/create', payload);
+    return res.data;
+  },
+
+  /**
+   * 获取耗材分类统计汇总
+   */
+  async getCostsSummary(startDate: string, endDate: string) {
+    const res = await api.get('/api/vas/cost/summary', {
+      params: { start_date: startDate, end_date: endDate },
+    });
+    return res.data;
+  },
+
+  // ===================== 过错赔偿与扣款 =====================
+  /**
+   * 查询过错赔偿记录
+   */
+  async listFaults(params?: FaultListParams) {
+    const res = await api.get('/api/vas/fault/list', { params });
+    return res.data;
+  },
+
+  /**
+   * 登记录错赔偿事件
+   */
+  async createFault(payload: VasFaultCreatePayload) {
+    const res = await api.post('/api/vas/fault/create', payload);
+    return res.data;
+  },
+
+  // ===================== 账期分润结算引擎 =====================
+  /**
+   * 期末分润试算预览 (Preview)
+   */
+  async previewSettlement(payload: SettlementPreviewRequest) {
+    const res = await api.post('/api/vas/settlement/preview', payload);
+    return res.data;
+  },
+
+  /**
+   * 正式确认并冻结账期分润 (Confirm & Snapshot)
+   */
+  async confirmSettlement(payload: SettlementConfirmRequest) {
+    const res = await api.post('/api/vas/settlement/confirm', payload);
+    return res.data;
+  },
+
+  /**
+   * 查询所有已固化的结算账期
+   */
+  async listPeriods(params?: { page?: number; size?: number }) {
+    const res = await api.get('/api/vas/settlement/periods', { params });
+    return res.data;
+  },
+
+  /**
+   * 查询账期内订单分润明细快照
+   */
+  async getPeriodDetails(periodId: string, params?: { page?: number; size?: number }) {
+    const res = await api.get(`/api/vas/settlement/period/${periodId}/details`, { params });
+    return res.data;
+  },
+};

+ 8 - 0
src/lib/services/userService.ts

@@ -19,6 +19,14 @@ export const userService = {
     return res.data;
   },
 
+  /**
+   * 获取所有系统管理员与合作者/开发者账户
+   */
+  async getAdmins() {
+    const res = await api.get('/api/user/admins');
+    return res.data;
+  },
+
   /**
    * 获取用户详情
    */

+ 1 - 0
src/types/index.ts

@@ -14,3 +14,4 @@ export * from './card';
 export * from './plugin';
 export * from './node_config';
 export * from './agent';
+export * from './settlement';

+ 31 - 0
src/types/node_config.ts

@@ -6,6 +6,7 @@ export interface PluginConfig {
   lib_path?: string;
   plugin_name?: string;
   plugin_bin?: string;
+  plugin_class?: string;
   plugin_proto?: string;
 }
 
@@ -210,3 +211,33 @@ export interface RevisionItem {
   updated_by?: string;
   created_at?: string;
 }
+
+// 节点档案注册资产 (Cluster Node Registry)
+export interface ClusterNode {
+  id: number;
+  node_id: string;
+  name: string;
+  ip_address?: string | null;
+  region?: string | null;
+  status: number; // 1: 启用, 0: 停用
+  notes?: string | null;
+  created_at: string;
+  updated_at: string;
+}
+
+export interface ClusterNodeCreatePayload {
+  node_id: string;
+  name: string;
+  ip_address?: string;
+  region?: string;
+  status?: number;
+  notes?: string;
+}
+
+export interface ClusterNodeUpdatePayload {
+  name?: string;
+  ip_address?: string;
+  region?: string;
+  status?: number;
+  notes?: string;
+}

+ 10 - 0
src/types/order.ts

@@ -72,6 +72,16 @@ export interface Order {
   product_name?: string;
   user_inputs?: Record<string, any>;
   applicant_name?: string;
+  // 渠道与分润归属
+  channel_type?: 'direct' | 'agency' | 'website' | string;
+  agency_id?: string | null;
+  handler_id?: string | null;
+  developer_id?: string | null;
+  // 结算与履约状态
+  settlement_status?: 'unsettled' | 'risk_period' | 'eligible' | 'settled' | string;
+  completed_at?: string | null;
+  risk_cleared_at?: string | null;
+  settlement_period_id?: string | null;
 }
 
 /**

+ 11 - 0
src/types/plugin.ts

@@ -5,9 +5,12 @@ export interface PluginItem {
   name: string;
   display_name: string;
   filename: string;
+  class_name?: string;
+  protocol?: string;
   latest_version: string;
   description: string;
   status: number; // 1: 启用, 0: 停用
+  developer_id?: string | null; // 插件开发管理者ID (享有20%技术分成)
   created_at: string;
   updated_at: string;
 }
@@ -31,17 +34,25 @@ export interface PublishPluginPayload {
   name: string;
   version: string;
   display_name?: string;
+  filename?: string;
+  class_name?: string;
+  protocol?: string;
   description?: string;
   download_url?: string;
   sha256?: string;
   changelog?: string;
   set_as_latest?: boolean;
+  developer_id?: string;
 }
 
 export interface UpdatePluginPayload {
   display_name?: string;
+  filename?: string;
+  class_name?: string;
+  protocol?: string;
   description?: string;
   status?: number;
+  developer_id?: string;
 }
 
 export interface SwitchVersionPayload {

+ 45 - 0
src/types/product.ts

@@ -68,6 +68,49 @@ export interface ProductRouting {
   updated_at?: string;
 }
 
+/**
+ * 教程步骤定义
+ */
+export interface TutorialStep {
+  step_no: number;
+  title: string;
+  desc: string;
+}
+
+/**
+ * 商品使用说明与指引教程配置
+ */
+export interface ProductTutorialConfig {
+  enabled: boolean;
+  display_type: 'modal' | 'link' | 'both' | 'embedded'; // 弹窗对话框、超链接、弹窗+超链接、内嵌折叠卡片
+  button_text?: string;
+  link_url?: string;
+  link_text?: string;
+  modal_title?: string;
+  badge_text?: string;
+  summary?: string;
+  content?: string;
+  steps?: TutorialStep[];
+}
+
+/**
+ * 商品前台展示卡片包装与海报定制
+ */
+export interface ProductCardConfig {
+  banner_url?: string;         // 自定义海报大图 URL (若填入则覆盖默认海报)
+  poster_title?: string;       // 海报大标题 (如 FRANCE, USA, UK)
+  poster_highlight?: string;   // 海报重点亮色词 (如 Schengen 4M, Plus 4M, FAST-PASS)
+  poster_sub?: string;         // 海报副标题 (如 申根短期签证官方代抢, 学生认证账号)
+  poster_tag?: string;         // 海报顶部小标签 (如 VFS 官方通道, SUZHE AI)
+  poster_accent_color?: string;// 海报高亮强调色 (如 #2563eb, #dc2626, #10b981)
+  official_tag?: string;       // 官方活动/通道角标 (如 官方直连, 官方活动, 官方特惠)
+  status_tag?: string;         // 状态徽标 (如 New, Hot, 现成可约)
+  pill_text?: string;          // 绿色细线胶囊文本 (如 无法完成绑卡?, 查看办理教程与材料清单)
+  sales_text?: string;         // 底部销售/库存描述 (如 仅剩 5 件 · 已售 77, 实时监控中 · 已售 88)
+  buy_button_text?: string;    // 购买按钮文案 (如 立即购买, 立即申请)
+  sublink_text?: string;       // 底部次级细字链接 (如 查阅服务细则 →, 已购买? 查工单 →)
+}
+
 /**
  * 商品主数据模型
  */
@@ -85,6 +128,7 @@ export interface Product {
   schema_content?: string | null;
   enabled: boolean | number; // 1 or 0 or boolean
   recommend_score?: number;
+  extra_fields?: Record<string, any> | null;
   created_at?: string;
   updated_at?: string;
   routings?: ProductRouting[];
@@ -96,3 +140,4 @@ export interface Product {
 export interface ProductDetail extends Product {
   schema_content?: string | null;
 }
+

+ 188 - 0
src/types/settlement.ts

@@ -0,0 +1,188 @@
+// src/types/settlement.ts
+
+/**
+ * 合作中介机构档案
+ */
+export interface VasAgency {
+  id: string;
+  name: string;
+  contact_name?: string | null;
+  contact_phone?: string | null;
+  owner_id: string;
+  min_floor_price: number; // 单位: 分
+  status: number; // 1: 启用, 0: 禁用
+  notes?: string | null;
+  created_at: string;
+  updated_at: string;
+}
+
+export interface VasAgencyCreatePayload {
+  id?: string;
+  name: string;
+  contact_name?: string;
+  contact_phone?: string;
+  owner_id: string;
+  min_floor_price: number;
+  notes?: string;
+}
+
+export interface VasAgencyUpdatePayload {
+  name?: string;
+  contact_name?: string;
+  contact_phone?: string;
+  owner_id?: string;
+  min_floor_price?: number;
+  status?: number;
+  notes?: string;
+}
+
+/**
+ * 运行耗材成本类别
+ */
+export type CostCategory = 'vps' | 'proxy_ip' | 'captcha_api' | 'sms_api' | 'other';
+
+export const COST_CATEGORY_LABELS: Record<CostCategory, string> = {
+  vps: '海外 VPS 服务器',
+  proxy_ip: '高匿代理 IP 池',
+  captcha_api: '自动打码平台 API',
+  sms_api: '短信接码平台 API',
+  other: '其他运行耗材',
+};
+
+/**
+ * 运行耗材成本记录
+ */
+export interface VasCostRecord {
+  id: number;
+  period_id?: string | null;
+  category: CostCategory | string;
+  amount: number; // 单位: 分
+  currency: string;
+  description?: string | null;
+  voucher_url?: string | null;
+  paid_at: string;
+  created_by: string;
+  created_at: string;
+}
+
+export interface VasCostCreatePayload {
+  category: CostCategory;
+  amount: number; // 单位: 分
+  currency?: string;
+  description?: string;
+  voucher_url?: string;
+  paid_at?: string;
+}
+
+/**
+ * 个人录错赔偿记录
+ */
+export interface VasFaultRecord {
+  id: number;
+  order_id: string;
+  liable_user_id: string;
+  penalty_amount: number; // 单位: 分
+  reason: string;
+  notes?: string | null;
+  period_id?: string | null;
+  deducted_status: number; // 0: 待扣除, 1: 已从提成中扣除
+  created_at: string;
+}
+
+export interface VasFaultCreatePayload {
+  order_id: string;
+  liable_user_id: string;
+  penalty_amount: number; // 单位: 分
+  reason: string;
+  notes?: string;
+}
+
+/**
+ * 分润打款汇总条目
+ */
+export interface SettlementPayoutItem {
+  user_id: string;
+  role_description: string;
+  gross_amount: number; // 分润金额(分)
+  fault_penalty: number; // 过错赔偿抵扣(分)
+  net_payout: number; // 实际应支付金额(分)
+}
+
+/**
+ * 订单分润快照详情
+ */
+export interface SettlementOrderDetail {
+  order_id: string;
+  channel_type: 'direct' | 'agency' | 'website' | string;
+  agency_id?: string | null;
+  handler_id?: string | null;
+  developer_id?: string | null;
+  order_amount: number; // 订单实收(分)
+  avg_cost: number; // 单均公共耗材(分)
+  net_profit: number; // 单笔净利(分)
+  tech_fee: number; // 20% 技术版权
+  sales_fee: number; // 40% 销售提成
+  pool_fee: number; // 40% 合伙池
+  partner_a_amount: number; // 甲方分红
+  partner_b_amount: number; // 乙方分红
+}
+
+/**
+ * 账期结算主表
+ */
+export interface SettlementPeriod {
+  id: string;
+  name: string;
+  start_date: string;
+  end_date: string;
+  total_orders: number;
+  total_revenue: number;
+  total_cost: number;
+  avg_cost: number;
+  net_profit: number;
+  status: 'draft' | 'confirmed' | 'paid' | string;
+  summary_data?: {
+    payout_summary?: SettlementPayoutItem[];
+    cost_breakdown?: Record<string, number>;
+    [key: string]: any;
+  } | null;
+  confirmed_by?: string | null;
+  confirmed_at?: string | null;
+  paid_at?: string | null;
+  created_at: string;
+}
+
+/**
+ * 试算账期分润请求
+ */
+export interface SettlementPreviewRequest {
+  start_date: string;
+  end_date: string;
+  partner_a_id?: string;
+  partner_b_id?: string;
+  default_developer_id?: string;
+}
+
+/**
+ * 确认账期结算请求
+ */
+export interface SettlementConfirmRequest extends SettlementPreviewRequest {
+  period_id: string;
+  period_name: string;
+  notes?: string;
+}
+
+/**
+ * 试算账期分润响应
+ */
+export interface SettlementPreviewResponse {
+  period_range: string;
+  total_orders: number;
+  total_revenue: number;
+  total_cost: number;
+  avg_cost: number;
+  net_profit: number;
+  payout_summary: SettlementPayoutItem[];
+  cost_breakdown: Record<string, number>;
+  details: SettlementOrderDetail[];
+}