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

联系人详情获取,联系人放入回收站修改

yusm 1 рік тому
батько
коміт
4b39e909fc

+ 14 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/BusinessOpportunity.java

@@ -18,7 +18,7 @@ import lombok.experimental.Accessors;
  * </p>
  *
  * @author Seyason
- * @since 2024-03-12
+ * @since 2024-03-13
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -35,7 +35,6 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
 
     private Integer productId;
 
-    private String inchargerId;
 
     private String productName;
 
@@ -56,6 +55,7 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
      */
     @TableField("customer_id")
     private Integer customerId;
+    private String customerName;
 
     /**
      * 商机金额
@@ -82,12 +82,24 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
     private Date createTime;
     private Date startTime;
     private Date endTIme;
+    /**
+     * 修改时间
+     */
+    @TableField("edit_time")
+    private LocalDateTime editTime;
 
     /**
      * 创建人
      */
     @TableField("creator_id")
     private String creatorId;
+    private String creatorName;
+    /**
+     * 负责人
+     */
+    @TableField("incharger_id")
+    private String inchargerId;
+    private String inchargerName;
 
     /**
      * 备注

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/vo/ContactsVo.java

@@ -1,5 +1,6 @@
 package com.management.platform.entity.vo;
 
+import com.management.platform.entity.BusinessOpportunity;
 import com.management.platform.entity.Contacts;
 import com.management.platform.entity.ContactsLog;
 import com.management.platform.entity.Task;
@@ -17,5 +18,6 @@ public class ContactsVo extends Contacts {
     private String ownerName;
     private List<ContactsLog> contactsLogList;
     private List<Task> taskList;
+    private List<BusinessOpportunity> businessOpportunityList;
 
 }

+ 46 - 9
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContactsServiceImpl.java

@@ -1,14 +1,12 @@
 package com.management.platform.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.ContactsVo;
-import com.management.platform.mapper.ContactsLogMapper;
-import com.management.platform.mapper.ContactsMapper;
-import com.management.platform.mapper.TaskMapper;
-import com.management.platform.mapper.UserMapper;
+import com.management.platform.mapper.*;
 import com.management.platform.service.ContactsService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.util.HttpRespMsg;
@@ -23,6 +21,7 @@ import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -44,6 +43,12 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     @Resource
     private TaskMapper taskMapper;
 
+    @Resource
+    private BusinessOpportunityMapper businessOpportunityMapper;
+
+    @Resource
+    private CustomMapper customMapper;
+
 
     @Override
     @Transactional
@@ -146,7 +151,24 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     public HttpRespMsg deleteContacts(List<Integer> ids, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
         UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
-        //todo 删除联系人的时候要检查是否有关联的商机和任务
+        List<BusinessOpportunity> opportunityList = businessOpportunityMapper.selectList(new QueryWrapper<BusinessOpportunity>().in("contacts_id", ids));
+        if (!opportunityList.isEmpty()){
+            List<BusinessOpportunity> collect = opportunityList.stream().filter(o -> o.getStage() < 4).collect(Collectors.toList());
+            if (!collect.isEmpty()){
+                String oName=" ";
+                for (BusinessOpportunity businessOpportunity : collect) {
+                    oName+=businessOpportunity.getName()+" ";
+                }
+                msg.setError(oName+"等商机正在进行且跟联系人有关");
+            }
+        }
+        List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().in("contacts_id", ids));
+        if (!taskList.isEmpty()){
+            List<Task> collect = taskList.stream().filter(t -> t.getStatus() != 2).collect(Collectors.toList());
+            if (!collect.isEmpty()){
+                msg.setError("存在任务未完成且跟联系人有关");
+            }
+        }
         contactsUpdateWrapper.in("id", ids);
         contactsUpdateWrapper.set("is_delete", 1);
         contactsMapper.update(null, contactsUpdateWrapper);
@@ -194,9 +216,6 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     @Override
     public HttpRespMsg getContactsDetail(Contacts contacts, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
-        String token = String.valueOf(request.getHeader("Token"));
-        User user = userMapper.selectById(token);
-        Integer companyId = user.getCompanyId();
 
         ContactsVo contactsVo = new ContactsVo();
         Contacts contactsSelect = contactsMapper.selectById(contacts.getId());
@@ -222,13 +241,31 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
             });
 
             //相关商机
+            LambdaQueryWrapper<BusinessOpportunity> bLqw = new LambdaQueryWrapper<>();
+            bLqw.eq(BusinessOpportunity::getContactsId,contactsSelect.getId());
+            List<BusinessOpportunity> opportunityList = businessOpportunityMapper.selectList(bLqw);
+            opportunityList.forEach(businessOpportunity -> {
+                Custom custom = customMapper.selectById(businessOpportunity.getCustomerId());
+                businessOpportunity.setCustomerName(custom.getCustomName());
+                if (businessOpportunity.getInchargerId()!=null){
+                    User chargeUser = userMapper.selectById(businessOpportunity.getInchargerId());
+                    businessOpportunity.setInchargerName(chargeUser.getName());
+                }
+                if (businessOpportunity.getCreatorId()!=null){
+                    User creatorUser = userMapper.selectById(businessOpportunity.getCreatorId());
+                    businessOpportunity.setCreatorName(creatorUser.getName());
+                }
+            });
 
+            //todo 附件信息查询  uploadFile()方法
 
             BeanUtils.copyProperties(contactsSelect, contactsVo);
             contactsVo.setContactsLogList(contactsLogs);
             contactsVo.setTaskList(taskList);
+            contactsVo.setBusinessOpportunityList(opportunityList);
         }
-        return null;
+        msg.setData(contactsVo);
+        return msg;
     }
 
 

+ 3 - 160
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/BusinessOpportunityMapper.xml

@@ -13,7 +13,9 @@
         <result column="expected_transaction_date" property="expectedTransactionDate" />
         <result column="stage" property="stage" />
         <result column="create_time" property="createTime" />
+        <result column="edit_time" property="editTime" />
         <result column="creator_id" property="creatorId" />
+        <result column="incharger_id" property="inchargerId" />
         <result column="remark" property="remark" />
         <result column="is_delete" property="isDelete" />
         <result column="plate1" property="plate1" />
@@ -25,166 +27,7 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, company_id, name, contacts_id, customer_id, amount_of_money, expected_transaction_date, stage, create_time, creator_id, incharger_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5
+        id, company_id, name, contacts_id, customer_id, amount_of_money, expected_transaction_date, stage, create_time, edit_time, creator_id, incharger_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5
     </sql>
-    <select id="selectAllList" resultType="com.management.platform.entity.BusinessOpportunity">
-        select
-        b.id,
-        b.`name`,
-        Sum(ip.total_price),
-        b.stage,
-        (SELECT GROUP_CONCAT(product_name) from business_item_product i LEFT JOIN product t on i.product_id = t.id  WHERE i.business_id = b.id) productName
-        FROM business_opportunity b
-                 left join business_item_product ip ON ip.business_id = b.id
-                 left join product p on p.id = ip.product_id
-        WHERE b.company_id = #{companyId}
-          and is_delete = #{isDelete}
-        <if test="name != null and name != ''" >
-         and b.name = #{name}
-        </if>
-        <if test="stage != null " >
-            and b.stage = #{stage}
-        </if>
-        <if test="startTime != null and bo.endTime != null " >
-            and b.expected_transaction_date BETWEEN #{startTime} and #{endTime}
-        </if>
-        <if test="productId != null ">
-            and p.id = #{productId}
-        </if>
-        GROUP BY b.id
-        LIMIT #{pageIndex},#{pageSize}
-    </select>
-    <select id="selectAllList1" resultType="com.management.platform.entity.BusinessOpportunity">
-        select
-        b.id,
-        b.`name`,
-        Sum(ip.total_price),
-        b.stage,
-        (SELECT GROUP_CONCAT(product_name) from business_item_product i LEFT JOIN product t on i.product_id = t.id WHERE
-        i.business_id = b.id) productName
-        FROM business_opportunity b
-        left join business_item_product ip ON ip.business_id = b.id
-        left join product p on p.id = ip.product_id
-        WHERE b.company_id = #{bo.companyId}
-          and b.is_delete = #{bo.isDelete}
-        and b.incharger_id in
-        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
-        and b.incharger_id is null
-        <if test="bo.name != null and bo.name != ''">
-            and b.name = #{bo.name}
-        </if>
-        <if test="bo.stage != null ">
-            and b.stage = #{bo.stage}
-        </if>
-        <if test="bo.startTime != null and bo.endTime != null ">
-            and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
-        </if>
-        <if test="bo.productId != null ">
-            and p.id = #{bo.productId}
-        </if>
-        GROUP BY b.id
-        LIMIT #{bo.pageIndex},#{bo.pageSize}
-    </select>
-    <select id="selectAllList2" resultType="com.management.platform.entity.BusinessOpportunity">
-        select
-        b.id,
-        b.`name`,
-        Sum(ip.total_price),
-        b.stage,
-        (SELECT GROUP_CONCAT(product_name) from business_item_product i LEFT JOIN product t on i.product_id = t.id WHERE
-        i.business_id = b.id) productName
-        FROM business_opportunity b
-        left join business_item_product ip ON ip.business_id = b.id
-        left join product p on p.id = ip.product_id
-        WHERE b.company_id = #{bo.companyId}
-        and b.incharger_id = #{userId}
-        and b.is_delete = #{bo.isDelete}
-        and b.incharger_id is null
-        <if test="bo.name != null and bo.name != ''">
-            and b.name = #{bo.name}
-        </if>
-        <if test="bo.stage != null ">
-            and b.stage = #{bo.stage}
-        </if>
-        <if test="bo.startTime != null and bo.endTime != null ">
-            and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
-        </if>
-        <if test="bo.productId != null ">
-            and p.id = #{bo.productId}
-        </if>
-        GROUP BY b.id
-        LIMIT #{bo.pageIndex},#{bo.pageSize}
-    </select>
-    <select id="getTotal" resultType="java.lang.Integer">
-        select
-        conut(b.id)
-        FROM business_opportunity b
-        left join business_item_product ip ON ip.business_id = b.id
-        left join product p on p.id = ip.product_id
-        WHERE b.company_id = #{companyId}
-          and b.is_delete = #{isDelete}
-        <if test="name != null and name != ''" >
-            and b.name = #{name}
-        </if>
-        <if test="stage != null " >
-            and b.stage = #{stage}
-        </if>
-        <if test="startTime != null and endTime != null " >
-            and b.expected_transaction_date BETWEEN #{startTime} and #{endTime}
-        </if>
-        <if test="productId != null ">
-            and p.id = #{productId}
-        </if>
-        GROUP BY b.id
-    </select>
-    <select id="getTotal1" resultType="java.lang.Integer">
-        select
-        count(b.id)
-        FROM business_opportunity b
-        left join business_item_product ip ON ip.business_id = b.id
-        left join product p on p.id = ip.product_id
-        WHERE b.company_id = #{bo.companyId}
-          and b.is_delete = #{bo.isDelete}
-        and b.incharger_id in
-        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
-        and b.incharger_id is null
-        <if test="bo.name != null and bo.name != ''">
-            and b.name = #{bo.name}
-        </if>
-        <if test="bo.stage != null ">
-            and b.stage = #{bo.stage}
-        </if>
-        <if test="bo.startTime != null and bo.endTime != null ">
-            and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
-        </if>
-        <if test="bo.productId != null ">
-            and p.id = #{bo.productId}
-        </if>
-        GROUP BY b.id
-    </select>
-    <select id="getTotal2" resultType="java.lang.Integer">
-        select
-        COUNT(b.id)
-        FROM business_opportunity b
-        left join business_item_product ip ON ip.business_id = b.id
-        left join product p on p.id = ip.product_id
-        WHERE b.company_id = #{bo.companyId}
-        and b.is_delete = #{bo.isDelete}
-        and b.incharger_id = #{userId}
-        and b.incharger_id is null
-        <if test="bo.name != null and bo.name != ''">
-            and b.name = #{bo.name}
-        </if>
-        <if test="bo.stage != null ">
-            and b.stage = #{bo.stage}
-        </if>
-        <if test="bo.startTime != null and bo.endTime != null ">
-            and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
-        </if>
-        <if test="bo.productId != null ">
-            and p.id = #{bo.productId}
-        </if>
-        GROUP BY b.id
-    </select>
 
 </mapper>