Browse Source

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min 1 year ago
parent
commit
e76bf99213

File diff suppressed because it is too large
+ 32955 - 18377
fhKeeper/formulahousekeeper/management-crm/crm.log


+ 5 - 11
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/BusinessOpportunityController.java

@@ -55,21 +55,12 @@ public class BusinessOpportunityController {
         User user = userMapper.selectById(request.getHeader("Token"));
         HttpRespMsg msg = new HttpRespMsg();
         if (bo.getId() == null){
-//            if(bOMapper.selectCount(new QueryWrapper<BusinessOpportunity>().eq("name",bo.getName())) > 0){
-//                msg.setError("商机名称重复");
-//                return msg;
-//            }
             //新增
             bo.setCompanyId(user.getCompanyId());
             bo.setCreatorId(user.getId());
             bo.setCreateTime(new Date());
             bOservice.insert(bo);
         }else {
-//            String name = bOMapper.selectById(bo).getName();
-//            if(bOMapper.selectCount(new QueryWrapper<BusinessOpportunity>().eq("name",bo.getName()).ne("name",name)) > 0){
-//                msg.setError("商机名称已存在");
-//                return msg;
-//            }
             //修改
             bOservice.update(bo,user.getId());
         }
@@ -78,11 +69,11 @@ public class BusinessOpportunityController {
     }
 
     @RequestMapping("claim")
-    public Object claim(Clue clue, HttpServletRequest request) {
+    public Object claim(BusinessOpportunity bo, HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("Token"));
         HttpRespMsg msg = new HttpRespMsg();
         msg.setMsg("操作成功");
-        bOservice.getAndTransfer(clue, user);
+        bOservice.getAndTransfer(bo, user);
         return msg;
     }
     @RequestMapping("list")
@@ -91,6 +82,9 @@ public class BusinessOpportunityController {
         User user = userMapper.selectById(request.getHeader("Token"));
         bo.setIsDelete(0);
         bo.setCompanyId(user.getCompanyId());
+        bo.setUserId(user.getId());
+        bo.setEndTime(bo.getEndTime() + " 23:59:59");
+        bo.setPageIndex((bo.getPageIndex()-1) * bo.getPageFrom());
         List<BusinessOpportunity> list = new ArrayList<>();
         boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部商机");
         boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门商机");

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

@@ -88,9 +88,9 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
     @TableField("create_time")
     private Date createTime;
     @TableField(exist = false)
-    private Date startTime;
+    private String startTime;
     @TableField(exist = false)
-    private Date endTIme;
+    private String endTime;
     /**
      * 修改时间
      */
@@ -117,6 +117,8 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
      */
     @TableField("remark")
     private String remark;
+    @TableField(exist = false)
+    private String ids;
 
     /**
      * 回收站(是否删除) 0-否 1-是
@@ -133,6 +135,8 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
      */
     @TableField("plate1")
     private String plate1;
+    @TableField(exist = false)
+    private String userId;
 
     /**
      * 自定义字段存值

+ 3 - 3
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Stage.java

@@ -46,10 +46,10 @@ public class Stage extends Model<Stage> {
     private Integer seq;
 
     /**
-     * 是否删除
+     * 是否为结束阶段
      */
-    @TableField("is_delete")
-    private String isDelete;
+    @TableField("is_finish")
+    private Integer isFinish;
 
 
     @Override

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

@@ -31,5 +31,5 @@ public interface BusinessOpportunityService extends IService<BusinessOpportunity
 
     void update(BusinessOpportunity bo,String userId);
 
-    void getAndTransfer(Clue clue, User user);
+    void getAndTransfer(BusinessOpportunity bo, User user);
 }

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

@@ -1,5 +1,6 @@
 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.ActionLog;
 import com.management.platform.entity.BusinessOpportunity;
@@ -12,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -81,8 +83,41 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
     }
 
     @Override
-    public void getAndTransfer(Clue clue, User user) {
+    public void getAndTransfer(BusinessOpportunity bo, User user) {
+        UpdateWrapper<BusinessOpportunity> updateWrapper = new UpdateWrapper<>();
+        String ids1 = bo.getIds();
+        List<Integer> ids = new ArrayList<>();
+        if (!ids1.isEmpty()) {
+            for (String id : ids1.split(",")) {
+                ids.add(Integer.parseInt(id));
+            }
+        }
+        updateWrapper.in("id", ids);
+        String inchargerId = bo.getInchargerId();
+        ActionLog clueLog = new ActionLog();
+        clueLog.setUserId(user.getId());
+        clueLog.setItemId(bo.getId());
+        clueLog.setCreatTime(new Date());
+        clueLog.setCode("business");
+
+        List<BusinessOpportunity> clues = bOMapper.selectList(new QueryWrapper<BusinessOpportunity>().in("id", ids));
+        for (BusinessOpportunity clue1 : clues) {
+            if (clue1.getInchargerId() == null) {
+                //认领
+                clueLog.setName("认领了线索");
+                clueLog.setUserId(user.getId());
+                bo.setInchargerId(user.getId());
+                actionLogMapper.insert(clueLog);
+            } else {
+                //转移
+                clueLog.setName("转移了线索");
+                bo.setInchargerId(bo.getInchargerId());
+                actionLogMapper.insert(clueLog);
+            }
+        }
 
+        updateWrapper.set("incharger_id",inchargerId);
+        bOMapper.update(null, updateWrapper);
     }
     private BusinessOpportunity setNull(BusinessOpportunity bo) {
         if (bo.getPlate1() == "") {

+ 170 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/BusinessOpportunityMapper.xml

@@ -12,7 +12,7 @@
         <result column="product_id" property="productId" />
         <result column="amount_of_money" property="amountOfMoney" />
         <result column="expected_transaction_date" property="expectedTransactionDate" />
-        <result column="stage" property="stage" />
+        <result column="stage_id" property="stageId" />
         <result column="create_time" property="createTime" />
         <result column="edit_time" property="editTime" />
         <result column="creator_id" property="creatorId" />
@@ -41,6 +41,7 @@
         (SELECT sum(total) from business_product WHERE business_id = id)
         from business_opportunity
         where company_id = #{companyId}
+        and is_delete = #{isDelete}
         <if test="name != null and name != ''">
             and `name` LIKE CONCAT('%', #{name}, '%')
         </if>
@@ -62,6 +63,174 @@
         <if test="productId != null ">
             and id in (select business_id from business_product where product_id = #{productId})
         </if>
+        ORDER BY id DESC
+        limit #{pageIndex},#{pageFrom}
     </select>
+    <select id="getTotal" resultType="java.lang.Integer">
+        select
+        count(id)
+        from business_opportunity
+        where company_id = #{companyId}
+        and is_delete = #{isDelete}
+        <if test="name != null and name != ''">
+            and `name` LIKE CONCAT('%', #{name}, '%')
+        </if>
+        <if test="inchargerId != null ">
+            and incharger_id = #{inchargerId}
+        </if>
+        <if test="startTime != null and endTime != null ">
+            and create_time BETWEEN #{startTime} and #{endTime}
+        </if>
+        <if test="contactsName != null and contactsName != ''">
+            and contacts_id in (select id from contacts where `name`LIKE CONCAT('%', #{contactsName}, '%'))
+        </if>
+        <if test="customerName != null and customerName != ''">
+            and customer_id in (select id from custom where `name`LIKE CONCAT('%', #{customerName}, '%'))
+        </if>
+        <if test="stageId != null ">
+            and stage_id = #{stageId}
+        </if>
+        <if test="productId != null ">
+            and id in (select business_id from business_product where product_id = #{productId})
+        </if>
+    </select>
+    <select id="selectAllList1" resultType="com.management.platform.entity.BusinessOpportunity">
+        select
+        <include refid="Base_Column_List"></include>,
+        (select `name` from  stage where id =  stage_id) stageValue,
+        (select custom_name from custom where id = customer_id) customerName,
+        (select `name` from contacts where id = contacts_id) contactsName,
+        (select `name` from `user` where id = contacts_id) inchargerName,
+        (select `name` from `user` where id = creator_id) creatorName,
+        (SELECT sum(total) from business_product WHERE business_id = id)
+        from business_opportunity
+        where company_id = #{companyId}
+        and is_delete = #{isDelete}
+        and (incharger_id in
+        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
+        or incharger_id is null)
+        <if test="name != null and name != ''">
+            and `name` LIKE CONCAT('%', #{name}, '%')
+        </if>
+        <if test="inchargerId != null ">
+            and incharger_id = #{inchargerId}
+        </if>
+        <if test="startTime != null and endTime != null ">
+            and create_time BETWEEN  #{startTime} and #{endTime}
+        </if>
+        <if test="contactsName != null and contactsName != ''">
+            and contacts_id in (select id from contacts where `name`LIKE CONCAT('%', #{contactsName}, '%'))
+        </if>
+        <if test="customerName != null and customerName != ''">
+            and customer_id in (select id from custom where `name`LIKE CONCAT('%', #{customerName}, '%'))
+        </if>
+        <if test="stageId != null ">
+            and stage_id = #{stageId}
+        </if>
+        <if test="productId != null ">
+            and id in (select business_id from business_product where product_id = #{productId})
+        </if>
+        ORDER BY id DESC
+        limit #{pageIndex},#{pageFrom}
+    </select>
+    <select id="getTotal1" resultType="java.lang.Integer">
+        select
+        count(id)
+        from business_opportunity
+        where company_id = #{companyId}
+        and is_delete = #{isDelete}
+        and (incharger_id in
+        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
+        or incharger_id is null)
+        <if test="name != null and name != ''">
+            and `name` LIKE CONCAT('%', #{name}, '%')
+        </if>
+        <if test="inchargerId != null ">
+            and incharger_id = #{inchargerId}
+        </if>
+        <if test="startTime != null and endTime != null ">
+            and create_time BETWEEN #{startTime} and #{endTime}
+        </if>
+        <if test="contactsName != null and contactsName != ''">
+            and contacts_id in (select id from contacts where `name`LIKE CONCAT('%', #{contactsName}, '%'))
+        </if>
+        <if test="customerName != null and customerName != ''">
+            and customer_id in (select id from custom where `name`LIKE CONCAT('%', #{customerName}, '%'))
+        </if>
+        <if test="stageId != null ">
+            and stage_id = #{stageId}
+        </if>
+        <if test="productId != null ">
+            and id in (select business_id from business_product where product_id = #{productId})
+        </if>
+    </select>
+    <select id="selectAllList2" resultType="com.management.platform.entity.BusinessOpportunity">
+        select
+        <include refid="Base_Column_List"></include>,
+        (select `name` from  stage where id =  stage_id) stageValue,
+        (select custom_name from custom where id = customer_id) customerName,
+        (select `name` from contacts where id = contacts_id) contactsName,
+        (select `name` from `user` where id = contacts_id) inchargerName,
+        (select `name` from `user` where id = creator_id) creatorName,
+        (SELECT sum(total) from business_product WHERE business_id = id)
+        from business_opportunity
+        where company_id = #{companyId}
+        and is_delete = #{isDelete}
+        and (incharger_id = #{userId} or incharger_id is null)
+        <if test="name != null and name != ''">
+            and `name` LIKE CONCAT('%', #{name}, '%')
+        </if>
+        <if test="inchargerId != null ">
+            and incharger_id = #{inchargerId}
+        </if>
+        <if test="startTime != null and endTime != null ">
+            and create_time BETWEEN  #{startTime} and #{endTime}
+        </if>
+        <if test="contactsName != null and contactsName != ''">
+            and contacts_id in (select id from contacts where `name`LIKE CONCAT('%', #{contactsName}, '%'))
+        </if>
+        <if test="customerName != null and customerName != ''">
+            and customer_id in (select id from custom where `name`LIKE CONCAT('%', #{customerName}, '%'))
+        </if>
+        <if test="stageId != null ">
+            and stage_id = #{stageId}
+        </if>
+        <if test="productId != null ">
+            and id in (select business_id from business_product where product_id = #{productId})
+        </if>
+        ORDER BY id DESC
+        limit #{pageIndex},#{pageFrom}
+    </select>
+    <select id="getTotal2" resultType="java.lang.Integer">
+        select
+        count(id)
+        from business_opportunity
+        where company_id = #{companyId}
+        and is_delete = #{isDelete}
+        and (incharger_id = #{userId} or incharger_id is null)
+        <if test="name != null and name != ''">
+            and `name` LIKE CONCAT('%', #{name}, '%')
+        </if>
+        <if test="inchargerId != null ">
+            and incharger_id = #{inchargerId}
+        </if>
+        <if test="startTime != null and endTime != null ">
+            and create_time BETWEEN #{startTime} and #{endTime}
+        </if>
+        <if test="contactsName != null and contactsName != ''">
+            and contacts_id in (select id from contacts where `name`LIKE CONCAT('%', #{contactsName}, '%'))
+        </if>
+        <if test="customerName != null and customerName != ''">
+            and customer_id in (select id from custom where `name`LIKE CONCAT('%', #{customerName}, '%'))
+        </if>
+        <if test="stageId != null ">
+            and stage_id = #{stageId}
+        </if>
+        <if test="productId != null ">
+            and id in (select business_id from business_product where product_id = #{productId})
+        </if>
+    </select>
+
+
 
 </mapper>

+ 2 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/StageMapper.xml

@@ -8,12 +8,12 @@
         <result column="name" property="name" />
         <result column="plan" property="plan" />
         <result column="seq" property="seq" />
-        <result column="is_delete" property="isDelete" />
+        <result column="is_finish" property="isFinish" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, name, plan, seq, is_delete
+        id, name, plan, seq, is_finish
     </sql>
 
 </mapper>

+ 1 - 0
fhKeeper/formulahousekeeper/management-crm/test.txt

@@ -0,0 +1 @@
+1