ct před 1 dnem
rodič
revize
b24078ea2c

+ 21 - 0
fs-admin/src/main/java/com/fs/task/CrmTask.java

@@ -0,0 +1,21 @@
+package com.fs.task;
+
+import com.fs.crm.service.ICrmCustomerService;
+import com.fs.store.domain.FsStoreOrder;
+import com.fs.store.service.IFsStoreOrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service("crmTask")
+@Slf4j
+public class CrmTask {
+    @Autowired
+    private ICrmCustomerService crmCustomerService;
+    /**
+     * 汇总crm订单成交总额
+     */
+    public void computePayMoney(){
+        crmCustomerService.computePayMoney();
+    }
+}

+ 6 - 0
fs-service-system/src/main/java/com/fs/crm/domain/CrmCustomer.java

@@ -184,4 +184,10 @@ public class CrmCustomer extends BaseEntity
      * 是否置顶
      */
     private Integer isTop;
+
+    @Excel(name = "最新跟进类型")
+    private Integer visitType;
+
+    @Excel(name = "最新跟进内容")
+    private String visitContent;
 }

+ 23 - 23
fs-service-system/src/main/java/com/fs/crm/domain/CrmCustomerVisit.java

@@ -9,7 +9,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 /**
  * 跟进对象 crm_customer_visit
- * 
+ *
  * @author fs
  * @date 2022-12-21
  */
@@ -26,7 +26,7 @@ public class CrmCustomerVisit extends BaseEntity
 
     /** 类型 1 电话 2 微信 */
     @Excel(name = "类型 1 电话 2 微信")
-    private Long visitType;
+    private Integer visitType;
 
     /** 走访内容 */
     @Excel(name = "走访内容")
@@ -77,97 +77,97 @@ public class CrmCustomerVisit extends BaseEntity
         this.visitId = visitId;
     }
 
-    public Long getVisitId() 
+    public Long getVisitId()
     {
         return visitId;
     }
-    public void setCustomerId(Long customerId) 
+    public void setCustomerId(Long customerId)
     {
         this.customerId = customerId;
     }
 
-    public Long getCustomerId() 
+    public Long getCustomerId()
     {
         return customerId;
     }
-    public void setVisitType(Long visitType) 
+    public void setVisitType(Integer visitType)
     {
         this.visitType = visitType;
     }
 
-    public Long getVisitType() 
+    public Integer getVisitType()
     {
         return visitType;
     }
-    public void setContent(String content) 
+    public void setContent(String content)
     {
         this.content = content;
     }
 
-    public String getContent() 
+    public String getContent()
     {
         return content;
     }
-    public void setPhotos(String photos) 
+    public void setPhotos(String photos)
     {
         this.photos = photos;
     }
 
-    public String getPhotos() 
+    public String getPhotos()
     {
         return photos;
     }
-    public void setNextTime(Date nextTime) 
+    public void setNextTime(Date nextTime)
     {
         this.nextTime = nextTime;
     }
 
-    public Date getNextTime() 
+    public Date getNextTime()
     {
         return nextTime;
     }
-    public void setLng(String lng) 
+    public void setLng(String lng)
     {
         this.lng = lng;
     }
 
-    public String getLng() 
+    public String getLng()
     {
         return lng;
     }
-    public void setLat(String lat) 
+    public void setLat(String lat)
     {
         this.lat = lat;
     }
 
-    public String getLat() 
+    public String getLat()
     {
         return lat;
     }
-    public void setAddress(String address) 
+    public void setAddress(String address)
     {
         this.address = address;
     }
 
-    public String getAddress() 
+    public String getAddress()
     {
         return address;
     }
-    public void setCompanyUserId(Long companyUserId) 
+    public void setCompanyUserId(Long companyUserId)
     {
         this.companyUserId = companyUserId;
     }
 
-    public Long getCompanyUserId() 
+    public Long getCompanyUserId()
     {
         return companyUserId;
     }
-    public void setCompanyId(Long companyId) 
+    public void setCompanyId(Long companyId)
     {
         this.companyId = companyId;
     }
 
-    public Long getCompanyId() 
+    public Long getCompanyId()
     {
         return companyId;
     }

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

@@ -212,154 +212,12 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer>
             "</script>"})
     int selectCrmCustomerMobileNum(CrmCustomer crmCustomer);
 
-    @Select({"<script> " +
-            "select c.*,com.company_name,cu.nick_name as company_user_nick_name,ccu.last_time as lastTime from crm_customer c left join company com on com.company_id=c.company_id left join company_user cu on cu.user_id=c.receive_user_id left join crm_customer_user ccu on ccu.customer_user_id = c.customer_user_id " +
-            "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.companyUserNickName != null and  maps.companyUserNickName !=\"\"    '> " +
-            "and cu.nick_name like CONCAT('%',#{maps.companyUserNickName},'%') " +
-            "</if>" +
-            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"    '> " +
-            "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
-            "</if>" +
-            "<if test = 'maps.tags != null and  maps.tags !=\"\"    '> " +
-            "and find_in_set(#{maps.tags}, c.tags)   " +
-            "</if>" +
-            "<if test = 'maps.status != null      '> " +
-            "and c.status =#{maps.status} " +
-            "</if>" +
-            "<if test = 'maps.visitStatus != null and maps.visitStatus !=\"\"     '> " +
-            "and c.visit_status =#{maps.visitStatus} " +
-            "</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.isLine != null      '> " +
-            "and c.is_line =#{maps.isLine} " +
-            "</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.source != null      '> " +
-            "and c.source IN " +
-            "<foreach collection=\"maps.source.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </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.receiveTimeList != null    '> " +
-            " AND date_format(c.receive_time,'%y%m%d') &gt;= date_format(#{maps.receiveTimeList[0]},'%y%m%d') " +
-            " AND date_format(c.receive_time,'%y%m%d') &lt;= date_format(#{maps.receiveTimeList[1]},'%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>" +
-            "<if test = 'maps.customerLevel != null'> " +
-            "and c.customer_level = #{maps.customerLevel} " +
-            "</if>" +
-            "${maps.params.dataScope}"+
-            " order by c.is_top desc, c.customer_id desc "+
-            "</script>"})
     List<CrmCustomerListVO> selectCrmCustomerListQueryParam(@Param("maps")CrmCustomerListQueryParam crmCustomer);
 
 
     List<CrmMyCustomerListQueryVO> selectCrmMyCustomerListQuery(@Param("maps")CrmMyCustomerListQueryParam param);
 
 
-    @Select({"<script> " +
-            "select c.*,u.nick_name as company_user_nick_name,ccu.start_time as startTime  from  crm_customer c left join company_user u on u.user_id=c.receive_user_id left join crm_customer_user ccu on c.customer_user_id = ccu.customer_user_id " +
-            "where 1=1 " +
-            "<if test = 'maps.companyId != null     '> " +
-            "and c.company_id =#{maps.companyId} " +
-            "</if>" +
-            "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=\"\"    '> " +
-            "and u.nick_name like CONCAT('%',#{maps.companyUserNickName},'%') " +
-            "</if>" +
-            "<if test = 'maps.companyUserId != null     '> " +
-            "and c.company_user_id =#{maps.companyUserId} " +
-            "</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 "+
-            "</script>"})
     List<CrmCustomerListQueryVO> selectCrmCustomerListQuery(@Param("maps")CrmCustomerListQueryParam param);
 
     @Select({"<script> " +

+ 1 - 1
fs-service-system/src/main/java/com/fs/crm/param/CrmCustomerVisitAddParam.java

@@ -24,7 +24,7 @@ public class CrmCustomerVisitAddParam   implements Serializable
 
     /** 类型 1 电话 2 微信 */
     @ApiParam(required=true,name="visitType",value="类型 1 电话 2 微信")
-    private Long visitType;
+    private Integer visitType;
 
     @ApiParam(required=true,name="customerUserStatus",value="跟进状态")
     @NotNull(message = "跟进状态不能为空")

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

@@ -145,4 +145,6 @@ public interface ICrmCustomerService
     void switchToTop(Long customerId);
 
     CrmCustomer selectFscrmByMobile(String mobile);
+
+    void computePayMoney();
 }

+ 57 - 2
fs-service-system/src/main/java/com/fs/crm/service/impl/CrmCustomerServiceImpl.java

@@ -28,6 +28,8 @@ import com.fs.crm.service.ICrmMsgService;
 import com.fs.crm.vo.*;
 import com.fs.jpush.service.JpushService;
 import com.fs.qwApi.param.QwCustomerDetailParam;
+import com.fs.store.domain.FsStoreOrder;
+import com.fs.store.mapper.FsStoreOrderMapper;
 import com.fs.system.service.ISysDictDataService;
 import com.fs.system.service.ISysDictTypeService;
 import lombok.Synchronized;
@@ -39,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
 
 /**
  * 客户Service业务层处理
@@ -77,6 +80,8 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
     private ISysDictTypeService dictTypeService;
     @Autowired
     private ThreadPoolTaskExecutor threadPoolTaskExecutor;
+    @Autowired
+    private FsStoreOrderMapper fsStoreOrderMapper;
     /**
      * 查询客户
      *
@@ -257,7 +262,18 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
 
     @Override
     public List<CrmCustomerListVO> selectCrmCustomerListQueryParam(CrmCustomerListQueryParam crmCustomer) {
-        return crmCustomerMapper.selectCrmCustomerListQueryParam(crmCustomer);
+        List<CrmCustomerListVO> vos = crmCustomerMapper.selectCrmCustomerListQueryParam(crmCustomer);
+        if(vos!=null && vos.size()>0){
+            for(CrmCustomerListVO vo:vos){
+                //订单相关信息
+                FsStoreOrder order = fsStoreOrderMapper.selectLastByCustomerId(vo.getCustomerId());
+                if (order != null) {
+                    vo.setOrderType(order.getOrderType().toString());
+                    vo.setOrderTime(order.getCreateTime());
+                }
+            }
+        }
+        return vos;
     }
 
     @Override
@@ -269,6 +285,12 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
                 CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
                     List<String> companyUserName = assistMapper.selectCompanyUserNameByCustomerId(vo.getCustomerId());
                     vo.setAssistUser(companyUserName);
+                    //订单相关信息
+                    FsStoreOrder order = fsStoreOrderMapper.selectLastByCustomerId(vo.getCustomerId());
+                    if (order != null) {
+                        vo.setOrderType(order.getOrderType().toString());
+                        vo.setOrderTime(order.getCreateTime());
+                    }
                 }, threadPoolTaskExecutor);
                 futures.add(future);
             });
@@ -285,7 +307,18 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
         if (param.getIsReceive() != null && param.getIsReceive() == 0){
             param.setIsLine(1);
         }
-        return crmCustomerMapper.selectCrmCustomerListQuery(param);
+        List<CrmCustomerListQueryVO> vos = crmCustomerMapper.selectCrmCustomerListQuery(param);
+        if(vos!=null && vos.size()>0){
+            for(CrmCustomerListQueryVO vo:vos){
+                //订单相关信息
+                FsStoreOrder order = fsStoreOrderMapper.selectLastByCustomerId(vo.getCustomerId());
+                if (order != null) {
+                    vo.setOrderType(order.getOrderType().toString());
+                    vo.setOrderTime(order.getCreateTime());
+                }
+            }
+        }
+        return vos;
     }
 
     @Override
@@ -932,6 +965,28 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
         return crmCustomerMapper.selectFscrmByMobile(mobile);
     }
 
+    @Override
+    public void computePayMoney() {
+        //1.查询用户
+        CrmCustomer crmCustomer = new CrmCustomer();
+        crmCustomer.setIsDel(0);
+        List<CrmCustomer> crmCustomers = selectCrmCustomerList(crmCustomer);
+//        crmCustomers = crmCustomers.stream().filter(item -> item.getUserId() != null).collect(Collectors.toList());
+        List<Long> customerIds = crmCustomers.stream().map(CrmCustomer::getCustomerId).collect(Collectors.toList());
+        if (!customerIds.isEmpty()){
+            List<FsStoreOrder> map = fsStoreOrderMapper.computePayMoney(customerIds);
+            if (map != null && !map.isEmpty()){
+                map.forEach(item ->{
+                    CrmCustomer addParam = new CrmCustomer();
+                    addParam.setCustomerId(item.getCustomerId());
+                    addParam.setPayMoney(item.getPayPrice());
+                    crmCustomerMapper.updateCrmCustomer(addParam);
+                });
+
+            }
+        }
+    }
+
     @Override
     @Transactional
     public R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param) {

+ 4 - 0
fs-service-system/src/main/java/com/fs/crm/service/impl/CrmCustomerVisitServiceImpl.java

@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
 import com.fs.crm.mapper.CrmCustomerVisitMapper;
 import com.fs.crm.domain.CrmCustomerVisit;
 import com.fs.crm.service.ICrmCustomerVisitService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 跟进Service业务层处理
@@ -129,6 +130,7 @@ public class CrmCustomerVisitServiceImpl implements ICrmCustomerVisitService
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public R addVisit(CrmCustomerVisitAddParam param) {
         CrmCustomer customer=crmCustomerMapper.selectCrmCustomerById(param.getCustomerId());
         if(customer.getIsReceive()!=null&&customer.getIsReceive()==1){
@@ -152,6 +154,8 @@ public class CrmCustomerVisitServiceImpl implements ICrmCustomerVisitService
                         customer.setCustomerType(param.getCustomerType());
                     }
                     customer.setVisitTime(new Date());
+                    customer.setVisitType(visit.getVisitType());
+                    customer.setVisitContent(visit.getContent());
                     crmCustomerMapper.updateCrmCustomer(customer);
                     return R.ok();
                 }

+ 19 - 1
fs-service-system/src/main/java/com/fs/crm/vo/CrmCustomerListQueryVO.java

@@ -84,7 +84,7 @@ public class CrmCustomerListQueryVO implements Serializable
 
     private String registerType;
 
-    private BigDecimal payMonay;
+    private BigDecimal payMoney;
 
     private Integer buyCount;
 
@@ -113,4 +113,22 @@ public class CrmCustomerListQueryVO implements Serializable
     /** 认领开始时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date startTime;
+
+    @Excel(name = "订单最新成交类型",dictType="store_order_type")
+    private String orderType;
+
+    @Excel(name = "订单最新成交时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date orderTime;
+
+    @Excel(name = "最新跟进类型",dictType="crm_customer_visit_type")
+    private String visitType;
+
+    @Excel(name = "最新跟进内容")
+    private String visitContent;
+
+    /** 最后一次跟进时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "最后一次跟进时间",dictType="crm_customer_visit_type")
+    private Date visitTime;
 }

+ 20 - 4
fs-service-system/src/main/java/com/fs/crm/vo/CrmCustomerListVO.java

@@ -80,9 +80,7 @@ public class CrmCustomerListVO implements Serializable
     @Excel(name = "流量来源")
     private String trafficSource;
 
-    /** 最后一次跟进时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date receiveTime;
+
 
     /** 入公海时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@@ -93,7 +91,7 @@ public class CrmCustomerListVO implements Serializable
 
     private String registerType;
 
-    private BigDecimal payMonay;
+    private BigDecimal payMoney;
 
     private Integer buyCount;
 
@@ -132,4 +130,22 @@ public class CrmCustomerListVO implements Serializable
     /** 置顶状态 0未置顶 1置顶 */
     private Integer isTop;
 
+    @Excel(name = "订单最新成交类型",dictType="store_order_type")
+    private String orderType;
+
+    @Excel(name = "订单最新成交时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date orderTime;
+
+    @Excel(name = "最新跟进类型",dictType="crm_customer_visit_type")
+    private String visitType;
+
+    @Excel(name = "最新跟进内容")
+    private String visitContent;
+
+    /** 最后一次跟进时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "最后一次跟进时间",dictType="crm_customer_visit_type")
+    private Date visitTime;
+
 }

+ 14 - 0
fs-service-system/src/main/java/com/fs/crm/vo/CrmMyCustomerListQueryVO.java

@@ -5,6 +5,7 @@ import com.fs.common.annotation.Excel;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -126,4 +127,17 @@ public class CrmMyCustomerListQueryVO implements Serializable
     /** 客户级别 */
     private Long customerLevel;
 
+    private BigDecimal payMoney;
+
+    @Excel(name = "订单最新成交类型",dictType="store_order_type")
+    private String orderType;
+
+    @Excel(name = "订单最新成交时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date orderTime;
+
+
+    @Excel(name = "最新跟进内容")
+    private String visitContent;
+
 }

+ 4 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreOrderMapper.java

@@ -1057,4 +1057,8 @@ public interface FsStoreOrderMapper
     List<OrderStatisticsVo> selectOrderSaleStatisticsList(@Param("param") OrderStatisticsParam param);
 
     List<FsStoreOrderCountsVO> selectFsStoreOrderCountsByDept(Map<String, Object> map);
+
+    List<FsStoreOrder> computePayMoney(@Param("customerIds")List<Long> customerIds);
+
+    FsStoreOrder selectLastByCustomerId(@Param("customerId")Long customerId);
 }

+ 171 - 2
fs-service-system/src/main/resources/mapper/crm/CrmCustomerMapper.xml

@@ -56,10 +56,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="clueId"    column="clue_id"    />
         <result property="customerLevel"    column="customer_level"    />
         <result property="isTop"    column="is_top"    />
+        <result property="visitType"    column="visit_type"    />
+        <result property="visitContent"    column="visit_content"    />
     </resultMap>
 
     <sql id="selectCrmCustomerVo">
-        select customer_id, customer_code, customer_name, mobile, sex, weixin, remark, user_id, create_user_id, receive_user_id, customer_user_id, address,city_ids, location, detail_address, lng, lat, create_time, update_time, status, is_receive, dept_id, is_del, customer_type, receive_time, pool_time, company_id, is_line, source, tags,ext_json,visit_status,register_date,register_link_url,register_desc,register_submit_time,is_pool,register_type,pay_money,buy_count,source_code,push_time,push_code,visit_time,traffic_source,import_type,third_account,clue_id,customer_level,is_top from crm_customer
+        select customer_id, customer_code, customer_name, mobile, sex, weixin, remark, user_id, create_user_id,
+               receive_user_id, customer_user_id, address,city_ids, location, detail_address, lng, lat, create_time,
+               update_time, status, is_receive, dept_id, is_del, customer_type, receive_time, pool_time, company_id,
+               is_line, source, tags,ext_json,visit_status,register_date,register_link_url,register_desc,
+               register_submit_time,is_pool,register_type,pay_money,buy_count,source_code,push_time,push_code,
+               visit_time,traffic_source,import_type,third_account,clue_id,customer_level,is_top,visit_type,visit_content from crm_customer
     </sql>
 
     <select id="selectCrmCustomerList" parameterType="CrmCustomer" resultMap="CrmCustomerResult">
@@ -97,6 +104,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="clueId != null "> and clue_id = #{clueId}</if>
             <if test="customerLevel != null "> and customer_level = #{customerLevel}</if>
             <if test="isTop != null "> and is_top = #{isTop}</if>
+            <if test="visitType != null"> and visit_type = #{visitType}</if>
+            <if test="visitContent != null and visitContent !=''"> and visit_content = #{visitContent}</if>
         </where>
         order by customer_id desc
     </select>
@@ -163,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="clueId != null">clue_id,</if>
             <if test="customerLevel != null">customer_level,</if>
             <if test="isTop != null">is_top,</if>
+            <if test="visitType != null">visit_type,</if>
+            <if test="visitContent != null">visit_content,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="customerCode != null">#{customerCode},</if>
@@ -214,6 +225,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="clueId != null">#{clueId},</if>
             <if test="customerLevel != null">#{customerLevel},</if>
             <if test="isTop != null">#{isTop},</if>
+            <if test="visitType != null">#{visitType},</if>
+            <if test="visitContent != null">#{visitContent},</if>
          </trim>
     </insert>
 
@@ -269,6 +282,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="clueId != null">clue_id = #{clueId},</if>
             <if test="customerLevel != null">customer_level = #{customerLevel},</if>
             <if test="isTop != null">is_top = #{isTop},</if>
+            <if test="visitType != null">visit_type = #{visitType},</if>
+            <if test="visitContent != null and visitContent !=''">visit_content = #{visitContent},</if>
         </trim>
         where customer_id = #{customerId}
     </update>
@@ -303,7 +318,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectCrmMyCustomerListQuery" resultType="com.fs.crm.vo.CrmMyCustomerListQueryVO">
         select cu.*,c.create_time as customer_create_time,c.visit_status,c.remark,c.register_desc,c.register_submit_time,
                c.customer_code,c.customer_name,c.mobile,c.sex,c.weixin,c.address,c.is_receive,c.customer_type,c.source,
-               c.tags,c.receive_time,c.customer_level
+               c.tags,c.receive_time,c.customer_level,c.pay_money,c.visit_content
         from crm_customer_user cu
             inner join crm_customer c on c.customer_user_id=cu.customer_user_id
         where cu.is_pool=0  and c.is_del = 0
@@ -442,4 +457,158 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectCustomerIdByCompanyUserId" resultType="java.lang.Long">
         SELECT customer_id FROM crm_customer_user where company_user_id = #{companyUserId}
     </select>
+    <select id="selectCrmCustomerListQueryParam" resultType="com.fs.crm.vo.CrmCustomerListVO">
+        select c.*,com.company_name,cu.nick_name as company_user_nick_name,ccu.last_time as lastTime
+        from crm_customer c
+            left join company com on com.company_id=c.company_id
+            left join company_user cu on cu.user_id=c.receive_user_id
+            left join crm_customer_user ccu on ccu.customer_user_id = c.customer_user_id
+        <where>
+            <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.companyUserNickName != null and  maps.companyUserNickName != ''">
+                and c.nick_name like CONCAT('%',#{maps.companyUserNickName},'%')
+            </if>
+            <if test="maps.mobile != null and  maps.mobile != ''">
+                and c.mobile like CONCAT('%',#{maps.mobile},'%')
+            </if>
+            <if test="maps.tags != null and  maps.tags != ''">
+                and find_in_set(#{maps.tags}, c.tags)
+            </if>
+            <if test="maps.status != null">
+                and c.status =#{maps.status}
+            </if>
+            <if test="maps.visitStatus != null and  maps.visitStatus != ''">
+                and c.visit_status =#{maps.visitStatus}
+            </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.isLine != null">
+                and c.is_line =#{maps.isLine}
+            </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.source != null ">
+                and c.source IN
+                <foreach collection="maps.source.split(',')" item='item' index='index'  open='(' separator=',' close=')'>
+                    #{item}
+                </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.receiveTimeList != null   ">
+                AND date_format(c.receive_time,'%y%m%d') &gt;= date_format(#{maps.receiveTimeList[0]},'%y%m%d')
+                AND date_format(c.receive_time,'%y%m%d') &lt;= date_format(#{maps.receiveTimeList[1]},'%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>
+            <if test="maps.customerLevel != null  ">
+                and c.customer_level = #{maps.customerLevel}
+            </if>
+        </where>
+        ${maps.params.dataScope}
+        order by c.is_top desc, c.customer_id desc
+    </select>
+    <select id="selectCrmCustomerListQuery" resultType="com.fs.crm.vo.CrmCustomerListQueryVO">
+        select c.*,u.nick_name as company_user_nick_name,ccu.start_time as startTime
+        from  crm_customer c
+            left join company_user u on u.user_id=c.receive_user_id
+            left join crm_customer_user ccu on c.customer_user_id = ccu.customer_user_id
+        <where>
+            <if test="maps.companyId != null">
+                and c.company_id =#{maps.companyId}
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName != ''">
+                and u.nick_name like CONCAT('%',#{maps.companyUserNickName},'%')
+            </if>
+            <if test="maps.companyUserId != null    ">
+                and c.company_user_id =#{maps.companyUserId}
+            </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="(" separator="OR" close=")">
+                    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>
+        </where>
+        ${maps.params.dataScope}
+       order by c.customer_id desc
+    </select>
 </mapper>

+ 13 - 0
fs-service-system/src/main/resources/mapper/store/FsStoreOrderMapper.xml

@@ -821,4 +821,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
         ) o GROUP BY o.company_user_id
     </select>
+    <select id="computePayMoney" resultMap="FsStoreOrderResult">
+        SELECT o.customer_id,o.pay_price FROM fs_store_order o WHERE `status` = 3
+            and o.customer_id in
+                <foreach collection="customerIds" item="customerId" open="(" close=")" separator=",">
+                    #{customerId}
+                </foreach>
+        GROUP BY o.customer_id
+    </select>
+    <select id="selectLastByCustomerId" resultMap="FsStoreOrderResult">
+        SELECT o.* FROM fs_store_order o WHERE `status` = 3
+        and o.customer_id = #{customerId}
+        order by o.create_time desc limit 1
+    </select>
 </mapper>