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

拜访计划、商机、客户、联系人置顶相关接口

zhouyy 6 місяців тому
батько
коміт
51cd71ed15
14 змінених файлів з 203 додано та 7 видалено
  1. 6 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/BusinessOpportunityController.java
  2. 27 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContactsController.java
  3. 5 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/CustomController.java
  4. 1 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/BusinessOpportunity.java
  5. 11 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Contacts.java
  6. 1 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Custom.java
  7. 3 4
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/ContactsMapper.java
  8. 2 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/BusinessOpportunityService.java
  9. 6 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContactsService.java
  10. 2 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/CustomService.java
  11. 13 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/BusinessOpportunityServiceImpl.java
  12. 65 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContactsServiceImpl.java
  13. 12 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/CustomServiceImpl.java
  14. 49 0
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ContactsMapper.xml

+ 6 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/BusinessOpportunityController.java

@@ -423,6 +423,12 @@ public class BusinessOpportunityController {
         return businessOpportunityService.pinBusinessOpportunity(bo,request);
     }
 
+    @PostMapping("/undoPin")
+    public HttpRespMsg undoPin(BusinessOpportunity bo, HttpServletRequest request) {
+        return businessOpportunityService.undoPin(bo,request);
+    }
+
+
     @RequestMapping("getAllByStage")
     public Object getAllByStage(BusinessOpportunity bo,HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("Token"));

+ 27 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContactsController.java

@@ -43,6 +43,33 @@ public class ContactsController {
     @Autowired
     private ContactsMapper contactsMapper;
 
+
+    /***
+     * 置顶联系人
+     * @param request
+     * @return
+     */
+    @PostMapping("/pinContacts")
+    public HttpRespMsg pinContacts(Contacts contacts ,HttpServletRequest request) {
+        return contactsService.pinContacts(contacts,request);
+    }
+
+    /***
+     * 取消置顶联系人
+     * @param request
+     * @return
+     */
+    @PostMapping("/undoPin")
+    public HttpRespMsg undoPin(Contacts contacts ,HttpServletRequest request) {
+        return contactsService.undoPin(contacts,request);
+    }
+
+    @RequestMapping("/pageContactsByPin")
+    public HttpRespMsg pageContactsByPin(@RequestParam Integer pageIndex, @RequestParam Integer pageSize,Integer customId, String name, String email,String creatorId, String phone, String ownerId){
+        return contactsService.pageContactsByPin(pageIndex,pageSize,customId,name,email,creatorId,phone,ownerId,request);
+    }
+
+
     /***
      * 获取常用联系人
      * @param request

+ 5 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/CustomController.java

@@ -72,6 +72,11 @@ public class CustomController {
         return customService.listByPin(custom, request);
     }
 
+    @PostMapping("/undoPin")
+    public HttpRespMsg undoPin(Custom custom, HttpServletRequest request) {
+        return customService.undoPin(custom,request);
+    }
+
     @PostMapping("/pinCustom")
     public HttpRespMsg pinCustom(Custom custom, HttpServletRequest request) {
         return customService.pinCutom(custom,request);

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

@@ -188,7 +188,7 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
     /**被置顶时间*/
     @TableField("pin_time")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private Date pinTime;
 
 

+ 11 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Contacts.java

@@ -12,6 +12,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 /**
  * <p>
@@ -150,6 +151,16 @@ public class Contacts extends Model<Contacts> {
     @TableField("is_frequent")
     private Integer isFrequent;
 
+    /**是否需要置顶 0/Flase 1/True*/
+    @TableField("need_pin")
+    private Boolean needPin;
+
+    /**被置顶时间*/
+    @TableField("pin_time")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date pinTime;
+
 
     @Override
     protected Serializable pkVal() {

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Custom.java

@@ -240,7 +240,7 @@ public class Custom extends Model<Custom> {
     /**被置顶时间*/
     @TableField("pin_time")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private Date pinTime;
 
     @TableField(exist = false)

+ 3 - 4
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/ContactsMapper.java

@@ -1,12 +1,9 @@
 package com.management.platform.mapper;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.management.platform.entity.Contacts;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.management.platform.entity.vo.ContactsVo;
-import com.management.platform.util.HttpRespMsg;
-import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 import java.util.Map;
@@ -25,4 +22,6 @@ public interface ContactsMapper extends BaseMapper<Contacts> {
     Page<ContactsVo> pageContacts(Page page, Map<String, Object> map);
 
     List<Contacts> selectListByIds(List<Integer> ids);
+
+    Page<ContactsVo> pageContactsByPin(Page page, Map<String, Object> map);
 }

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

@@ -72,4 +72,6 @@ public interface BusinessOpportunityService extends IService<BusinessOpportunity
     HttpRespMsg listByPin(BusinessOpportunity bo, HttpServletRequest request);
 
     HttpRespMsg pinBusinessOpportunity(BusinessOpportunity bo, HttpServletRequest request);
+
+    HttpRespMsg undoPin(BusinessOpportunity bo, HttpServletRequest request);
 }

+ 6 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContactsService.java

@@ -51,4 +51,10 @@ public interface ContactsService extends IService<Contacts> {
     HttpRespMsg getAll(HttpServletRequest request);
 
     HttpRespMsg getFrequentContacts(HttpServletRequest request);
+
+    HttpRespMsg pinContacts(Contacts contacts, HttpServletRequest request);
+
+    HttpRespMsg pageContactsByPin(Integer pageIndex, Integer pageSize, Integer customId, String name, String email, String creatorId, String phone, String ownerId, HttpServletRequest request);
+
+    HttpRespMsg undoPin(Contacts contacts, HttpServletRequest request);
 }

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

@@ -64,4 +64,6 @@ public interface CustomService extends IService<Custom> {
     HttpRespMsg listByPin(Custom custom, HttpServletRequest request);
 
     HttpRespMsg pinCutom(Custom custom, HttpServletRequest request);
+
+    HttpRespMsg undoPin(Custom custom, HttpServletRequest request);
 }

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

@@ -780,7 +780,19 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
         HttpRespMsg respMsg = new HttpRespMsg();
 //        User user = userMapper.selectById(request.getHeader("Token"));
         businessOpportunityMapper.update(null,new LambdaUpdateWrapper<BusinessOpportunity>()
-                .set(BusinessOpportunity::getNeedPin,1)
+                .set(BusinessOpportunity::getNeedPin,Boolean.TRUE)
+                .set(BusinessOpportunity::getPinTime,new Date())
+                .eq(BusinessOpportunity::getId,bo.getId())
+        );
+        return respMsg;
+    }
+
+    @Override
+    public HttpRespMsg undoPin(BusinessOpportunity bo, HttpServletRequest request) {
+        HttpRespMsg respMsg = new HttpRespMsg();
+//        User user = userMapper.selectById(request.getHeader("Token"));
+        businessOpportunityMapper.update(null,new LambdaUpdateWrapper<BusinessOpportunity>()
+                .set(BusinessOpportunity::getNeedPin,Boolean.FALSE)
                 .set(BusinessOpportunity::getPinTime,new Date())
                 .eq(BusinessOpportunity::getId,bo.getId())
         );

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

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.management.platform.entity.*;
@@ -843,5 +844,69 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         return msg;
     }
 
+    @Override
+    public HttpRespMsg pinContacts(Contacts contacts, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        contactsMapper.update(null,new LambdaUpdateWrapper<Contacts>()
+                        .set(Contacts::getNeedPin,Boolean.TRUE)
+                        .set(Contacts::getPinTime,new Date())
+                .eq(Contacts::getId,contacts.getId())
+        );
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg pageContactsByPin(Integer pageIndex, Integer pageSize, Integer customId, String name, String email, String creatorId, String phone, String ownerId, HttpServletRequest request) {
+        String token = String.valueOf(request.getHeader("Token"));
+        User user = userMapper.selectById(token);
+        boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部联系人");
+        boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门联系人");
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("customId", customId);
+        map.put("name", name);
+        map.put("phone", phone);
+        map.put("ownerId", ownerId);
+        map.put("email", email);
+        map.put("creatorId", creatorId);
+        map.put("companyId", user.getCompanyId());
+        map.put("isDelete", 0);
+
+
+        if (isAll){
+            System.out.println("do nothing");
+        }else if (isNotAll){
+            Integer departmentId = user.getDepartmentId();//找出对应的部门id
+            map.put("departmentId",departmentId);
+        }else {
+            //查看负责人为自己和null的数据
+            map.put("ownerIdByMyselfAndNull",user.getId());
+        }
+
+        Page<ContactsVo> pageContacts = contactsMapper.pageContactsByPin(new Page( pageIndex, pageSize), map);
+
+        List<ContactsVo> records = pageContacts.getRecords();
+        long total = pageContacts.getTotal();
+
+        HashMap<String, Object> hashMap = new HashMap<>();
+        hashMap.put("records", records);
+        hashMap.put("total", total);
+
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.setData(hashMap);
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg undoPin(Contacts contacts, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        contactsMapper.update(null,new LambdaUpdateWrapper<Contacts>()
+                .set(Contacts::getNeedPin,Boolean.FALSE)
+                .set(Contacts::getPinTime,new Date())
+                .eq(Contacts::getId,contacts.getId())
+        );
+        return msg;
+    }
+
 
 }

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

@@ -919,6 +919,18 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         return respMsg;
     }
 
+    @Override
+    public HttpRespMsg undoPin(Custom custom, HttpServletRequest request) {
+        HttpRespMsg respMsg = new HttpRespMsg();
+//        User user = userMapper.selectById(request.getHeader("Token"));
+        customMapper.update(null,new LambdaUpdateWrapper<Custom>()
+                .set(Custom::getNeedPin,0)
+                .set(Custom::getPinTime,new Date())
+                .eq(Custom::getId,custom.getId())
+        );
+        return respMsg;
+    }
+
 
     private Custom setNull(Custom clue) {
         if (clue.getPlate1() == "") {

+ 49 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ContactsMapper.xml

@@ -102,6 +102,55 @@
             </if>
         </where>
     </select>
+    <select id="pageContactsByPin" resultType="com.management.platform.entity.vo.ContactsVo">
+        SELECT c.*, cust.custom_name as customName, own.name as ownerName,u.name as creatorName
+        FROM contacts c
+        LEFT JOIN custom cust ON c.custom_id = cust.id
+        LEFT JOIN user own ON c.owner_id = own.id
+        LEFT JOIN user u ON c.creator_id = u.id
+        <where>
+            <if test="map.isDelete != null ">
+                AND c.is_delete =#{map.isDelete}
+            </if>
+            <if test="map.customName != null and map.customName != ''">
+                AND cust.custom_name LIKE CONCAT('%', #{map.customName}, '%')
+            </if>
+            <if test="map.ownerName != null and map.ownerName != ''">
+                AND own.name LIKE CONCAT('%', #{map.ownerName}, '%')
+            </if>
+            <if test="map.creatorName != null and map.creatorName != ''">
+                AND own.name LIKE CONCAT('%', #{map.creatorName}, '%')
+            </if>
+            <if test="map.customId != null and map.customId != ''">
+                AND cust.id =#{map.customId}
+            </if>
+            <if test="map.ownerId != null and map.ownerId != ''">
+                AND own.id =#{map.ownerId}
+            </if>
+            <if test="map.creatorId != null and map.creatorId != ''">
+                AND u.id =#{map.creatorId}
+            </if>
+            <if test="map.phone != null and map.phone != ''">
+                AND c.phone LIKE CONCAT('%', #{map.phone}, '%')
+            </if>
+            <if test="map.name != null and map.name != ''">
+                AND c.name LIKE CONCAT('%', #{map.name}, '%')
+            </if>
+            <if test="map.email != null and map.email != ''">
+                AND c.email LIKE CONCAT('%', #{map.email}, '%')
+            </if>
+            <if test="map.companyId != null">
+                AND c.company_id=#{map.companyId}
+            </if>
+            <if test="map.departmentId != null">
+                AND own.department_id=#{map.departmentId}
+            </if>
+            <if test="map.ownerIdByMyselfAndNull != null and map.ownerIdByMyselfAndNull != ''">
+                AND ( own.id=#{map.ownerIdByMyselfAndNull} or own.id is null )
+            </if>
+        </where>
+        ORDER BY need_pin desc,pin_time desc
+    </select>
 
 
 </mapper>