Guo1B0 1 vuosi sitten
vanhempi
commit
0bf74e163f

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 16156 - 27181
fhKeeper/formulahousekeeper/management-crm/crm.log


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

@@ -6,7 +6,6 @@ import com.management.platform.entity.User;
 import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.BusinessOpportunityService;
 import com.management.platform.service.SysFunctionService;
-import com.management.platform.service.UserService;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -48,19 +48,27 @@ public class BusinessOpportunityController {
     }
 
     @RequestMapping("list")
-    public HttpRespMsg list(@RequestBody BusinessOpportunity bo, HttpServletRequest request) {
-        HttpRespMsg msg = new HttpRespMsg();
+    public HashMap<Object, Object> list(@RequestBody BusinessOpportunity bo, HttpServletRequest request) {
+        HashMap<Object, Object> r = new HashMap<>();
+
         User user = userMapper.selectById(request.getHeader("Token"));
         bo.setCompanyId(user.getCompanyId());
         List<BusinessOpportunity> list = new ArrayList<>();
         boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部商机");
-        boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部商机");
+        boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门商机");
+        int i = 0;
         if (!isAll) {
             list = bOservice.getAll(bo);
+            i = bOservice.getTotal(bo);
         } else if (!isNotAll) {
-            list = bOservice.getAll(bo);
+            list = bOservice.getAll1(bo, user);
+            i = bOservice.getTotal1(bo, user);
+        } else {
+            list = bOservice.getAll2(bo, user);
         }
-        return msg;
+        r.put("data", list);
+        r.put("total",i);
+        return r;
 
     }
 

+ 10 - 12
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ClueController.java

@@ -47,7 +47,6 @@ public class ClueController {
     private SysDictMapper sysDictMapper;
 
 
-
     @RequestMapping("getDetail")
     public Object getDetail(@RequestBody Clue clue) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -82,9 +81,12 @@ public class ClueController {
     @RequestMapping("listDeleterClue")
     public Object listDeleterClue(@RequestBody Clue clue, HttpServletRequest request) {
         //TODO token待定
-         User user = userMapper.selectById(request.getHeader(  "Token"));
-         clue.setCompanyId(user.getCompanyId());
-        List<Clue> list = clueService.getDeleterList(clue);
+        User user = userMapper.selectById(request.getHeader("Token"));
+        clue.setCompanyId(user.getCompanyId());
+        List<Clue> list = new ArrayList<>();
+        clueService.getDeleterList(clue);
+        boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部线索");
+        boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门线索");
         HashMap<Object, Object> map = new HashMap<>();
         map.put("data", list);
         map.put("total", clueService.getDeleterTotal(clue));
@@ -96,8 +98,8 @@ public class ClueController {
         HttpRespMsg msg = new HttpRespMsg();
         //操作前校验
         //TODO token待定
-        // User user = userMapper.selectById(request.getHeader(  "Token"));
-        // Integer companyId = user.getCompanyId();
+        User user = userMapper.selectById(request.getHeader("Token"));
+        clue.setCompanyId(user.getCompanyId());
         if (null == clue.getClueName() || "".equals(clue.getClueName())) {
             msg.setError("线索名称不能为空");
             return msg;
@@ -113,12 +115,8 @@ public class ClueController {
             msg.setMsg("操作成功");
         } else {
             //新增
-            //TODO token待定
-            // clue.setCompanyId(companyId);
-            // clue.setCreateId(user.getId());
-
+            clue.setCreateId(user.getId());
             clueService.insert(clue);
-
             msg.setMsg("操作成功");
         }
         return msg;
@@ -146,7 +144,7 @@ public class ClueController {
         User user = userMapper.selectById(request.getHeader("Token"));
         HttpRespMsg msg = new HttpRespMsg();
         msg.setMsg("操作成功");
-        clueService.getAndTransfer(clue,user);
+        clueService.getAndTransfer(clue, user);
         return msg;
     }
 

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

@@ -32,9 +32,13 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
 
     @TableField("company_id")
     private Integer companyId;
+
     private Integer productId;
+
     private String inchargerId;
 
+    private String productName;
+
     /**
      * 商机名称
      */

+ 9 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/BusinessOpportunityMapper.java

@@ -2,6 +2,7 @@ package com.management.platform.mapper;
 
 import com.management.platform.entity.BusinessOpportunity;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -16,4 +17,12 @@ import java.util.List;
 public interface BusinessOpportunityMapper extends BaseMapper<BusinessOpportunity> {
 
     List<BusinessOpportunity> selectAllList(BusinessOpportunity bo);
+
+    List<BusinessOpportunity> selectAllList1(@Param("bo") BusinessOpportunity bo,@Param("userId") String userId);
+
+    List<BusinessOpportunity> selectAllList2(@Param("bo") BusinessOpportunity bo,@Param("userId") String userId);
+
+    int getTotal(BusinessOpportunity bo);
+    int getTotal1(@Param("bo") BusinessOpportunity bo,@Param("userId") String userId);
+    int getTotal2(@Param("bo") BusinessOpportunity bo,@Param("userId") String userId);
 }

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

@@ -2,6 +2,7 @@ package com.management.platform.service;
 
 import com.management.platform.entity.BusinessOpportunity;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.entity.User;
 
 import java.util.List;
 
@@ -16,4 +17,11 @@ import java.util.List;
 public interface BusinessOpportunityService extends IService<BusinessOpportunity> {
 
     List<BusinessOpportunity> getAll(BusinessOpportunity bo);
+    List<BusinessOpportunity> getAll1(BusinessOpportunity bo, User user);
+
+    List<BusinessOpportunity> getAll2(BusinessOpportunity bo, User user);
+
+    int getTotal(BusinessOpportunity bo);
+
+    int getTotal1(BusinessOpportunity bo, User user);
 }

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

@@ -1,6 +1,7 @@
 package com.management.platform.service.impl;
 
 import com.management.platform.entity.BusinessOpportunity;
+import com.management.platform.entity.User;
 import com.management.platform.mapper.BusinessOpportunityMapper;
 import com.management.platform.service.BusinessOpportunityService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -26,4 +27,24 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
     public List<BusinessOpportunity> getAll(BusinessOpportunity bo) {
         return bOMapper.selectAllList(bo);
     }
+
+    @Override
+    public List<BusinessOpportunity> getAll1(BusinessOpportunity bo, User user) {
+        return bOMapper.selectAllList1(bo,user.getId());
+    }
+
+    @Override
+    public List<BusinessOpportunity> getAll2(BusinessOpportunity bo, User user) {
+        return bOMapper.selectAllList2(bo,user.getId());
+    }
+
+    @Override
+    public int getTotal(BusinessOpportunity bo) {
+        return bOMapper.getTotal(bo);
+    }
+
+    @Override
+    public int getTotal1(BusinessOpportunity bo, User user) {
+        return bOMapper.getTotal1(bo,user.getId());
+    }
 }

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

@@ -27,17 +27,23 @@
         id, company_id, name, customer_id, amount_of_money, expected_transaction_date, stage, create_time, creator_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5
     </sql>
     <select id="selectAllList" resultType="com.management.platform.entity.BusinessOpportunity">
-        select * FROM business_opportunity b
+        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}
         <if test="name != null and name != ''" >
-         and b.name = #{name}
+         and b.name = #{bo.name}
         </if>
         <if test="stage != null " >
             and b.stage = #{stage}
         </if>
-        <if test="startTime != null and endTime != null " >
+        <if test="startTime != null and bo.endTime != null " >
             and b.expected_transaction_date BETWEEN #{startTime} and #{endTime}
         </if>
         <if test="productId != null ">
@@ -46,5 +52,132 @@
         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.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 = #{companyId}
+        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
+        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 = #{bo.companyId}
+        <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="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.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.incharger_id = #{userId}
+        and b.incharger_id is null
+        <if test="bo.name != null and bo.name != ''">
+            and b.name = #{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>

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

@@ -93,7 +93,7 @@
         where
         c.company_id = #{companyId} and is_delete = 0
         and c.incharger_id in
-        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = c.id))
+        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
         and c.incharger_id is null
         <if test="startTime != null and endTime != null ">
             and  c.create_time BETWEEN  #{startTime} and #{endTime}