Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

zyy 3 дней назад
Родитель
Сommit
83aaab7825

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

@@ -5,12 +5,15 @@ import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.entity.SysDictData;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
+import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.company.util.OrderUtils;
 import com.fs.crm.domain.CrmCustomer;
@@ -21,6 +24,8 @@ import com.fs.crm.service.ICrmCustomerUserService;
 import com.fs.crm.vo.*;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.service.TokenService;
+import com.fs.system.service.ISysConfigService;
+import com.fs.system.service.ISysDictTypeService;
 import com.github.pagehelper.PageHelper;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -32,7 +37,9 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 客户Controller
@@ -54,6 +61,12 @@ public class CrmCustomerController extends BaseController
     ICrmCustomerUserService crmCustomerUserService;
     @Autowired
     private ICrmCustomerPropertyService crmCustomerPropertyService;
+    @Autowired
+    private ICompanyService companyService;
+    @Autowired
+    private ISysConfigService configService;
+    @Autowired
+    private ISysDictTypeService dictTypeService;
 
     @ApiOperation("获取线索客户")
     @PreAuthorize("@ss.hasPermi('crm:customer:lineList')")
@@ -466,4 +479,61 @@ public class CrmCustomerController extends BaseController
         return R.ok().put("data",list);
     }
 
+    @ApiOperation("动态数据字典查询")
+    @GetMapping("/tradeDicts")
+    public AjaxResult getTradeDicts() {
+        // 1. 获取当前登录用户的公司ID
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+
+        // 2. 查询公司行业配置 (company_trade)
+        String prefix = "";
+        Company company = companyService.selectCompanyById(companyId);
+        Integer companyTrade = company.getCompanyTrade();
+
+        if (companyTrade != null) {
+            // 查 trade_type 字典获取 remark 前缀
+            prefix = getDictRemarkByValue("trade_type", String.valueOf(companyTrade));
+        }
+
+        // 3. 如果公司没有行业配置,回退查租户配置
+        if (StringUtils.isEmpty(prefix)) {
+            String tenantTrade = configService.selectConfigByKey("his.config.tenantTrade");
+            if (StringUtils.isNotEmpty(tenantTrade)) {
+                prefix = getDictRemarkByValue("trade_type", tenantTrade);
+            }
+        }
+
+        // 4. 构建四个字典的查询结果(带保底逻辑)
+        String[] dictTypes = {"crm_customer_source", "crm_customer_user_status",
+                              "crm_customer_type", "crm_customer_tag"};
+        Map<String, List<SysDictData>> result = new HashMap<>();
+
+        for (String dictType : dictTypes) {
+            List<SysDictData> data = null;
+            if (StringUtils.isNotEmpty(prefix)) {
+                data = dictTypeService.selectDictDataByType(prefix + dictType);
+            }
+            // 保底逻辑:前缀查不到数据则使用原始字典
+            if (data == null || data.isEmpty()) {
+                data = dictTypeService.selectDictDataByType(dictType);
+            }
+            result.put(dictType, data);
+        }
+
+        return AjaxResult.success(result);
+    }
+
+    private String getDictRemarkByValue(String dictType, String dictValue) {
+        List<SysDictData> dictDataList = dictTypeService.selectDictDataByType(dictType);
+        if (dictDataList != null) {
+            for (SysDictData data : dictDataList) {
+                if (dictValue.equals(data.getDictValue())) {
+                    return StringUtils.isNotEmpty(data.getRemark()) ? data.getRemark() : "";
+                }
+            }
+        }
+        return "";
+    }
+
 }

+ 5 - 0
fs-service/src/main/java/com/fs/company/domain/Company.java

@@ -146,4 +146,9 @@ public class Company extends BaseEntity
 
     @TableField(exist = false)
     private List<Long> showGatewayIds;
+
+    /**
+     * 公司行业
+     */
+    private Integer companyTrade;
 }

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

@@ -313,6 +313,10 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
             "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>" +

+ 2 - 1
fs-service/src/main/java/com/fs/crm/param/CrmMyCustomerListQueryParam.java

@@ -60,7 +60,8 @@ public class CrmMyCustomerListQueryParam extends BaseQueryParam
     /** 客户状态  0锁定 1 正常 */
     private String status;
 
-
+    /** 跟进阶段 */
+    private String visitStatus;
 
     /** 所属部门ID */
     private Long deptId;

+ 11 - 10
fs-service/src/main/resources/db/tenant-initTable.sql

@@ -1259,6 +1259,7 @@ CREATE TABLE `company`
     `company_belong_owner`     varchar(50)   NULL DEFAULT NULL COMMENT '经销售归属',
     `live_show`                int NULL DEFAULT NULL COMMENT '直播是否展示',
     `is_open_rest_reminder`    tinyint NULL DEFAULT NULL COMMENT '控制休息提示是否打开要暂停  0-关闭 1-打开 null-默认打开',
+    `company_trade` int NULL DEFAULT NULL COMMENT '公司行业,数据字典项:trade_type',
     PRIMARY KEY (`company_id`) USING BTREE
 ) ENGINE = InnoDB AUTO_INCREMENT = 1 COMMENT = '企业表' ROW_FORMAT = DYNAMIC;
 
@@ -17983,21 +17984,21 @@ CREATE TABLE `company_bind_ai_model`
 DROP TABLE IF EXISTS `company_ai_workflow_version`;
 CREATE TABLE `company_ai_workflow_version`
 (
-    `version_id`      bigint                                                        NOT NULL AUTO_INCREMENT COMMENT '版本ID',
-    `workflow_id`     bigint                                                        NOT NULL COMMENT '工作流ID,关联主表company_ai_workflow.workflow_id',
-    `version_no`      int                                                           NOT NULL COMMENT '版本号,从1开始递增',
-    `workflow_name`   varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '工作流名称',
-    `workflow_desc`   varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '工作流描述',
+    `version_id`      bigint       NOT NULL AUTO_INCREMENT COMMENT '版本ID',
+    `workflow_id`     bigint       NOT NULL COMMENT '工作流ID,关联主表company_ai_workflow.workflow_id',
+    `version_no`      int          NOT NULL COMMENT '版本号,从1开始递增',
+    `workflow_name`   varchar(100) NOT NULL COMMENT '工作流名称',
+    `workflow_desc`   varchar(500) NULL DEFAULT NULL COMMENT '工作流描述',
     `workflow_type`   tinyint NULL DEFAULT 1 COMMENT '工作流类型 1对话流程 2任务流程 3审批流程',
     `status`          tinyint NULL DEFAULT 1 COMMENT '状态 0禁用 1启用',
-    `canvas_data`     longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '画布数据JSON',
-    `start_node_key`  varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '流程开始节点',
-    `end_node_key`    varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '流程结束节点',
+    `canvas_data`     longtext NULL COMMENT '画布数据JSON',
+    `start_node_key`  varchar(64) NULL DEFAULT NULL COMMENT '流程开始节点',
+    `end_node_key`    varchar(64) NULL DEFAULT NULL COMMENT '流程结束节点',
     `company_user_id` bigint NULL DEFAULT NULL COMMENT '绑定销售id',
     `company_id`      int NULL DEFAULT NULL COMMENT '公司id',
     `snapshot_time`   datetime NULL DEFAULT NULL COMMENT '快照生成时间',
-    `snapshot_by`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '快照生成者',
-    `remark`          varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
+    `snapshot_by`     varchar(64) NULL DEFAULT '' COMMENT '快照生成者',
+    `remark`          varchar(500) NULL DEFAULT NULL COMMENT '备注',
     PRIMARY KEY (`version_id`) USING BTREE,
     INDEX             `idx_workflow_id`(`workflow_id`) USING BTREE,
     INDEX             `idx_workflow_version_no`(`workflow_id`, `version_no`) USING BTREE

+ 3 - 0
fs-service/src/main/resources/mapper/company/CompanyMapper.xml

@@ -123,6 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maxPadNum != null">max_pad_num,</if>
             <if test="deptId != null">dept_id,</if>
             <if test="isOpenRestReminder != null">is_open_rest_reminder,</if>
+            <if test="companyTrade != null">company_trade,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="companyName != null">#{companyName},</if>
@@ -160,6 +161,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maxPadNum != null">#{maxPadNum},</if>
             <if test="deptId != null">#{deptId},</if>
             <if test="isOpenRestReminder != null">is_open_rest_reminder = #{isOpenRestReminder},</if>
+            <if test="companyTrade != null">#{companyTrade},</if>
          </trim>
     </insert>
 
@@ -204,6 +206,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deptId != null">dept_id = #{deptId},</if>
             <if test="redPackageMoney != null">red_package_money = #{redPackageMoney},</if>
             <if test="isOpenRestReminder != null">is_open_rest_reminder = #{isOpenRestReminder},</if>
+            <if test="companyTrade != null">company_trade = #{companyTrade},</if>
         </trim>
         where company_id = #{companyId}
     </update>