Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

zhujing 3 týždňov pred
rodič
commit
fd1be7929b
24 zmenil súbory, kde vykonal 972 pridanie a 158 odobranie
  1. 25 19
      java/storlead-knowledge/storlead-knowledge-api/src/main/java/com/storlead/knowledge/api/KnowledgeController.java
  2. 337 0
      java/storlead-mail/storlead-mail-api/src/main/java/com/storlead/mail/controller/crm/MailApiController.java
  3. 72 3
      java/storlead-mail/storlead-mail-api/src/main/java/com/storlead/mail/webclient/client/CrmMailRemoteClient.java
  4. 40 1
      java/storlead-mail/storlead-mail-api/src/main/java/com/storlead/mail/webclient/constant/MailRemoteApiConstants.java
  5. 81 0
      java/storlead-mail/storlead-mail-core/src/main/java/com/storlead/mail/pojo/dto/MailDTO.java
  6. 1 1
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/entity/MarketEmailsEntity.java
  7. 16 12
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/mapper/MarketEmailsMapper.java
  8. 65 30
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketEmailsServiceImpl.java
  9. 1 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketEmailsStatusSyncServiceImpl.java
  10. 36 10
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketingCampaignServiceImpl.java
  11. 16 9
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/task/CustomerSyncTask.java
  12. 7 6
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/CampaignStatsVO.java
  13. 4 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsOpenVO.java
  14. 4 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsProtectVO.java
  15. 3 0
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsStatsVO.java
  16. 7 8
      java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsTodayStatsVO.java
  17. 5 3
      ui/smarttrade-platform/src/assets/styles/marketing.css
  18. 56 4
      ui/smarttrade-platform/src/components/addMarketing.vue
  19. 56 7
      ui/smarttrade-platform/src/components/marketing/customerDetail.vue
  20. 7 6
      ui/smarttrade-platform/src/components/marketing/emailList.vue
  21. 47 16
      ui/smarttrade-platform/src/components/marketing/interventionCustomers.vue
  22. 4 3
      ui/smarttrade-platform/src/components/marketing/marketingDetail.vue
  23. 39 8
      ui/smarttrade-platform/src/components/marketing/openedCustomers.vue
  24. 43 12
      ui/smarttrade-platform/src/components/marketing/replyCustomers.vue

+ 25 - 19
java/storlead-knowledge/storlead-knowledge-api/src/main/java/com/storlead/knowledge/api/KnowledgeController.java

@@ -108,33 +108,38 @@ public class KnowledgeController {
                                     new TypeReference<>() {}
                             );
 
-
                             if (documents_list.isSuccess()) {
                                 Object responseData1 = documents_list.getResult();
-                                Map<?, ?> responseMap2 = (Map<?, ?>) responseData1;
-                                Object dataObj1 = responseMap2.get("data");
+                                Map<?, ?> responseMap1 = (Map<?, ?>) responseData1;
+                                Object dataObj1 = responseMap1.get("data");
                                 if (dataObj1 instanceof List) {
                                     List<?> dataList1 = (List<?>) dataObj1;
                                     for (Object item1 : dataList1) {
                                         if (item1 instanceof Map) {
                                             Map<?, ?> datasetMap1 = (Map<?, ?>) item1;
                                             String document_id = datasetMap1.get("id").toString();
-                                            Long create_at = Long.parseLong(datasetMap1.get("created_at") + "");
-                                            String url2 = difyProperties.getBaseUrl() + "datasets/" + datasets_id + "/documents/" + document_id;
-                                            Result<Object> document_detail_result = httpService.get(
-                                                    url2,
-                                                    null,
-                                                    "Bearer " + difyProperties.getDatasetApiKey(),
-                                                    new TypeReference<>() {
-                                                    });
-                                            if (document_detail_result.isSuccess()) {
-                                                Object responseData2 = document_detail_result.getResult();
-                                                Map<?, ?> responseMap3 = (Map<?, ?>) responseData2;
-                                                Object segment_count = responseMap3.get("segment_count");
-                                                if  (segment_count instanceof Number) {
-                                                    totalChunks += Integer.parseInt(segment_count.toString());
-                                                    if (create_at > oneWeekAgo) {
-                                                        thisWeekCount += Integer.parseInt(segment_count.toString()  );
+                                            String url3 = difyProperties.getBaseUrl()  + "datasets/"+ datasets_id +"/documents/"+document_id +"/segments";
+                                            Result<Object> chunk_results = httpService.get(
+                                                    url3,
+                                                    Map.of("page", 1, "limit", 1000),
+                                                    "Bearer "+difyProperties.getDatasetApiKey(),
+                                                    new TypeReference<>() {}
+                                            );
+                                            if (chunk_results.isSuccess()) {
+                                                Object responseData3 = chunk_results.getResult();
+                                                Map<?, ?> responseMap3 = (Map<?, ?>) responseData3;
+                                                Object dataObj2 = responseMap3.get("data");
+                                                if (dataObj2 instanceof List) {
+                                                    List<?> dataList2 = (List<?>) dataObj2;
+                                                    totalChunks += dataList2.size();
+                                                    for (Object item2 : dataList2) {
+                                                        if (item2 instanceof Map) {
+                                                            Map<?, ?> datasetMap2 = (Map<?, ?>) item2;
+                                                            Long create_at = Long.parseLong(datasetMap2.get("created_at") + "");
+                                                            if (create_at > oneWeekAgo) {
+                                                                thisWeekCount += 1;
+                                                            }
+                                                        }
                                                     }
                                                 }
                                             }
@@ -369,4 +374,5 @@ public class KnowledgeController {
         return Result.ok(result);
     }
 
+
 }

+ 337 - 0
java/storlead-mail/storlead-mail-api/src/main/java/com/storlead/mail/controller/crm/MailApiController.java

@@ -0,0 +1,337 @@
+package com.storlead.mail.controller.crm;
+
+import com.storlead.framework.common.result.Result;
+import com.storlead.mail.pojo.AttachmentDTO;
+import com.storlead.mail.pojo.MailListDTO;
+import com.storlead.mail.pojo.MailMoveDTO;
+import com.storlead.mail.pojo.QueryEmailAddressDTO;
+import com.storlead.mail.pojo.SendMailDTO;
+import com.storlead.mail.pojo.dto.MailDTO;
+import com.storlead.mail.webclient.client.CrmMailRemoteClient;
+import com.storlead.mail.webclient.support.MailRemoteResponseWriter;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * CRM 邮件主流程(路径保持 /mail/**,转发独立邮件服务 /crm/**)。
+ */
+@RestController
+@RequestMapping("/mail")
+@Api(tags = "020.邮件管理相关接口")
+@Log4j2
+public class MailApiController {
+
+    @Resource
+    private CrmMailRemoteClient crmMailRemoteClient;
+
+    @PostMapping(value = "/page_list")
+    @ApiOperation(value = "获取邮件")
+    public Result<?> pageList(MailDTO dto) {
+        return crmMailRemoteClient.pageList(dto);
+    }
+
+    @PostMapping(value = "/get_no_read_count")
+    @ApiOperation(value = "获取未读邮件")
+    public Result<?> getNoReadCount() {
+        return crmMailRemoteClient.getNoReadCount();
+    }
+
+    @PostMapping(value = "/send_mail")
+    @ApiOperation(value = "发送邮件")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> sendMail(SendMailDTO dto) {
+        return crmMailRemoteClient.sendMail(dto);
+    }
+
+    @PostMapping(value = "/asyn_send_mail")
+    @ApiOperation(value = "发送邮件")
+    public Result<?> asynSendMail(SendMailDTO dto) {
+        return crmMailRemoteClient.asynSendMail(dto);
+    }
+
+    @PostMapping(value = "/save_draft")
+    @ApiOperation(value = "保存草稿")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> saveDraft(SendMailDTO dto) {
+        return crmMailRemoteClient.saveDraft(dto);
+    }
+
+    @PostMapping(value = "/receive_mail")
+    @ApiOperation(value = "接收邮件")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> receiveMail() {
+        return crmMailRemoteClient.receiveMail();
+    }
+
+    @PostMapping(value = "/download_mail_eml_zip")
+    @ApiOperation(value = "下载邮件")
+    public void downloadMailEmlZip(MailDTO dto, HttpServletResponse response) {
+        MailRemoteResponseWriter.write(response, crmMailRemoteClient.downloadMailEmlZip(dto));
+    }
+
+    @PostMapping(value = "/download_mail_eml")
+    @ApiOperation(value = "下载邮件")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public void downloadMail(MailDTO dto, HttpServletResponse response) {
+        MailRemoteResponseWriter.write(response, crmMailRemoteClient.downloadMailEml(dto));
+    }
+
+    @PostMapping(value = "/getMailDetail")
+    @ApiOperation(value = "获取邮件详情")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> getMailDetail(Long mailId, Long customerId) {
+        return crmMailRemoteClient.getMailDetail(mailId, customerId);
+    }
+
+    @PostMapping(value = "/mv_mail_box")
+    @ApiOperation(value = "移动邮件")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> mvMailBox(MailMoveDTO dto) {
+        return crmMailRemoteClient.mvMailBox(dto);
+    }
+
+    @PostMapping(value = "/get_contact_mail")
+    @ApiOperation(value = "获取同事邮箱")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> contactMailAccount() {
+        return crmMailRemoteClient.contactMailAccount();
+    }
+
+    @PostMapping(value = "/get_customer_liaison")
+    @ApiOperation(value = "获取客户联系人")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> customerLiaison() {
+        return crmMailRemoteClient.customerLiaison();
+    }
+
+    @PostMapping(value = "/get_mail_customer_liaison")
+    @ApiOperation(value = "获取客户联系人")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> getMailCustomerLiaison(@RequestBody QueryEmailAddressDTO dto) {
+        return crmMailRemoteClient.getMailCustomerLiaison(dto);
+    }
+
+    @PostMapping(value = "/mark_trash")
+    @ApiOperation(value = "垃圾箱")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> mvTrashBox(MailMoveDTO dto) {
+        return crmMailRemoteClient.markTrash(dto);
+    }
+
+    @ApiOperation(value = "彻底删除")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    @PostMapping("/deleteIds")
+    public Result<?> deleteIds(Long[] ids) {
+        return crmMailRemoteClient.deleteIds(ids);
+    }
+
+    @ApiOperation(value = "彻底删除草稿")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    @PostMapping("/deleteDraftIds")
+    public Result<?> deleteDraftIds(Long[] ids) {
+        return crmMailRemoteClient.deleteDraftIds(ids);
+    }
+
+    @PostMapping(value = "/get_mail_detial")
+    @ApiOperation(value = "获取详情接口")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> getMailDetial(Long mailId) {
+        return crmMailRemoteClient.getMailDetial(mailId);
+    }
+
+    @PostMapping(value = "/mv_custom_folder")
+    @ApiOperation(value = "迁移邮件到自定义文件夹", notes = "迁移邮件到自定义文件夹")
+    public Result<?> getMailPortConfig(Long[] mailIds, Long folderId) {
+        return crmMailRemoteClient.mvCustomFolder(mailIds, folderId);
+    }
+
+    @PostMapping(value = "/del_custom_folder_mail")
+    @ApiOperation(value = "获取邮箱端口配置", notes = "获取邮箱端口配置")
+    public Result<?> delCustomFolderMail(Long[] mailIds) {
+        return crmMailRemoteClient.delCustomFolderMail(mailIds);
+    }
+
+    @PostMapping(value = "/mark_star")
+    @ApiOperation(value = "星标")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> takeStar(MailMoveDTO dto) {
+        return crmMailRemoteClient.markStar(dto);
+    }
+
+    @PostMapping(value = "/mark_read")
+    @ApiOperation(value = "已读未读标记")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> markRead(MailMoveDTO dto) {
+        return crmMailRemoteClient.markRead(dto);
+    }
+
+    @PostMapping(value = "/mark_reply_msg_id")
+    @ApiOperation(value = "标记陌生客户回复不回复")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> markReplyMsgId(MailMoveDTO dto) {
+        return crmMailRemoteClient.markReplyMsgId(dto);
+    }
+
+    @PostMapping(value = "/mark_all_read")
+    @ApiOperation(value = "已读未读标记")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> markAllRead() {
+        return crmMailRemoteClient.markAllRead();
+    }
+
+    @PostMapping(value = "/list_mail_attachment")
+    @ApiOperation(value = "邮件附件")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> listMailAttachment(AttachmentDTO dto) {
+        return crmMailRemoteClient.listMailAttachment(dto);
+    }
+
+    @PostMapping(value = "/download_zip")
+    @ApiOperation(value = "打包下载")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public void downloadZip(AttachmentDTO dto, HttpServletResponse response) {
+        MailRemoteResponseWriter.write(response, crmMailRemoteClient.downloadZip(dto));
+    }
+
+    @PostMapping(value = "/download_url")
+    @ApiOperation(value = "下载", notes = "下载")
+    public Result<?> downloadUrl(Long attachmentId) throws IOException {
+        return crmMailRemoteClient.downloadUrl(attachmentId);
+    }
+
+    @PostMapping(value = "/draft_download_url")
+    @ApiOperation(value = "下载", notes = "下载")
+    public Result<?> draft_download(Long attachmentId) throws IOException {
+        return crmMailRemoteClient.draftDownloadUrl(attachmentId);
+    }
+
+    @PostMapping(value = "/draft_download")
+    @ApiOperation(value = "下载", notes = "下载")
+    public void draft_download(Long attachmentId, HttpServletResponse response) throws IOException {
+        MailRemoteResponseWriter.write(response, crmMailRemoteClient.draftDownload(attachmentId));
+    }
+
+    @RequestMapping(value = "/download")
+    @ApiOperation(value = "下载", notes = "下载")
+    public void download(Long attachmentId, HttpServletResponse response) throws IOException {
+        MailRemoteResponseWriter.write(response, crmMailRemoteClient.download(attachmentId));
+    }
+
+    @PostMapping(value = "/mail_port_config")
+    @ApiOperation(value = "获取邮箱端口配置", notes = "获取邮箱端口配置")
+    public Result<?> getMailPortConfig(String mailAccount) throws IOException {
+        return crmMailRemoteClient.mailPortConfig(mailAccount);
+    }
+
+    @PostMapping(value = "/get_unread_count")
+    @ApiOperation(value = "获取邮箱未读数", notes = "获取邮箱未读数")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> getUnReadCount() {
+        return crmMailRemoteClient.getUnReadCount();
+    }
+
+    @PostMapping(value = "/get_new_mail")
+    @ApiOperation(value = "获取未读和最新的邮件", notes = "获取邮箱未读数")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> getNewMail() {
+        return crmMailRemoteClient.getNewMail();
+    }
+
+    @PostMapping(value = "/bind_mail_customer")
+    @ApiOperation(value = "修改客户关系")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> repairMailCustomer(Long userId) {
+        return crmMailRemoteClient.bindMailCustomer(userId);
+    }
+
+    @PostMapping(value = "/bind_mail_customer_all")
+    @ApiOperation(value = "修改客户关系")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> repairMailCustomerAll() {
+        return crmMailRemoteClient.bindMailCustomerAll();
+    }
+
+    @PostMapping(value = "/email_list")
+    @ApiOperation(value = "客户列表-获取邮件")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> emailList(MailListDTO dto) {
+        return crmMailRemoteClient.emailList(dto);
+    }
+
+    @PostMapping(value = "/import_mail_eml")
+    @ApiOperation(value = "导入邮件eml")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> importMailEml(HttpServletResponse response,
+                                   @RequestParam(value = "file", required = true) MultipartFile file) {
+        return crmMailRemoteClient.importMailEml(file);
+    }
+
+    @PostMapping(value = "/import_mail_eml_zip")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "", response = Result.class)
+    })
+    public Result<?> importMailEmlZip(HttpServletResponse response,
+                                      @RequestParam(value = "file", required = true) MultipartFile file,
+                                      String mobileNo) {
+        return crmMailRemoteClient.importMailEmlZip(file, mobileNo);
+    }
+}

+ 72 - 3
java/storlead-mail/storlead-mail-api/src/main/java/com/storlead/mail/webclient/client/CrmMailRemoteClient.java

@@ -2,21 +2,36 @@ package com.storlead.mail.webclient.client;
 
 import com.storlead.framework.common.result.Result;
 import com.storlead.mail.pojo.AttachmentDTO;
-import com.storlead.mail.pojo.MailDTO;
+import com.storlead.mail.pojo.MailListDTO;
 import com.storlead.mail.pojo.MailMoveDTO;
+import com.storlead.mail.pojo.QueryEmailAddressDTO;
 import com.storlead.mail.pojo.SendMailDTO;
+import com.storlead.mail.pojo.dto.MailDTO;
 import com.storlead.mail.webclient.constant.MailRemoteApiConstants;
 import com.storlead.mail.webclient.support.MailRemoteHttpSupport;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
- * CRM 邮件主流程远程客户端,对齐 B 服务 {@code /mail/**}。
+ * CRM 邮件主流程远程客户端,对齐 B 服务 {@code /crm/**}。
  */
 @RequiredArgsConstructor
 public class CrmMailRemoteClient {
 
     private final MailRemoteHttpSupport http;
 
+    public Result<?> pageList(MailDTO dto) {
+        return http.postForm(MailRemoteApiConstants.CRM_PAGE_LIST, dto);
+    }
+
+    public Result<?> getNoReadCount() {
+        return http.postForm(MailRemoteApiConstants.CRM_GET_NO_READ_COUNT, http.formOf());
+    }
+
     public Result<?> sendMail(SendMailDTO dto) {
         return http.postForm(MailRemoteApiConstants.CRM_SEND_MAIL, dto);
     }
@@ -41,10 +56,27 @@ public class CrmMailRemoteClient {
         return http.postForBytes(MailRemoteApiConstants.CRM_DOWNLOAD_MAIL_EML, http.toForm(dto));
     }
 
+    public Result<?> getMailDetail(Long mailId, Long customerId) {
+        return http.postForm(MailRemoteApiConstants.CRM_GET_MAIL_DETAIL_FULL,
+                http.formOf("mailId", mailId, "customerId", customerId));
+    }
+
     public Result<?> mvMailBox(MailMoveDTO dto) {
         return http.postForm(MailRemoteApiConstants.CRM_MV_MAIL_BOX, dto);
     }
 
+    public Result<?> contactMailAccount() {
+        return http.postForm(MailRemoteApiConstants.CRM_GET_CONTACT_MAIL, http.formOf());
+    }
+
+    public Result<?> customerLiaison() {
+        return http.postForm(MailRemoteApiConstants.CRM_GET_CUSTOMER_LIAISON, http.formOf());
+    }
+
+    public Result<?> getMailCustomerLiaison(QueryEmailAddressDTO dto) {
+        return http.postJson(MailRemoteApiConstants.CRM_GET_MAIL_CUSTOMER_LIAISON, dto);
+    }
+
     public Result<?> markTrash(MailMoveDTO dto) {
         return http.postForm(MailRemoteApiConstants.CRM_MARK_TRASH, dto);
     }
@@ -57,7 +89,7 @@ public class CrmMailRemoteClient {
         return http.postForm(MailRemoteApiConstants.CRM_DELETE_DRAFT_IDS, http.formOf("ids", ids));
     }
 
-    public Result<?> getMailDetail(Long mailId) {
+    public Result<?> getMailDetial(Long mailId) {
         return http.postForm(MailRemoteApiConstants.CRM_GET_MAIL_DETAIL, http.formOf("mailId", mailId));
     }
 
@@ -109,4 +141,41 @@ public class CrmMailRemoteClient {
     public byte[] download(Long attachmentId) {
         return http.postForBytes(MailRemoteApiConstants.CRM_DOWNLOAD, http.formOf("attachmentId", attachmentId));
     }
+
+    public Result<?> mailPortConfig(String mailAccount) {
+        return http.postForm(MailRemoteApiConstants.COMMON_MAIL_PORT_CONFIG, http.formOf("mailAccount", mailAccount));
+    }
+
+    public Result<?> getUnReadCount() {
+        return http.postForm(MailRemoteApiConstants.CRM_GET_UNREAD_COUNT, http.formOf());
+    }
+
+    public Result<?> getNewMail() {
+        return http.postForm(MailRemoteApiConstants.CRM_GET_NEW_MAIL, http.formOf());
+    }
+
+    public Result<?> bindMailCustomer(Long userId) {
+        return http.postForm(MailRemoteApiConstants.CRM_BIND_MAIL_CUSTOMER, http.formOf("userId", userId));
+    }
+
+    public Result<?> bindMailCustomerAll() {
+        return http.postForm(MailRemoteApiConstants.CRM_BIND_MAIL_CUSTOMER_ALL, http.formOf());
+    }
+
+    public Result<?> emailList(MailListDTO dto) {
+        return http.postForm(MailRemoteApiConstants.CRM_EMAIL_LIST, dto);
+    }
+
+    public Result<?> importMailEml(MultipartFile file) {
+        return http.postFile(MailRemoteApiConstants.CRM_IMPORT_MAIL_EML, "file", file, null);
+    }
+
+    public Result<?> importMailEmlZip(MultipartFile file, String mobileNo) {
+        Map<String, String> extra = new HashMap<>(2);
+        if (mobileNo != null) {
+            extra.put("mobileNo", mobileNo);
+        }
+        return http.postFile(MailRemoteApiConstants.CRM_IMPORT_MAIL_EML_ZIP, "file", file,
+                extra.isEmpty() ? Collections.emptyMap() : extra);
+    }
 }

+ 40 - 1
java/storlead-mail/storlead-mail-api/src/main/java/com/storlead/mail/webclient/constant/MailRemoteApiConstants.java

@@ -114,7 +114,13 @@ public final class MailRemoteApiConstants {
     /** 测试营销邮箱连通性(以 SMTP 为主),JSON:SmtpPopSettingsEntity */
     public static final String MKT_ACCOUNT_TEST_CONNECT = "/mkt/account/test_connect";
 
-    // ========================= CRM 邮件主流程 /mail =========================
+    // ========================= CRM 邮件主流程 /crm =========================
+
+    /** 邮件分页,form:MailDTO */
+    public static final String CRM_PAGE_LIST = "/crm/page_list";
+
+    /** 未读邮件数量(旧接口 get_no_read_count) */
+    public static final String CRM_GET_NO_READ_COUNT = "/crm/get_no_read_count";
 
     /** 同步发送邮件,form:SendMailDTO */
     public static final String CRM_SEND_MAIL = "/crm/send_mail";
@@ -134,9 +140,21 @@ public final class MailRemoteApiConstants {
     /** 下载单封邮件 eml,form:MailDTO,返回二进制 */
     public static final String CRM_DOWNLOAD_MAIL_EML = "/crm/download_mail_eml";
 
+    /** 邮件详情(含客户),参数:mailId、customerId */
+    public static final String CRM_GET_MAIL_DETAIL_FULL = "/crm/getMailDetail";
+
     /** 移动邮件到指定箱,form:MailMoveDTO */
     public static final String CRM_MV_MAIL_BOX = "/crm/mv_mail_box";
 
+    /** 同事邮箱列表 */
+    public static final String CRM_GET_CONTACT_MAIL = "/crm/get_contact_mail";
+
+    /** 客户联系人邮箱列表 */
+    public static final String CRM_GET_CUSTOMER_LIAISON = "/crm/get_customer_liaison";
+
+    /** 分页查询客户联系人邮箱,JSON:QueryEmailAddressDTO */
+    public static final String CRM_GET_MAIL_CUSTOMER_LIAISON = "/crm/get_mail_customer_liaison";
+
     /** 标记/移入垃圾箱,form:MailMoveDTO */
     public static final String CRM_MARK_TRASH = "/crm/mark_trash";
 
@@ -185,6 +203,27 @@ public final class MailRemoteApiConstants {
     /** 下载正式附件文件流,参数:attachmentId */
     public static final String CRM_DOWNLOAD = "/crm/download";
 
+    /** 未读汇总 get_unread_count */
+    public static final String CRM_GET_UNREAD_COUNT = "/crm/get_unread_count";
+
+    /** 未读与最新邮件 tip */
+    public static final String CRM_GET_NEW_MAIL = "/crm/get_new_mail";
+
+    /** 按用户重绑邮件客户关系,参数:userId */
+    public static final String CRM_BIND_MAIL_CUSTOMER = "/crm/bind_mail_customer";
+
+    /** 全量重绑邮件客户关系 */
+    public static final String CRM_BIND_MAIL_CUSTOMER_ALL = "/crm/bind_mail_customer_all";
+
+    /** 客户列表侧邮件分页,form:MailListDTO */
+    public static final String CRM_EMAIL_LIST = "/crm/email_list";
+
+    /** 导入单封 eml,multipart:file */
+    public static final String CRM_IMPORT_MAIL_EML = "/crm/import_mail_eml";
+
+    /** 导入 eml zip,multipart:file + mobileNo */
+    public static final String CRM_IMPORT_MAIL_EML_ZIP = "/crm/import_mail_eml_zip";
+
     /** 根据邮箱账号查询端口/服务器配置,参数:mailAccount */
     public static final String COMMON_MAIL_PORT_CONFIG = "/common/mail_port_config";
 

+ 81 - 0
java/storlead-mail/storlead-mail-core/src/main/java/com/storlead/mail/pojo/dto/MailDTO.java

@@ -0,0 +1,81 @@
+package com.storlead.mail.pojo.dto;
+
+import com.storlead.framework.mybatis.page.Page;
+import com.storlead.framework.mybatis.query.QueryBaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class MailDTO  extends QueryBaseEntity {
+
+    private String boxCode;
+
+    @ApiModelProperty(value = "邮箱")
+    private String emailAddress;
+
+    private Long mailId;
+    @ApiModelProperty(value = "1:星标")
+    private Integer isStar;
+    @ApiModelProperty(value = "1:垃圾箱")
+    private Integer isTrash;
+    @ApiModelProperty(value = "客户id")
+    private Long customerId;
+
+    @ApiModelProperty(value = "1:已读,0:未读")
+    private Integer readStatu;
+
+    @ApiModelProperty(value = "1:有客户,0:无客户")
+    private Integer bindCustomer;
+
+    @ApiModelProperty(value = "1:线索,0:无线索")
+    private Integer bindClue;
+
+    @ApiModelProperty(value = "1: 只取客户的最后一封邮箱")
+    private Integer latestMail;
+
+    @ApiModelProperty(value = "0:未跟进,1:跟进")
+    private Integer followUpState;
+
+    @ApiModelProperty(value = "系统邮箱")
+    private Integer systemMail;
+
+    @ApiModelProperty(value = "客户类型:10:客户,11: 档案")
+    private Integer customerType;
+
+    private Long ownerBy;
+
+    private Long smtpPopId;
+
+    private  String folder;
+
+    @ApiModelProperty(value = "客户名称")
+    private String customerName;
+
+    @ApiModelProperty(value = "客户类型")
+    private String customerTypeDictValue;
+
+    @ApiModelProperty(value = "客户等级value(对应字典客户等级value)")
+    private String customerLevelDictValue;
+
+    @ApiModelProperty(value = "客户来源value(对应字典客户来源value)")
+    private String customerSourceDictValue;
+
+    @ApiModelProperty(value = "所属大洲(区域)")
+    private String continent;
+
+    @ApiModelProperty(value = "所属国家(区域)")
+    private String country;
+
+    @ApiModelProperty(value = "线索状态value(对应字典线索状态value)")
+    private String clueStatusDictValue;
+
+    @ApiModelProperty(value = "自定义文件夹id")
+    private Long folderId;
+
+    @ApiModelProperty(value = "跟进提醒:默认null,1:查询跟进提醒")
+    private Integer followRemind;
+
+    private List<Long> mailIds;
+}

+ 1 - 1
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/entity/MarketEmailsEntity.java

@@ -35,7 +35,7 @@ public class MarketEmailsEntity extends SysBaseField {
     @TableField("email_id")
     private Long emailId;
 
-    @ApiModelProperty(value = "发送状态:-3取消 -2草稿 -1定时 0发送中 1成功 2失败;收信记录一般为1")
+    @ApiModelProperty(value = "发送状态:-4退回 -3取消 -2草稿 -1定时 0发送中 1成功 2失败;收信记录一般为1")
     @TableField("status")
     private Integer status;
 

+ 16 - 12
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/mapper/MarketEmailsMapper.java

@@ -20,19 +20,23 @@ public interface MarketEmailsMapper extends TradeBaseMapper<MarketEmailsEntity>
     List<MarketEmailsCustomerVO> selectCustomerInfoByCampaign(@Param("dto") MarketEmailsDTO dto);
 
     /**
-     * 客户回复率的分子/分母:先把邮件按「客户×营销活动」(customer_id, marketing_campaign_id) 聚合去重,
-     * 再统计组合总数与「有回复」的组合数。
+     * 邮件回复率的分子/分母,口径为「邮件维度」:<br>
+     * 分母 = 已发送成功的邮件数(status = 1),分子 = 其中 has_reply = 1 的邮件数。
      * <p>
-     * 一个组合内只要有一封邮件 has_reply=1,MAX 就是 1,即该组合记 1 次回复(不因多封回复重复计数)。
-     * customer_id / marketing_campaign_id 为空的邮件不属于任何组合,两边都不计入。
+     * <strong>不做「客户×营销活动」去重</strong>:同一客户在同一活动下发的每一封邮件都单独计数。
+     * 例:9 封已发送邮件、1 封有回复 → 1/9 = 0.1111;
+     * 若按组合去重则只有 5 个组合、结果 1/5 = 0.2,与产品口径不符。
+     * <p>
+     * <strong>必须带 status = 1</strong>:草稿(-2)/待发送(-1)/已取消(-3)/失败(2) 的邮件根本没到客户手上,
+     * 不可能产生回复,算进分母只会稀释回复率。
+     * <p>
+     * 分母与 {@code MarketEmailsTodayStatsVO#totalSendCount} 同源(都是 status = 1 的邮件数)。
      *
-     * @return 单行:combo_count(分母)、replied_count(分子)
+     * @return 单行:send_email_count(分母)、reply_email_count(分子)
      */
-    @Select("SELECT COUNT(*) AS combo_count, "
-            + "COUNT(CASE WHEN replied_flag = 1 THEN 1 END) AS replied_count "
-            + "FROM (SELECT customer_id, marketing_campaign_id, MAX(IFNULL(has_reply, 0)) AS replied_flag "
-            + "      FROM market_emails "
-            + "      WHERE is_delete = 0 AND customer_id IS NOT NULL AND marketing_campaign_id IS NOT NULL "
-            + "      GROUP BY customer_id, marketing_campaign_id) combo")
-    List<Map<String, Object>> selectCustomerReplyRate();
+    @Select("SELECT COUNT(*) AS send_email_count, "
+            + "COUNT(CASE WHEN IFNULL(has_reply, 0) = 1 THEN 1 END) AS reply_email_count "
+            + "FROM market_emails "
+            + "WHERE is_delete = 0 AND status = 1")
+    List<Map<String, Object>> selectEmailReplyRate();
 }

+ 65 - 30
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketEmailsServiceImpl.java

@@ -293,6 +293,13 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
                         }
                     }
                 }
+                // 回填客户 AI 分析结果(一对一关联 customer_analysis_result,取最新一条)
+                Map<Long, CustomerAnalysisResultEntity> analysisMap = getLatestAnalysisMap(customerIdSet);
+                for (MarketEmailsOpenVO v : voList) {
+                    if (v.getCustomerId() != null) {
+                        v.setCustomerAnalysisResult(analysisMap.get(v.getCustomerId()));
+                    }
+                }
             } catch (Exception ex) {
                 log.warn("查询客户名称失败,customerIds={} err={}", customerIdSet, ex.getMessage());
             }
@@ -707,22 +714,8 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
                             if (c.getId() != null) customerMap.put(c.getId(), c);
                         }
                     }
-                    // 回填客户等级 / 核心标签(从 CustomerAnalysisResultEntity)
-                    // 一个 customer 可能有多个分析结果,取最新一条(id 最大)
-                    List<CustomerAnalysisResultEntity> analysisList =
-                            customerAnalysisResultEntityService.list(
-                                    new LambdaQueryWrapper<CustomerAnalysisResultEntity>()
-                                            .in(CustomerAnalysisResultEntity::getCustomerId, customerIdSet)
-                                            .eq(CustomerAnalysisResultEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
-                                            .orderByDesc(CustomerAnalysisResultEntity::getId));
-                    Map<Long, CustomerAnalysisResultEntity> analysisMap = new HashMap<>();
-                    if (!CollectionUtils.isEmpty(analysisList)) {
-                        for (CustomerAnalysisResultEntity a : analysisList) {
-                            if (a.getCustomerId() != null && !analysisMap.containsKey(a.getCustomerId())) {
-                                analysisMap.put(a.getCustomerId(), a);
-                            }
-                        }
-                    }
+                    // 回填客户等级 / 核心标签(从 CustomerAnalysisResultEntity,一对一关联,取最新一条)
+                    Map<Long, CustomerAnalysisResultEntity> analysisMap = getLatestAnalysisMap(customerIdSet);
                     for (MarketEmailsReplyVO v : voList) {
                         CustomerEntity c = customerMap.get(v.getCustomerId());
                         if (c != null) {
@@ -854,6 +847,13 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
                             v.setCustomerName(c.getCustomerName());
                         }
                     }
+                    // 回填客户 AI 分析结果(一对一关联 customer_analysis_result,取最新一条)
+                    Map<Long, CustomerAnalysisResultEntity> analysisMap = getLatestAnalysisMap(customerIdSet);
+                    for (MarketEmailsProtectVO v : voList) {
+                        if (v.getCustomerId() != null) {
+                            v.setCustomerAnalysisResult(analysisMap.get(v.getCustomerId()));
+                        }
+                    }
                 } catch (Exception ex) {
                     log.warn("回填客户名失败,customerIds={} err={}", customerIdSet, ex.getMessage());
                 }
@@ -862,6 +862,36 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
         return Result.ok(voList);
     }
 
+    /**
+     * 批量查询客户最新的 AI 分析结果(一对一关联 customer_analysis_result)。
+     * <p>
+     * 客户与 CustomerAnalysisResultEntity 理论上是一对一,但 DB 上可能因重算产生多条记录;
+     * 这里按 id DESC 取最新一条,避免重复计数。
+     *
+     * @param customerIdSet 客户 id 集合(可为空)
+     * @return key = customerId,value = 最新一条 CustomerAnalysisResultEntity(无命中则为空 map)
+     */
+    private Map<Long, CustomerAnalysisResultEntity> getLatestAnalysisMap(Set<Long> customerIdSet) {
+        Map<Long, CustomerAnalysisResultEntity> analysisMap = new HashMap<>();
+        if (CollectionUtils.isEmpty(customerIdSet)) {
+            return analysisMap;
+        }
+        List<CustomerAnalysisResultEntity> analysisList =
+                customerAnalysisResultEntityService.list(
+                        new LambdaQueryWrapper<CustomerAnalysisResultEntity>()
+                                .in(CustomerAnalysisResultEntity::getCustomerId, customerIdSet)
+                                .eq(CustomerAnalysisResultEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
+                                .orderByDesc(CustomerAnalysisResultEntity::getId));
+        if (!CollectionUtils.isEmpty(analysisList)) {
+            for (CustomerAnalysisResultEntity a : analysisList) {
+                if (a.getCustomerId() != null && !analysisMap.containsKey(a.getCustomerId())) {
+                    analysisMap.put(a.getCustomerId(), a);
+                }
+            }
+        }
+        return analysisMap;
+    }
+
     /**
      * 移除保护:按邮件主键 id 把 has_protect 置 0(保留 has_suspend)
      */
@@ -973,6 +1003,7 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
         base.eq(MarketEmailsEntity::getMarketingCampaignId, marketingCampaignId);
         base.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
         vo.setCancelledCount(this.count(base.clone().eq(MarketEmailsEntity::getStatus, -3)));
+        vo.setFailCount(this.count(base.clone().eq(MarketEmailsEntity::getStatus, -4)));
         vo.setPendingInsertCount(this.count(base.clone().eq(MarketEmailsEntity::getStatus, -2)));
         vo.setPendingSendCount(this.count(base.clone().eq(MarketEmailsEntity::getStatus, -1)));
         vo.setSentCount(this.count(base.clone().eq(MarketEmailsEntity::getStatus, 1)));
@@ -1047,29 +1078,33 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
     }
 
     /**
-     * 客户回复率 = 有回复的「客户×营销活动」组合数 ÷ 全部「客户×营销活动」组合数。
+     * 邮件回复率 = 有回复的已发送邮件数 ÷ 已发送邮件总数(邮件维度,不做客户/活动去重)。
+     * <p>
+     * 口径为「邮件维度」:每一封已发送成功的邮件都单独计数。
+     * 同一客户在同一活动下发的 3 封邮件,分母就贡献 3;回了其中 1 封,分子贡献 1。
      * <p>
-     * 组合指的是 (customer_id, marketing_campaign_id) 这一对:
-     * 同一客户在同一活动下可能收到多封邮件,回过任意一封就算这个组合「已回复」(记 1 次);
-     * 同一客户参加两个活动、只回了其中一个,则是 1/2 = 0.5。
+     * 只统计 status = 1(已发送成功)的邮件:草稿/待发送/已取消/失败的邮件客户收不到,
+     * 不可能有回复,计入分母会把回复率稀释(详见 Mapper 上的 SQL 注释)。
      * <p>
-     * 用 MAX(has_reply) 而不是 COUNT:一个组合内多封邮件只要有一封回复就记 1,不重复计数。
-     * customer_id / marketing_campaign_id 为空的记录不属于任何组合,两边都不计入。
+     * 注意:分母与 {@code totalSendCount} 同源(都是 status = 1 的邮件数),两者应相等;
+     * 这里仍然独立查一次,避免依赖外部调用顺序。
      */
     private void fillCustomerReplyRate(MarketEmailsTodayStatsVO vo) {
-        List<Map<String, Object>> rows = this.baseMapper.selectCustomerReplyRate();
+        List<Map<String, Object>> rows = this.baseMapper.selectEmailReplyRate();
 
         if (CollectionUtils.isEmpty(rows) || rows.get(0) == null) {
             return;
         }
         Map<String, Object> row = rows.get(0);
-        int comboCount = toInteger(row.get("combo_count"));
-        int repliedCount = toInteger(row.get("replied_count"));
-        vo.setCustomerCampaignCount(comboCount);
-        vo.setCustomerRepliedCount(repliedCount);
-        if (comboCount > 0) {
-            vo.setCustomerReplyRate(BigDecimal.valueOf(repliedCount)
-                    .divide(BigDecimal.valueOf(comboCount), 4, RoundingMode.HALF_UP));
+        int sendCount = toInteger(row.get("send_email_count"));
+        int replyCount = toInteger(row.get("reply_email_count"));
+        vo.setReplyEmailCount(replyCount);
+        if (sendCount > 0) {
+            // 前端展示百分比时会 ×100,所以这里的比例要保留 6 位小数,
+            // 转百分比后才有 4 位小数(如 0.111111 → 11.1111%)。
+            // 原来按 4 位算比例,×100 后只剩 2 位小数(0.1111 → 11.11%)。
+            vo.setCustomerReplyRate(BigDecimal.valueOf(replyCount)
+                    .divide(BigDecimal.valueOf(sendCount), 6, RoundingMode.HALF_UP));
         }
     }
 

+ 1 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketEmailsStatusSyncServiceImpl.java

@@ -181,6 +181,7 @@ public class MarketEmailsStatusSyncServiceImpl implements MarketEmailsStatusSync
         if (Integer.valueOf(1).equals(change.getHasRefuse())
                 && !Integer.valueOf(1).equals(existing.getHasRefuse())) {
             update.set(MarketEmailsEntity::getHasRefuse, 1);
+            update.set(MarketEmailsEntity::getStatus, -4);
             changed = true;
         }
         if (!changed) {

+ 36 - 10
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketingCampaignServiceImpl.java

@@ -38,6 +38,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.ZoneId;
 
@@ -140,7 +142,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));
+                    "count(*) as cnt", qw -> qw.eq("status", 1).eq("has_first", 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,
@@ -220,14 +222,19 @@ public class MarketingCampaignServiceImpl
     }
 
     /**
-     * 计算百分比并带 % 返回。denominator <= 0 时返回 "0%"。
+     * 计算百分比并以字符串返回(带 %)。
+     * 先四舍五入保留两位小数,再去掉末尾多余的 0:
+     * 11.11 -> "11.11%",11.10 -> "11.1%",11.00 -> "11%",0.00 -> "0%"。
+     * denominator <= 0 时返回 "0%"。
      */
     private String buildRate(int numerator, int denominator) {
         if (denominator <= 0) {
             return "0%";
         }
-        int pct = (int) Math.round(numerator * 100.0 / denominator);
-        return pct + "%";
+        BigDecimal rate = BigDecimal.valueOf(numerator)
+                .multiply(BigDecimal.valueOf(100))
+                .divide(BigDecimal.valueOf(denominator), 2, RoundingMode.HALF_UP);
+        return rate.stripTrailingZeros().toPlainString() + "%";
     }
 
     @Override
@@ -341,6 +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::getStatus, 1)
                 .count();
         Integer sentCount = sentCountLong == null ? 0 : sentCountLong.intValue();
@@ -350,6 +358,7 @@ public class MarketingCampaignServiceImpl
         Integer emailCountAllLong = marketEmailsService.lambdaQuery()
                 .eq(MarketEmailsEntity::getMarketingCampaignId, id)
                 .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
+                .eq(MarketEmailsEntity::getHasFirst, 1)
                 .count();
         int emailCountAll = emailCountAllLong == null ? 0 : emailCountAllLong.intValue();
 
@@ -358,6 +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::getStatus, 1)
                 .eq(MarketEmailsEntity::getHasReader, 1)
                 .count();
@@ -367,18 +377,19 @@ public class MarketingCampaignServiceImpl
         Integer replyCountLong = marketEmailsService.lambdaQuery()
                 .eq(MarketEmailsEntity::getMarketingCampaignId, id)
                 .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
+//                .eq(MarketEmailsEntity::getHasFirst, 1)
                 .eq(MarketEmailsEntity::getStatus, 1)
                 .eq(MarketEmailsEntity::getHasReply, 1)
                 .count();
         Integer replyCount = replyCountLong == null ? 0 : replyCountLong.intValue();
         stats.setReplyCount(replyCount);
 
-        // 打开率 = openCount / sentCount
-        stats.setOpenRate(sentCount > 0 ? Math.round(openCount * 100f / sentCount) : 0);
-        // 回复率 = replyCount / sentCount
-        stats.setReplyRate(sentCount > 0 ? Math.round(replyCount * 100f / sentCount) : 0);
-        // 达成率 = 已发送数 / 全部未删邮件数(与 getList sentRate 口径一致)
-        stats.setAchievementRate(emailCountAll > 0 ? Math.round(sentCount * 100f / emailCountAll) : 0);
+        // 打开率 = openCount / sentCount,保留两位小数
+        stats.setOpenRate(calcRatePercent(openCount, sentCount));
+        // 回复率 = replyCount / sentCount,保留两位小数
+        stats.setReplyRate(calcRatePercent(replyCount, sentCount));
+        // 达成率 = 已发送数 / 全部未删邮件数(与 getList sentRate 口径一致),保留两位小数
+        stats.setAchievementRate(calcRatePercent(sentCount, emailCountAll));
 
         // 已打开邮件的客户数(distinct customer_id where hasReader=1)
         List<MarketEmailsEntity> openedEmailList = marketEmailsService.lambdaQuery()
@@ -405,6 +416,21 @@ public class MarketingCampaignServiceImpl
         return Result.result(detailVO);
     }
 
+    /**
+     * 计算百分比(0-100,保留两位小数):numerator / denominator * 100,四舍五入(HALF_UP)。
+     * denominator <= 0 时返回 0.00(避免除零)。
+     */
+    private BigDecimal calcRatePercent(int numerator, int denominator) {
+//        numerator =1;
+//        denominator = 3;
+        if (denominator <= 0) {
+            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+        }
+        return BigDecimal.valueOf(numerator)
+                .multiply(BigDecimal.valueOf(100))
+                .divide(BigDecimal.valueOf(denominator), 2, RoundingMode.HALF_UP);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Result<Object> addMarket(MarketingCampaignDTO marketingCampaignDTO) {

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

@@ -70,25 +70,32 @@ public class CustomerSyncTask {
 
     private void doSync() {
         // 1. 查 customer_analysis_result 中已有的最大 customer_id(无记录则从 0 开始全量同步)
-        CustomerAnalysisResultEntity maxEntity = customerAnalysisResultService.lambdaQuery()
+//        CustomerAnalysisResultEntity maxEntity = customerAnalysisResultService.lambdaQuery()
+//                .select(CustomerAnalysisResultEntity::getCustomerId)
+//                .orderByDesc(CustomerAnalysisResultEntity::getCustomerId)
+//                .last("LIMIT 1")
+//                .one();
+//        long maxCustomerId = maxEntity == null || maxEntity.getCustomerId() == null
+//                ? 0L : maxEntity.getCustomerId();
+        List<Long> customerIdList = customerAnalysisResultService.list(new LambdaQueryWrapper<CustomerAnalysisResultEntity>()
                 .select(CustomerAnalysisResultEntity::getCustomerId)
-                .orderByDesc(CustomerAnalysisResultEntity::getCustomerId)
-                .last("LIMIT 1")
-                .one();
-        long maxCustomerId = maxEntity == null || maxEntity.getCustomerId() == null
-                ? 0L : maxEntity.getCustomerId();
+                .eq(CustomerAnalysisResultEntity::getIsDelete, CommonConstant.DEL_FLAG_0))
+                .stream()
+                .map(CustomerAnalysisResultEntity::getCustomerId)
+                .collect(Collectors.toList());
+
 
         // 2. 查客户表中 id 大于 maxCustomerId 的未删除客户(只取 id)
         List<Long> newCustomerIdList = customerTradeService.list(new LambdaQueryWrapper<CustomerEntity>()
                 .select(CustomerEntity::getId)
                 .eq(CustomerEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
-                .gt(CustomerEntity::getId, maxCustomerId))
+                .ne(CustomerEntity::getId, customerIdList))
                 .stream()
                 .map(CustomerEntity::getId)
                 .collect(Collectors.toList());
 
         if (newCustomerIdList.isEmpty()) {
-            log.info("[CustomerSyncTask] 无新增客户,maxCustomerId={},本次同步 0 条", maxCustomerId);
+            log.info("[CustomerSyncTask] 无新增客户");
             return;
         }
 
@@ -104,6 +111,6 @@ public class CustomerSyncTask {
             }).collect(Collectors.toList());
             customerAnalysisResultService.saveBatch(entityList);
         }
-        log.info("[CustomerSyncTask] 同步完成,maxCustomerId={},新增 {} 条客户待分析记录", maxCustomerId, total);
+        log.info("[CustomerSyncTask] 同步完成,新增 {} 条客户待分析记录",  total);
     }
 }

+ 7 - 6
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/CampaignStatsVO.java

@@ -2,6 +2,7 @@ package com.storlead.trade.vo;
 
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import java.math.BigDecimal;
 import lombok.Data;
 
 @Data
@@ -23,14 +24,14 @@ public class CampaignStatsVO {
     @ApiModelProperty(value = "回复数(market_emails.hasReply=1)")
     private Integer replyCount;
 
-    @ApiModelProperty(value = "打开率(0-100)")
-    private Integer openRate;
+    @ApiModelProperty(value = "打开率(0-100,保留两位小数)")
+    private BigDecimal openRate;
 
-    @ApiModelProperty(value = "回复率(0-100)")
-    private Integer replyRate;
+    @ApiModelProperty(value = "回复率(0-100,保留两位小数)")
+    private BigDecimal replyRate;
 
-    @ApiModelProperty(value = "达成率(0-100)")
-    private Integer achievementRate;
+    @ApiModelProperty(value = "达成率(0-100,保留两位小数)")
+    private BigDecimal achievementRate;
 
     @ApiModelProperty(value = "已打开邮件的客户数(distinct customer_id, hasReader=1)")
     private Integer openCustomerCount;

+ 4 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsOpenVO.java

@@ -3,6 +3,7 @@ package com.storlead.trade.vo;
 import com.alibaba.fastjson.annotation.JSONField;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.storlead.trade.entity.CustomerAnalysisResultEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -32,6 +33,9 @@ public class MarketEmailsOpenVO implements Serializable {
     @ApiModelProperty(value = "客户名称")
     private String customerName;
 
+    @ApiModelProperty(value = "客户AI分析结果(一对一关联 customer_analysis_result,取最新一条)")
+    private CustomerAnalysisResultEntity customerAnalysisResult;
+
     @ApiModelProperty(value = "打开次数(来自 market_emails.open_count 字段)")
     private Integer openCount;
 

+ 4 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsProtectVO.java

@@ -3,6 +3,7 @@ package com.storlead.trade.vo;
 import com.alibaba.fastjson.annotation.JSONField;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.storlead.trade.entity.CustomerAnalysisResultEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -37,6 +38,9 @@ public class MarketEmailsProtectVO implements Serializable {
     @ApiModelProperty(value = "客户名称")
     private String customerName;
 
+    @ApiModelProperty(value = "客户AI分析结果(一对一关联 customer_analysis_result,取最新一条)")
+    private CustomerAnalysisResultEntity customerAnalysisResult;
+
     @ApiModelProperty(value = "保护原因")
     private String protectReason;
 

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

@@ -21,6 +21,9 @@ public class MarketEmailsStatsVO implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    @ApiModelProperty(value = "已取消数量(status = -4)")
+    private Integer failCount;
+
     @ApiModelProperty(value = "已取消数量(status = -3)")
     private Integer cancelledCount;
 

+ 7 - 8
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsTodayStatsVO.java

@@ -31,14 +31,13 @@ public class MarketEmailsTodayStatsVO implements Serializable {
     @ApiModelProperty(value = "累计邮件发送总数(全部 status=1 发送成功的邮件,不限时间)")
     private Integer totalSendCount = 0;
 
-    @ApiModelProperty(value = "客户回复率:对「客户×营销活动」去重后,有回复的组合占比。"
-            + "同一客户在同一活动回过一封即算 1;同一客户在两个活动只回了其中一个,则为 0.5。"
-            + "取值范围 0~1,保留 4 位小数;无有效组合时为 0")
+    @ApiModelProperty(value = "邮件回复率(0~1 的比例,不是百分比):有回复的邮件数 ÷ 已发送邮件数。"
+            + "邮件维度,不做客户/活动去重,同一客户在同一活动发的多封邮件各自单独计数。"
+            + "取值范围 0~1,保留 6 位小数,前端 ×100 转百分比后即得 4 位小数(如 0.111111 → 11.1111%)。"
+            + "分母为 0 时为 0。"
+            + "注意:末位是 0 时 JS 会按 number 抹掉尾零(0.100000 解析成 0.1),前端展示请用 toFixed(4)")
     private BigDecimal customerReplyRate = BigDecimal.ZERO;
 
-    @ApiModelProperty(value = "参与统计的「客户×营销活动」组合数(分母,已去重)")
-    private Integer customerCampaignCount = 0;
-
-    @ApiModelProperty(value = "有回复的「客户×营销活动」组合数(分子,已去重)")
-    private Integer customerRepliedCount = 0;
+    @ApiModelProperty(value = "有回复的已发送邮件数(回复率的分子,status=1 且 has_reply=1)")
+    private Integer replyEmailCount = 0;
 }

+ 5 - 3
ui/smarttrade-platform/src/assets/styles/marketing.css

@@ -203,6 +203,7 @@
 .customer-item .customer-info { flex: 1; }
 .customer-item .customer-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
 .customer-item .protection-badge { font-size: 10px; padding: 2px 8px; background: rgba(16, 185, 129, 0.2); color: var(--success); border-radius: 10px; font-weight: normal; }
+.customer-item .suspend-badge { font-size: 10px; padding: 2px 8px; background: rgba(245, 158, 11, 0.2); color: var(--warning); border-radius: 10px; font-weight: normal; }
 .customer-item .customer-email { font-size: 12px; color: var(--text-muted); }
 .customer-item .customer-badges { display: flex; gap: 8px; }
 .customer-item .value-badge { font-size: 11px; padding: 4px 10px; border-radius: 10px; }
@@ -210,12 +211,12 @@
 .customer-item .value-badge.中价值 { background: rgba(245, 158, 11, 0.2); color: #F59E0B; }
 .customer-item .value-badge.低价值 { background: rgba(107, 114, 128, 0.2); color: #6B7280; }
 .customer-item .engagement-badge { font-size: 11px; padding: 4px 10px; border-radius: 10px; }
-.customer-item .customer-details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-size: 12px; }
+.customer-item .customer-details { font-size: 12px; }
 .customer-item .detail-item { display: flex; justify-content: space-between; padding: 6px 8px; background: var(--bg-dark); border-radius: 6px; }
 .customer-item .detail-item .label { color: var(--text-muted); }
 .customer-item .detail-item .value { font-weight: 600; }
 .customer-item .customer-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
-.customer-item .customer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
+.customer-item .customer-actions { display: flex; gap: 8px; flex-wrap: wrap;justify-content: flex-end; }
 
 .replies-list { display: flex; flex-direction: column; gap: 12px; }
 .reply-item { padding: 14px; background: var(--bg-hover); border-radius: 10px; border-left: 3px solid var(--border); transition: all 0.2s; }
@@ -236,7 +237,7 @@
 .reply-item .priority-badge.medium { background: rgba(245, 158, 11, 0.2); color: #F59E0B; }
 .reply-item .priority-badge.low { background: rgba(107, 114, 128, 0.2); color: #6B7280; }
 .reply-item .reply-customer-info { display: flex; gap: 16px; font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
-.reply-item .reply-time { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
+.reply-item .reply-time { font-size: 11px; color: var(--text-muted); }
 .reply-item .reply-content { padding: 10px; background: var(--bg-dark); border-radius: 8px; margin-bottom: 10px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
 .reply-item .reply-review-notes { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; background: rgba(99, 102, 241, 0.1); border-radius: 6px; margin-bottom: 10px; font-size: 12px; color: var(--text-secondary); }
 .reply-item .reply-review-notes i { color: var(--primary); margin-top: 2px; flex-shrink: 0; }
@@ -311,6 +312,7 @@
 .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-icon-lg.success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
+.stat-icon-lg.warning { background: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }
 .stat-content-lg h3 { font-size: 24px; font-weight: 700; }
 .stat-content-lg p { font-size: 12px; color: var(--text-secondary); }
 

+ 56 - 4
ui/smarttrade-platform/src/components/addMarketing.vue

@@ -205,6 +205,37 @@
                             <h5><i class="fas fa-filter"></i> 高级筛选</h5>
                             <button class="btn-link" @click="clearFilters">清除筛选</button>
                         </div>
+                        <div class="filter-row">
+                            <div class="form-group">
+                                <label class="form-label">客户分类</label>
+                                <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-group">
+                                <label class="form-label">客户来源</label>
+                                <el-select v-model="customerParams.customerSourceDictValue" clearable placeholder="客户来源" @change="getCustomerData()">
+                                    <el-option label="搜索引擎(例:Google)" value="1" />
+                                    <el-option label="公司网站live chat咨询" value="2" />
+                                    <el-option label="公司网站留言" value="3" />
+                                    <el-option label="sales信箱" value="4" />
+                                    <el-option label="德国Embedded展会" value="5" />
+                                    <el-option label="CES展会" value="6" />
+                                    <el-option label="B2ClT" value="7" />
+                                    <el-option label="CEBIT展会" value="8" />
+                                    <el-option label="中国制造网" value="9" />
+                                    <el-option label="Computex展会" value="10" />
+                                    <el-option label="客户介绍" value="11" />
+                                    <el-option label="社交媒体(例:Linkedln)" value="12" />
+                                    <el-option label="SalesForce" value="13" />
+                                    <el-option label="香港电子展" value="14" />
+                                    <el-option label="官网注册用户" value="15" />
+                                </el-select>
+                            </div>
+                        </div>
                         <div class="filter-row">
                             <div class="form-group">
                                 <label class="form-label">地区</label>
@@ -1003,9 +1034,13 @@
             country: '',
             customerStatusDictValue: '',
             customerTypeDictValue: '',
-            customerLevelDictValue: ''
+            customerLevelDictValue: '',
+            customerSourceDictValue: '',
         }
-        getCustomerData()
+        customerClassify.value = ''
+        regionValue.value = []
+        customerList.value = []
+        sourceData.value = []
     }
     const removeTag = (tag) => {
         const idx = newCampaign.value.filters.selectedTags.indexOf(tag)
@@ -1167,12 +1202,29 @@
         country: '',
         customerStatusDictValue: '',
         customerTypeDictValue: '',
-        customerLevelDictValue: ''
+        customerLevelDictValue: '',
+        customerSourceDictValue: ''
     })
+    const customerClassify = ref('')
     const customerList = ref([])
     const sourceData = ref([])
     const getCustomerData = () => {
-        getTradeCustomer({ pageIndex: 1, pageSize: 10000, ...customerParams.value }).then(res => {
+        let params = {
+            pageIndex: 1,
+            pageSize: 10000,
+            ...customerParams.value
+        }
+        if(customerClassify.value == 1) {
+            params.hasPublicCustomer = 1
+        }else if(customerClassify.value == 2) {
+            params.hasGarbageCustomer = 1
+        }else if(customerClassify.value == 3) {
+            params.hasFollowCustomer = 1
+        }else if(customerClassify.value == 4) {
+            params.hasOrderForm = 1
+            params.hasPublicCustomer = 0
+        }
+        getTradeCustomer(params).then(res => {
             customerList.value = res.result.records || []
             newCampaign.value.filters.selectedTags = customerList.value.map(item => item.customerName)
             sourceData.value = []

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

@@ -52,6 +52,33 @@
                                 <el-option label="D级" value="4" />
                             </el-select>
                         </el-form-item>
+                        <el-form-item label="" prop="customerClassify">
+                            <el-select v-model="customerClassify" clearable placeholder="客户分类">
+                                <el-option label="公海客户" value="1" />
+                                <el-option label="无效客户" value="2" />
+                                <el-option label="重点客户" value="3" />
+                                <el-option label="成交客户" value="4" />
+                            </el-select>
+                        </el-form-item>
+                        <el-form-item label="" prop="customerSourceDictValue">
+                            <el-select v-model="customerParams.customerSourceDictValue" clearable placeholder="客户来源">
+                                <el-option label="搜索引擎(例:Google)" value="1" />
+                                <el-option label="公司网站live chat咨询" value="2" />
+                                <el-option label="公司网站留言" value="3" />
+                                <el-option label="sales信箱" value="4" />
+                                <el-option label="德国Embedded展会" value="5" />
+                                <el-option label="CES展会" value="6" />
+                                <el-option label="B2ClT" value="7" />
+                                <el-option label="CEBIT展会" value="8" />
+                                <el-option label="中国制造网" value="9" />
+                                <el-option label="Computex展会" value="10" />
+                                <el-option label="客户介绍" value="11" />
+                                <el-option label="社交媒体(例:Linkedln)" value="12" />
+                                <el-option label="SalesForce" value="13" />
+                                <el-option label="香港电子展" value="14" />
+                                <el-option label="官网注册用户" value="15" />
+                            </el-select>
+                        </el-form-item>
                     </el-form>
                     <div class="btn-div">
                         <button class="btn btn-primary" @click="searchCustomer">
@@ -82,7 +109,7 @@
                                 </div>
                                 <div class="customer-card-right">
                                     <div class="card-right" v-if="customer.customerAnalysisResult">
-                                        <div class="customer-score">{{ customer.customerAnalysisResult.potentialScore }}</div>
+                                        <div class="customer-score">{{ customer.customerAnalysisResult.potentialScore || 0 }}</div>
                                         <div class="customer-score-label">意向分</div>
                                     </div>
                                     <div class="right-btn" @click="handleBtn(customer)">
@@ -142,13 +169,17 @@
             customerStatusDictValue: '',
             customerTypeDictValue: '',
             customerLevelDictValue: '',
-            liaisonName: ''
+            liaisonName: '',
+            customerSourceDictValue: ''
         }
+        customerClassify.value = ''
         if(type == 'detail'){
             filterData.value = data
             allData.value = data
             customers.value = data.slice(0, 10)
             total.value = data.length
+        }else{
+            getCustomerData()
         }
         showCustomerPreview.value = true
     }
@@ -161,8 +192,10 @@
         customerStatusDictValue: '',
         customerTypeDictValue: '',
         customerLevelDictValue: '',
-        liaisonName: ''
+        liaisonName: '',
+        customerSourceDictValue: ''
     })
+    const customerClassify = ref('')
     const regionValue = ref([])
     const getRegion = (value) => {
         customerParams.value.country = value ? value[1] : ''
@@ -173,7 +206,18 @@
     const customers = ref([])
     const total = ref(0)
     const getCustomerData = () => {
-        getTradeCustomer(customerParams.value).then(res => {
+        let params = JSON.parse(JSON.stringify(customerParams.value))
+        if(customerClassify.value == 1) {
+            params.hasPublicCustomer = 1
+        }else if(customerClassify.value == 2) {
+            params.hasGarbageCustomer = 1
+        }else if(customerClassify.value == 3) {
+            params.hasFollowCustomer = 1
+        }else if(customerClassify.value == 4) {
+            params.hasOrderForm = 1
+            params.hasPublicCustomer = 0
+        }
+        getTradeCustomer(params).then(res => {
             customers.value = res.result.records || []
             total.value = res.result.total || 0
         })
@@ -199,7 +243,12 @@
                 const typeMatch = customerParams.value.customerTypeDictValue ? (item.customerTypeDictValue == customerParams.value.customerTypeDictValue) : true
                 const levelMatch = customerParams.value.customerLevelDictValue ? (item.customerLevelDictValue == customerParams.value.customerLevelDictValue) : true
                 const countryMatch = customerParams.value.country ? (item.country == customerParams.value.country) : true
-                return blurryMatch && liaisonMatch && statusMatch && typeMatch && levelMatch && countryMatch
+                const sourceMatch = customerParams.value.customerSourceDictValue ? (item.customerSourceDictValue == customerParams.value.customerSourceDictValue) : true
+                const publicMatch = customerClassify.value == 1 ? (item.hasPublicCustomer == 1) : true
+                const garbageMatch = customerClassify.value == 2 ? (item.hasGarbageCustomer == 1) : true
+                const followMatch = customerClassify.value == 3 ? (item.hasFollowCustomer == 1) : true
+                const orderFormMatch = customerClassify.value == 4 ? (item.hasOrderForm == 1 && item.hasPublicCustomer == 0) : true
+                return blurryMatch && liaisonMatch && statusMatch && typeMatch && levelMatch && countryMatch && sourceMatch && publicMatch && garbageMatch && followMatch && orderFormMatch
             })
             customers.value = filterData.value.slice(0, 10)
             total.value = filterData.value.length
@@ -209,9 +258,9 @@
     const resetCustomerParams = () => {
         customerFormRef.value.resetFields()
         regionValue.value = []
+        customerClassify.value = ''
         if(modalType.value == 'add'){
-            customers.value = []
-            total.value = 0
+            getCustomerData()
         }else{
             filterData.value = allData.value
             customers.value = allData.value.slice(0, 10)

+ 7 - 6
ui/smarttrade-platform/src/components/marketing/emailList.vue

@@ -36,19 +36,19 @@
                     <span class="status-pill">{{ item.stageName }}</span>
                   </div>
                   <div class="email-card-subtitle">{{ item.recipient }}</div>
-                  <div class="email-card-subtitle">预计发送时间:{{ item.expectSendTime }}</div>
+                  <div class="email-card-subtitle">{{ activeFilter == 'error' || activeFilter == 'sent' ? '' : '预计' }}发送时间:{{ item.expectSendTime }}</div>
                 </div>
                 
               </div>
             </div>
             <div class="email-card-actions">
-              <button v-if="activeFilter !== 'sent'" class="btn btn-secondary" @click="cancelSend(item)">
+              <button v-if="activeFilter !== 'sent' && activeFilter !== 'error'" class="btn btn-secondary" @click="cancelSend(item)">
                 {{  activeFilter === 'pending' ? '取消' : '重新' }}发送
               </button>
-              <button class="btn btn-secondary" @click="viewDetail(item)" v-if="activeFilter == 'sent'">
+              <button class="btn btn-secondary" @click="viewDetail(item)" v-if="activeFilter == 'sent' || activeFilter == 'error'">
                 邮件详情
               </button>
-              <button v-if="activeFilter !== 'sent'" class="btn btn-primary" @click="editEmail(item)">
+              <button v-if="activeFilter !== 'sent' && activeFilter !== 'error'" class="btn btn-primary" @click="editEmail(item)">
                 编辑邮件
               </button>
             </div>
@@ -95,7 +95,8 @@ const getStatusCounts = () => {
     tabData.value = [
       { value: 'pending', title: '待发送', count: res.result.pendingSendCount || 0 },
       { value: 'sent', title: '已发送', count: res.result.sentCount || 0 },
-      { value: 'failed', title: '已取消', count: res.result.cancelledCount || 0 }
+      { value: 'failed', title: '已取消', count: res.result.cancelledCount || 0 },
+      { value: 'error', title: '发送失败', count: res.result.failCount || 0 }
     ]
   })
 }
@@ -107,7 +108,7 @@ const getList = () => {
     marketingCampaignId: selectedCampaign.value.id,
     pageIndex: 1,
     pageSize: 10000,
-    status: activeFilter.value === 'pending' ? -1 : activeFilter.value === 'sent' ? 1 : -3
+    status: activeFilter.value === 'pending' ? -1 : activeFilter.value === 'sent' ? 1 : activeFilter.value === 'failed' ? -3 : -4
   }
   getEmailList(params).then((res) => {
     emailList.value = res.result.records || []

+ 47 - 16
ui/smarttrade-platform/src/components/marketing/interventionCustomers.vue

@@ -21,25 +21,33 @@
           <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 class="customer-header">
-                  <div class="customer-info">
-                    <div class="customer-name">
-                      {{ customer.customerName }}
-                      <!-- <span class="protection-level" :class="customer.protectionLevel">
-                        {{ customer.protectionLevel }}保护
-                      </span> -->
+                <div style="display: flex;justify-content: space-between;align-items: center;">
+                  <div>
+                    <div class="customer-header">
+                      <div class="customer-info">
+                        <div class="customer-name">
+                          {{ customer.customerName }}
+                          <!-- <span class="protection-level" :class="customer.protectionLevel">
+                            {{ customer.protectionLevel }}保护
+                          </span> -->
+                        </div>
+                        <div class="customer-email">{{ customer.recipient }}</div>
+                      </div>
+                    </div>
+                    <div class="customer-details">
+                      <!-- <span class="detail">{{ tabType == 'protect' ? '保护' : "暂停" }}原因: {{ customer.protectReason }}</span> -->
+                      <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)">
+                        <i class="fas fa-times"></i> {{ tabType == 'protect' ? '移除保护' : "取消暂停" }}
+                      </button>
                     </div>
-                    <div class="customer-email">{{ customer.recipient }}</div>
                   </div>
+                  <div class="card-score" v-if="customer.customerAnalysisResult">
+                    <div class="customer-score">{{ customer.customerAnalysisResult.potentialScore || 0 }}</div>
+                    <div class="customer-score-label">意向分</div>
                 </div>
-                <div class="customer-details">
-                  <!-- <span class="detail">{{ tabType == 'protect' ? '保护' : "暂停" }}原因: {{ customer.protectReason }}</span> -->
-                  <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)">
-                    <i class="fas fa-times"></i> {{ tabType == 'protect' ? '移除保护' : "取消暂停" }}
-                  </button>
                 </div>
               </div>
             </div>
@@ -120,4 +128,27 @@
 
 <style scoped>
     @import '../../assets/styles/marketing.css';
+    .card-score{
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+    }
+    .customer-score {
+        width: 54px;
+        height: 54px;
+        display: flex;
+        border-radius: 50%;
+        align-items: center;
+        background: rgba(34, 197, 94, 0.12);
+        color: var(--success);
+        font-size: 18px;
+        font-weight: 700;
+        justify-content: center;
+    }
+
+    .customer-score-label {
+        margin-top: 3px;
+        font-size: 12px;
+        color: #64748B;
+    }
 </style>

+ 4 - 3
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 }}%</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>
@@ -101,8 +101,9 @@
                     <span>回复率: {{ selectedCampaign.replyRate }}%</span>
                   </div>
                 </div>
-                <div class="channel-status">
-                  <span class="status-dot active"></span> 运行中
+                <div class="channel-status" :style="{ color: selectedCampaign.status == 0 ? 'white' : selectedCampaign.status == 1 ? 'var(--success)' : selectedCampaign.status == 2 ? 'var(--warning)' : 'var(--primary)' }">
+                  <span class="status-dot" :class="{ 'active': selectedCampaign.status == 1 }"></span> 
+                  {{ getStatusLabel(selectedCampaign.status || 0) }}
                 </div>
               </div>
             </div>

+ 39 - 8
ui/smarttrade-platform/src/components/marketing/openedCustomers.vue

@@ -1,6 +1,6 @@
 <template>
     <div v-if="showOpenedCustomersModal" class="modal-overlay" @click.self="showOpenedCustomersModal = false">
-      <div class="modal detail-modal">
+      <div class="modal detail-modal" style="max-width: 800px;">
         <div class="modal-header">
           <div class="modal-title">
             <i class="fas fa-envelope-open"></i> 打开邮件的客户 ({{ openedCustomers.length }})
@@ -31,19 +31,25 @@
                     <span v-if="customer.hasProtect" class="protection-badge">
                       <i class="fas fa-shield-alt"></i> 已保护
                     </span>
+                    <span v-if="customer.hasSuspend" class="suspend-badge">
+                      <i class="fas fa-pause"></i> 营销暂停
+                    </span>
                   </div>
                   <div class="customer-email">{{ customer.recipient }}</div>
+                  <div class="customer-email" style="margin-top: 3px;">打开时间:{{ customer.firstOpenTime }}</div>
                 </div>
               </div>
-              <div class="customer-details">
-                <div class="detail-item">
-                  <span class="label">打开时间:</span>
-                  <span class="value">{{ customer.firstOpenTime }}</span>
-                </div>
-                <div class="detail-item">
+              <div class="card-score" v-if="customer.customerAnalysisResult">
+                  <div class="customer-score">{{ customer.customerAnalysisResult.potentialScore || 0 }}</div>
+                  <div class="customer-score-label">意向分</div>
+              </div>
+              <div class="card-score">
+                <!-- <div class="detail-item">
                   <span class="label">点击次数:</span>
                   <span class="value">{{ customer.openCount }}次</span>
-                </div>
+                </div> -->
+                <div class="customer-score" style="background: var(--bg-dark);color: #FFF;">{{ customer.openCount }}</div>
+                <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="添加到保护白名单">
@@ -153,5 +159,30 @@
     @import '../../assets/styles/marketing.css';
     .customer-item{
       justify-content: space-between;
+      display: grid;
+      grid-template-columns: 2.5fr 1fr 1fr 1.5fr;
+    }
+    .card-score{
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+    }
+    .customer-score {
+        width: 54px;
+        height: 54px;
+        display: flex;
+        border-radius: 50%;
+        align-items: center;
+        background: rgba(34, 197, 94, 0.12);
+        color: var(--success);
+        font-size: 18px;
+        font-weight: 700;
+        justify-content: center;
+    }
+
+    .customer-score-label {
+        margin-top: 3px;
+        font-size: 12px;
+        color: #64748B;
     }
 </style>

+ 43 - 12
ui/smarttrade-platform/src/components/marketing/replyCustomers.vue

@@ -24,21 +24,29 @@
           </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 class="reply-header">
-                <div class="reply-info">
-                  <div class="reply-name">
-                    {{ reply.customerName }}
+              <div style="display: flex;justify-content: space-between;margin-bottom: 10px;align-items: center;">
+                <div>
+                  <div class="reply-header">
+                    <div class="reply-info">
+                      <div class="reply-name">
+                        {{ reply.customerName }}
+                      </div>
+                      <div class="reply-email">{{ reply.recipient }}</div>
+                    </div>
+                    <!-- <div class="reply-badges">
+                      <span class="priority-badge" :class="reply.priority">
+                        {{ reply.priority }}优先级
+                      </span>
+                      <span class="value-badge" :class="reply.value">{{ reply.value }}</span>
+                    </div> -->
                   </div>
-                  <div class="reply-email">{{ reply.recipient }}</div>
+                  <div class="reply-time">回复时间: {{ reply.firstReplyTime }}</div>
+                </div>
+                <div class="card-score" v-if="reply.customerAnalysisResult">
+                    <div class="customer-score">{{ reply.customerAnalysisResult.potentialScore || 0 }}</div>
+                    <div class="customer-score-label">意向分</div>
                 </div>
-                <!-- <div class="reply-badges">
-                  <span class="priority-badge" :class="reply.priority">
-                    {{ reply.priority }}优先级
-                  </span>
-                  <span class="value-badge" :class="reply.value">{{ reply.value }}</span>
-                </div> -->
               </div>
-              <div class="reply-time">回复时间: {{ reply.firstReplyTime }}</div>
               <div class="reply-content">
                 <p>{{ reply.replyContent }}</p>
               </div>
@@ -150,4 +158,27 @@
 
 <style scoped>
     @import '../../assets/styles/marketing.css';
+    .card-score{
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+    }
+    .customer-score {
+        width: 54px;
+        height: 54px;
+        display: flex;
+        border-radius: 50%;
+        align-items: center;
+        background: rgba(34, 197, 94, 0.12);
+        color: var(--success);
+        font-size: 18px;
+        font-weight: 700;
+        justify-content: center;
+    }
+
+    .customer-score-label {
+        margin-top: 3px;
+        font-size: 12px;
+        color: #64748B;
+    }
 </style>