Guo1B0 před 1 rokem
rodič
revize
debf1fd4fb

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

@@ -91,6 +91,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(), "查看负责部门商机");

+ 4 - 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;
     /**
      * 修改时间
      */
@@ -133,6 +133,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

+ 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>