Ver Fonte

修改转移联系人,编写客户总量分析表

yusm há 11 meses atrás
pai
commit
0778e2004d

+ 10 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContactsController.java

@@ -1,6 +1,7 @@
 package com.management.platform.controller;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.Contacts;
 import com.management.platform.entity.Custom;
@@ -101,8 +102,15 @@ public class ContactsController {
      * @return
      */
     @RequestMapping("deleteContacts")
-    public HttpRespMsg deleteContacts( List<Integer> ids){
-        return contactsService.deleteContacts(ids,request);
+    public HttpRespMsg deleteContacts( String ids){
+        if (!StringUtils.isEmpty(ids)) {
+            ids="["+ids+"]";
+            List<Integer> array = JSONArray.parseArray(ids, Integer.class);
+            return contactsService.deleteContacts(array,request);
+        }
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.setError("参数不能为空");
+        return msg;
     }
 
     /**

+ 16 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ReportController.java

@@ -15,6 +15,7 @@ import com.management.platform.entity.vo.WorktimeItem;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
 import com.management.platform.util.*;
+import me.chanjar.weixin.mp.constant.WxMpEventConstants;
 import okhttp3.OkHttpClient;
 import okhttp3.Request;
 import okhttp3.WebSocket;
@@ -106,6 +107,9 @@ public class ReportController {
     @Resource
     private EstimateTimeSettingMapper estimateTimeSettingMapper;
 
+    @Autowired
+    private CustomService customService;
+
     //获取任务相关的日报列表
     @RequestMapping("/getTaskReportList")
     public HttpRespMsg getTaskReportList(Integer taskId) {
@@ -214,6 +218,18 @@ public class ReportController {
         return reportService.getReportFillStatus(startDate, endDate, userId, request);
     }
 
+    /**
+     * 客户总量分析
+     * @param startDate
+     * @param endDate
+     * @param userId
+     * @return
+     */
+    @RequestMapping("/getCustomerTotalCount")
+    public HttpRespMsg getCustomerTotalCount(String startDate, String endDate, String userId) {
+        return  customService.getCustomerTotalCount(startDate, endDate, userId, request);
+    }
+
     @RequestMapping("/getReportList")
     public HttpRespMsg getReportList(@RequestParam String date, @RequestParam(required = false) Integer deptId, @RequestParam(required = false) String userId) {
         return reportService.getReportList(date, deptId, userId, request);

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

@@ -26,4 +26,8 @@ public class UserVO extends User {
 
     private boolean hasAuditDept;
 
+    private Integer customertotal;//客户总量
+    private Integer customerDeal;//客户成交量
+    private Double dealRate;//客户成交量率
+
 }

+ 1 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/CustomMapper.java

@@ -3,6 +3,7 @@ package com.management.platform.mapper;
 import com.management.platform.entity.Clue;
 import com.management.platform.entity.Custom;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.management.platform.util.HttpRespMsg;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;

+ 3 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/UserMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.management.platform.entity.User;
+import com.management.platform.entity.vo.UserVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
 
@@ -57,4 +58,6 @@ public interface UserMapper extends BaseMapper<User> {
     List<User> getInActiveBewttenStartAndEndList(ArrayList<Integer> deptIds, String startDate, String endDate);
 
     void updateActiveByIds(List<String> array, int isActive);
+
+    List<UserVO> getCustomerTotalCount(String startDate, String endDate, String userId, Integer companyId);
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/CustomService.java

@@ -54,4 +54,6 @@ public interface CustomService extends IService<Custom> {
     Map<String, Object> getDataSummary(Integer companyId,String startDate, String endDate, String userId,@Param("list") List<String> targetUserIds);
 
     void deleterDelete(List<Integer> ids);
+
+    HttpRespMsg getCustomerTotalCount(String startDate, String endDate, String userId, HttpServletRequest request);
 }

+ 1 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContactsDocumentServiceImpl.java

@@ -155,6 +155,7 @@ public class ContactsDocumentServiceImpl extends ServiceImpl<ContactsDocumentMap
         ContactsDocument contactsDocument = contactsDocumentMapper.selectById(fileId);
         if (contactsDocument==null){
             msg.setError("文件不存在");
+            return msg;
         }
         LambdaUpdateWrapper<ContactsDocument> ulw = new LambdaUpdateWrapper<>();
         ulw.set(ContactsDocument::getDocumentName,newName).eq(ContactsDocument::getId,fileId);

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

@@ -88,15 +88,19 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         Integer companyId = user.getCompanyId();
         if (StringUtils.isEmpty(contacts.getName())){
             httpRespMsg.setError("请输入联系人姓名");
+            return httpRespMsg;
         }
         if (contacts.getCustomId()==null){
             httpRespMsg.setError("客户信息为空");
+            return httpRespMsg;
         }
         if (StringUtils.isEmpty(contacts.getPhone())){
             httpRespMsg.setError("联系人电话号码为空");
+            return httpRespMsg;
         }
         if (contacts.getOwnerId() == null) {
             httpRespMsg.setError("负责人信息为空!");
+            return httpRespMsg;
         }
 
         LambdaQueryWrapper<Contacts> lqw_contacts = new LambdaQueryWrapper<>();
@@ -107,6 +111,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         Contacts selectedOne = contactsMapper.selectOne(lqw_contacts);
         if (selectedOne != null) {
             httpRespMsg.setError("已存在该联系人!");
+            return httpRespMsg;
         }
         contacts.setCompanyId(companyId)
                 //todo:联系人的所有人是可选择的
@@ -203,6 +208,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
                     oName+=businessOpportunity.getName()+" ";
                 }
                 msg.setError(oName+"等商机正在进行且跟联系人有关");
+                return msg;
             }
         }
         List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().in("contacts_id", ids));
@@ -210,6 +216,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
             List<Task> collect = taskList.stream().filter(t ->t.getStatus()!=null&&t.getStatus() != 2).collect(Collectors.toList());
             if (!collect.isEmpty()){
                 msg.setError("存在任务未完成且跟联系人有关");
+                return msg;
             }
         }
         contactsUpdateWrapper.in("id", ids);
@@ -305,7 +312,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
 
             //附件信息查询
             LambdaQueryWrapper<ContactsDocument> cDLqw = new LambdaQueryWrapper<>();
-            cDLqw.eq(ContactsDocument::getContactsId,contactsSelect.getId());
+            cDLqw.eq(ContactsDocument::getContactsId,contactsSelect.getId()).ne(ContactsDocument::getIsDeleted,1);
             List<ContactsDocument> contactsDocuments = contactsDocumentMapper.selectList(cDLqw);
 
             //返回数据

+ 20 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/CustomServiceImpl.java

@@ -3,6 +3,7 @@ package com.management.platform.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.management.platform.entity.*;
+import com.management.platform.entity.vo.UserVO;
 import com.management.platform.mapper.*;
 import com.management.platform.service.CustomService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -396,6 +397,25 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         customMapper.deleteBatchIds(ids);
     }
 
+    @Override
+    public HttpRespMsg getCustomerTotalCount(String startDate, String endDate, String userId, HttpServletRequest request) {
+        User user = userMapper.selectById(request.getHeader("token"));
+        Integer companyId = user.getCompanyId();
+        List<UserVO> userVoList=userMapper.getCustomerTotalCount(startDate,endDate,userId,companyId);
+        if (userVoList!=null&&!userVoList.isEmpty()){
+            for (UserVO userVO : userVoList) {
+                if (userVO.getCustomertotal()==0){
+                    userVO.setDealRate((double) 0);
+                }else {
+                    userVO.setDealRate((double) (userVO.getCustomerDeal()/userVO.getCustomertotal()));
+                }
+            }
+        }
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.setData(userVoList);
+        return msg;
+    }
+
 
     private Custom setNull(Custom clue) {
         if (clue.getPlate1() == "") {

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -272,6 +272,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             List<Task> collect = taskList.stream().filter(task ->task.getStatus()!=0&& task.getStatus() != 2).collect(Collectors.toList());
             if (collect.size()>0){
                 msg.setError("存在任务未完成,不能删除");
+                return msg;
             }
             LambdaUpdateWrapper<Task> tUlw = new LambdaUpdateWrapper<>();
             tUlw.set(Task::getIsDelete,1).in(Task::getId,taskIds);
@@ -860,6 +861,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         HttpRespMsg msg = new HttpRespMsg();
         if (taskDto==null||taskDto.getId()==null){
             msg.setError("缺少用户的关键信息");
+            return msg;
         }
         LambdaUpdateWrapper<Task> luw = new LambdaUpdateWrapper<>();
         luw.set(Task::getStatus,taskDto.getStatus()).eq(Task::getId,taskDto.getId());

+ 20 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/UserMapper.xml

@@ -277,6 +277,26 @@
         AND (induction_date &lt;= #{startDate} OR induction_date is NULL)
         AND id not IN (SELECT * from user_exclude)
     </select>
+    <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.UserVO">
+
+        select count(*) as customertotal ,
+               sum(case when c.close_deal=1 then 1 else 0 end) as customerDeal ,
+               u.name,u.id
+            from custom c
+            left join user u on c.incharger_id=u.id
+        <where>
+            1=1 and c.company_id=#{companyId}
+
+            <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
+                AND  c.create_time BETWEEN #{startDate} AND #{endDate}
+            </if>
+            <if test="userId !=null and userId!=''">
+                AND  c.incharger_id=#{userId}
+            </if>
+        </where>
+            group by c.incharger_id
+
+    </select>
 
     <update id="updateActiveByIds">
         update user set is_active=1 WHERE id IN