Переглянути джерело

客户档案、公海、私海页面功能优化 跟进来源数据修改

yzc 1 рік тому
батько
коміт
84c1cb4e02

+ 14 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerFollowRecordsVo.java

@@ -5,6 +5,7 @@ import com.fjhx.file.entity.ObsFile;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -25,4 +26,17 @@ public class CustomerFollowRecordsVo extends CustomerFollowRecords {
      * 客户名称
      */
     private String customerName;
+
+    /**
+     * 合同金额
+     */
+    private BigDecimal amount;
+    /**
+     * 合同编号
+     */
+    private String contractCode;
+    /**
+     * 跟进类型
+     */
+    private String type;
 }

+ 1 - 2
hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerVo.java

@@ -2,7 +2,6 @@ package com.fjhx.customer.entity.customer.vo;
 
 import com.fjhx.area.service.SetCustomizeAreaName;
 import com.fjhx.customer.entity.customer.po.Customer;
-import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
 import com.fjhx.customer.entity.customer.po.CustomerUser;
 import lombok.Getter;
 import lombok.Setter;
@@ -46,7 +45,7 @@ public class CustomerVo extends Customer implements SetCustomizeAreaName {
     /**
      * 客户跟进记录
      */
-    private List<CustomerFollowRecords> customerFollowRecordsList;
+    private List<CustomerFollowRecordsVo> customerFollowRecordsList;
 
     /**
      * 是否置顶

+ 2 - 2
hx-customer/src/main/java/com/fjhx/customer/mapper/customer/CustomerFollowRecordsMapper.java

@@ -1,8 +1,8 @@
 package com.fjhx.customer.mapper.customer;
 
-import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
 import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
@@ -21,6 +21,6 @@ public interface CustomerFollowRecordsMapper extends BaseMapper<CustomerFollowRe
     /**
      * 客户跟进记录分页
      */
-    Page<CustomerFollowRecordsVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<CustomerFollowRecords> wrapper);
+    Page<CustomerFollowRecordsVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<CustomerFollowRecords> wrapper, @Param("id") Long id, @Param("tenantId") String tenantId);
 
 }

+ 6 - 3
hx-customer/src/main/java/com/fjhx/customer/mapper/customer/CustomerMapper.java

@@ -1,11 +1,11 @@
 package com.fjhx.customer.mapper.customer;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.fjhx.customer.entity.customer.dto.CustomerDto;
-import com.fjhx.customer.entity.customer.po.Customer;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.dto.CustomerDto;
+import com.fjhx.customer.entity.customer.po.Customer;
+import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
 import com.fjhx.customer.entity.customer.vo.CustomerVo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
@@ -52,4 +52,7 @@ public interface CustomerMapper extends BaseMapper<Customer> {
      * 客户分配
      */
     void customerAllocation(CustomerDto dto);
+
+    List<CustomerFollowRecordsVo> getFollowUp(@Param("id") Long id, @Param("tenantId") String tenantId);
+
 }

+ 4 - 3
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerFollowRecordsServiceImpl.java

@@ -19,6 +19,7 @@ import com.fjhx.file.entity.ObsFile;
 import com.fjhx.file.service.FileInfoService;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -47,9 +48,9 @@ public class CustomerFollowRecordsServiceImpl extends ServiceImpl<CustomerFollow
     @Override
     public Page<CustomerFollowRecordsVo> getPage(CustomerFollowRecordsSelectDto dto) {
         IWrapper<CustomerFollowRecords> wrapper = getWrapper();
-        wrapper.eq("cfr", CustomerFollowRecords::getCustomerId, dto.getCustomerId());//根据客户id过滤
-        wrapper.orderByDesc("cfr", CustomerFollowRecords::getDate);
-        Page<CustomerFollowRecordsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+//        wrapper.eq("cfr", CustomerFollowRecords::getCustomerId, dto.getCustomerId());//根据客户id过滤
+        wrapper.orderByDesc("t1", CustomerFollowRecords::getDate);
+        Page<CustomerFollowRecordsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper, dto.getCustomerId(), SecurityUtils.getTenantId());
         List<CustomerFollowRecordsVo> records = page.getRecords();
         //赋值文件列表信息
         List<Long> ids = records.stream().map(CustomerFollowRecordsVo::getId).filter(ObjectUtil::isNotNull).distinct().collect(Collectors.toList());

+ 9 - 7
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -16,9 +16,9 @@ import com.fjhx.common.service.coding.CodingRuleCustomerService;
 import com.fjhx.customer.entity.customer.dto.CustomerDto;
 import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
 import com.fjhx.customer.entity.customer.po.Customer;
-import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
 import com.fjhx.customer.entity.customer.po.CustomerTop;
 import com.fjhx.customer.entity.customer.po.CustomerUser;
+import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
 import com.fjhx.customer.entity.customer.vo.CustomerVo;
 import com.fjhx.customer.mapper.customer.CustomerMapper;
 import com.fjhx.customer.service.customer.CustomerFollowRecordsService;
@@ -145,12 +145,14 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
 
         // 赋值客户跟进记录
         for (CustomerVo record : records) {
-            List<CustomerFollowRecords> customerFollowRecordsList = customerFollowRecordsService.list(q -> q
-                    .eq(CustomerFollowRecords::getCustomerId, record.getId())
-                    .orderByDesc(CustomerFollowRecords::getDate)
-                    .last("limit 3")
-            );
-            record.setCustomerFollowRecordsList(customerFollowRecordsList);
+            List<CustomerFollowRecordsVo> followUp = baseMapper.getFollowUp(record.getId(), SecurityUtils.getTenantId());
+//            List<CustomerFollowRecords> customerFollowRecordsList = customerFollowRecordsService.list(q -> q
+//                    .eq(CustomerFollowRecords::getCustomerId, record.getId())
+//                    .orderByDesc(CustomerFollowRecords::getDate)
+//                    .last("limit 3")
+//            );
+//            record.setCustomerFollowRecordsList(customerFollowRecordsList);
+            record.setCustomerFollowRecordsList(followUp);
 
             //赋值客户状态字典值
             record.setStatusVal(customerStatusDic.get(record.getStatus()));

+ 31 - 10
hx-customer/src/main/resources/mapper/customer/CustomerFollowRecordsMapper.xml

@@ -2,16 +2,37 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.customer.mapper.customer.CustomerFollowRecordsMapper">
     <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo">
-        select
-            cfr.id,
-            cfr.customer_id,
-            cfr.date,
-            cfr.content,
-            cfr.create_user,
-            cfr.create_time,
-            cfr.update_user,
-            cfr.update_time
-        from customer_follow_records cfr
+        SELECT t1.*
+        FROM ((SELECT id,
+                      amount,
+                      create_time `date`,
+                      NULL AS     contractCode,
+                      10   AS     type,
+                      NULL AS     remark
+               FROM bytesailing_sale.sale_quotation sq
+               WHERE sq.buy_corporation_id = #{id}
+                 and sq.tenant_id = #{tenantId}
+                 and sq.del_flag = 0)
+              UNION
+              (SELECT id,
+                      amount,
+                      create_time `date`,
+                      CODE AS     contractCode,
+                      20   AS     type,
+                      NULL AS     remark
+               FROM bytesailing_sale.contract c
+               WHERE c.buy_corporation_id = #{id}
+                 and c.tenant_id = #{tenantId}
+                 and c.del_flag = 0)
+              UNION
+              (SELECT id,
+                      NULL    AS amount,
+                      `date`,
+                      NULL    AS contractCode,
+                      30      AS type,
+                      content AS remark
+               FROM customer_follow_records cfr
+               WHERE cfr.customer_id = #{id})) t1
             ${ew.customSqlSegment}
     </select>
 

+ 55 - 21
hx-customer/src/main/resources/mapper/customer/CustomerMapper.xml

@@ -2,7 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.customer.mapper.customer.CustomerMapper">
     <update id="customerAllocation">
-        update customer set user_id = #{userId},update_time = now() where id = #{id}
+        update customer set user_id     = #{userId},
+                            update_time = now()
+        where id = #{id}
     </update>
     <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
         select
@@ -28,24 +30,23 @@
     </select>
 
     <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
-        select
-            c.id,
-            c.customer_code,
-            c.code,
-            c.country_id,
-            c.province_id,
-            c.city_id,
-            c.address,
-            c.zip_code,
-            c.name,
-            c.status,
-            c.source,
-            c.user_id,
-            c.create_user,
-            c.create_time,
-            c.update_user,
-            c.update_time,
-            c.tag
+        select c.id,
+               c.customer_code,
+               c.code,
+               c.country_id,
+               c.province_id,
+               c.city_id,
+               c.address,
+               c.zip_code,
+               c.name,
+               c.status,
+               c.source,
+               c.user_id,
+               c.create_user,
+               c.create_time,
+               c.update_user,
+               c.update_time,
+               c.tag
         from customer c
             ${ew.customSqlSegment}
     </select>
@@ -62,13 +63,46 @@
     </select>
 
     <select id="sourceIncrement" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
-        SELECT
-            COUNT(*) count,
+        SELECT COUNT(*) count,
 	        ifnull(c.source,-1) source,
             ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
         FROM
             customer c
             ${ew.customSqlSegment}
     </select>
+    <select id="getFollowUp" resultType="com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo">
+        SELECT t1.*
+        FROM ((SELECT id,
+                      amount,
+                      create_time `date`,
+                      NULL AS     contractCode,
+                      10   AS     type,
+                      NULL AS     remark
+               FROM bytesailing_sale.sale_quotation sq
+               WHERE sq.buy_corporation_id = #{id}
+                 and sq.tenant_id = #{tenantId}
+                 and sq.del_flag = 0)
+              UNION
+              (SELECT id,
+                      amount,
+                      create_time `date`,
+                      CODE AS     contractCode,
+                      20   AS     type,
+                      NULL AS     remark
+               FROM bytesailing_sale.contract c
+               WHERE c.buy_corporation_id = #{id}
+                 and c.tenant_id = #{tenantId}
+                 and c.del_flag = 0)
+              UNION
+              (SELECT id,
+                      NULL    AS amount,
+                      `date`,
+                      NULL    AS contractCode,
+                      30      AS type,
+                      content AS remark
+               FROM customer_follow_records cfr
+               WHERE cfr.customer_id = #{id})) t1
+        ORDER BY t1.date DESC LIMIT 3
+    </select>
 
 </mapper>

+ 4 - 3
hx-sale/src/main/java/com/fjhx/sale/mapper/sale/SaleQuotationMapper.java

@@ -2,12 +2,13 @@ package com.fjhx.sale.mapper.sale;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.customer.entity.customer.dto.CustomerDto;
 import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
 import com.fjhx.sale.entity.sale.po.SaleQuotation;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -43,7 +44,7 @@ public interface SaleQuotationMapper extends BaseMapper<SaleQuotation> {
 
     Page<SaleQuotationVo> saleDetail(@Param("page") Page<Object> page,@Param("dto") CustomerSelectDto dto);
 
-    Page<SaleQuotationVo> latestFollowUp(@Param("page") Page<Object> page,@Param("ew") QueryWrapper<Object> orderByDesc);
+    Page<SaleQuotationVo> latestFollowUp(@Param("page") Page<Object> page, @Param("ew") IWrapper<Object> orderByDesc, @Param("id") Long id, @Param("tenantId") String tenantId);
 
     /**
      * 类型统计(客户分析)

+ 8 - 3
hx-sale/src/main/java/com/fjhx/sale/service/sale/impl/SaleQuotationServiceImpl.java

@@ -19,7 +19,6 @@ import com.fjhx.customer.entity.customer.po.Customer;
 import com.fjhx.customer.entity.customer.vo.CustomerVo;
 import com.fjhx.customer.service.customer.CustomerService;
 import com.fjhx.flow.service.flow.FlowExampleService;
-import com.fjhx.sale.entity.contract.vo.ContractProductVo;
 import com.fjhx.sale.entity.contract.vo.ContractVo;
 import com.fjhx.sale.entity.quotation.po.QuotationPay;
 import com.fjhx.sale.entity.quotation.po.QuotationProduct;
@@ -38,6 +37,8 @@ import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
 import com.fjhx.tenant.service.dict.DictTenantDataService;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -224,8 +225,12 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
      */
     @Override
     public Page<SaleQuotationVo> latestFollowUp(CustomerSelectDto dto) {
-        Page<SaleQuotationVo> saleQuotationVoPage = baseMapper.latestFollowUp(dto.getPage(), Wrappers.query().eq("buy_corporation_id", dto.getId())
-                .orderByDesc("create_time"));
+        Page<SaleQuotationVo> saleQuotationVoPage = baseMapper.latestFollowUp(
+                dto.getPage(),
+                IWrapper.getWrapper().orderByDesc("create_time"),
+                dto.getId(),
+                SecurityUtils.getTenantId()
+        );
 
         return saleQuotationVoPage;
     }

+ 26 - 19
hx-sale/src/main/resources/mapper/sale/SaleQuotationMapper.xml

@@ -59,25 +59,32 @@
     </select>
 
     <select id="latestFollowUp" resultType="com.fjhx.sale.entity.sale.vo.SaleQuotationVo">
-        (SELECT
-            id,
-            amount,
-            create_time,
-            NULL AS contractCode,
-            10 as type
-        FROM
-            sale_quotation
-        ${ew.customSqlSegment})
-        UNION
-        (SELECT
-            id,
-            amount,
-            create_time,
-            code as contractCode,
-            20 as type
-        FROM
-            contract
-        ${ew.customSqlSegment})
+        select t1.*
+        from ((SELECT id,
+                      amount,
+                      create_time,
+                      NULL AS contractCode,
+                      10   as type,
+                      NULL AS remark
+               FROM sale_quotation sq
+               where sq.buy_corporation_id = #{id})
+              UNION
+              (SELECT id,
+                      amount,
+                      create_time,
+                      code as contractCode,
+                      20   as type,
+                      NULL AS remark
+               FROM contract c
+               where c.buy_corporation_id = #{id})
+              UNION
+              (SELECT id,
+                      NULL AS amount, date AS create_time, NULL AS contractCode, 30 AS type, content AS remark
+               FROM
+                   bytesailing_customer.customer_follow_records cfr
+               where cfr.customer_id = #{id}
+                 and cfr.tenant_id = #{tenantId}
+                 and cfr.del_flag = 0)) t1 ${ew.customSqlSegment}
     </select>
 
     <select id="saleStatistics" resultType="com.fjhx.sale.entity.sale.vo.SaleQuotationVo">