吴树波 6 дней назад
Родитель
Сommit
60a308c9d3

+ 2 - 1
fs-company/src/main/java/com/fs/company/controller/common/CaptchaController.java

@@ -50,7 +50,8 @@ public class CaptchaController
     public AjaxResult getCode(HttpServletResponse response) throws IOException
     {
         AjaxResult ajax = AjaxResult.success();
-        boolean captchaOnOff = configService.selectCaptchaOnOff();
+//        boolean captchaOnOff = configService.selectCaptchaOnOff();
+        boolean captchaOnOff = true;
         ajax.put("captchaOnOff", captchaOnOff);
 //        captchaOnOff = true;
         if (!captchaOnOff)

+ 22 - 0
fs-company/src/main/java/com/fs/company/controller/crm/CrmCustomerController.java

@@ -320,6 +320,28 @@ public class CrmCustomerController extends BaseController
 
     }
 
+    //条件分配-统计数量
+    @PreAuthorize("@ss.hasPermi('crm:customer:assignToUser')")
+    @PostMapping("/countByCondition")
+    public R countByCondition(@RequestBody CrmCustomerConditionAssignParam param)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.getQueryParams().put("companyId", loginUser.getCompany().getCompanyId());
+        int count = crmCustomerService.countByCondition(param.getQueryType(), param.getQueryParams());
+        return R.ok().put("count", count);
+    }
+
+    //条件分配-执行分配
+    @PreAuthorize("@ss.hasPermi('crm:customer:assignToUser')")
+    @PostMapping("/assignByCondition")
+    public R assignByCondition(@RequestBody CrmCustomerConditionAssignParam param)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.setCompanyId(loginUser.getCompany().getCompanyId());
+        param.getQueryParams().put("companyId", loginUser.getCompany().getCompanyId());
+        return crmCustomerService.assignByCondition(loginUser.getUsername(), loginUser.getUser().getUserId(), param);
+    }
+
 
     @PreAuthorize("@ss.hasPermi('crm:customer:add')")
     @Log(title = "创建客户", businessType = BusinessType.INSERT)

+ 1 - 11
fs-company/src/main/resources/application.yml

@@ -3,14 +3,4 @@ server:
 # Spring配置
 spring:
   profiles:
-    active: dev
-#    active: druid-jnsyj-test
-#    active: druid-jnmy-test
-#    active: druid-jzzx-test
-#    active: druid-hdt
-#    active: druid-bjzm-test
-#    active: druid-yzt
-#    active: druid-myhk
-#    active: druid-sft
-#    active: dev-jnlzjk
-#    active: dev-yjb
+    active: dev-test

+ 39 - 1
fs-service/src/main/java/com/fs/company/service/impl/CompanyVoiceRoboticServiceImpl.java

@@ -1841,7 +1841,45 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
             }
         });
 
-        return buildResult(pageInfo, records);
+
+        // 统计全量节点数据(不受分页限制):查全量instanceIds,再查全量nodeLogs
+        List<String> allInstanceIds = companyAiWorkflowExecMapper.selectExecRecordsByRoboticId(
+                roboticId, null, null, false, null)
+                .stream()
+                .map(WorkflowExecRecordVo::getWorkflowInstanceId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toList());
+
+        long callDone = 0;
+        long addWxDone = 0;
+        long sendMsgDone = 0;
+
+        if (!allInstanceIds.isEmpty()) {
+            List<CompanyAiWorkflowExecLog> allNodeLogs = companyAiWorkflowExecLogMapper.selectByInstanceIds(allInstanceIds);
+            // nodeType: 6=AI外呼电话, 7=AI发送短信, 8=AI添加微信, 9=AI企微添加个微, 10=AI添加微信(新)
+            callDone = allNodeLogs.stream()
+                    .filter(e -> e.getStatus() == 1)
+                    .filter(e -> e.getNodeType().equals(NodeTypeEnum.AI_CALL_TASK.getValue()))
+                    .count();
+            addWxDone = allNodeLogs.stream()
+                    .filter(e -> e.getStatus() == 1)
+                    .filter(e -> e.getNodeType().equals(NodeTypeEnum.AI_ADD_WX_TASK.getValue())
+                            || e.getNodeType().equals(NodeTypeEnum.AI_QW_ADD_WX_TASK.getValue())
+                            || e.getNodeType().equals(NodeTypeEnum.AI_ADD_WX_TASK_NEW.getValue()))
+                    .count();
+            sendMsgDone = allNodeLogs.stream()
+                    .filter(e -> e.getStatus() == 1)
+                    .filter(e -> e.getNodeType().equals(NodeTypeEnum.AI_SEND_MSG_TASK.getValue()))
+                    .count();
+        }
+
+        Map<String, Object> result = buildResult(pageInfo, records);
+        Map<String, Object> stats = new HashMap<>();
+        stats.put("callDone", callDone);
+        stats.put("addWxDone", addWxDone);
+        stats.put("sendMsgDone", sendMsgDone);
+        result.put("stats", stats);
+        return result;
     }
 
     private Map<String, Object> buildResult(PageInfo<?> pageInfo, List<?> records) {

+ 11 - 0
fs-service/src/main/java/com/fs/config/tencent/TencentCOSClientConfig.java

@@ -1,5 +1,6 @@
 package com.fs.config.tencent;
 
+import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
 import com.qcloud.cos.COSClient;
 import com.qcloud.cos.ClientConfig;
 import com.qcloud.cos.auth.BasicCOSCredentials;
@@ -9,8 +10,11 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Lazy;
+import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
+import java.util.Objects;
+
 @Component
 @AllArgsConstructor
 @Slf4j
@@ -20,9 +24,16 @@ public class TencentCOSClientConfig {
     @Lazy
     private final TencentProperties tencentProperties;
 
+    private Environment environment;
+
     @Bean
     public COSClient createClient() {
         log.info("创建COSClient...");
+        if(Objects.equals(environment.getProperty("spring.profiles.active"), "dev-test")){
+            String secretId = "";
+            String secretKey = "";
+            String region = "";
+        }
         // 检查配置
         if (!tencentProperties.isConfigValid()) {
             log.error("腾讯云配置不完整,无法创建COS客户端");

+ 1 - 1
fs-service/src/main/java/com/fs/core/config/WxPayConfiguration.java

@@ -31,7 +31,7 @@ public class WxPayConfiguration {
     try {
       // 每次创建服务时都获取最新的配置
       log.info("创建微信支付服务,检查配置...");
-      if(Objects.equals(environment.getProperty("spring.profiles.active"), "dev")){
+      if(Objects.equals(environment.getProperty("spring.profiles.active"), "dev-test")){
         return new WxPayServiceImpl();
       }
 

+ 391 - 0
fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerMapper.java

@@ -1137,4 +1137,395 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
      * @return CRM客户
      */
     CrmCustomer selectCrmCustomerByCallphoneLogId(@Param("callphoneLogId") Long callphoneLogId);
+
+    // ==================== 条件分配:统计和查询ID ====================
+
+    /** 公海客户条件统计 */
+    @Select({"<script> " +
+            "select count(1) from crm_customer c " +
+            "where c.is_line=0 and is_del=0 and c.is_pool=1 " +
+            "<if test = 'maps.companyId != null     '> " +
+            "and c.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.address != null and  maps.address !=\"\"    '> " +
+            "and c.address like CONCAT('%',#{maps.address},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerCode != null and  maps.customerCode !=\"\"    '> " +
+            "and c.customer_code like CONCAT(#{maps.customerCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerName != null and  maps.customerName !=\"\"    '> " +
+            "and c.customer_name like CONCAT('%',#{maps.customerName},'%') " +
+            "</if>" +
+            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"    '> " +
+            "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
+            "</if>" +
+            "<if test = 'maps.status != null and maps.status !=\"\"     '> " +
+            "and c.status =#{maps.status} " +
+            "</if>" +
+            "<if test = 'maps.visitStatus != null and maps.visitStatus !=\"\"     '> " +
+            "and c.visit_status IN " +
+            "<foreach collection=\"maps.visitStatus.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.customerType != null      '> " +
+            "and c.customer_type IN " +
+            "<foreach collection=\"maps.customerType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.isReceive != null      '> " +
+            "and c.is_receive =#{maps.isReceive} " +
+            "</if>" +
+            "<if test = 'maps.source != null and maps.source !=\"\"      '> " +
+            "and c.source IN " +
+            "<foreach collection=\"maps.source.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.tags != null      '> " +
+            "and  " +
+            "<foreach collection=\"maps.tags.split(',')\" item=\"tag\"   open=\"(\" close=\")\" separator=\"OR\">" +
+            "find_in_set(#{tag},c.tags)" +
+            "</foreach> " +
+            "</if>" +
+            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.deptId != null  and maps.deptId != 0 '> " +
+            "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
+            "</if>" +
+            "${maps.params.dataScope}"+
+            "</script>"})
+    int countCrmFullCustomerByCondition(@Param("maps") CrmFullCustomerListQueryParam param);
+
+    /** 公海客户条件查询ID */
+    @Select({"<script> " +
+            "select c.customer_id from crm_customer c " +
+            "where c.is_line=0 and is_del=0 and c.is_pool=1 " +
+            "<if test = 'maps.companyId != null     '> " +
+            "and c.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.address != null and  maps.address !=\"\"    '> " +
+            "and c.address like CONCAT('%',#{maps.address},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerCode != null and  maps.customerCode !=\"\"    '> " +
+            "and c.customer_code like CONCAT(#{maps.customerCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerName != null and  maps.customerName !=\"\"    '> " +
+            "and c.customer_name like CONCAT('%',#{maps.customerName},'%') " +
+            "</if>" +
+            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"    '> " +
+            "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
+            "</if>" +
+            "<if test = 'maps.status != null and maps.status !=\"\"     '> " +
+            "and c.status =#{maps.status} " +
+            "</if>" +
+            "<if test = 'maps.visitStatus != null and maps.visitStatus !=\"\"     '> " +
+            "and c.visit_status IN " +
+            "<foreach collection=\"maps.visitStatus.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.customerType != null      '> " +
+            "and c.customer_type IN " +
+            "<foreach collection=\"maps.customerType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.isReceive != null      '> " +
+            "and c.is_receive =#{maps.isReceive} " +
+            "</if>" +
+            "<if test = 'maps.source != null and maps.source !=\"\"      '> " +
+            "and c.source IN " +
+            "<foreach collection=\"maps.source.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.tags != null      '> " +
+            "and  " +
+            "<foreach collection=\"maps.tags.split(',')\" item=\"tag\"   open=\"(\" close=\")\" separator=\"OR\">" +
+            "find_in_set(#{tag},c.tags)" +
+            "</foreach> " +
+            "</if>" +
+            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.deptId != null  and maps.deptId != 0 '> " +
+            "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
+            "</if>" +
+            "${maps.params.dataScope}"+
+            " order by c.customer_id desc limit 1000 "+
+            "</script>"})
+    List<Long> selectCrmFullCustomerIdsByCondition(@Param("maps") CrmFullCustomerListQueryParam param);
+
+    /** 我的客户条件统计 */
+    @Select({"<script> " +
+            "select count(1) from crm_customer_user cu inner join crm_customer c on c.customer_user_id=cu.customer_user_id " +
+            "where cu.is_pool=0 " +
+            "<if test = 'maps.companyId != null     '> " +
+            "and cu.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.companyUserId != null     '> " +
+            "and cu.company_user_id =#{maps.companyUserId} " +
+            "</if>" +
+            "<if test = 'maps.address != null and  maps.address !=\"\"    '> " +
+            "and c.address like CONCAT('%',#{maps.address},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerCode != null and  maps.customerCode !=\"\"    '> " +
+            "and c.customer_code like CONCAT('%',#{maps.customerCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerName != null and  maps.customerName !=\"\"    '> " +
+            "and c.customer_name like CONCAT('%',#{maps.customerName},'%') " +
+            "</if>" +
+            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"    '> " +
+            "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
+            "</if>" +
+            "<if test = 'maps.status != null and maps.status !=\"\"     '> " +
+            "and cu.status IN " +
+            "<foreach collection=\"maps.status.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.visitStatus != null and maps.visitStatus !=\"\"'> " +
+            "and c.visit_status IN " +
+            "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>" +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  = 0 " +
+            "</if>" +
+            "<if test = 'maps.isManualCall != null and maps.isManualCall==1      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time &gt; 0)  &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isManualCall != null and maps.isManualCall==0      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time &gt; 0)  = 0 " +
+            "</if>" +
+            "<if test = 'maps.customerType != null      '> " +
+            "and c.customer_type IN " +
+            "<foreach collection=\"maps.customerType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.source != null and maps.source !=\"\"      '> " +
+            "and c.source IN " +
+            "<foreach collection=\"maps.source.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.tags != null and maps.tags!=\"\"     '> " +
+            "and  " +
+            "<foreach collection=\"maps.tags.split(',')\" item=\"tag\"   open=\"(\" close=\")\" separator=\"OR\">" +
+            "find_in_set(#{tag},c.tags)" +
+            "</foreach> " +
+            "</if>" +
+            "<if test = 'maps.customerCreateTime != null    '> " +
+            " AND date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.customerCreateTime[0]},'%y%m%d') " +
+            " AND date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.customerCreateTime[1]},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
+            "and date_format(c.receive_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
+            "and date_format(c.receive_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
+            "</if>" +
+            "</script>"})
+    int countCrmMyCustomerByCondition(@Param("maps") CrmMyCustomerListQueryParam param);
+
+    /** 我的客户条件查询ID */
+    @Select({"<script> " +
+            "select c.customer_id from crm_customer_user cu inner join crm_customer c on c.customer_user_id=cu.customer_user_id " +
+            "where cu.is_pool=0 " +
+            "<if test = 'maps.companyId != null     '> " +
+            "and cu.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.companyUserId != null     '> " +
+            "and cu.company_user_id =#{maps.companyUserId} " +
+            "</if>" +
+            "<if test = 'maps.address != null and  maps.address !=\"\"    '> " +
+            "and c.address like CONCAT('%',#{maps.address},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerCode != null and  maps.customerCode !=\"\"    '> " +
+            "and c.customer_code like CONCAT('%',#{maps.customerCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerName != null and  maps.customerName !=\"\"    '> " +
+            "and c.customer_name like CONCAT('%',#{maps.customerName},'%') " +
+            "</if>" +
+            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"    '> " +
+            "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
+            "</if>" +
+            "<if test = 'maps.status != null and maps.status !=\"\"     '> " +
+            "and cu.status IN " +
+            "<foreach collection=\"maps.status.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.visitStatus != null and maps.visitStatus !=\"\"'> " +
+            "and c.visit_status IN " +
+            "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>" +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  = 0 " +
+            "</if>" +
+            "<if test = 'maps.isManualCall != null and maps.isManualCall==1      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time &gt; 0)  &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isManualCall != null and maps.isManualCall==0      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time &gt; 0)  = 0 " +
+            "</if>" +
+            "<if test = 'maps.customerType != null      '> " +
+            "and c.customer_type IN " +
+            "<foreach collection=\"maps.customerType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.source != null and maps.source !=\"\"      '> " +
+            "and c.source IN " +
+            "<foreach collection=\"maps.source.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.tags != null and maps.tags!=\"\"     '> " +
+            "and  " +
+            "<foreach collection=\"maps.tags.split(',')\" item=\"tag\"   open=\"(\" close=\")\" separator=\"OR\">" +
+            "find_in_set(#{tag},c.tags)" +
+            "</foreach> " +
+            "</if>" +
+            "<if test = 'maps.customerCreateTime != null    '> " +
+            " AND date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.customerCreateTime[0]},'%y%m%d') " +
+            " AND date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.customerCreateTime[1]},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
+            "and date_format(c.receive_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
+            "and date_format(c.receive_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
+            "</if>" +
+            " order by cu.customer_user_id desc limit 1000 "+
+            "</script>"})
+    List<Long> selectCrmMyCustomerIdsByCondition(@Param("maps") CrmMyCustomerListQueryParam param);
+
+    /** 客户管理条件统计 */
+    @Select({"<script> " +
+            "select count(1) from crm_customer c " +
+            "where 1=1 " +
+            "<if test = 'maps.companyId != null     '> " +
+            "and c.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.customerCode != null and  maps.customerCode !=\"\"    '> " +
+            "and c.customer_code like CONCAT('%',#{maps.customerCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerName != null and  maps.customerName !=\"\"    '> " +
+            "and c.customer_name like CONCAT('%',#{maps.customerName},'%') " +
+            "</if>" +
+            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"    '> " +
+            "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
+            "</if>" +
+            "<if test = 'maps.status != null and maps.status !=\"\"     '> " +
+            "and c.status =#{maps.status} " +
+            "</if>" +
+            "<if test = 'maps.visitStatus != null       '> " +
+            "and c.visit_status IN " +
+            "<foreach collection=\"maps.visitStatus.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.isBuy != null and maps.isBuy==1      '> " +
+            "and c.buy_count &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isBuy != null and maps.isBuy==0      '> " +
+            "and (c.buy_count = 0 or c.buy_count is null) " +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  = 0 " +
+            "</if>" +
+            "<if test = 'maps.customerType != null      '> " +
+            "and c.customer_type IN " +
+            "<foreach collection=\"maps.customerType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.source != null and maps.source !=\"\"      '> " +
+            "and c.source IN " +
+            "<foreach collection=\"maps.source.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.isReceive != null      '> " +
+            "and c.is_receive =#{maps.isReceive} " +
+            "</if>" +
+            "<if test = 'maps.isLine != null      '> " +
+            "and c.is_line =#{maps.isLine} " +
+            "</if>" +
+            "<if test = 'maps.tags != null      '> " +
+            "and  " +
+            "<foreach collection=\"maps.tags.split(',')\" item=\"tag\"   open=\"(\" close=\")\" separator=\"OR\">" +
+            "find_in_set(#{tag},c.tags)" +
+            "</foreach> " +
+            "</if>" +
+            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.deptId != null  and maps.deptId != 0 '> " +
+            "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
+            "</if>" +
+            "${maps.params.dataScope}"+
+            "</script>"})
+    int countCrmCustomerByCondition(@Param("maps") CrmCustomerListQueryParam param);
+
+    /** 客户管理条件查询ID */
+    @Select({"<script> " +
+            "select c.customer_id from crm_customer c " +
+            "where 1=1 " +
+            "<if test = 'maps.companyId != null     '> " +
+            "and c.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.customerCode != null and  maps.customerCode !=\"\"    '> " +
+            "and c.customer_code like CONCAT('%',#{maps.customerCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.customerName != null and  maps.customerName !=\"\"    '> " +
+            "and c.customer_name like CONCAT('%',#{maps.customerName},'%') " +
+            "</if>" +
+            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"    '> " +
+            "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
+            "</if>" +
+            "<if test = 'maps.status != null and maps.status !=\"\"     '> " +
+            "and c.status =#{maps.status} " +
+            "</if>" +
+            "<if test = 'maps.visitStatus != null       '> " +
+            "and c.visit_status IN " +
+            "<foreach collection=\"maps.visitStatus.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.isBuy != null and maps.isBuy==1      '> " +
+            "and c.buy_count &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isBuy != null and maps.isBuy==0      '> " +
+            "and (c.buy_count = 0 or c.buy_count is null) " +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  &gt; 0 " +
+            "</if>" +
+            "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0      '> " +
+            "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  = 0 " +
+            "</if>" +
+            "<if test = 'maps.customerType != null      '> " +
+            "and c.customer_type IN " +
+            "<foreach collection=\"maps.customerType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.source != null and maps.source !=\"\"      '> " +
+            "and c.source IN " +
+            "<foreach collection=\"maps.source.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach>"+
+            "</if>" +
+            "<if test = 'maps.isReceive != null      '> " +
+            "and c.is_receive =#{maps.isReceive} " +
+            "</if>" +
+            "<if test = 'maps.isLine != null      '> " +
+            "and c.is_line =#{maps.isLine} " +
+            "</if>" +
+            "<if test = 'maps.tags != null      '> " +
+            "and  " +
+            "<foreach collection=\"maps.tags.split(',')\" item=\"tag\"   open=\"(\" close=\")\" separator=\"OR\">" +
+            "find_in_set(#{tag},c.tags)" +
+            "</foreach> " +
+            "</if>" +
+            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
+            "and date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.deptId != null  and maps.deptId != 0 '> " +
+            "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
+            "</if>" +
+            "${maps.params.dataScope}"+
+            " order by c.customer_id desc limit 1000 "+
+            "</script>"})
+    List<Long> selectCrmCustomerIdsByCondition(@Param("maps") CrmCustomerListQueryParam param);
 }

+ 35 - 0
fs-service/src/main/java/com/fs/crm/param/CrmCustomerConditionAssignParam.java

@@ -0,0 +1,35 @@
+package com.fs.crm.param;
+
+import com.fs.crm.dto.CrmCustomerAssignUserDTO;
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 条件分配请求参数
+ * 根据筛选条件匹配客户进行批量分配,无需手动勾选
+ */
+@Data
+public class CrmCustomerConditionAssignParam extends BaseQueryParam {
+    /**
+     * 公司ID
+     */
+    private Long companyId;
+    /**
+     * 分配类型 2=公海分配 3=已领取转移
+     */
+    private Integer assignType;
+    /**
+     * 查询类型 "my" / "customer" / "full"
+     */
+    private String queryType;
+    /**
+     * 分配员工列表
+     */
+    private List<CrmCustomerAssignUserDTO> users;
+    /**
+     * 前端筛选条件(与列表查询接口参数一致)
+     */
+    private Map<String, Object> queryParams;
+}

+ 19 - 0
fs-service/src/main/java/com/fs/crm/service/ICrmCustomerService.java

@@ -183,4 +183,23 @@ public interface ICrmCustomerService
      * @return CRM客户
      */
     CrmCustomer selectCrmCustomerByCallphoneLogId(Long callphoneLogId);
+
+    /**
+     * 根据筛选条件统计客户数量
+     *
+     * @param queryType   查询类型 "my" / "customer" / "full"
+     * @param queryParams 前端筛选条件
+     * @return 符合条件的客户数量
+     */
+    int countByCondition(String queryType, Map<String, Object> queryParams);
+
+    /**
+     * 根据筛选条件批量分配客户
+     *
+     * @param operUserName 操作人姓名
+     * @param operUserId   操作人ID
+     * @param param        条件分配参数(含queryType、queryParams、users、assignType)
+     * @return 分配结果
+     */
+    R assignByCondition(String operUserName, Long operUserId, CrmCustomerConditionAssignParam param);
 }

+ 60 - 0
fs-service/src/main/java/com/fs/crm/service/impl/CrmCustomerServiceImpl.java

@@ -1161,4 +1161,64 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
         return crmCustomerMapper.selectCrmCustomerByCallphoneLogId(callphoneLogId);
     }
 
+    @Override
+    public int countByCondition(String queryType, Map<String, Object> queryParams) {
+        switch (queryType) {
+            case "full":
+                CrmFullCustomerListQueryParam fullParam = JSONObject.parseObject(
+                        JSONObject.toJSONString(queryParams), CrmFullCustomerListQueryParam.class);
+                return crmCustomerMapper.countCrmFullCustomerByCondition(fullParam);
+            case "my":
+                CrmMyCustomerListQueryParam myParam = JSONObject.parseObject(
+                        JSONObject.toJSONString(queryParams), CrmMyCustomerListQueryParam.class);
+                return crmCustomerMapper.countCrmMyCustomerByCondition(myParam);
+            case "customer":
+                CrmCustomerListQueryParam customerParam = JSONObject.parseObject(
+                        JSONObject.toJSONString(queryParams), CrmCustomerListQueryParam.class);
+                return crmCustomerMapper.countCrmCustomerByCondition(customerParam);
+            default:
+                throw new CustomException("不支持的查询类型: " + queryType);
+        }
+    }
+
+    @Override
+    @Transactional
+    public R assignByCondition(String operUserName, Long operUserId, CrmCustomerConditionAssignParam param) {
+        String queryType = param.getQueryType();
+        Map<String, Object> queryParams = param.getQueryParams();
+        List<Long> customerIds;
+
+        switch (queryType) {
+            case "full":
+                CrmFullCustomerListQueryParam fullParam = JSONObject.parseObject(
+                        JSONObject.toJSONString(queryParams), CrmFullCustomerListQueryParam.class);
+                customerIds = crmCustomerMapper.selectCrmFullCustomerIdsByCondition(fullParam);
+                break;
+            case "my":
+                CrmMyCustomerListQueryParam myParam = JSONObject.parseObject(
+                        JSONObject.toJSONString(queryParams), CrmMyCustomerListQueryParam.class);
+                customerIds = crmCustomerMapper.selectCrmMyCustomerIdsByCondition(myParam);
+                break;
+            case "customer":
+                CrmCustomerListQueryParam customerParam = JSONObject.parseObject(
+                        JSONObject.toJSONString(queryParams), CrmCustomerListQueryParam.class);
+                customerIds = crmCustomerMapper.selectCrmCustomerIdsByCondition(customerParam);
+                break;
+            default:
+                throw new CustomException("不支持的查询类型: " + queryType);
+        }
+
+        if (customerIds == null || customerIds.isEmpty()) {
+            return R.error("未找到符合条件的客户");
+        }
+
+        // 复用已有的 assignToUser 逻辑
+        CrmCustomeAssignParam assignParam = new CrmCustomeAssignParam();
+        assignParam.setCustomerIds(customerIds);
+        assignParam.setAssignType(param.getAssignType());
+        assignParam.setUsers(param.getUsers());
+        assignParam.setCompanyId(param.getCompanyId());
+        return assignToUser(operUserName, operUserId, assignParam);
+    }
+
 }

+ 3 - 3
fs-service/src/main/resources/application-dev-test.yml

@@ -43,9 +43,9 @@ spring:
             druid:
                 # 主库数据源
                 master:
-                    url: jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
-                    username: root
-                    password: Ylrz_1q2w3e4r5t6y
+                    url: jdbc:mysql://139.186.77.83:3306/yLrz_saas_his_scrm?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
+                    username: Rtroot
+                    password: Rtroot
                 # 初始连接数
                 initialSize: 5
                 # 最小连接池数量