Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

18118724055@163.com 18 stundas atpakaļ
vecāks
revīzija
07704635a7
33 mainītis faili ar 1340 papildinājumiem un 452 dzēšanām
  1. 272 0
      deploy/master/market.sql
  2. 9 2
      java/storlead-api/src/main/resources/application.yml
  3. 1 1
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/config/CustomerAnalysisWorkflowProperties.java
  4. 6 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/controller/CustomerTradeController.java
  5. 4 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/controller/MarketingCampaignSopDetailController.java
  6. 56 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/dto/MarketingCampaignSopDetailDTO.java
  7. 63 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/entity/MarketingCampaignSopDetailEntity.java
  8. 7 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/CustomerTradeService.java
  9. 41 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/CustomerTradeServiceImpl.java
  10. 14 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketEmailsServiceImpl.java
  11. 79 21
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketingCampaignServiceImpl.java
  12. 2 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketingCampaignSopDetailServiceImpl.java
  13. 1 1
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/task/CustomerAnalysisWorkflowTask.java
  14. 1 1
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/task/CustomerSyncTask.java
  15. 1 1
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/task/MarketStartOrEndTask.java
  16. 30 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/CustomerStatsVO.java
  17. 3 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsManagementVO.java
  18. 3 1
      ui/smarttrade-platform/src/api/customer/index.js
  19. 2 1
      ui/smarttrade-platform/src/api/marketing/index.js
  20. 10 0
      ui/smarttrade-platform/src/assets/images/icon-gh.svg
  21. 132 0
      ui/smarttrade-platform/src/assets/styles/customer.css
  22. 1 1
      ui/smarttrade-platform/src/components/addMarketing.vue
  23. 222 0
      ui/smarttrade-platform/src/components/customerDetail.vue
  24. 222 28
      ui/smarttrade-platform/src/components/marketing/aiGenerator.vue
  25. 1 1
      ui/smarttrade-platform/src/components/marketing/customerDetail.vue
  26. 31 9
      ui/smarttrade-platform/src/components/marketing/emailList.vue
  27. 15 4
      ui/smarttrade-platform/src/components/marketing/interventionCustomers.vue
  28. 1 1
      ui/smarttrade-platform/src/components/marketing/marketingDetail.vue
  29. 13 5
      ui/smarttrade-platform/src/components/marketing/openedCustomers.vue
  30. 17 5
      ui/smarttrade-platform/src/components/marketing/replyCustomers.vue
  31. 74 366
      ui/smarttrade-platform/src/views/CustomersView.vue
  32. 4 2
      ui/smarttrade-platform/src/views/MarketingView.vue
  33. 2 1
      ui/smarttrade-platform/src/views/emails/detail.vue

+ 272 - 0
deploy/master/market.sql

@@ -0,0 +1,272 @@
+ALTER TABLE `customer`
+    ADD COLUMN `next_analysis_date` date DEFAULT NULL COMMENT '下次分析日期' AFTER `delete_remind_date`;
+
+INSERT INTO `sys_dict`(`dict_id`, `code`, `name`, `description`, `create_by`, `dict_type`, `owner_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `enabled`, `sort`) VALUES (62, 'company_base', '公司基本信息', '公司基本信息', NULL, NULL, NULL, NULL, 0, '2026-11-28 00:00:01', 0, 0, 0);
+
+INSERT INTO `sys_dict_detail`(`dict_detail_id`, `dict_id`, `label`, `value`, `create_by`, `ext_field`, `ext_field2`, `owner_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `enabled`, `sort`) VALUES (284, 62, 'yourTitle', '你的标题', NULL, NULL, NULL, NULL, '2026-11-28 00:00:01', 1, '2026-11-28 00:00:01', 0, 1, 0);
+INSERT INTO `sys_dict_detail`(`dict_detail_id`, `dict_id`, `label`, `value`, `create_by`, `ext_field`, `ext_field2`, `owner_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `enabled`, `sort`) VALUES (285, 62, 'yourCompany', '公司名称', NULL, NULL, NULL, NULL, '2026-11-28 00:00:01', 1, '2026-11-28 00:00:01', 0, 1, 0);
+INSERT INTO `sys_dict_detail`(`dict_detail_id`, `dict_id`, `label`, `value`, `create_by`, `ext_field`, `ext_field2`, `owner_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `enabled`, `sort`) VALUES (286, 62, 'yourPhone', '你的电话', NULL, NULL, NULL, NULL, '2026-11-28 00:00:01', 1, '2026-11-28 00:00:01', 0, 1, 0);
+INSERT INTO `sys_dict_detail`(`dict_detail_id`, `dict_id`, `label`, `value`, `create_by`, `ext_field`, `ext_field2`, `owner_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `enabled`, `sort`) VALUES (287, 62, 'yourEmail', '你的邮箱', NULL, NULL, NULL, NULL, '2026-11-28 00:00:01', 1, '2026-11-28 00:00:01', 0, 1, 0);
+INSERT INTO `sys_dict_detail`(`dict_detail_id`, `dict_id`, `label`, `value`, `create_by`, `ext_field`, `ext_field2`, `owner_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `enabled`, `sort`) VALUES (288, 62, 'fullCompanyAddress', '公司完整地址', NULL, NULL, NULL, NULL, '2026-11-28 00:00:01', 1, '2026-11-28 00:00:01', 0, 1, 0);
+INSERT INTO `sys_dict_detail`(`dict_detail_id`, `dict_id`, `label`, `value`, `create_by`, `ext_field`, `ext_field2`, `owner_by`, `create_time`, `update_by`, `update_time`, `is_delete`, `enabled`, `sort`) VALUES (289, 62, 'companyName', '领存技术', NULL, NULL, NULL, NULL, '2026-11-28 00:00:01', 1, '2026-11-28 00:00:01', 0, 1, 0);
+
+
+CREATE TABLE `customer_analysis_record` (
+                                            `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                                            `customer_id` bigint NOT NULL COMMENT '客户ID,对应customer.id',
+                                            `analysis_batch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1' COMMENT '分析批次号',
+                                            `analysis_scene` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'potential' COMMENT '分析场景(potential/grade/churn等)',
+                                            `analysis_status` int NOT NULL DEFAULT '1' COMMENT '分析状态(-1 待分析  0 分析中  1 成功,2失败)',
+                                            `potential_score` decimal(5,2) DEFAULT NULL COMMENT '潜力分(0-100)',
+                                            `customer_level` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '客户分级(S/A/B/C/D)',
+                                            `confidence` decimal(5,2) DEFAULT NULL COMMENT '置信度(0-100)',
+                                            `priority` int DEFAULT NULL COMMENT '优先级(数字越小优先级越高)',
+                                            `core_tags` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '核心标签(JSON数组或逗号分隔)',
+                                            `reason_summary` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分析结论摘要',
+                                            `suggested_actions` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '建议动作(JSON数组)',
+                                            `risk_signals` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '风险信号(JSON数组)',
+                                            `feature_snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '分析时使用的特征快照(JSON)',
+                                            `model_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模型名称',
+                                            `model_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模型版本',
+                                            `prompt_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '提示词版本',
+                                            `error_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '失败错误码',
+                                            `error_message` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '失败原因',
+                                            `next_follow_up_at` datetime DEFAULT NULL COMMENT '建议下次跟进时间',
+                                            `analysis_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '分析时间',
+                                            `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
+                                            `owner_by` bigint DEFAULT NULL COMMENT '客户拥有者ID',
+                                            `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+                                            `enabled` int DEFAULT '1' COMMENT '是否启用:1启用,0不启用',
+                                            `create_by` bigint DEFAULT NULL COMMENT '创建者',
+                                            `update_by` bigint DEFAULT NULL COMMENT '更新者',
+                                            `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                            `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                            `sort` int DEFAULT '0' COMMENT '显示顺序',
+                                            `has_protect` int DEFAULT '0' COMMENT '是否是保护客户(0否,1是)',
+                                            `has_suspend` int DEFAULT '0' COMMENT '是否是暂停客户(0否,1是)',
+                                            PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='客户AI分析结果表';
+
+CREATE TABLE `customer_analysis_result` (
+                                            `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                                            `customer_id` bigint NOT NULL COMMENT '客户ID,对应customer.id',
+                                            `analysis_batch_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1' COMMENT '分析批次号',
+                                            `analysis_scene` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'potential' COMMENT '分析场景(potential/grade/churn等)',
+                                            `analysis_status` int NOT NULL DEFAULT '1' COMMENT '分析状态(-1 待分析  0 分析中  1 成功,2失败)',
+                                            `potential_score` decimal(5,2) DEFAULT NULL COMMENT '潜力分(0-100)',
+                                            `customer_level` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '客户分级(S/A/B/C/D)',
+                                            `confidence` decimal(5,2) DEFAULT NULL COMMENT '置信度(0-100)',
+                                            `priority` int DEFAULT NULL COMMENT '优先级(数字越小优先级越高)',
+                                            `core_tags` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '核心标签(JSON数组或逗号分隔)',
+                                            `reason_summary` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分析结论摘要',
+                                            `suggested_actions` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '建议动作(JSON数组)',
+                                            `risk_signals` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '风险信号(JSON数组)',
+                                            `feature_snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '分析时使用的特征快照(JSON)',
+                                            `model_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模型名称',
+                                            `model_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模型版本',
+                                            `prompt_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '提示词版本',
+                                            `error_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '失败错误码',
+                                            `error_message` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '失败原因',
+                                            `next_follow_up_at` datetime DEFAULT NULL COMMENT '建议下次跟进时间',
+                                            `analysis_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '分析时间',
+                                            `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
+                                            `owner_by` bigint DEFAULT NULL COMMENT '客户拥有者ID',
+                                            `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+                                            `enabled` int DEFAULT '1' COMMENT '是否启用:1启用,0不启用',
+                                            `create_by` bigint DEFAULT NULL COMMENT '创建者',
+                                            `update_by` bigint DEFAULT NULL COMMENT '更新者',
+                                            `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                            `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                            `sort` int DEFAULT '0' COMMENT '显示顺序',
+                                            `has_protect` int DEFAULT '0' COMMENT '是否是保护客户(0否,1是)',
+                                            `has_suspend` int DEFAULT '0' COMMENT '是否是暂停客户(0否,1是)',
+                                            PRIMARY KEY (`id`) USING BTREE,
+                                            UNIQUE KEY `uq_customer_id` (`customer_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='客户AI分析结果表';
+
+CREATE TABLE `market_emails` (
+                                 `id` bigint NOT NULL AUTO_INCREMENT COMMENT '营销对应邮件信息id',
+                                 `customer_id` bigint NOT NULL COMMENT '客户id',
+                                 `marketing_campaign_id` bigint NOT NULL COMMENT '营销活动id',
+                                 `marketing_campaign_sop_detail_id` bigint DEFAULT NULL COMMENT '营销活动关联邮件模板id',
+                                 `email_id` bigint DEFAULT NULL COMMENT '对应的邮件id',
+                                 `status` int DEFAULT '-2' COMMENT '发送状态:-4退回 -3取消 -2草稿 -1定时 0发送中 1成功 2失败;收信记录一般为1',
+                                 `has_reader` int DEFAULT '0' COMMENT '是否已读',
+                                 `open_count` int NOT NULL DEFAULT '0' COMMENT '打开次数(每次像素回调+1)',
+                                 `has_reply` int DEFAULT '0' COMMENT '是否已回复',
+                                 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+                                 `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+                                 `enabled` int DEFAULT '1' COMMENT '是否启用:1:启用,0:不启用',
+                                 `create_by` bigint DEFAULT NULL COMMENT '创建者',
+                                 `owner_by` bigint DEFAULT '0' COMMENT '拥有者',
+                                 `update_by` bigint DEFAULT NULL COMMENT '更新者',
+                                 `sort` int DEFAULT '0' COMMENT '显示顺序',
+                                 `expect_send_time` timestamp NULL DEFAULT NULL COMMENT '预计发送时间',
+                                 `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '邮件内容',
+                                 `has_protect` int DEFAULT '0' COMMENT '是否保护(0未保护、1保护)',
+                                 `has_suspend` int DEFAULT '0' COMMENT '是否暂停(0未暂停、1暂停)',
+                                 `recipient` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '收件人邮箱',
+                                 `first_open_time` datetime DEFAULT NULL COMMENT '首次打开时间',
+                                 `first_reply_time` datetime DEFAULT NULL COMMENT '首次回复时间',
+                                 `first_reply_email_id` bigint DEFAULT NULL COMMENT '首次回复邮件id',
+                                 `first_reply_theme` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '首次回复邮件主题',
+                                 `protect_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '保护原因',
+                                 `subject` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '主题',
+                                 `protect_time` datetime DEFAULT NULL COMMENT '客户保护时间',
+                                 `suspend_time` datetime DEFAULT NULL COMMENT '客户暂停时间',
+                                 `has_first` int DEFAULT '1' COMMENT '是否是第一封邮件(1首次发送2第二次发送)',
+                                 `first_send_id` int DEFAULT NULL COMMENT '第一次发送的id(第二次发送时写入)',
+                                 `reply_email_ids` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '全部回复邮件id,逗号隔开',
+                                 `outbox` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '发件箱',
+                                 `has_refuse` int DEFAULT '0' COMMENT '是否拒收(0没有、1拒收)',
+                                 `outbox_id` int DEFAULT NULL COMMENT '发件箱id',
+                                 PRIMARY KEY (`id`),
+                                 UNIQUE KEY `uq_second_first_send` (`first_send_id`,`has_first`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='营销对应邮件信息id';
+
+CREATE TABLE `marketing_campaign` (
+                                      `id` bigint NOT NULL AUTO_INCREMENT,
+                                      `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动名称',
+                                      `type` int DEFAULT NULL COMMENT '活动类型',
+                                      `priority` int DEFAULT NULL COMMENT '优先级',
+                                      `begin_data` date DEFAULT NULL COMMENT '开始日期',
+                                      `end_date` date DEFAULT NULL COMMENT '结束日期',
+                                      `supervisor` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '负责人id',
+                                      `link_to_opportunity` bigint DEFAULT NULL COMMENT '关联商机',
+                                      `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '活动描述',
+                                      `send_volume` int DEFAULT NULL COMMENT '发送量',
+                                      `open_rate` double(5,2) DEFAULT NULL COMMENT '打开率',
+  `reply_rate` double(5,2) DEFAULT NULL COMMENT '回复率',
+  `opportunity_count` int DEFAULT NULL COMMENT '商机数',
+  `channel_configuration` int DEFAULT NULL COMMENT '取到配置',
+  `email_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发送邮箱',
+  `email_sent_time` timestamp NULL DEFAULT NULL COMMENT '发送时间',
+  `email_template` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '邮件模板',
+  `email_batch_size` int DEFAULT NULL COMMENT '每批发送量',
+  `email_subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '邮件主题',
+  `track_config_open` tinyint DEFAULT NULL COMMENT '是否追踪邮件',
+  `track_config_click` tinyint DEFAULT NULL COMMENT '是否点击链接',
+  `track_config_reply` tinyint DEFAULT NULL COMMENT '是否回复',
+  `sop_id` int DEFAULT NULL COMMENT 'SOP序列id',
+  `sop_detail_ids` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'sop详情id(逗号分隔)',
+  `follow_up_rules_not_opened` int DEFAULT NULL COMMENT '跟进规则--未打开邮件自动跟进',
+  `follow_up_rules_not_opened_days` int DEFAULT NULL COMMENT '跟进规则--未打开邮件自动跟进--天数',
+  `follow_up_rules_not_replied` int DEFAULT NULL COMMENT '跟进规则--未回复邮件自动跟进',
+  `follow_up_rules_not_replied_days` int DEFAULT NULL COMMENT '跟进规则--未打开邮件自动跟进--天数',
+  `follow_up_rules_link_not_clicked` int DEFAULT NULL COMMENT '跟进规则--未点击链接邮件跟进',
+  `follow_up_rules_link_not_clicked_days` int DEFAULT NULL COMMENT '跟进规则--未点击链接邮件跟进--天数',
+  `follow_up_rules_replied` int DEFAULT NULL COMMENT '跟进规则--客户回复后自动停止',
+  `follow_up_rules_appointment_booked` int DEFAULT NULL COMMENT '跟进规则--客户预约停止',
+  `a_b_testing` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'A/B 测试',
+  `smart_scheduling_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '智能调度类型',
+  `smart_scheduling_start_date` date DEFAULT NULL COMMENT '智能调度开始日期',
+  `smart_scheduling_start_time` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '智能调度开始时间',
+  `has_content_compliant` tinyint DEFAULT '0' COMMENT '已确认营销内容符合规范',
+  `has_schedule_approved` tinyint DEFAULT '0' COMMENT '已确认发送时间和频率合理',
+  `has_gdpr_compliant` tinyint DEFAULT '0' COMMENT '已确认符合反垃圾邮件法规',
+  `has_unsubscribe_link` tinyint DEFAULT '0' COMMENT '已确认邮件包含退订链接',
+  `progress_percent` double(5,2) DEFAULT NULL COMMENT '进度',
+  `status` int DEFAULT '0' COMMENT '状态 0未开始 1运行中 2 暂停 3 完成',
+  `create_by` bigint DEFAULT NULL COMMENT '创建者',
+  `update_by` bigint DEFAULT NULL,
+  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建更新',
+  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+  `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+  `enabled` int DEFAULT '1' COMMENT '是否启用:1:启用,0:不启用',
+  `owner_by` bigint DEFAULT '0' COMMENT '拥有者',
+  `sort` int DEFAULT '0' COMMENT '显示顺序',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='营销活动';
+
+CREATE TABLE `marketing_campaign_sop_detail` (
+                                                 `id` bigint NOT NULL AUTO_INCREMENT,
+                                                 `marketing_id` bigint NOT NULL COMMENT '活动id',
+                                                 `sop_detail_id` bigint DEFAULT NULL COMMENT 'SOP序列详情id',
+                                                 `email_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '邮件内容模板',
+                                                 `create_by` bigint DEFAULT NULL COMMENT '创建者',
+                                                 `update_by` bigint DEFAULT NULL,
+                                                 `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建更新',
+                                                 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                                 `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+                                                 `enabled` int DEFAULT '1' COMMENT '是否启用:1:启用,0:不启用',
+                                                 `owner_by` bigint DEFAULT '0' COMMENT '拥有者',
+                                                 `sort` int DEFAULT '0' COMMENT '显示顺序',
+                                                 `step` tinyint DEFAULT NULL COMMENT '步骤',
+                                                 `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '名称',
+                                                 `days` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '间隔天数',
+                                                 `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '触达渠道',
+                                                 `email_subject` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '主题模板',
+                                                 `product_name` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '产品名称(逗号分隔,前端以List传入/返回)',
+                                                 `product_highlights` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '产品亮点/核心卖点(逗号分隔)',
+                                                 `tone_style` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '语气风格(逗号分隔)',
+                                                 `language` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '语言(逗号分隔)',
+                                                 `additional_requirements` varchar(1000) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附加要求/额外要求(自由文本)',
+                                                 PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='营销活动关联sop详情表';
+
+CREATE TABLE `sop` (
+                       `id` bigint NOT NULL AUTO_INCREMENT,
+                       `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'sop名称',
+                       `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                       `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+                       `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+                       `enabled` int DEFAULT '1' COMMENT '是否启用:1:启用,0:不启用',
+                       `create_by` bigint DEFAULT NULL COMMENT '创建者',
+                       `owner_by` bigint DEFAULT '0' COMMENT '拥有者',
+                       `update_by` bigint DEFAULT NULL COMMENT '更新者',
+                       `sort` int DEFAULT '0' COMMENT '显示顺序',
+                       PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='SOP';
+
+CREATE TABLE `sop_detail` (
+                              `id` bigint NOT NULL AUTO_INCREMENT,
+                              `sop_id` bigint DEFAULT NULL COMMENT 'sopid',
+                              `step` tinyint DEFAULT NULL COMMENT '步骤',
+                              `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '名称',
+                              `email_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '邮件内容模板',
+                              `days` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '间隔天数',
+                              `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '触达渠道',
+                              `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                              `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+                              `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+                              `enabled` int DEFAULT '1' COMMENT '是否启用:1:启用,0:不启用',
+                              `create_by` bigint DEFAULT NULL COMMENT '创建者',
+                              `owner_by` bigint DEFAULT '0' COMMENT '拥有者',
+                              `update_by` bigint DEFAULT NULL COMMENT '更新者',
+                              `sort` int DEFAULT '0' COMMENT '显示顺序',
+                              `send_number` int DEFAULT '0' COMMENT '发送数',
+                              `open_rate` decimal(10,0) DEFAULT '0' COMMENT '打开率',
+                              PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='SOP步骤';
+
+
+CREATE TABLE `customer_base` (
+                                 `id` bigint NOT NULL AUTO_INCREMENT,
+                                 `customer_id` bigint NOT NULL COMMENT '客户id',
+                                 `marketing_campaign_id` bigint NOT NULL COMMENT '营销活动id',
+                                 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+                                 `is_delete` int DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
+                                 `enabled` int DEFAULT '1' COMMENT '是否启用:1:启用,0:不启用',
+                                 `create_by` bigint DEFAULT NULL COMMENT '创建者',
+                                 `owner_by` bigint DEFAULT '0' COMMENT '拥有者',
+                                 `update_by` bigint DEFAULT NULL COMMENT '更新者',
+                                 `sort` int DEFAULT '0' COMMENT '显示顺序',
+                                 PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='营销客户组';
+
+
+CREATE TABLE `mkt_mail_inbox_cursor` (
+                                         `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                                         `last_mail_id` bigint NOT NULL DEFAULT '0' COMMENT '已处理的收件箱未读邮件最大id(mkt_mail_message.id)',
+                                         `owner_by` bigint DEFAULT NULL,
+                                         `create_by` bigint DEFAULT NULL,
+                                         `update_by` bigint DEFAULT NULL,
+                                         `create_time` datetime DEFAULT NULL,
+                                         `update_time` datetime DEFAULT NULL,
+                                         `is_delete` int DEFAULT '0',
+                                         `enabled` tinyint DEFAULT '1',
+                                         `sort` int DEFAULT NULL,
+                                         PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='营销收件箱新邮件提醒游标';

+ 9 - 2
java/storlead-api/src/main/resources/application.yml

@@ -111,6 +111,7 @@ storlead:
       - packages:
           - com.storlead.system.service
           - com.storlead.system.mapper
+
         datasource: master
       # 消息模板 / 站内信必须走 master(避免被 trade/sales 外层数据源污染)
       - packages:
@@ -118,6 +119,8 @@ storlead:
           - com.storlead.message.mapper
         datasource: master
       # 分布式调度元数据固定 master
+
+
       - packages:
           - com.storlead.schedule.service
           - com.storlead.schedule.mapper
@@ -138,9 +141,13 @@ storlead:
     customer-analysis:
       workflow:
         enabled: true
-        url: http://192.168.1.77/v1/workflows/run
+        url: http://47.112.196.2:11434/v1/workflows/run
+        # http://192.168.1.77/v1/workflows/run
         # Authorization Bearer token,勿提交真实密钥到公共仓库时可改配到 application-*.yml
-        api-key: app-3rhnhpC4DvVa2indhA2C4TVw
+        api-key: app-987GIlcekdNz6P4Zy9Gg5cut
+        #app-RNro7Ck0KZjOKCRUyQhB9FzD
+        #app-61q9Bn5oxJk9hlZUjIRBnQqG
+        #app-3rhnhpC4DvVa2indhA2C4TVw
         user: admin-schedule
         response-mode: blocking
         batch-size: 20

+ 1 - 1
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/config/CustomerAnalysisWorkflowProperties.java

@@ -16,7 +16,7 @@ public class CustomerAnalysisWorkflowProperties {
     private boolean enabled = true;
 
     /** Dify / 工作流地址,如 http://xxx/v1/workflows/run */
-    private String url = "http://192.168.1.77/v1/workflows/run";
+    private String url = "http://47.112.196.2:11434/v1/workflows/run";
 
     /** Authorization: Bearer {apiKey} */
     private String apiKey = "";

+ 6 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/controller/CustomerTradeController.java

@@ -67,4 +67,10 @@ public class CustomerTradeController {
     public Result<Object> sourceDistribution(@RequestParam(required = false) List<Long> idList) {
         return Result.result(customerTradeService.getSourceDistribution(idList));
     }
+
+    @GetMapping("/stats")
+    @ApiOperation(value = "客户统计看板", notes = "返回总客户数、重点客户、成交客户、公海客户、无效客户各自的数量;统计基准为「未删除 + 客户种类=10(区别于线索=11)」")
+    public Result<Object> stats() {
+        return Result.result(customerTradeService.getCustomerStats());
+    }
 }

+ 4 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/controller/MarketingCampaignSopDetailController.java

@@ -62,6 +62,8 @@ public class MarketingCampaignSopDetailController {
         if (entity == null) {
             return Result.error("数据不存在");
         }
+        // 把逗号分隔的 DB 字段拆成 List,供前端直接使用
+        entity.populateListViewFields();
         return Result.result(entity);
     }
 
@@ -110,6 +112,7 @@ public class MarketingCampaignSopDetailController {
         }
         MarketingCampaignSopDetailEntity entity = new MarketingCampaignSopDetailEntity();
         BeanUtils.copyProperties(dto, entity);
+        MarketingCampaignSopDetailDTO.applyListFieldsToEntity(dto, entity);
         boolean isOk = marketingCampaignSopDetailService.save(entity);
         if (!isOk) {
             return Result.error("添加失败");
@@ -350,6 +353,7 @@ public class MarketingCampaignSopDetailController {
         for (MarketingCampaignSopDetailDTO dto : dtoList) {
             MarketingCampaignSopDetailEntity entity = new MarketingCampaignSopDetailEntity();
             BeanUtils.copyProperties(dto, entity);
+            MarketingCampaignSopDetailDTO.applyListFieldsToEntity(dto, entity);
             entityList.add(entity);
         }
         boolean isOk = marketingCampaignSopDetailService.saveBatch(entityList);

+ 56 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/dto/MarketingCampaignSopDetailDTO.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.storlead.trade.entity.MarketingCampaignSopDetailEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -218,4 +219,59 @@ public class MarketingCampaignSopDetailDTO implements Serializable {
     @ApiModelProperty(value = "状态 0未开始 1运行中 2暂停 3完成")
     @TableField("status")
     private Integer status;
+
+    @ApiModelProperty(value = "产品名称(前端传 List;入库逗号分隔)")
+    private List<String> productName;
+
+    @ApiModelProperty(value = "产品亮点/核心卖点(前端传 List;入库逗号分隔)")
+    private List<String> productHighlights;
+
+    @ApiModelProperty(value = "语气风格(前端传 List;入库逗号分隔)")
+    private List<String> toneStyle;
+
+    @ApiModelProperty(value = "语言(前端传 List;入库逗号分隔)")
+    private List<String> language;
+
+    @ApiModelProperty(value = "附加要求/额外要求(自由文本)")
+    private String additionalRequirements;
+
+    /**
+     * 把 DTO 中的 List 型字段 join 成逗号分隔字符串,写入 entity 对应 DB 列。
+     * BeanUtils.copyProperties 无法在 List↔String 间拷贝,故需手动处理。
+     * additionalRequirements 为 String,BeanUtils 已自动拷贝,此处兜底覆盖。
+     */
+    public static void applyListFieldsToEntity(MarketingCampaignSopDetailDTO dto, MarketingCampaignSopDetailEntity entity) {
+        if (dto == null || entity == null) {
+            return;
+        }
+        entity.setProductName(joinCsv(dto.getProductName()));
+        entity.setProductHighlights(joinCsv(dto.getProductHighlights()));
+        entity.setToneStyle(joinCsv(dto.getToneStyle()));
+        entity.setLanguage(joinCsv(dto.getLanguage()));
+        entity.setAdditionalRequirements(dto.getAdditionalRequirements());
+    }
+
+    /**
+     * 将 List 合并为逗号分隔字符串;空/全空返回 null(保持 DB 列可空语义)。
+     */
+    public static String joinCsv(List<String> list) {
+        if (list == null || list.isEmpty()) {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder();
+        for (String s : list) {
+            if (s == null) {
+                continue;
+            }
+            String trimmed = s.trim();
+            if (trimmed.isEmpty()) {
+                continue;
+            }
+            if (sb.length() > 0) {
+                sb.append(",");
+            }
+            sb.append(trimmed);
+        }
+        return sb.length() == 0 ? null : sb.toString();
+    }
 }

+ 63 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/entity/MarketingCampaignSopDetailEntity.java

@@ -10,6 +10,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 营销活动SOP明细关联表 Entity
@@ -61,4 +63,65 @@ public class MarketingCampaignSopDetailEntity extends SysBaseField implements Se
     @TableField("email_subject")
     private String emailSubject;
 
+    @ApiModelProperty(value = "产品名称(逗号分隔;前端以 List 传入/返回)")
+    @TableField("product_name")
+    private String productName;
+
+    @ApiModelProperty(value = "产品亮点/核心卖点(逗号分隔;前端以 List 传入/返回)")
+    @TableField("product_highlights")
+    private String productHighlights;
+
+    @ApiModelProperty(value = "语气风格(逗号分隔;前端以 List 传入/返回)")
+    @TableField("tone_style")
+    private String toneStyle;
+
+    @ApiModelProperty(value = "语言(逗号分隔;前端以 List 传入/返回)")
+    @TableField("language")
+    private String language;
+
+    @ApiModelProperty(value = "附加要求/额外要求(自由文本)")
+    @TableField("additional_requirements")
+    private String additionalRequirements;
+
+    // ===== 以下为只读视图字段(不落库):读取接口按逗号拆分后填充,前端直接拿到 List =====
+    @ApiModelProperty(value = "产品名称列表(由 product_name 拆分,前端读此字段)")
+    @TableField(exist = false)
+    private List<String> productNameList;
+
+    @ApiModelProperty(value = "产品亮点列表(由 product_highlights 拆分,前端读此字段)")
+    @TableField(exist = false)
+    private List<String> productHighlightsList;
+
+    @ApiModelProperty(value = "语气风格列表(由 tone_style 拆分,前端读此字段)")
+    @TableField(exist = false)
+    private List<String> toneStyleList;
+
+    @ApiModelProperty(value = "语言列表(由 language 拆分,前端读此字段)")
+    @TableField(exist = false)
+    private List<String> languageList;
+
+    /**
+     * 读取接口调用:把逗号分隔的 DB 字段拆成 List,填充到 exist=false 的视图字段,供前端直接使用。
+     */
+    public void populateListViewFields() {
+        this.productNameList = splitCsv(this.productName);
+        this.productHighlightsList = splitCsv(this.productHighlights);
+        this.toneStyleList = splitCsv(this.toneStyle);
+        this.languageList = splitCsv(this.language);
+    }
+
+    private static List<String> splitCsv(String csv) {
+        List<String> list = new ArrayList<>();
+        if (csv == null || csv.trim().isEmpty()) {
+            return list;
+        }
+        for (String s : csv.split(",")) {
+            String trimmed = s.trim();
+            if (!trimmed.isEmpty()) {
+                list.add(trimmed);
+            }
+        }
+        return list;
+    }
+
 }

+ 7 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/CustomerTradeService.java

@@ -6,6 +6,7 @@ import com.storlead.framework.mybatis.service.MyBaseService;
 import com.storlead.trade.dto.CustomerDTO;
 import com.storlead.trade.entity.CustomerEntity;
 import com.storlead.trade.vo.CustomerSourceDistributionVO;
+import com.storlead.trade.vo.CustomerStatsVO;
 import com.storlead.trade.vo.CustomerVO;
 
 import java.util.List;
@@ -43,4 +44,10 @@ public interface CustomerTradeService extends MyBaseService<CustomerEntity> {
      * @return 按客户数降序的分布列表
      */
     List<CustomerSourceDistributionVO> getSourceDistribution(List<Long> idList);
+
+    /**
+     * 客户统计看板:返回总客户数、重点客户、成交客户、公海客户、无效客户各自的数量。
+     * 统计基准为「未删除 + 客户种类=10(客户,区别于线索=11)」。
+     */
+    CustomerStatsVO getCustomerStats();
 }

+ 41 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/CustomerTradeServiceImpl.java

@@ -27,6 +27,7 @@ import com.storlead.trade.service.LiaisonTradeService;
 import com.storlead.trade.service.SysDictService;
 import com.storlead.trade.vo.CustomerMailThreadVO;
 import com.storlead.trade.vo.CustomerSourceDistributionVO;
+import com.storlead.trade.vo.CustomerStatsVO;
 import com.storlead.trade.vo.CustomerVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -631,4 +632,44 @@ public class CustomerTradeServiceImpl
         });
         return result;
     }
+
+    @Override
+    public CustomerStatsVO getCustomerStats() {
+        // 统计基准:未删除 + 客户种类=10(客户,区别于线索=11)。
+        // 各类目均为在该基准上的独立计数(彼此可重叠,如某客户既可重点又可成交)。
+        Integer notDeleted = CommonConstant.DEL_FLAG_0;
+        int customerForm = 10;
+
+        long totalCustomerCount = this.count(new LambdaQueryWrapper<CustomerEntity>()
+                .eq(CustomerEntity::getIsDelete, notDeleted)
+                .eq(CustomerEntity::getCustomerForm, customerForm));
+
+        long keyCustomerCount = this.count(new LambdaQueryWrapper<CustomerEntity>()
+                .eq(CustomerEntity::getIsDelete, notDeleted)
+                .eq(CustomerEntity::getCustomerForm, customerForm)
+                .eq(CustomerEntity::getHasFollowCustomer, 1));
+
+        long dealCustomerCount = this.count(new LambdaQueryWrapper<CustomerEntity>()
+                .eq(CustomerEntity::getIsDelete, notDeleted)
+                .eq(CustomerEntity::getCustomerForm, customerForm)
+                .eq(CustomerEntity::getHasOrderForm, 1));
+
+        long publicCustomerCount = this.count(new LambdaQueryWrapper<CustomerEntity>()
+                .eq(CustomerEntity::getIsDelete, notDeleted)
+                .eq(CustomerEntity::getCustomerForm, customerForm)
+                .eq(CustomerEntity::getHasPublicCustomer, 1));
+
+        long invalidCustomerCount = this.count(new LambdaQueryWrapper<CustomerEntity>()
+                .eq(CustomerEntity::getIsDelete, notDeleted)
+                .eq(CustomerEntity::getCustomerForm, customerForm)
+                .eq(CustomerEntity::getHasGarbageCustomer, 1));
+
+        CustomerStatsVO vo = new CustomerStatsVO();
+        vo.setTotalCustomerCount(totalCustomerCount);
+        vo.setKeyCustomerCount(keyCustomerCount);
+        vo.setDealCustomerCount(dealCustomerCount);
+        vo.setPublicCustomerCount(publicCustomerCount);
+        vo.setInvalidCustomerCount(invalidCustomerCount);
+        return vo;
+    }
 }

+ 14 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketEmailsServiceImpl.java

@@ -1590,6 +1590,20 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
         log.info("queryWrapper: {}", queryWrapper);
         log.info("marketEmailList: {}", marketEmailList);
         for (MarketEmailsEntity marketEmail : marketEmailList){
+            //如果是二次发送,判断前序发送是否已经打开,如果打开改为取消
+            if (marketEmail.getHasFirst() == 2) {
+                MarketEmailsEntity marketEmailFirst = this.getOne(new LambdaQueryWrapper<MarketEmailsEntity>()
+                        .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
+                        .eq(MarketEmailsEntity::getHasFirst, 1)
+                        .eq(MarketEmailsEntity::getMarketingCampaignId, marketEmail.getMarketingCampaignId())
+                        .eq(MarketEmailsEntity::getCustomerId, marketEmail.getCustomerId())
+                        .eq(MarketEmailsEntity::getMarketingCampaignSopDetailId, marketEmail.getMarketingCampaignSopDetailId()));
+                if (marketEmailFirst != null && marketEmailFirst.getHasReader() != null && marketEmailFirst.getHasReader() == 1) {
+                    marketEmail.setStatus(-3);
+                    this.updateById(marketEmail);
+                    return;
+                }
+            }
             MktSendMailRemoteDTO dto = new MktSendMailRemoteDTO();
             List<String> recipientls = new ArrayList<>();
             recipientls.add(marketEmail.getRecipient());

+ 79 - 21
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketingCampaignServiceImpl.java

@@ -30,12 +30,7 @@ import org.springframework.util.ObjectUtils;
 
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import java.math.BigDecimal;
@@ -143,7 +138,7 @@ public class MarketingCampaignServiceImpl
             Map<Long, Long> pendingMap = countEmailsByCampaign(marketingCampaignIdList,
                     "count(*) as cnt", qw -> qw.eq("status", -1));
             Map<Long, Long> sentMap = countEmailsByCampaign(marketingCampaignIdList,
-                    "count(*) as cnt", qw -> qw.eq("status", 1).eq("has_first", 1));
+                    "count(*) as cnt", qw -> qw.eq("status", 1));
             Map<Long, Long> firstSentMap = countEmailsByCampaign(marketingCampaignIdList,
                     "count(*) as cnt", qw -> qw.eq("status", 1).eq("has_first", 1));
             Map<Long, Long> openedEmailMap = countEmailsByCampaign(marketingCampaignIdList,
@@ -152,6 +147,9 @@ public class MarketingCampaignServiceImpl
                     "count(*) as cnt", qw -> qw.eq("status", 1).eq("has_reply", 1));
             Map<Long, Long> cancelledMap = countEmailsByCampaign(marketingCampaignIdList,
                     "count(*) as cnt", qw -> qw.eq("status", -3));
+            //退回
+            Map<Long, Long> backMap = countEmailsByCampaign(marketingCampaignIdList,
+                    "count(*) as cnt", qw -> qw.eq("status", -4));
             Map<Long, Long> totalEmailMap = countEmailsByCampaign(marketingCampaignIdList,
                     "count(*) as cnt", qw -> { });
 
@@ -168,14 +166,15 @@ public class MarketingCampaignServiceImpl
                 int sent = toInt(sentMap.get(id));
                 int firstSent = toInt(firstSentMap.get(id));
                 int cancelled = toInt(cancelledMap.get(id));
+                int back = toInt(backMap.get(id));
                 vo.setPendingEmailCount(pending);
                 vo.setSentEmailCount(sent);
                 vo.setCancelledEmailCount(cancelled);
-                vo.setEmailCountStats(pending + sent + cancelled);
+                vo.setEmailCountStats(pending + sent + cancelled+back);
                 int totalEmail = toInt(totalEmailMap.get(id));
 
                 int firstTotalEmail = toInt(firstTotalEmailMap.get(id));
-                vo.setSentRate(totalEmail > 0 ? (double) firstSent / firstTotalEmail : 0.0);
+                vo.setSentRate(totalEmail > 0 ? (double) sent / totalEmail : 0.0);
                 vo.setOpenRateText(buildRate(toInt(openedEmailMap.get(id)), sent));
                 vo.setReplyRateText(buildRate(toInt(repliedEmailMap.get(id)), sent));
             }
@@ -271,7 +270,7 @@ public class MarketingCampaignServiceImpl
         Map<Long, List<MarketEmailsEntity>> emailsBySopDetail = new HashMap<>();
         List<MarketEmailsEntity> campaignEmails = marketEmailsService.lambdaQuery()
                 .eq(MarketEmailsEntity::getMarketingCampaignId, id)
-                .eq(MarketEmailsEntity::getHasFirst, 1)
+//                .eq(MarketEmailsEntity::getHasFirst, 1)
                 .ne(MarketEmailsEntity::getStatus,-3)
                 .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
                 .list();
@@ -349,7 +348,7 @@ public class MarketingCampaignServiceImpl
         Integer sentCountLong = marketEmailsService.lambdaQuery()
                 .eq(MarketEmailsEntity::getMarketingCampaignId, id)
                 .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
-                .eq(MarketEmailsEntity::getHasFirst, 1)
+//                .eq(MarketEmailsEntity::getHasFirst, 1)
                 .eq(MarketEmailsEntity::getStatus, 1)
                 .count();
         Integer sentCount = sentCountLong == null ? 0 : sentCountLong.intValue();
@@ -359,7 +358,7 @@ public class MarketingCampaignServiceImpl
         Integer emailCountAllLong = marketEmailsService.lambdaQuery()
                 .eq(MarketEmailsEntity::getMarketingCampaignId, id)
                 .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
-                .eq(MarketEmailsEntity::getHasFirst, 1)
+//                .eq(MarketEmailsEntity::getHasFirst, 1)
                 .count();
         int emailCountAll = emailCountAllLong == null ? 0 : emailCountAllLong.intValue();
 
@@ -368,7 +367,7 @@ public class MarketingCampaignServiceImpl
         Integer openCountLong = marketEmailsService.lambdaQuery()
                 .eq(MarketEmailsEntity::getMarketingCampaignId, id)
                 .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
-                .eq(MarketEmailsEntity::getHasFirst, 1)
+//                .eq(MarketEmailsEntity::getHasFirst, 1)
                 .eq(MarketEmailsEntity::getStatus, 1)
                 .eq(MarketEmailsEntity::getHasReader, 1)
                 .count();
@@ -582,15 +581,35 @@ public class MarketingCampaignServiceImpl
         if (entity == null || CommonConstant.DEL_FLAG_1.equals(entity.getIsDelete())) {
             return Result.error("营销活动不存在");
         }
-        //如果要开启营销活动,需要先生成邮件模板(即存在待发送的邮件)
+        //如果要开启营销活动,需要先生成全部邮件模板
         if (status == STATUS_RUNNING) {
-            LambdaQueryWrapper<MarketEmailsEntity> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq(MarketEmailsEntity::getMarketingCampaignId, id);
-            queryWrapper.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
-            queryWrapper.eq(MarketEmailsEntity::getStatus, -1);
-            Integer emailsCount = marketEmailsService.count(queryWrapper);
-            if (emailsCount == null || emailsCount <= 0) {
-                return Result.error("请于创建/修改20分钟后,且完成邮件模板配置启动营销!");
+            // 1. 查询该营销活动绑定的 SOP 步骤(marketing_campaign_sop_detail_id 列表)
+            LambdaQueryWrapper<MarketingCampaignSopDetailEntity> sopWrapper = new LambdaQueryWrapper<>();
+            sopWrapper.eq(MarketingCampaignSopDetailEntity::getMarketingId, id);
+            sopWrapper.eq(MarketingCampaignSopDetailEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
+            List<MarketingCampaignSopDetailEntity> sopDetailList = marketingCampaignSopDetailService.list(sopWrapper);
+            if (CollectionUtils.isEmpty(sopDetailList)) {
+                return Result.error("请先配置营销序列(SOP步骤)后再启动营销!");
+            }
+            List<Long> sopDetailIds = sopDetailList.stream()
+                    .map(MarketingCampaignSopDetailEntity::getId)
+                    .filter(sopId -> sopId != null)
+                    .collect(Collectors.toList());
+
+            // 2. 这些 SOP 步骤在 market_emails 表中,每个步骤至少有一封待发送(-1)的邮件即可。
+            //    允许部分客户取消/已发送(状态非 -1),只要该步骤还存在待发送邮件就认为模板就绪。
+            List<MarketEmailsEntity> readyEmails = marketEmailsService.lambdaQuery()
+                    .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
+                    .in(MarketEmailsEntity::getMarketingCampaignSopDetailId, sopDetailIds)
+                    .in(MarketEmailsEntity::getStatus, Arrays.asList(-1,-3))
+                    .select(MarketEmailsEntity::getMarketingCampaignSopDetailId)
+                    .list();
+            Set<Long> readySopDetailIds = readyEmails.stream()
+                    .map(MarketEmailsEntity::getMarketingCampaignSopDetailId)
+                    .filter(sopId -> sopId != null)
+                    .collect(Collectors.toSet());
+            if (readySopDetailIds.size() < sopDetailIds.size()) {
+                return Result.error("营销活动存在未配置待发送邮件模板的营销序列步骤,请确认后再启动营销!");
             }
         }
         entity.setStatus(status);
@@ -630,6 +649,45 @@ public class MarketingCampaignServiceImpl
                 .le(MarketingCampaignEntity::getBeginData, today)
                 .list();
         if (!CollectionUtils.isEmpty(autoStartList)) {
+            List<MarketingCampaignEntity> removeList = new ArrayList<>();
+
+            for (MarketingCampaignEntity entity : autoStartList) {
+                    // 1. 查询该营销活动绑定的 SOP 步骤(marketing_campaign_sop_detail_id 列表)
+                    LambdaQueryWrapper<MarketingCampaignSopDetailEntity> sopWrapper = new LambdaQueryWrapper<>();
+                    sopWrapper.eq(MarketingCampaignSopDetailEntity::getMarketingId, entity.getId());
+                    sopWrapper.eq(MarketingCampaignSopDetailEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
+                    List<MarketingCampaignSopDetailEntity> sopDetailList = marketingCampaignSopDetailService.list(sopWrapper);
+                    if (CollectionUtils.isEmpty(sopDetailList)) {
+                        removeList.add(entity);
+                    }
+                    List<Long> sopDetailIds = sopDetailList.stream()
+                            .map(MarketingCampaignSopDetailEntity::getId)
+                            .filter(sopId -> sopId != null)
+                            .collect(Collectors.toList());
+
+                    // 2. 这些 SOP 步骤在 market_emails 表中,每个步骤至少有一封待发送(-1)的邮件即可。
+                    //    允许部分客户取消/已发送(状态非 -1),只要该步骤还存在待发送邮件就认为模板就绪。
+                    List<MarketEmailsEntity> readyEmails = marketEmailsService.lambdaQuery()
+                            .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
+                            .in(MarketEmailsEntity::getMarketingCampaignSopDetailId, sopDetailIds)
+                            .in(MarketEmailsEntity::getStatus, Arrays.asList(-1,-3))
+                            .select(MarketEmailsEntity::getMarketingCampaignSopDetailId)
+                            .list();
+                    Set<Long> readySopDetailIds = readyEmails.stream()
+                            .map(MarketEmailsEntity::getMarketingCampaignSopDetailId)
+                            .filter(sopId -> sopId != null)
+                            .collect(Collectors.toSet());
+                    if (readySopDetailIds.size() < sopDetailIds.size()) {
+                        removeList.add(entity);
+                    }
+
+            }
+            if (!CollectionUtils.isEmpty(removeList)){
+                autoStartList.removeAll(removeList);
+            }
+            if (CollectionUtils.isEmpty(autoStartList)){
+                return;
+            }
             List<Long> autoStartIdList = autoStartList.stream()
                     .map(MarketingCampaignEntity::getId)
                     .collect(Collectors.toList());

+ 2 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketingCampaignSopDetailServiceImpl.java

@@ -86,6 +86,8 @@ public class MarketingCampaignSopDetailServiceImpl
 
         MarketingCampaignSopDetailEntity entity = new MarketingCampaignSopDetailEntity();
         BeanUtils.copyProperties(dto, entity);
+        // 新增字段:把 DTO 的 List 型字段 join 成逗号串写入 DB(BeanUtils 无法 List↔String 拷贝)
+        MarketingCampaignSopDetailDTO.applyListFieldsToEntity(dto, entity);
         boolean isOk = this.updateById(entity);
         if (!isOk) {
             return Result.error("修改失败");

+ 1 - 1
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/task/CustomerAnalysisWorkflowTask.java

@@ -32,7 +32,7 @@ public class CustomerAnalysisWorkflowTask {
     /**
      * fixedDelayString 读取配置;未配时默认 10000ms。
      */
-    @Scheduled(fixedDelayString = "${storlead.trade.customer-analysis.workflow.interval-ms:10000}")
+    @Scheduled(fixedDelayString = "${storlead.trade.customer-analysis.workflow.interval-ms}")
     public void run() {
         if (!properties.isEnabled()) {
             return;

+ 1 - 1
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/task/CustomerSyncTask.java

@@ -89,7 +89,7 @@ public class CustomerSyncTask {
         List<Long> newCustomerIdList = customerTradeService.list(new LambdaQueryWrapper<CustomerEntity>()
                 .select(CustomerEntity::getId)
                 .eq(CustomerEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
-                .ne(CustomerEntity::getId, customerIdList))
+                .notIn(CustomerEntity::getId, customerIdList))
                 .stream()
                 .map(CustomerEntity::getId)
                 .collect(Collectors.toList());

+ 1 - 1
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/task/MarketStartOrEndTask.java

@@ -18,7 +18,7 @@ public class MarketStartOrEndTask {
     @Resource
     private MarketingCampaignService marketingCampaignService;
 
-    @Scheduled(cron = "0 0 16 * * ?")
+    @Scheduled(cron = "0 0 8 * * ?")
     public void dispatch() {
         long start = System.currentTimeMillis();
         log.info("营销活动开始/结束状态同步任务开始");

+ 30 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/CustomerStatsVO.java

@@ -0,0 +1,30 @@
+package com.storlead.trade.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@ApiModel(value = "CustomerStatsVO", description = "客户统计看板(数量统计)")
+public class CustomerStatsVO implements Serializable {
+
+    @ApiModelProperty(value = "总客户数(未删除 + 客户种类=10,区别于线索=11)")
+    private Long totalCustomerCount;
+
+    @ApiModelProperty(value = "重点客户数(hasFollowCustomer=1)")
+    private Long keyCustomerCount;
+
+    @ApiModelProperty(value = "成交客户数(hasOrderForm=1,有订单)")
+    private Long dealCustomerCount;
+
+    @ApiModelProperty(value = "公海客户数(hasPublicCustomer=1)")
+    private Long publicCustomerCount;
+
+    @ApiModelProperty(value = "无效客户数(hasGarbageCustomer=1,垃圾客户)")
+    private Long invalidCustomerCount;
+
+
+
+}

+ 3 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsManagementVO.java

@@ -58,6 +58,9 @@ public class MarketEmailsManagementVO implements Serializable {
     @ApiModelProperty(value = "邮件状态(1 已发送 / 2 待发送 / 0 已取消)")
     private Integer status;
 
+    @ApiModelProperty("主题")
+    private String subject;
+
     @ApiModelProperty(value = "邮件内容")
     private String content;
 

+ 3 - 1
ui/smarttrade-platform/src/api/customer/index.js

@@ -4,4 +4,6 @@ export const getCustomerList = (data = {}) => post('/router/rest/customerTrade/l
 
 export const getCustomerDetail = (params = {}) => get('/router/rest/customerTrade/getById', params)
 
-export const blocking = (data = {}) => post('/router/rest/chat/blocking', data,{ timeout: 90000 })
+export const getCustomerStats = (params = {}) => get('/router/rest/customerTrade/stats', params)
+
+export const blocking = (data = {}) => post('/router/rest/workflows/blocking', data,{ timeout: 90000 })

+ 2 - 1
ui/smarttrade-platform/src/api/marketing/index.js

@@ -23,4 +23,5 @@ export const saveGenerateEmail = (data = {}) => post('/router/rest/marketing/cam
 export const getEmailDetail = (data = {}) => post('/router/rest/mkt/email/detail', data)
 export const getEmailById = (data = {}) => get('/router/rest/marketEmails/getById', data)
 export const editEmail = (data = {}) => post('/router/rest/marketEmails/editContent', data)
-export const getCustomerSource = (data = {}) => get('/router/rest/customerTrade/source-distribution', data)
+export const getCustomerSource = (data = {}) => get('/router/rest/customerTrade/source-distribution', data)
+export const getSopDetail = (id) => get(`/router/rest/marketing/campaign/sop-detail/get/${id}`)

+ 10 - 0
ui/smarttrade-platform/src/assets/images/icon-gh.svg

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <title>编组 19</title>
+    <g id="生成邮件" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
+        <g id="编组-19" fill-rule="nonzero">
+            <rect id="矩形" x="0" y="0" width="24" height="24"></rect>
+            <path d="M19.3001457,15.0490657 C20.8574653,15.0478614 22.2485377,16.0227368 22.7788591,17.486979 C23.3091806,18.9512211 22.8650107,20.5907873 21.6681047,21.5871116 C20.4711987,22.5834358 18.7782625,22.7228319 17.4345075,21.9357052 C15.6771535,23.093932 13.5944815,23.657604 11.4928554,23.5438042 C10.4598815,23.4909785 9.44163168,23.2761059 8.47538839,22.9070538 L8.21582134,22.8036325 L8.89718485,21.1651155 C9.74483351,21.5179645 10.6492625,21.7227791 11.5841094,21.7734758 C13.1781087,21.8595906 14.7618104,21.4707227 16.1346444,20.6561207 C15.4468913,19.5141094 15.4268816,18.0903602 16.0822691,16.929472 C16.7376566,15.7685839 17.9670318,15.0501836 19.3001457,15.0490657 L19.3001457,15.0490657 Z M6.6401682,5.39641698 L7.60340532,6.8848718 C4.85608741,8.65053524 3.43956864,11.8946912 4.01205178,15.1099028 C5.84363275,14.7645669 7.64583826,15.836732 8.21635632,17.6111206 C8.78687438,19.3855092 7.94724946,21.3071003 6.25762362,22.0939359 C4.56799777,22.8807715 2.55687853,22.2867327 1.56595128,20.7081229 C0.575024021,19.1295131 0.914246431,17.0601145 2.35731181,15.8804925 C1.45432277,11.9111353 3.08311555,7.79484885 6.45766012,5.51808903 L6.6401682,5.39641698 L6.6401682,5.39641698 Z M11.9957666,1 C13.9651556,1.00078574 15.5881784,2.54533271 15.6864856,4.5122667 C19.4494808,6.0358365 21.8977851,9.70588014 21.8593146,13.7654266 L21.8552589,13.974297 L20.0808747,13.9175167 C20.1800943,10.6503509 18.3086031,7.6428542 15.3336366,6.28867873 C14.5462648,7.94156163 12.6676639,8.76913912 10.9166254,8.23449863 C9.1655869,7.69985814 8.06965165,5.96407248 8.33983633,4.15327803 C8.61002102,2.34248359 10.1649263,1.00222405 11.9957666,1.00202787 L11.9957666,1 Z" id="形状" fill="#13BA81"></path>
+        </g>
+    </g>
+</svg>

+ 132 - 0
ui/smarttrade-platform/src/assets/styles/customer.css

@@ -0,0 +1,132 @@
+.data-page { flex: 1; display: flex; flex-direction: column; padding: 24px; overflow-y: auto; background: var(--bg-dark); }
+.data-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
+.data-title { font-size: 20px; font-weight: 600; }
+.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
+.stat-card-lg { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--bg-card); border-radius: 14px; border: 1px solid var(--border); cursor: auto; transition: all 0.2s; }
+/* .stat-card-lg:hover { border-color: var(--primary); } */
+.stat-icon-lg { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: rgba(99, 102, 241, 0.2); color: var(--primary); }
+.stat-icon-lg.green { background: rgba(16, 185, 129, 0.2); color: var(--success); }
+.stat-icon-lg.purple { background: rgba(139, 92, 246, 0.2); color: var(--secondary); }
+.stat-icon-lg.orange { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
+.stat-content-lg h3 { font-size: 24px; font-weight: 700; }
+.stat-content-lg p { font-size: 12px; color: var(--text-secondary); }
+.search-box { position: relative; }
+.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
+.search-input { width: 100%; padding: 10px 14px 10px 40px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); font-size: 13px; }
+.search-input:focus { outline: none; border-color: var(--primary); }
+.form-select { background: var(--bg-card); border: none; color: var(--text-primary);width: auto;padding: 0; }
+.form-select :deep(.el-input__wrapper){ background: var(--bg-card);box-shadow:none;border: 1px solid var(--border);border-radius: 8px;padding: 3px 10px;}
+.form-select :deep(.el-input__wrapper .el-input__inner){color:#fff;}
+.form-select :deep(.el-input__wrapper .el-input__inner::placeholder),
+.filter-customer :deep(.el-select__placeholder.is-transparent){
+  color:#64748b;
+}
+.filter-customer :deep(.el-select__placeholder){
+  color:#fff;
+}
+.filter-customer .form-select{
+  flex: 1;
+}
+.filter-customer :deep(.el-input__wrapper),
+.filter-customer :deep(.el-textarea__inner),
+.filter-customer :deep(.el-select .el-select__wrapper),
+.filter-customer :deep(.el-input-number__wrapper),
+.filter-customer :deep(.el-date-editor.el-input__wrapper) {
+    background: var(--bg-card);
+    border: 1px solid var(--border);
+    box-shadow: none;
+    border-radius: 8px;
+    color: var(--text-primary);
+    width: 100%;
+    box-sizing: border-box;
+    min-width: 0;
+    color:#fff;
+    height: 38px;
+}
+.customer-card { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--bg-card); border-radius: 12px; margin-bottom: 12px; border: 1px solid var(--border); cursor: pointer; transition: all 0.2s; }
+.customer-card:hover { border-color: var(--primary); }
+.customer-flag { font-size: 32px; }
+.customer-info { flex: 1; }
+.customer-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
+.customer-name { font-size: 15px; font-weight: 600; }
+.customer-status { font-size: 10px; padding: 2px 8px; border-radius: 10px; }
+.customer-contact { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
+.customer-meta { display: flex; gap: 16px; font-size: 11px; color: var(--text-muted); }
+.customer-score { text-align: center; margin-right: 20px; }
+.score-circle { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; }
+.score-circle.high { background: rgba(16, 185, 129, 0.2); color: var(--success); }
+.score-circle.medium { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
+.score-circle.low { background: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }
+.score-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
+.customer-actions { display: flex; gap: 8px; }
+.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
+.modal { background: var(--bg-card); border-radius: 16px; width: 100%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
+.customer-detail-modal { max-width: 800px; }
+.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); }
+.modal-title { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 600; }
+.modal-title h3 { font-size: 16px; font-weight: 600; margin: 0;word-break: break-all;}
+.modal-title p { font-size: 12px; color: var(--text-secondary); margin: 4px 0 0 0; }
+.detail-flag { font-size: 32px; }
+.modal-close { width: 32px; height: 32px; background: var(--bg-hover); border: none; border-radius: 8px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
+.modal-close:hover { background: var(--border); color: var(--text-primary); }
+.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
+.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 20px; border-top: 1px solid var(--border); }
+.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
+.detail-stat-card { background: var(--bg-hover); border-radius: 12px; padding: 16px; text-align: center; }
+.detail-stat-value { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
+.detail-stat-value.high { color: var(--success); }
+.detail-stat-value.medium { color: var(--warning); }
+.detail-stat-value.success { color: var(--success); }
+.detail-stat-label { font-size: 12px; color: var(--text-secondary); }
+.detail-section { margin-bottom: 24px; }
+.detail-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
+.detail-section h4 i { color: var(--primary); }
+.contact-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
+.contact-item { display: flex; gap: 12px; padding: 12px; background: var(--bg-hover); border-radius: 10px; }
+.contact-item i { font-size: 16px; color: var(--primary); width: 20px; }
+.contact-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
+.contact-value { font-size: 13px; font-weight: 500; }
+.contact-value.link { color: var(--primary); cursor: pointer; }
+.contact-sub { font-size: 11px; color: var(--text-secondary); }
+.ai-insight-cards { display: flex; flex-direction: column; gap: 10px; }
+.ai-insight-card { display: flex; gap: 12px; padding: 14px; background: var(--bg-hover); border-radius: 12px; border-left: 3px solid var(--primary); }
+.insight-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
+.insight-icon.high { background: rgba(16, 185, 129, 0.2); color: var(--success); }
+.insight-icon.medium { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
+.insight-title { font-size: 13px;  margin-bottom: 4px;white-space: pre-line; }
+.insight-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
+.timeline { display: flex; flex-direction: column; gap: 12px; position: relative; padding-left: 24px; }
+.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--border); }
+.timeline-item { position: relative; }
+.timeline-dot { position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg-card); }
+.timeline-dot.email { background: var(--primary); }
+.timeline-dot.call { background: var(--success); }
+.timeline-dot.meeting { background: var(--warning); }
+.timeline-dot.visit { background: var(--secondary); }
+.timeline-dot.order { background: var(--success); }
+.timeline-content { padding: 12px; background: var(--bg-hover); border-radius: 10px; }
+.timeline-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
+.timeline-action { font-size: 13px; font-weight: 500; }
+.timeline-time { font-size: 11px; color: var(--text-muted); }
+.timeline-detail { font-size: 12px; color: var(--text-secondary); display: flex;justify-content: space-between;}
+.related-opps { display: flex; flex-direction: column; gap: 10px; }
+.related-opp { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg-hover); border-radius: 10px; }
+.opp-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
+.opp-meta { font-size: 11px; color: var(--text-secondary); }
+.opp-status { font-size: 10px; padding: 3px 8px; border-radius: 10px; }
+.opp-status.negotiation { background: rgba(99, 102, 241, 0.2); color: var(--primary); }
+.opp-status.proposal { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
+.opp-status.won { background: rgba(16, 185, 129, 0.2); color: var(--success); }
+.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; gap: 10px; font-size: 13px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); z-index: 2000; }
+.toast.success { border-color: var(--success); }
+.toast.success i { color: var(--success); }
+.toast-enter-active, .toast-leave-active { transition: all 0.3s ease; }
+.toast-enter-from, .toast-leave-to { opacity: 0; transform: translateY(20px); }
+
+.icon-spin {
+  animation: spin 1s linear infinite !important;
+}
+@keyframes spin {
+  0% { transform: rotate(0deg); }
+  100% { transform: rotate(360deg); }
+}

+ 1 - 1
ui/smarttrade-platform/src/components/addMarketing.vue

@@ -1,6 +1,6 @@
 <template>
     <div v-if="showCreateModal" class="modal-overlay" @click.self="closeCreateModal">
-        <div class="modal create-modal">
+        <div class="modal create-modal" style="max-width: 776px">
             <div class="modal-header">
                 <div class="modal-title">
                     <i class="fas fa-plus-circle"></i> {{ modalTitle }}

+ 222 - 0
ui/smarttrade-platform/src/components/customerDetail.vue

@@ -0,0 +1,222 @@
+<template>
+    <div v-if="showDetailModal" class="modal-overlay" @click.self="closeDetail()">
+      <div class="modal customer-detail-modal" v-loading="detailLoading" element-loading-background="rgba(0, 0, 0, 0.5)">
+        <div class="modal-header">
+          <div class="modal-title">
+            <span class="detail-flag">{{ selectedCustomer.flag }}</span>
+            <div>
+              <h3>{{ selectedCustomer.customerName }}</h3>
+              <p>{{ selectedCustomer.industry }} · {{ selectedCustomer.continent }}·{{ selectedCustomer.country }}</p>
+            </div>
+          </div>
+          <button class="modal-close" @click="showDetailModal = false"><i class="fas fa-times"></i></button>
+        </div>
+        <div class="modal-body">
+          <!-- Quick Stats -->
+          <div class="detail-stats">
+            <div class="detail-stat-card">
+              <div class="detail-stat-value" :class="getScoreClass(selectedCustomer?.customerAnalysisResult?.potentialScore ?? 0)">{{selectedCustomer?.customerAnalysisResult?.potentialScore ?? 0}}</div>
+              <div class="detail-stat-label">意向分</div>
+            </div>
+            <div class="detail-stat-card">
+              <div class="detail-stat-value">{{ selectedCustomer.totalOrderCount }}</div>
+              <div class="detail-stat-label">累计订单</div>
+            </div>
+            <div class="detail-stat-card">
+              <div class="detail-stat-value success">¥{{ formatNumber(selectedCustomer.totalOrderAmount) }}</div>
+              <div class="detail-stat-label">累计金额</div>
+            </div>
+            <div class="detail-stat-card">
+              <div class="detail-stat-value">{{selectedCustomer.lastContactDays==null?' - ':selectedCustomer.lastContactDays}}天前</div>
+              <div class="detail-stat-label">最后联系</div>
+            </div>
+          </div>
+
+          <!-- Contact Info -->
+          <div class="detail-section">
+            <h4><i class="fas fa-address-card"></i> 联系信息</h4>
+            <div class="contact-grid">
+              <div class="contact-item">
+                <i class="fas fa-user"></i>
+                <div class="contact-content">
+                  <div class="contact-label">主要联系人</div>
+                  <div class="contact-value">{{ selectedCustomer.liaison?.name }}</div>
+                  <div class="contact-sub">{{ selectedCustomer.liaison?.departmentPosition }}</div>
+                </div>
+              </div>
+              <div class="contact-item">
+                <i class="fas fa-envelope"></i>
+                <div class="contact-content">
+                  <div class="contact-label">邮箱</div>
+                  <div class="contact-value">{{ selectedCustomer.customerCompany?.email }}</div>
+                </div>
+              </div>
+              <div class="contact-item">
+                <i class="fas fa-phone"></i>
+                <div class="contact-content">
+                  <div class="contact-label">电话</div>
+                  <div class="contact-value">{{ selectedCustomer.liaison?.telephone }}</div>
+                </div>
+              </div>
+              <div class="contact-item">
+                <i class="fas fa-globe"></i>
+                <div class="contact-content">
+                  <div class="contact-label">官网</div>
+                  <div class="contact-value link">{{ selectedCustomer.customerCompany?.website }}</div>
+                </div>
+              </div>
+            </div>
+          </div>
+
+          <!-- AI Insights -->
+          <div class="detail-section" >
+            <h4>
+              <div><i class="fas fa-robot"></i> AI 洞察</div>
+              <div><button class="btn btn-primary" @click="aiStreaming(selectedCustomer.id)" style="margin-left: 10px;padding: 4px 8px;border-radius: 4px;" :disabled="aiContentLoading"><i class="fas fa-sync" :class="{'icon-spin': aiContentLoading}" style="color: #fff;"></i> AI分析</button></div> 
+            </h4>
+            <div class="ai-insight-cards" v-if="formattedText">
+              <div class="ai-insight-card">
+                <!-- <div class="insight-icon" :class="insight.level">
+                  <i :class="insight.icon"></i>
+                </div> -->
+                <div class="insight-content">
+                  <div class="insight-title">{{ formattedText }}</div>
+                  <!-- <div class="insight-desc">{{ insight.description }}</div> -->
+                </div>
+              </div>
+            </div>
+          </div>
+
+          <!-- Interaction Timeline -->
+          <div class="detail-section">
+            <h4><i class="fas fa-history"></i> 互动记录</h4>
+            <div class="timeline" v-if="selectedCustomer.mailThreadList">
+              <div class="timeline-item" v-for="record in selectedCustomer.mailThreadList" :key="record.id">
+                <div class="timeline-dot" :class="record.type"></div>
+                <div class="timeline-content">
+                  <div class="timeline-header">
+                    <span class="timeline-action">{{ record.subject }}</span>
+                    <span class="timeline-time">{{ record.expectSendTime }}</span>
+                  </div>
+                  <div class="timeline-detail" v-for="item in record.replyList">
+                    <span class="timeline-action">{{ item.subject }}</span>
+                    <span class="timeline-time">{{ item.recipientDate }}</span>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+
+          <!-- Related Opportunities -->
+          <!-- <div class="detail-section">
+            <h4><i class="fas fa-briefcase"></i> 关联商机</h4>
+            <div class="related-opps">
+              <div class="related-opp" v-for="opp in selectedCustomer.opportunities" :key="opp.id">
+                <div class="opp-info">
+                  <div class="opp-name">{{ opp.name }}</div>
+                  <div class="opp-meta">¥{{ formatNumber(opp.amount) }} · {{ opp.stage }}</div>
+                </div>
+                <div class="opp-status" :class="opp.statusClass">{{ opp.statusLabel }}</div>
+              </div>
+            </div>
+          </div> -->
+        </div>
+        <div class="modal-footer">
+          <button class="btn btn-secondary" @click="closeDetail()">关闭</button>
+          <!-- <button class="btn btn-secondary"><i class="fas fa-edit"></i> 编辑</button> -->
+          <button class="btn btn-primary" @click="goOtherProject(selectedCustomer)">
+            <i class="fas fa-rocket"></i> 客户详情
+          </button>
+        </div>
+      </div>
+    </div>
+</template>
+
+<script setup>
+    import { ref } from 'vue'
+    import { getCustomerDetail,blocking } from '../api/customer'
+
+    const showDetailModal = ref(false)
+    const selectedCustomer = ref({})
+    const detailLoading = ref(false)
+
+    const formattedText = ref('')
+    const customerDetailId = ref()
+    const open = (id) => {
+        aiContentLoading.value = false
+        detailLoading.value = true
+        showDetailModal.value = true
+        customerDetailId.value = id
+        getCustomerDetail({id:id}).then(res => {
+            detailLoading.value = false
+            if(res.success){
+                selectedCustomer.value = res.result
+                if(selectedCustomer.value.customerAnalysisResult){
+                    formattedText.value = selectedCustomer.value.customerAnalysisResult.reasonSummary
+                }else{
+                    formattedText.value = ''
+                }
+            }else{
+                ElMessage.warning(res.message)
+            }
+        })
+    }
+
+    const getScoreClass = (score) => score >= 85 ? 'high' : score >= 70 ? 'medium' : 'low'
+    const formatNumber = (num = 0) => num.toLocaleString()
+
+    const aiContentLoading = ref(false)
+    const aiStreaming= (id) =>{
+        let params = {
+            appId: "app-987GIlcekdNz6P4Zy9Gg5cut",
+            inputs: {"analysis_batch_no":"1","customer_id":+id},
+            // query: "1",
+            response_mode: "blocking",
+            user: "1",
+            // files:[]
+        }
+        if(aiContentLoading.value) return
+        aiContentLoading.value = true
+        ElMessage.warning('AI分析时间大概为2-4分钟,请稍后查看')
+        blocking(params).then(res => {
+            aiContentLoading.value = false
+            if(res.success){
+                open(customerDetailId.value)
+            }
+            // else{
+            //   return ElMessage.error('请求超时,请稍后再试')
+            // }
+        })
+    }
+
+    const goOtherProject = (data) => {
+        const baseUrl = 'https://sales.test.storlead.com/customer/followPanel' // 销售管理系统
+        const params = {
+            id: data.id,
+            resourceType: 10,
+            customerForm: 10,
+            queryRangeType: 0,
+            hasPublicCustomer: true,
+            hasFollowMode: false,
+        }
+        // 拼接参数
+        const queryStr = new URLSearchParams(params).toString()
+        const jumpUrl = `${baseUrl}?${queryStr}`
+        // 新窗口打开
+        window.open(jumpUrl, '_blank')
+        // 当前窗口打开:window.location.href = jumpUrl
+    }
+
+    const closeDetail = ()=>{
+        showDetailModal.value = false
+        aiContentLoading.value = false
+    }
+
+    defineExpose({
+        open
+    })
+</script>
+
+<style scoped>
+@import '../assets/styles/customer.css';
+</style>

+ 222 - 28
ui/smarttrade-platform/src/components/marketing/aiGenerator.vue

@@ -1,6 +1,6 @@
 <template>
     <div v-if="showAIModal" class="modal-overlay" @click.self="showAIModal = false">
-      <div class="modal ai-modal">
+      <div class="modal ai-modal" v-loading="isGenerating" element-loading-text="邮件模板生成中,请稍后">
         <div class="modal-header">
           <div class="modal-title"><i class="fas fa-envelope"></i> AI 邮件生成器</div>
           <button class="modal-close" @click="showAIModal = false"><i class="fas fa-times"></i></button>
@@ -10,14 +10,14 @@
             <div class="generator-input">
               <h4>输入要求</h4>
               <div class="form-group">
-                <label class="form-label">邮件类型</label>
-                <el-select v-model="aiGenerator.inputs.scene">
-                  <el-option v-for="item in typeData" :value="item.name" :label="item.name"></el-option>
+                <label class="form-label">营销序列</label>
+                <el-select v-model="selectedSopId" @change="changeType" :disabled="isGenerating">
+                  <el-option v-for="item in typeData" :key="item.id" :value="item.id" :label="item.name"></el-option>
                 </el-select>
               </div>
               <div class="form-group">
                 <label class="form-label">产品/服务</label>
-                <el-select v-model="aiGenerator.inputs.products">
+                <el-select v-model="aiGenerator.inputs.products" :disabled="isSopLoading">
                   <el-option value="固态硬盘 SSD" label="固态硬盘 SSD"></el-option>
                   <el-option value="机械硬盘 HDD" label="机械硬盘 HDD"></el-option>
                   <el-option value="内存条" label="内存条"></el-option>
@@ -27,7 +27,7 @@
               <div class="form-group">
                 <label class="form-label">核心卖点</label>
                 <div>
-                  <el-checkbox-group v-model="aiGenerator.inputs.core_selling_points">
+                  <el-checkbox-group v-model="aiGenerator.inputs.core_selling_points" :disabled="isSopLoading">
                     <el-checkbox :label="point.label" :value="point.label" v-for="point in sellingPoints" />
                   </el-checkbox-group>
                 </div>
@@ -36,23 +36,23 @@
                 <label class="form-label">语气风格</label>
                 <div class="tone-options">
                   <span v-for="tone in toneOptions" :key="tone.value"
-                        class="tone-option" :class="{ active: aiGenerator.inputs.style === tone.label }"
-                        @click="aiGenerator.inputs.style = tone.label">{{ tone.label }}</span>
+                        class="tone-option" :class="{ active: aiGenerator.inputs.style === tone.label, disabled: isSopLoading }"
+                        @click="!isSopLoading && (aiGenerator.inputs.style = tone.label)">{{ tone.label }}</span>
                 </div>
               </div>
               <div class="form-group">
                 <label class="form-label">语言</label>
                 <div class="language-options">
                   <span v-for="lang in languageOptions" :key="lang.value"
-                        class="language-option" :class="{ active: aiGenerator.inputs.language === lang.label }"
-                        @click="aiGenerator.inputs.language = lang.label">{{ lang.label }}</span>
+                        class="language-option" :class="{ active: aiGenerator.inputs.language === lang.label, disabled: isSopLoading }"
+                        @click="!isSopLoading && (aiGenerator.inputs.language = lang.label)">{{ lang.label }}</span>
                 </div>
               </div>
               <div class="form-group">
                 <label class="form-label">额外要求</label>
-                <el-input type="textarea" v-model="aiGenerator.inputs.extra" :rows="3" resize="none" placeholder="例如:强调价格优势、提及促销信息"></el-input>
+                <el-input type="textarea" v-model="aiGenerator.inputs.extra" :rows="3" resize="none" placeholder="例如:强调价格优势、提及促销信息" :disabled="isSopLoading"></el-input>
               </div>
-              <el-button style="height: 38px;" class="btn btn-primary btn-block" @click="generateEmail" :loading="isGenerating">生成邮件</el-button>
+              <el-button style="height: 38px;" class="btn btn-primary btn-block" @click="generateEmail" :disabled="!selectedSopId || isSopLoading || isGenerating">生成邮件</el-button>
             </div>
             <div class="generator-output">
               <h4>可用参数</h4>
@@ -135,17 +135,17 @@
         <div class="modal-footer">
           <button class="btn btn-secondary" @click="showAIModal = false">关闭</button>
           <button class="btn btn-secondary" @click="previewEmail" :disabled="!emailContent">预览</button>
-          <button class="btn btn-primary" @click="useEmail" :disabled="!emailContent">保存使用</button>
+          <button class="btn btn-primary" @click="useEmail" :disabled="!hasEmailChanges || isSopLoading || isGenerating || isSaving">保存使用</button>
         </div>
       </div>
     </div>
 </template>
 
 <script setup>
-    import { ref } from 'vue'
+    import { computed, ref } from 'vue'
     import { useRouter } from 'vue-router'
     import ckeditor from '@/components/ckeditor/index.vue'
-    import { getSopById, saveGenerateEmail } from '@/api/marketing'
+    import { getSopById, saveGenerateEmail, getSopDetail } from '@/api/marketing'
     import { getToken } from '@/utils/auth'
 
     const showAIModal = ref(false)
@@ -182,12 +182,20 @@
 
     const marketingData = ref()
     const typeData = ref([])
+    const selectedSopId = ref()
+    const activeSopId = ref()
+    const emailDrafts = ref({})
+    const isSopLoading = ref(false)
+    const isSaving = ref(false)
     const emailSubject = ref('')
     const open = (data) => {
         marketingData.value = data
-        getSopById(data.id).then(res => {
-            typeData.value = res.result || []
-        })
+        typeData.value = []
+        emailDrafts.value = {}
+        selectedSopId.value = undefined
+        activeSopId.value = undefined
+        isSopLoading.value = false
+        isSaving.value = false
         aiGenerator.value.inputs = {
             scene: '',
             products: '',
@@ -199,6 +207,125 @@
         emailContent.value = ''
         emailSubject.value = ''
         showAIModal.value = true
+        getSopById(data.id).then(async res => {
+            typeData.value = res.result || []
+            if (typeData.value.length > 0) {
+                selectedSopId.value = typeData.value[0].id
+                await changeType()
+            }
+        }).catch(err => {
+            ElMessage.error(err.message || '营销序列加载失败')
+        })
+    }
+
+    const normalizeProductHighlights = (value) => {
+        if (Array.isArray(value)) return [...value]
+        if (typeof value !== 'string' || !value) return []
+        return value.split(',').filter(Boolean)
+    }
+
+    const normalizeSingleSelection = (listValue, value) => {
+        const values = normalizeProductHighlights(listValue ?? value)
+        return values[0] || ''
+    }
+
+    const getCurrentSettings = () => ({
+        productName: aiGenerator.value.inputs.products,
+        productHighlights: [...aiGenerator.value.inputs.core_selling_points],
+        toneStyle: aiGenerator.value.inputs.style,
+        language: aiGenerator.value.inputs.language,
+        additionalRequirements: aiGenerator.value.inputs.extra
+    })
+
+    const emptySettings = () => ({
+        productName: '',
+        productHighlights: [],
+        toneStyle: '',
+        language: '',
+        additionalRequirements: ''
+    })
+
+    const applySettings = (settings) => {
+        aiGenerator.value.inputs.products = settings.productName
+        aiGenerator.value.inputs.core_selling_points = [...settings.productHighlights]
+        aiGenerator.value.inputs.style = settings.toneStyle
+        aiGenerator.value.inputs.language = settings.language
+        aiGenerator.value.inputs.extra = settings.additionalRequirements
+    }
+
+    const syncActiveEmailDraft = () => {
+        if (activeSopId.value === undefined || activeSopId.value === null) return
+        const draft = emailDrafts.value[String(activeSopId.value)]
+        if (!draft) return
+        draft.emailContent = emailContent.value
+        draft.emailSubject = emailSubject.value
+        draft.settings = getCurrentSettings()
+    }
+
+    const changeType = async () => {
+        syncActiveEmailDraft()
+        const id = selectedSopId.value
+        activeSopId.value = id
+        const selectedSop = typeData.value.find(item => String(item.id) === String(id))
+        aiGenerator.value.inputs.scene = selectedSop ? selectedSop.name : ''
+        if (id === undefined || id === null) {
+            emailContent.value = ''
+            emailSubject.value = ''
+            applySettings(emptySettings())
+            isSopLoading.value = false
+            return
+        }
+
+        const key = String(id)
+        const draft = emailDrafts.value[key]
+        if (draft) {
+            emailContent.value = draft.emailContent
+            emailSubject.value = draft.emailSubject
+            applySettings(draft.settings)
+            isSopLoading.value = false
+            return
+        }
+
+        emailContent.value = ''
+        emailSubject.value = ''
+        applySettings(emptySettings())
+        isSopLoading.value = true
+        try {
+            const res = await getSopDetail(id)
+            const detail = res.result || {}
+            const originalContent = detail.emailContent || ''
+            const originalSubject = detail.emailSubject || ''
+            const originalSettings = {
+                productName: normalizeSingleSelection(detail.productNameList, detail.productName),
+                productHighlights: normalizeProductHighlights(detail.productHighlightsList ?? detail.productHighlights),
+                toneStyle: normalizeSingleSelection(detail.toneStyleList, detail.toneStyle),
+                language: normalizeSingleSelection(detail.languageList, detail.language),
+                additionalRequirements: detail.additionalRequirements || ''
+            }
+            emailDrafts.value[key] = {
+                id,
+                originalContent,
+                originalSubject,
+                emailContent: originalContent,
+                emailSubject: originalSubject,
+                originalSettings,
+                settings: {
+                    ...originalSettings,
+                    productHighlights: [...originalSettings.productHighlights]
+                }
+            }
+            if (String(selectedSopId.value) === String(id)) {
+                emailContent.value = originalContent
+                emailSubject.value = originalSubject
+                applySettings(originalSettings)
+            }
+        } catch (err) {
+            ElMessage.error(err.message || '营销序列邮件加载失败')
+        } finally {
+            if (String(selectedSopId.value) === String(id)) {
+                isSopLoading.value = false
+            }
+        }
     }
 
     const aiShow = ref(false)
@@ -285,6 +412,8 @@
     const generateEmail = async() => {
         isGenerating.value = true
         let params = JSON.parse(JSON.stringify(aiGenerator.value))
+        const selectedSop = typeData.value.find(item => String(item.id) === String(selectedSopId.value))
+        params.inputs.scene = selectedSop ? selectedSop.name : ''
         params.inputs.core_selling_points = params.inputs.core_selling_points.join(',')
         const url = import.meta.env.VITE_API_BASE_URL + 'router/rest/workflows/streaming';
         try {
@@ -384,9 +513,11 @@
             }
             emailContent.value = doneData.replace(/<p>\s*<\/p>/g, '')
             emailSubject.value = subject.replace(': ', '')
-            isGenerating.value = false
         } catch (error) {
             console.error('Fetch error:', error);
+            ElMessage.error('生成失败')
+        } finally {
+            isGenerating.value = false
         }
     }
     const previewEmail = () => {
@@ -400,19 +531,79 @@
         })
         window.open(href, '_blank')
     }
-    const useEmail = () => {
-        let params = {
-            id: typeData.value.filter(item => item.name == aiGenerator.value.inputs.scene)[0].id,
+    const hasSettingsChanged = (settings, originalSettings) =>
+        settings.productName !== originalSettings.productName ||
+        JSON.stringify(settings.productHighlights) !== JSON.stringify(originalSettings.productHighlights) ||
+        settings.toneStyle !== originalSettings.toneStyle ||
+        settings.language !== originalSettings.language ||
+        settings.additionalRequirements !== originalSettings.additionalRequirements
+
+    const hasDraftChanged = (draft) =>
+        draft.emailContent !== draft.originalContent ||
+        draft.emailSubject !== draft.originalSubject ||
+        hasSettingsChanged(draft.settings, draft.originalSettings)
+
+    const hasEmailChanges = computed(() => {
+        const changedDraft = Object.values(emailDrafts.value).some(hasDraftChanged)
+        const activeDraft = emailDrafts.value[String(activeSopId.value)]
+        return changedDraft || Boolean(activeDraft && hasDraftChanged({
+            ...activeDraft,
             emailContent: emailContent.value,
             emailSubject: emailSubject.value,
-            marketingCampaignId: marketingData.value.id
-        }
-        saveGenerateEmail(params).then(res => {
-            ElMessage.success('保存成功')
+            settings: getCurrentSettings()
+        }))
+    })
+
+    const useEmail = async () => {
+        syncActiveEmailDraft()
+        const changedDrafts = Object.entries(emailDrafts.value).filter(([, draft]) => hasDraftChanged(draft))
+        if (changedDrafts.length === 0) return
+
+        isSaving.value = true
+        try {
+            const results = await Promise.allSettled(changedDrafts.map(([, draft]) =>
+                saveGenerateEmail({
+                    id: draft.id,
+                    emailContent: draft.emailContent,
+                    emailSubject: draft.emailSubject,
+                    productName: draft.settings.productName ? [draft.settings.productName] : [],
+                    productHighlights: [...draft.settings.productHighlights],
+                    toneStyle: draft.settings.toneStyle ? [draft.settings.toneStyle] : [],
+                    language: draft.settings.language ? [draft.settings.language] : [],
+                    additionalRequirements: draft.settings.additionalRequirements,
+                    marketingCampaignId: marketingData.value.id
+                })
+            ))
+            results.forEach((result, index) => {
+                if (result.status === 'fulfilled') {
+                    const draft = changedDrafts[index][1]
+                    draft.originalContent = draft.emailContent
+                    draft.originalSubject = draft.emailSubject
+                    draft.originalSettings = {
+                        ...draft.settings,
+                        productHighlights: [...draft.settings.productHighlights]
+                    }
+                }
+            })
+            const failedCount = results.filter(result => result.status === 'rejected').length
+            const messages = results.map((result, index) => {
+                const [, draft] = changedDrafts[index]
+                const sequenceName = typeData.value.find(item => String(item.id) === String(draft.id))?.name || `序列${draft.id}`
+                return result.status === 'fulfilled'
+                    ? `${sequenceName}保存成功`
+                    : `${sequenceName}保存失败:${result.reason?.message || '保存失败'}`
+            })
+            if (failedCount > 0) {
+                ElMessage.error(messages.join(';'))
+                return
+            }
+            ElMessage.success(messages.join(';'))
             showAIModal.value = false
-        }).catch(err => {
+        } catch (err) {
             ElMessage.error(err.message || '保存失败')
-        })
+        } finally {
+            isSaving.value = false
+        }
     }
 
     defineExpose({ open })
@@ -565,4 +756,7 @@
     align-items: center;
     margin-top: 16px;
 }
+.ai-modal :deep(.el-loading-mask){
+    background: #1e293b9a;
+}
 </style>

+ 1 - 1
ui/smarttrade-platform/src/components/marketing/customerDetail.vue

@@ -61,7 +61,7 @@
                             </el-select>
                         </el-form-item>
                         <el-form-item label="" prop="customerSourceDictValue">
-                            <el-select v-model="customerParams.customerSourceDictValue" clearable placeholder="客户来源">
+                            <el-select v-model="customerParams.customerSourceDictValue" fit-input-width clearable placeholder="客户来源">
                                 <el-option label="搜索引擎(例:Google)" value="1" />
                                 <el-option label="公司网站live chat咨询" value="2" />
                                 <el-option label="公司网站留言" value="3" />

+ 31 - 9
ui/smarttrade-platform/src/components/marketing/emailList.vue

@@ -27,6 +27,7 @@
             :key="item.id"
             class="email-card"
             v-if="emailList.length > 0"
+             @click="showDetail(item.customerId)"
           >
             <div class="email-card-left">
               <div class="email-card-top">
@@ -42,13 +43,13 @@
               </div>
             </div>
             <div class="email-card-actions">
-              <button v-if="activeFilter !== 'sent' && activeFilter !== 'error'" class="btn btn-secondary" @click="cancelSend(item)">
+              <button v-if="activeFilter !== 'sent' && activeFilter !== 'error'" class="btn btn-secondary" @click.stop="cancelSend(item)">
                 {{  activeFilter === 'pending' ? '取消' : '重新' }}发送
               </button>
-              <button class="btn btn-secondary" @click="viewDetail(item)" v-if="activeFilter == 'sent' || activeFilter == 'error'">
+              <button class="btn btn-secondary" @click.stop="viewDetail(item)" v-if="activeFilter == 'sent' || activeFilter == 'error'">
                 邮件详情
               </button>
-              <button v-if="activeFilter !== 'sent' && activeFilter !== 'error'" class="btn btn-primary" @click="editEmail(item)">
+              <button v-if="activeFilter !== 'sent' && activeFilter !== 'error'" class="btn btn-primary" @click.stop="editEmail(item)">
                 编辑邮件
               </button>
             </div>
@@ -61,6 +62,8 @@
       </div>
     </div>
   </div>
+
+  <CustomerDetail ref="customerDetailRef" />
 </template>
 
 <script setup>
@@ -68,6 +71,7 @@ import { ref } from 'vue'
 import { useRouter } from 'vue-router'
 import { getEmailList, getEmailCount, cancelEmail } from '@/api/marketing'
 import { ElMessageBox } from 'element-plus'
+import CustomerDetail from '@/components/customerDetail.vue';
 
 const emits = defineEmits(['refresh']);
 const selectedCampaign = ref(null)
@@ -153,12 +157,24 @@ const cancelSend = (item) => {
 }
 
 const viewDetail = (item) => {
-  // 这里可以接入查看详情逻辑
-  const { href } = router.resolve({
-    path: '/emails/detail',
-    query: { id: item.emailId }
-  })
-  window.open(href, '_blank')
+  if(item.status == -4){
+    sessionStorage.setItem('aiEmailPreview', JSON.stringify({
+        subject: item.subject,
+        content: item.content,
+        recipient: item.recipient
+    }))
+    const { href } = router.resolve({
+        path: '/emails/detail',
+        query: { preview: '1' }
+    })
+    window.open(href, '_blank')
+  }else{
+    const { href } = router.resolve({
+      path: '/emails/detail',
+      query: { id: item.emailId }
+    })
+    window.open(href, '_blank')
+  }
 }
 
 const editEmail = (item) => {
@@ -178,6 +194,11 @@ const close = () => {
   showEmailListModal.value = false
 }
 
+const customerDetailRef = ref()
+const showDetail = (id) => {
+  customerDetailRef.value.open(id)
+}
+
 defineExpose({ open, close })
 </script>
 
@@ -247,6 +268,7 @@ defineExpose({ open, close })
   border-left: 4px solid rgba(99, 102, 241, 0.6);
   border-radius: 16px;
   align-items: center;
+  cursor: pointer;
 }
 
 .email-card-left {

+ 15 - 4
ui/smarttrade-platform/src/components/marketing/interventionCustomers.vue

@@ -20,7 +20,7 @@
           <!-- Protected Customers List -->
           <div class="detail-section" v-if="protectedCustomersList.length > 0">
             <div class="protected-customers">
-              <div v-for="customer in protectedCustomersList" :key="customer.id" class="intervention-item" :class="{ 'protected-customer-item': tabType == 'protect', 'suspended-customer-item': tabType == 'suspend' }">
+              <div v-for="customer in protectedCustomersList" :key="customer.id" class="intervention-item" :class="{ 'protected-customer-item': tabType == 'protect', 'suspended-customer-item': tabType == 'suspend' }" @click="showDetail(customer.customerId)">
                 <div style="display: flex;justify-content: space-between;align-items: center;">
                   <div>
                     <div class="customer-header">
@@ -39,7 +39,7 @@
                       <span class="detail">{{ tabType == 'protect' ? '保护' : "暂停" }}时间: {{ tabType == 'protect' ? customer.protectTime : customer.suspendTime }}</span>
                     </div>
                     <div class="customer-actions">
-                      <button class="btn btn-secondary btn-sm" @click="unprotectCustomer(customer)">
+                      <button class="btn btn-secondary btn-sm" @click.stop="unprotectCustomer(customer)">
                         <i class="fas fa-times"></i> {{ tabType == 'protect' ? '移除保护' : "取消暂停" }}
                       </button>
                     </div>
@@ -56,18 +56,21 @@
         </div>
         <div class="modal-footer">
           <button class="btn btn-secondary" @click="showInterventionModal = false">关闭</button>
-          <button class="btn btn-primary" @click="showInterventionModal = false">
+          <!-- <button class="btn btn-primary" @click="showInterventionModal = false">
             <i class="fas fa-download"></i> 导出报告
-          </button>
+          </button> -->
         </div>
       </div>
     </div>
+
+    <CustomerDetail ref="customerDetailRef" />
 </template>
 
 <script setup>
     import { ref } from 'vue';
     import { getInterventionCustomer, setProtectCustomer, setSuspendCustomer } from '@/api/marketing'
     import { ElMessageBox } from 'element-plus'
+    import CustomerDetail from '@/components/customerDetail.vue';
 
     const emits = defineEmits(['refresh']);
     const showInterventionModal = ref(false);
@@ -123,6 +126,11 @@
         getData()
     }
 
+    const customerDetailRef = ref()
+    const showDetail = (id) => {
+      customerDetailRef.value.open(id)
+    }
+
     defineExpose({ open });
 </script>
 
@@ -151,4 +159,7 @@
         font-size: 12px;
         color: #64748B;
     }
+    .intervention-item{
+      cursor: pointer;
+    }
 </style>

+ 1 - 1
ui/smarttrade-platform/src/components/marketing/marketingDetail.vue

@@ -53,7 +53,7 @@
           <div class="detail-section">
             <div class="section-header">
               <h4><i class="fas fa-chart-line"></i> 核心数据</h4>
-              <div class="progress-info">达成 {{ statsData.achievementRate.toFixed(2) }}%</div>
+              <div class="progress-info">活动进度 {{ statsData.achievementRate.toFixed(2) }}%</div>
             </div>
             <div class="detail-progress-bar">
               <div class="progress-fill" :style="{ width: (statsData.achievementRate) + '%' }"></div>

+ 13 - 5
ui/smarttrade-platform/src/components/marketing/openedCustomers.vue

@@ -23,7 +23,7 @@
             </div>
           </div>
           <div v-if="openedCustomers.length > 0" class="customers-list">
-            <div v-for="customer in openedCustomers" class="customer-item" :class="{ protected: customer.hasProtect, suspended: !customer.hasProtect && customer.hasSuspend }">
+            <div v-for="customer in openedCustomers" class="customer-item" :class="{ protected: customer.hasProtect, suspended: !customer.hasProtect && customer.hasSuspend }" @click="showDetail(customer.customerId)">
               <div class="customer-header">
                 <div class="customer-info">
                   <div class="customer-name">
@@ -52,16 +52,16 @@
                 <div class="customer-score-label">点击次数</div>
               </div>
               <div class="customer-actions">
-                <button v-if="!customer.hasProtect" class="btn btn-secondary btn-sm" @click="protectCustomer(customer)" title="添加到保护白名单">
+                <button v-if="!customer.hasProtect" class="btn btn-secondary btn-sm" @click.stop="protectCustomer(customer)" title="添加到保护白名单">
                   <i class="fas fa-shield-alt"></i> 保护
                 </button>
-                <button v-else class="btn btn-secondary btn-sm" @click="protectCustomer(customer)" title="从保护白名单中移除">
+                <button v-else class="btn btn-secondary btn-sm" @click.stop="protectCustomer(customer)" title="从保护白名单中移除">
                   <i class="fas fa-times"></i> 取消保护
                 </button>
-                <button class="btn btn-secondary btn-sm" @click="pauseCampaignForCustomer(customer)" v-if="!customer.hasSuspend" title="暂停向该客户发送邮件">
+                <button class="btn btn-secondary btn-sm" @click.stop="pauseCampaignForCustomer(customer)" v-if="!customer.hasSuspend" title="暂停向该客户发送邮件">
                   <i class="fas fa-pause"></i> 暂停
                 </button>
-                <button class="btn btn-secondary btn-sm" @click="pauseCampaignForCustomer(customer)" v-else title="恢复向该客户发送邮件">
+                <button class="btn btn-secondary btn-sm" @click.stop="pauseCampaignForCustomer(customer)" v-else title="恢复向该客户发送邮件">
                   <i class="fas fa-play"></i> 恢复
                 </button>
               </div>
@@ -77,12 +77,15 @@
         </div>
       </div>
     </div>
+
+    <CustomerDetail ref="customerDetailRef" />
 </template>
 
 <script setup>
     import { ref } from 'vue'
     import { getOpenCustomer, setProtectCustomer, setSuspendCustomer } from '@/api/marketing'
     import { ElMessageBox } from 'element-plus'
+    import CustomerDetail from '@/components/customerDetail.vue';
 
     const emits = defineEmits(['refresh']);
     const showOpenedCustomersModal = ref(false)
@@ -150,6 +153,11 @@
       })
     }
 
+    const customerDetailRef = ref()
+    const showDetail = (id) => {
+      customerDetailRef.value.open(id)
+    }
+
     defineExpose({
         open
     })

+ 17 - 5
ui/smarttrade-platform/src/components/marketing/replyCustomers.vue

@@ -23,7 +23,7 @@
             </div>
           </div>
           <div class="replies-list" v-if="repliedCustomers.length > 0">
-            <div v-for="reply in repliedCustomers" :key="reply.id" class="reply-item" :class="{ approved: reply.hasProtect, 'pending-review': !reply.hasProtect && reply.hasSuspend }">
+            <div v-for="reply in repliedCustomers" :key="reply.id" class="reply-item" :class="{ approved: reply.hasProtect, 'pending-review': !reply.hasProtect && reply.hasSuspend }" @click="showDetail(reply.customerId)">
               <div style="display: flex;justify-content: space-between;margin-bottom: 10px;align-items: center;">
                 <div>
                   <div class="reply-header">
@@ -55,16 +55,16 @@
                 <span>{{ reply.reviewNotes }}</span>
               </div> -->
               <div class="reply-actions">
-                <button v-if="!reply.hasProtect" class="btn btn-secondary btn-sm" @click="protectCustomer(reply)" title="添加到保护白名单">
+                <button v-if="!reply.hasProtect" class="btn btn-secondary btn-sm" @click.stop="protectCustomer(reply)" title="添加到保护白名单">
                   <i class="fas fa-shield-alt"></i> 保护
                 </button>
-                <button v-else class="btn btn-secondary btn-sm" @click="protectCustomer(reply)" title="从保护白名单中移除">
+                <button v-else class="btn btn-secondary btn-sm" @click.stop="protectCustomer(reply)" title="从保护白名单中移除">
                   <i class="fas fa-times"></i> 取消保护
                 </button>
-                <button class="btn btn-secondary btn-sm" @click="pauseCampaignForCustomer(reply)" v-if="!reply.hasSuspend" title="暂停向该客户发送邮件">
+                <button class="btn btn-secondary btn-sm" @click.stop="pauseCampaignForCustomer(reply)" v-if="!reply.hasSuspend" title="暂停向该客户发送邮件">
                   <i class="fas fa-pause"></i> 暂停
                 </button>
-                <button class="btn btn-secondary btn-sm" @click="pauseCampaignForCustomer(reply)" v-else title="恢复向该客户发送邮件">
+                <button class="btn btn-secondary btn-sm" @click.stop="pauseCampaignForCustomer(reply)" v-else title="恢复向该客户发送邮件">
                   <i class="fas fa-play"></i> 恢复
                 </button>
               </div>
@@ -80,12 +80,15 @@
         </div>
       </div>
     </div>
+
+    <CustomerDetail ref="customerDetailRef" />
 </template>
 
 <script setup>
     import { ref } from 'vue';
     import { getReplyCustomer, setProtectCustomer, setSuspendCustomer } from '@/api/marketing'
     import { ElMessageBox } from 'element-plus'
+    import CustomerDetail from '@/components/customerDetail.vue';
 
     const emits = defineEmits(['refresh']);
     const showReplyReviewModal = ref(false);
@@ -151,6 +154,11 @@
       })
     }
 
+    const customerDetailRef = ref()
+    const showDetail = (id) => {
+      customerDetailRef.value.open(id)
+    }
+
     defineExpose({
         open
     })
@@ -181,4 +189,8 @@
         font-size: 12px;
         color: #64748B;
     }
+
+    .reply-item{
+      cursor: pointer;
+    }
 </style>

+ 74 - 366
ui/smarttrade-platform/src/views/CustomersView.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="data-page">
     <div class="data-header">
-      <div class="data-title">📋 客户池 - 共{{ customerStats.total }}家</div>
+      <div class="data-title">📋 客户池 - 共{{ customerStats.totalCustomerCount }}家</div>
       <div style="display: flex; gap: 8px;">
         <button class="btn btn-secondary"><i class="fas fa-download"></i> 导出</button>
         <!-- <button class="btn btn-primary" @click="showAddModal = true"><i class="fas fa-plus"></i> 添加客户</button> -->
@@ -12,46 +12,48 @@
     <div class="stat-row">
       <div class="stat-card-lg"> <!-- @click="filterTab = 'all'" -->
         <div class="stat-icon-lg blue"><i class="fas fa-users"></i></div>
-        <div class="stat-content-lg"><h3>{{ customerStats.total }}</h3><p>总客户数</p></div>
+        <div class="stat-content-lg"><h3>{{ customerStats.totalCustomerCount }}</h3><p>总客户数</p></div>
       </div>
       <div class="stat-card-lg"><!-- @click="filterTab = 'prospect'" -->
         <div class="stat-icon-lg purple"><i class="fas fa-user-clock"></i></div>
-        <div class="stat-content-lg"><h3>{{ customerStats.prospect }}</h3><p>潜在客户</p></div>
+        <div class="stat-content-lg"><h3>{{ customerStats.keyCustomerCount }}</h3><p>重点客户</p></div>
       </div>
       <div class="stat-card-lg"><!-- @click="filterTab = 'intent'" -->
         <div class="stat-icon-lg orange"><i class="fas fa-star"></i></div>
-        <div class="stat-content-lg"><h3>{{ customerStats.intent }}</h3><p>意向客户</p></div>
+        <div class="stat-content-lg"><h3>{{ customerStats.dealCustomerCount }}</h3><p>成交客户</p></div>
       </div>
       <div class="stat-card-lg"><!-- @click="filterTab = 'deal'" -->
-        <div class="stat-icon-lg green"><i class="fas fa-handshake"></i></div>
-        <div class="stat-content-lg"><h3>{{ customerStats.deal }}</h3><p>成交客户</p></div>
+        <div class="stat-icon-lg green"><img src="../assets/images/icon-gh.svg" /></div>
+        <div class="stat-content-lg"><h3>{{ customerStats.publicCustomerCount }}</h3><p>公海客户</p></div>
       </div>
       <div class="stat-card-lg"><!-- @click="filterTab = 'silent'" -->
         <div class="stat-icon-lg" style="background: rgba(148, 163, 184, 0.2); color: var(--text-secondary);"><i class="fas fa-moon"></i></div>
-        <div class="stat-content-lg"><h3>{{ customerStats.silent }}</h3><p>沉默客户</p></div>
+        <div class="stat-content-lg"><h3>{{ customerStats.invalidCustomerCount }}</h3><p>无效客户</p></div>
       </div>
     </div>
 
     <!-- Search & Filter -->
-    <div style="display: flex; gap: 16px; margin-bottom: 20px;">
-      <div class="search-box"  style="flex: 1;">
+    <div style="display: flex; gap: 16px; margin-bottom: 20px;width:100%;" class="filter-customer">
+      <div class="search-box" style="flex: 1;">
         <i class="fas fa-search search-icon"></i>
         <input type="text" v-model="searchQuery" class="search-input" placeholder="搜索公司名称、联系人、邮箱..." @change="getCustomerData">
       </div>
-      <div class="form-select">
-        <el-cascader placeholder="区域名称" :options="region"
-        v-model="regionValue" clearable filterable @change="getRegion" />
+      <div style="flex: 1;display: flex; gap: 16px;width:100%;" >
+        <div class="form-select">
+          <el-cascader placeholder="区域名称" :options="region"
+          v-model="regionValue" clearable filterable @change="getRegion" style="width: 100%;"/>
+        </div>
+        <div class="form-select">
+            <el-select v-model="customerClassify" clearable placeholder="客户分类" @change="getCustomerData()">
+                <el-option label="公海客户" value="1" />
+                <el-option label="无效客户" value="2" />
+                <el-option label="重点客户" value="3" />
+                <el-option label="成交客户" value="4" />
+            </el-select>
+        </div>
       </div>
     </div>
     <div style="display: flex; gap: 16px; margin-bottom: 20px;width:100%;" class="filter-customer">
-      <div class="form-select">
-          <el-select v-model="customerClassify" clearable placeholder="客户分类" @change="getCustomerData()">
-              <el-option label="公海客户" value="1" />
-              <el-option label="无效客户" value="2" />
-              <el-option label="重点客户" value="3" />
-              <el-option label="成交客户" value="4" />
-          </el-select>
-      </div>
       <div class="form-select">
           <el-select v-model="customerParams.customerSourceDictValue" clearable placeholder="客户来源" @change="getCustomerData()">
               <el-option label="搜索引擎(例:Google)" value="1" />
@@ -179,137 +181,7 @@
     /> -->
 
     <!-- Customer Detail Modal -->
-    <div v-if="showDetailModal && selectedCustomer" class="modal-overlay" @click.self="closeDetail()">
-      <div class="modal customer-detail-modal" v-loading="detailLoading" element-loading-background="rgba(0, 0, 0, 0.5)">
-        <div class="modal-header">
-          <div class="modal-title">
-            <span class="detail-flag">{{ selectedCustomer.flag }}</span>
-            <div>
-              <h3>{{ selectedCustomer.customerName }}</h3>
-              <p>{{ selectedCustomer.industry }} · {{ selectedCustomer.continent }}·{{ selectedCustomer.country }}</p>
-            </div>
-          </div>
-          <button class="modal-close" @click="showDetailModal = false"><i class="fas fa-times"></i></button>
-        </div>
-        <div class="modal-body">
-          <!-- Quick Stats -->
-          <div class="detail-stats">
-            <div class="detail-stat-card">
-              <div class="detail-stat-value" :class="getScoreClass(selectedCustomer?.customerAnalysisResult?.potentialScore ?? 0)">{{selectedCustomer?.customerAnalysisResult?.potentialScore ?? 0}}</div>
-              <div class="detail-stat-label">意向分</div>
-            </div>
-            <div class="detail-stat-card">
-              <div class="detail-stat-value">{{ selectedCustomer.totalOrderCount }}</div>
-              <div class="detail-stat-label">累计订单</div>
-            </div>
-            <div class="detail-stat-card">
-              <div class="detail-stat-value success">¥{{ formatNumber(selectedCustomer.totalOrderAmount) }}</div>
-              <div class="detail-stat-label">累计金额</div>
-            </div>
-            <div class="detail-stat-card">
-              <div class="detail-stat-value">{{selectedCustomer.lastContactDays==null?' - ':selectedCustomer.lastContactDays}}天前</div>
-              <div class="detail-stat-label">最后联系</div>
-            </div>
-          </div>
-
-          <!-- Contact Info -->
-          <div class="detail-section">
-            <h4><i class="fas fa-address-card"></i> 联系信息</h4>
-            <div class="contact-grid">
-              <div class="contact-item">
-                <i class="fas fa-user"></i>
-                <div class="contact-content">
-                  <div class="contact-label">主要联系人</div>
-                  <div class="contact-value">{{ selectedCustomer.liaison?.name }}</div>
-                  <div class="contact-sub">{{ selectedCustomer.liaison?.departmentPosition }}</div>
-                </div>
-              </div>
-              <div class="contact-item">
-                <i class="fas fa-envelope"></i>
-                <div class="contact-content">
-                  <div class="contact-label">邮箱</div>
-                  <div class="contact-value">{{ selectedCustomer.customerCompany?.email }}</div>
-                </div>
-              </div>
-              <div class="contact-item">
-                <i class="fas fa-phone"></i>
-                <div class="contact-content">
-                  <div class="contact-label">电话</div>
-                  <div class="contact-value">{{ selectedCustomer.liaison?.telephone }}</div>
-                </div>
-              </div>
-              <div class="contact-item">
-                <i class="fas fa-globe"></i>
-                <div class="contact-content">
-                  <div class="contact-label">官网</div>
-                  <div class="contact-value link">{{ selectedCustomer.customerCompany?.website }}</div>
-                </div>
-              </div>
-            </div>
-          </div>
-
-          <!-- AI Insights -->
-          <div class="detail-section" >
-            <h4>
-              <div><i class="fas fa-robot"></i> AI 洞察</div>
-              <div><button class="btn btn-primary" @click="aiStreaming(selectedCustomer.id)" style="margin-left: 10px;padding: 4px 8px;border-radius: 4px;" :disabled="aiContentLoading"><i class="fas fa-sync" :class="{'icon-spin': aiContentLoading}" style="color: #fff;"></i> AI分析</button></div> 
-            </h4>
-            <div class="ai-insight-cards" v-if="formattedText">
-              <div class="ai-insight-card">
-                <!-- <div class="insight-icon" :class="insight.level">
-                  <i :class="insight.icon"></i>
-                </div> -->
-                <div class="insight-content">
-                  <div class="insight-title">{{ formattedText }}</div>
-                  <!-- <div class="insight-desc">{{ insight.description }}</div> -->
-                </div>
-              </div>
-            </div>
-          </div>
-
-          <!-- Interaction Timeline -->
-          <div class="detail-section">
-            <h4><i class="fas fa-history"></i> 互动记录</h4>
-            <div class="timeline" v-if="selectedCustomer.mailThreadList">
-              <div class="timeline-item" v-for="record in selectedCustomer.mailThreadList" :key="record.id">
-                <div class="timeline-dot" :class="record.type"></div>
-                <div class="timeline-content">
-                  <div class="timeline-header">
-                    <span class="timeline-action">{{ record.subject }}</span>
-                    <span class="timeline-time">{{ record.expectSendTime }}</span>
-                  </div>
-                  <div class="timeline-detail" v-for="item in record.replyList">
-                    <span class="timeline-action">{{ item.subject }}</span>
-                    <span class="timeline-time">{{ item.recipientDate }}</span>
-                  </div>
-                </div>
-              </div>
-            </div>
-          </div>
-
-          <!-- Related Opportunities -->
-          <!-- <div class="detail-section">
-            <h4><i class="fas fa-briefcase"></i> 关联商机</h4>
-            <div class="related-opps">
-              <div class="related-opp" v-for="opp in selectedCustomer.opportunities" :key="opp.id">
-                <div class="opp-info">
-                  <div class="opp-name">{{ opp.name }}</div>
-                  <div class="opp-meta">¥{{ formatNumber(opp.amount) }} · {{ opp.stage }}</div>
-                </div>
-                <div class="opp-status" :class="opp.statusClass">{{ opp.statusLabel }}</div>
-              </div>
-            </div>
-          </div> -->
-        </div>
-        <div class="modal-footer">
-          <button class="btn btn-secondary" @click="closeDetail()">关闭</button>
-          <!-- <button class="btn btn-secondary"><i class="fas fa-edit"></i> 编辑</button> -->
-          <button class="btn btn-primary" @click="goOtherProject(selectedCustomer)">
-            <i class="fas fa-rocket"></i> 客户详情
-          </button>
-        </div>
-      </div>
-    </div>
+    <CustomerDetail ref="customerDetailRef" />
 
     <!-- Toast -->
     <transition name="toast">
@@ -323,10 +195,11 @@
 
 <script setup>
 import { ref, computed } from 'vue'
-import { getCustomerList,getCustomerDetail,blocking } from '../api/customer'
+import { getCustomerList,getCustomerStats } from '../api/customer'
 import {region} from '@/utils/region';
 // 引入添加客户组件
 import AddCustomerModal from '../components/addCustomer.vue'
+import CustomerDetail from '../components/customerDetail.vue';
 
 const showAddModal = ref(false)
 const showDetailModal = ref(false)
@@ -343,21 +216,18 @@ const aiContentLoading = ref(false)
 const formattedText = ref('')
 const detailLoading = ref(false)
 
-const customerParams = ref({
-    customerStatusDictValue: '',
-    customerTypeDictValue: '',
-    customerLevelDictValue: '',
-    customerSourceDictValue: ''
-})
 const customerClassify = ref('')
 
-const customerStats = ref({
-  total: 0,
-  prospect: 0,
-  intent: 0,
-  deal: 0,
-  silent: 0
-})
+const customerStats = ref({})
+
+const getStats = ()=>{
+  getCustomerStats({}).then(res => {
+    if(res.success){
+      customerStats.value = res.result
+    }
+  })
+}
+getStats()
 
 const tabs = ref([
   { key: 'all', label: '全部客户', count: 0 },
@@ -373,26 +243,34 @@ const params = ref({
   pageSize: 10,
   blurry:null,
   country:null,
-  ...customerParams.value
+})
+const customerParams = ref({
+    customerStatusDictValue: '',
+    customerTypeDictValue: '',
+    customerLevelDictValue: '',
+    customerSourceDictValue: ''
 })
 const getCustomer = (type) => {
+    let paramsData = {
+      ...params.value,
+      ...customerParams.value
+    }
     dataLoading.value= true
-    params.value.blurry = searchQuery.value
+    paramsData.blurry = searchQuery.value
     if(customerClassify.value == 1) {
-        params.hasPublicCustomer = 1
+        paramsData.hasPublicCustomer = 1
     }else if(customerClassify.value == 2) {
-        params.hasGarbageCustomer = 1
+        paramsData.hasGarbageCustomer = 1
     }else if(customerClassify.value == 3) {
-        params.hasFollowCustomer = 1
+        paramsData.hasFollowCustomer = 1
     }else if(customerClassify.value == 4) {
-        params.hasOrderForm = 1
-        params.hasPublicCustomer = 0
+        paramsData.hasOrderForm = 1
     }
-    getCustomerList(params.value).then(res => {
+    getCustomerList(paramsData).then(res => {
     dataLoading.value= false
-    if(type=='init'){ //页面初始记录客户总数量
-      customerStats.value.total = res.result.total
-    }
+    // if(type=='init'){ //页面初始记录客户总数量
+    //   customerStats.value.total = res.result.total
+    // }
     customerTotal.value = tabs.value[0].count = res.result.total
     customers.value = res.result.records
   })
@@ -412,69 +290,26 @@ const getRegion = (value) => {
 }
 
 const customerDetailId = ref()
+const customerDetailRef = ref()
 const showCustomerDetail = (id) => {
-  aiContentLoading.value = false
-  detailLoading.value = true
-  showDetailModal.value = true
-  customerDetailId.value = id
-  getCustomerDetail({id:id}).then(res => {
-    detailLoading.value = false
-    if(res.success){
-      selectedCustomer.value = res.result
-      if(selectedCustomer.value.customerAnalysisResult){
-        formattedText.value = selectedCustomer.value.customerAnalysisResult.reasonSummary
-      }else{
-        formattedText.value = ''
-      }
-    }else{
-      ElMessage.warning(res.message)
-    }
-  })
-}
-
-const aiStreaming= (id) =>{
-  let params = {
-    appId: "app-rQrSHhudWbi5LVRkIX4tfVrg",
-    inputs: {"analysis_batch_no":"1","customer_id":+id},
-    query: "1",
-    response_mode: "blocking",
-    user: "1",
-    files:[]
-  }
-  if(aiContentLoading.value) return
-  aiContentLoading.value = true
-  ElMessage.warning('AI分析时间大概为2-4分钟,请稍后查看')
-  blocking(params).then(res => {
-    aiContentLoading.value = false
-    if(res.success){
-      showCustomerDetail(customerDetailId.value)
-    }
-    // else{
-    //   return ElMessage.error('请求超时,请稍后再试')
-    // }
-  })
-}
-
-const goOtherProject = (data) => {
-  const baseUrl = 'https://sales.test.storlead.com/customer/followPanel' // 销售管理系统
-  const params = {
-    id: data.id,
-    resourceType: 10,
-    customerForm: 10,
-    queryRangeType: 0,
-    hasPublicCustomer: true,
-    hasFollowMode: false,
-  }
-  // 拼接参数
-  const queryStr = new URLSearchParams(params).toString()
-  const jumpUrl = `${baseUrl}?${queryStr}`
-  // 新窗口打开
-  window.open(jumpUrl, '_blank')
-  // 当前窗口打开:window.location.href = jumpUrl
-}
-const closeDetail = ()=>{
-  showDetailModal.value = false
-  aiContentLoading.value = false
+  customerDetailRef.value.open(id)
+  // aiContentLoading.value = false
+  // detailLoading.value = true
+  // showDetailModal.value = true
+  // customerDetailId.value = id
+  // getCustomerDetail({id:id}).then(res => {
+  //   detailLoading.value = false
+  //   if(res.success){
+  //     selectedCustomer.value = res.result
+  //     if(selectedCustomer.value.customerAnalysisResult){
+  //       formattedText.value = selectedCustomer.value.customerAnalysisResult.reasonSummary
+  //     }else{
+  //       formattedText.value = ''
+  //     }
+  //   }else{
+  //     ElMessage.warning(res.message)
+  //   }
+  // })
 }
 // const customers = ref([
 //   { 
@@ -556,10 +391,6 @@ const closeDetail = ()=>{
 //   return result
 // })
 
-const formatNumber = (num) => num.toLocaleString()
-
-const getScoreClass = (score) => score >= 85 ? 'high' : score >= 70 ? 'medium' : 'low'
-
 const getStatusBg = (status) => ({
   prospect: 'rgba(139, 92, 246, 0.2)',
   intent: 'rgba(245, 158, 11, 0.2)',
@@ -671,128 +502,5 @@ const handleAddCustomer = (customerData) => {
 </script>
 
 <style scoped>
-.data-page { flex: 1; display: flex; flex-direction: column; padding: 24px; overflow-y: auto; background: var(--bg-dark); }
-.data-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
-.data-title { font-size: 20px; font-weight: 600; }
-.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
-.stat-card-lg { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--bg-card); border-radius: 14px; border: 1px solid var(--border); cursor: auto; transition: all 0.2s; }
-/* .stat-card-lg:hover { border-color: var(--primary); } */
-.stat-icon-lg { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: rgba(99, 102, 241, 0.2); color: var(--primary); }
-.stat-icon-lg.green { background: rgba(16, 185, 129, 0.2); color: var(--success); }
-.stat-icon-lg.purple { background: rgba(139, 92, 246, 0.2); color: var(--secondary); }
-.stat-icon-lg.orange { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
-.stat-content-lg h3 { font-size: 24px; font-weight: 700; }
-.stat-content-lg p { font-size: 12px; color: var(--text-secondary); }
-.search-box { position: relative; }
-.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
-.search-input { width: 100%; padding: 10px 14px 10px 40px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); font-size: 13px; }
-.search-input:focus { outline: none; border-color: var(--primary); }
-.form-select { background: var(--bg-card); border: none; color: var(--text-primary);width: auto;padding: 0; }
-.form-select :deep(.el-input__wrapper){ background: var(--bg-card);box-shadow:none;border: 1px solid var(--border);border-radius: 8px;padding: 3px 10px;}
-.form-select :deep(.el-input__wrapper .el-input__inner){color:#fff;}
-.form-select :deep(.el-input__wrapper .el-input__inner::placeholder){color:#64748b;}
-.filter-customer .form-select{
-  flex: 1;
-}
-.filter-customer :deep(.el-input__wrapper),
-.filter-customer :deep(.el-textarea__inner),
-.filter-customer :deep(.el-select .el-select__wrapper),
-.filter-customer :deep(.el-input-number__wrapper),
-.filter-customer :deep(.el-date-editor.el-input__wrapper) {
-    background: var(--bg-dark);
-    border: 1px solid var(--border);
-    box-shadow: none;
-    border-radius: 8px;
-    color: var(--text-primary);
-    width: 100%;
-    box-sizing: border-box;
-    min-width: 0;
-}
-.customer-card { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--bg-card); border-radius: 12px; margin-bottom: 12px; border: 1px solid var(--border); cursor: pointer; transition: all 0.2s; }
-.customer-card:hover { border-color: var(--primary); }
-.customer-flag { font-size: 32px; }
-.customer-info { flex: 1; }
-.customer-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
-.customer-name { font-size: 15px; font-weight: 600; }
-.customer-status { font-size: 10px; padding: 2px 8px; border-radius: 10px; }
-.customer-contact { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
-.customer-meta { display: flex; gap: 16px; font-size: 11px; color: var(--text-muted); }
-.customer-score { text-align: center; margin-right: 20px; }
-.score-circle { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; }
-.score-circle.high { background: rgba(16, 185, 129, 0.2); color: var(--success); }
-.score-circle.medium { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
-.score-circle.low { background: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }
-.score-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
-.customer-actions { display: flex; gap: 8px; }
-.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
-.modal { background: var(--bg-card); border-radius: 16px; width: 100%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
-.customer-detail-modal { max-width: 800px; }
-.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); }
-.modal-title { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 600; }
-.modal-title h3 { font-size: 16px; font-weight: 600; margin: 0;word-break: break-all;}
-.modal-title p { font-size: 12px; color: var(--text-secondary); margin: 4px 0 0 0; }
-.detail-flag { font-size: 32px; }
-.modal-close { width: 32px; height: 32px; background: var(--bg-hover); border: none; border-radius: 8px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
-.modal-close:hover { background: var(--border); color: var(--text-primary); }
-.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
-.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 20px; border-top: 1px solid var(--border); }
-.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
-.detail-stat-card { background: var(--bg-hover); border-radius: 12px; padding: 16px; text-align: center; }
-.detail-stat-value { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
-.detail-stat-value.high { color: var(--success); }
-.detail-stat-value.medium { color: var(--warning); }
-.detail-stat-value.success { color: var(--success); }
-.detail-stat-label { font-size: 12px; color: var(--text-secondary); }
-.detail-section { margin-bottom: 24px; }
-.detail-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
-.detail-section h4 i { color: var(--primary); }
-.contact-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
-.contact-item { display: flex; gap: 12px; padding: 12px; background: var(--bg-hover); border-radius: 10px; }
-.contact-item i { font-size: 16px; color: var(--primary); width: 20px; }
-.contact-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
-.contact-value { font-size: 13px; font-weight: 500; }
-.contact-value.link { color: var(--primary); cursor: pointer; }
-.contact-sub { font-size: 11px; color: var(--text-secondary); }
-.ai-insight-cards { display: flex; flex-direction: column; gap: 10px; }
-.ai-insight-card { display: flex; gap: 12px; padding: 14px; background: var(--bg-hover); border-radius: 12px; border-left: 3px solid var(--primary); }
-.insight-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
-.insight-icon.high { background: rgba(16, 185, 129, 0.2); color: var(--success); }
-.insight-icon.medium { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
-.insight-title { font-size: 13px;  margin-bottom: 4px;white-space: pre-line; }
-.insight-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
-.timeline { display: flex; flex-direction: column; gap: 12px; position: relative; padding-left: 24px; }
-.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--border); }
-.timeline-item { position: relative; }
-.timeline-dot { position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg-card); }
-.timeline-dot.email { background: var(--primary); }
-.timeline-dot.call { background: var(--success); }
-.timeline-dot.meeting { background: var(--warning); }
-.timeline-dot.visit { background: var(--secondary); }
-.timeline-dot.order { background: var(--success); }
-.timeline-content { padding: 12px; background: var(--bg-hover); border-radius: 10px; }
-.timeline-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
-.timeline-action { font-size: 13px; font-weight: 500; }
-.timeline-time { font-size: 11px; color: var(--text-muted); }
-.timeline-detail { font-size: 12px; color: var(--text-secondary); display: flex;justify-content: space-between;}
-.related-opps { display: flex; flex-direction: column; gap: 10px; }
-.related-opp { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg-hover); border-radius: 10px; }
-.opp-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
-.opp-meta { font-size: 11px; color: var(--text-secondary); }
-.opp-status { font-size: 10px; padding: 3px 8px; border-radius: 10px; }
-.opp-status.negotiation { background: rgba(99, 102, 241, 0.2); color: var(--primary); }
-.opp-status.proposal { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
-.opp-status.won { background: rgba(16, 185, 129, 0.2); color: var(--success); }
-.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; gap: 10px; font-size: 13px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); z-index: 2000; }
-.toast.success { border-color: var(--success); }
-.toast.success i { color: var(--success); }
-.toast-enter-active, .toast-leave-active { transition: all 0.3s ease; }
-.toast-enter-from, .toast-leave-to { opacity: 0; transform: translateY(20px); }
-
-.icon-spin {
-  animation: spin 1s linear infinite !important;
-}
-@keyframes spin {
-  0% { transform: rotate(0deg); }
-  100% { transform: rotate(360deg); }
-}
+@import '../assets/styles/customer.css';
 </style>

+ 4 - 2
ui/smarttrade-platform/src/views/MarketingView.vue

@@ -911,8 +911,8 @@ const aiGeneratorRef = ref()
 const openAIGenerator = (campaign) => {
   let time = campaign.updateTime || campaign.createTime
   // time跟当前时间比,小于20分钟的话,暂时不让操作
-  if (new Date().getTime() - new Date(time).getTime() < 20 * 60 * 1000) {
-    ElMessage.error('邮件正在生成中,请稍后操作')
+  if ((new Date().getTime() - new Date(time).getTime() < 20 * 60 * 1000) && campaign.status == 0) {
+    ElMessage.error('邮件序列正在初始化,请稍后编辑模板')
     return
   }
   selectedCampaign.value = campaign
@@ -938,6 +938,8 @@ const changeStatus = (campaign) => {
     setMarketingStatus({ id: campaign.id, status: campaign.status == 1 ? 2 : 1 }).then(() => {
       ElMessage.success('操作成功')
       getData()
+    }).catch(err => {
+      ElMessage.error(err.message || '操作失败')
     })
   })
 }

+ 2 - 1
ui/smarttrade-platform/src/views/emails/detail.vue

@@ -72,7 +72,8 @@
             const previewData = JSON.parse(sessionStorage.getItem('aiEmailPreview') || '{}')
             Object.assign(emailDetail.value, {
                 subject: previewData.subject || '',
-                content: previewData.content || ''
+                content: previewData.content || '',
+                recipient: previewData.recipient || '',
             })
         } catch (error) {
             console.error('读取邮件预览数据失败:', error)