yzc 1 год назад
Родитель
Сommit
e057a04820

+ 11 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerDto.java

@@ -3,6 +3,7 @@ package com.fjhx.customer.entity.customer.dto;
 import com.fjhx.area.service.SetCustomizeAreaId;
 import com.fjhx.customer.entity.customer.po.Customer;
 import com.fjhx.customer.entity.customer.po.CustomerUser;
+import com.fjhx.file.entity.ObsFile;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -30,5 +31,15 @@ public class CustomerDto extends Customer implements SetCustomizeAreaId {
      */
     private String endTime;
 
+    /**
+     * 客户文件列表
+     */
+    private List<ObsFile> fileList;
+
+    /**
+     * 客户图片列表
+     */
+    private List<ObsFile> imgFileList;
+
 
 }

+ 49 - 1
hx-customer/src/main/java/com/fjhx/customer/entity/customer/po/Customer.java

@@ -149,6 +149,11 @@ public class Customer extends BasePo {
      * 传真
      */
     private String fax;
+
+    /**
+     * 税号
+     */
+    private String dutyParagraph;
     //================================
 
     /**
@@ -218,7 +223,50 @@ public class Customer extends BasePo {
      * 客户状态
      */
     private String state;
+    //==============================================
+    /**
+     * 发票id
+     */
+    private String invoiceType;
+    /**
+     * 合作状态
+     */
+    private String cooperateStatus;
+    /**
+     * 账户名称(公司名)
+     */
+    private String accountName;
+
+    /**
+     * 账户地址
+     */
+    private String accountAddress;
+    /**
+     * 账户电话
+     */
+    private String accountTel;
+    /**
+     * 账户开户行
+     */
+    private String accountBank;
+
+    /**
+     * 账户账号
+     */
+    private String accountNumber;
+
+    /**
+     * 对私开户行
+     */
+    private String privAccountBank;
+    /**
+     * 对私账户名称
+     */
+    private String privAccountName;
+    /**
+     * 对私账户账号
+     */
+    private String privAccountNumber;
 
-    //================================
 
 }

+ 23 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerVo.java

@@ -6,6 +6,8 @@ import com.fjhx.customer.entity.customer.po.CustomerUser;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -61,4 +63,25 @@ public class CustomerVo extends Customer implements SetCustomizeAreaName {
      * 业务部门名称
      */
     private String deptName;
+
+    /**
+     * 跟进次数
+     */
+    private Integer followCount;
+    /**
+     * 最近一次下单时间
+     */
+    private Date lastSaleDate;
+    /**
+     * 下单距离天数
+     */
+    private Integer lastSaleDay;
+    /**
+     * 订单数
+     */
+    private Integer orderCount;
+    /**
+     * 订单总金额
+     */
+    private BigDecimal orderAmountSum;
 }

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

@@ -25,6 +25,7 @@ import com.fjhx.customer.service.customer.CustomerService;
 import com.fjhx.customer.service.customer.CustomerTopService;
 import com.fjhx.customer.service.customer.CustomerUserService;
 import com.fjhx.customer.utils.code.CodeEnum;
+import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
 import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
 import com.fjhx.tenant.service.dict.DictTenantDataService;
@@ -236,9 +237,6 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
 
     /**
      * 查询客户的详情
-     *
-     * @param id
-     * @return
      */
     @Override
     public CustomerVo detail(Long id) {
@@ -290,6 +288,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         this.save(customerDto);
         //添加库户-联系人表的信息
         saveCustomerUse(customerDto);
+
+        //客户附件
+        ObsFileUtil.saveFile(customerDto.getFileList(), customerDto.getId(), 10);
+        ObsFileUtil.saveFile(customerDto.getImgFileList(), customerDto.getId(), 20);
     }
 
     /**
@@ -316,6 +318,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         customerUserService.remove(Wrappers.<CustomerUser>lambdaQuery().eq(CustomerUser::getCustomerId, customerDto.getId()));
         // 添加客户-联系人表的信息
         saveCustomerUse(customerDto);
+
+        //客户附件
+        ObsFileUtil.editFile(customerDto.getFileList(), customerDto.getId(), 10);
+        ObsFileUtil.editFile(customerDto.getImgFileList(), customerDto.getId(), 20);
     }
 
     /**

+ 70 - 57
hx-customer/src/main/resources/mapper/customer/CustomerMapper.xml

@@ -2,72 +2,85 @@
 <!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(),allocation_time = now() where id = #{id}
+        update customer
+        set user_id         = #{userId},
+            update_time     = now(),
+            allocation_time = now()
+        where id = #{id}
     </update>
-    <select id="getList" 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
+
+    <sql id="listOrPage">
+        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,
+               c.main_part,
+               c.minor_part,
+               c.dept_id,
+               c.main_categories,
+               c.company_size,
+               c.settlement_mode,
+               c.level,
+               c.maintain_level,
+               c.new_old,
+               c.annual_quantity,
+               c.follow_up_ask,
+               c.remind,
+               c.create_group_time,
+               c.state,
+               c.invoice_type,
+               c.cooperate_status,
+               c.account_name,
+               c.account_address,
+               c.account_tel,
+               c.account_bank,
+               c.account_number,
+               c.priv_account_name,
+               c.priv_account_bank,
+               c.priv_account_number,
+               t1.followCount,
+               t1.lastSaleDate,
+               t1.lastSaleDay,
+               t1.orderCount,
+               t1.orderAmountSum
         from customer c
-            ${ew.customSqlSegment}
+                 LEFT JOIN (SELECT c.id,
+                                   count(cfr.id)                                 AS followCount,
+                                   max(co.sale_date)                             AS lastSaleDate,
+                                   IFNULL(DATEDIFF(NOW(), max(co.sale_date)), 0) AS lastSaleDay,
+                                   count(co.id)                                  AS orderCount,
+                                   IFNULL(sum(co.amount), 0)                     AS orderAmountSum
+                            FROM customer c
+                                     LEFT JOIN customer_follow_records cfr ON cfr.customer_id = c.id
+                                     LEFT JOIN contract co ON co.buy_corporation_id = c.id
+                            GROUP BY c.id) t1 ON t1.id = c.id
+    </sql>
+    <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
+        <include refid="listOrPage"/>
+        ${ew.customSqlSegment}
     </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,
-            c.main_part,
-            c.minor_part,
-            c.dept_id,
-            c.main_categories,
-            c.company_size,
-            c.settlement_mode,
-            c.level,
-            c.maintain_level,
-            c.new_old,
-            c.annual_quantity,
-            c.follow_up_ask,
-            c.remind,
-            c.create_group_time,
-            c.state
-        from customer c
-            ${ew.customSqlSegment}
+        <include refid="listOrPage"/>
+        ${ew.customSqlSegment}
     </select>
 
 
     <select id="sourceStock" 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