From 3d5fd12b8c0189206c87885515324209fe11dcbc Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期五, 04 八月 2023 16:47:40 +0800
Subject: [PATCH] #报价单界面审核功能

---
 src/main/java/com/zy/crm/manager/controller/PriOnlineController.java |   45 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java b/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java
index 8333bff..37dfe12 100644
--- a/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java
+++ b/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java
@@ -6,9 +6,11 @@
 import com.baomidou.mybatisplus.plugins.Page;
 import com.core.common.DateUtils;
 import com.zy.crm.manager.entity.Item;
+import com.zy.crm.manager.entity.Order;
 import com.zy.crm.manager.entity.Pri;
 import com.zy.crm.manager.entity.PriOnline;
 import com.zy.crm.manager.service.ItemService;
+import com.zy.crm.manager.service.OrderService;
 import com.zy.crm.manager.service.PriOnlineService;
 import com.core.annotations.ManagerAuth;
 import com.core.common.BaseRes;
@@ -17,6 +19,7 @@
 import com.core.domain.KeyValueVo;
 import com.zy.crm.common.web.BaseController;
 import com.zy.crm.manager.service.PriService;
+import com.zy.crm.system.entity.Role;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.util.ClassUtils;
@@ -38,7 +41,7 @@
     private PriService priService;
 
     @Autowired
-    private ItemService itemService;
+    private OrderService orderService;
 
     @RequestMapping(value = "/priOnline/{id}/auth")
     @ManagerAuth
@@ -65,7 +68,7 @@
                   @RequestParam(required = false)String condition,
                   @RequestParam Map<String, Object> param){
         EntityWrapper<PriOnline> wrapper = new EntityWrapper<>();
-        wrapper.setSqlSelect("id,title,create_time as createTime,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId");
+        wrapper.setSqlSelect("id,title,create_time as createTime,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId");
         wrapper.in("member_id", getUserRoleBelongsToUserId("allopen"));
         excludeTrash(param);
         convert(param, wrapper);
@@ -75,15 +78,33 @@
     }
 
     private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
+        Long deptId = getDeptId();
+        boolean signUserId = false;
+        boolean signDeptId = false;
+        for (Map.Entry<String, Object> entry : map.entrySet()){
+            if (entry.getKey().equals("dept_id")){
+                signDeptId = true;
+            }
+        }
         for (Map.Entry<String, Object> entry : map.entrySet()){
             String val = String.valueOf(entry.getValue());
             if (val.contains(RANGE_TIME_LINK)){
                 String[] dates = val.split(RANGE_TIME_LINK);
                 wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                 wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
+            } else if (entry.getKey().equals("dept_id")){
+                if (!val.equals("19")){
+                    wrapper.eq(entry.getKey(), val);
+                }
+            } else if (entry.getKey().equals("user_id") && !signDeptId){
+                signUserId = true;
+                wrapper.eq(entry.getKey(), val);
             } else {
                 wrapper.like(entry.getKey(), val);
             }
+        }
+        if (!signUserId && !signDeptId){
+            wrapper.eq("user_id", getUserId());
         }
     }
 
@@ -106,6 +127,8 @@
         priOnline.setOrderNum(format.format(new Date()));
         //鍒涘缓浜哄憳
         priOnline.setUserId(getUserId());
+        //鍒涘缓浜哄憳閮ㄩ棬
+        priOnline.setDeptId(getDeptId());
         //鏇存柊鏃堕棿
         priOnline.setUpdateTime(new Date());
         //鏇存柊浜哄憳
@@ -113,12 +136,14 @@
         //鐘舵�侊紝鏈畬鎴�
         priOnline.setStatus(0);
         //涓氬姟鍛�
-        Item item = itemService.selectById(priOnline.getItemId());
-        priOnline.setMemberId(item.getMember());
+//        Item item = itemService.selectById(priOnline.getItemId());
+        Order order = orderService.selectById(priOnline.getItemId());
+        priOnline.setMemberId(order.getUserId());
+
 
         //璁剧疆椤圭洰娴佺▼
-        item.setStep(2);
-        itemService.updateById(item);
+        order.setStep(2);
+        orderService.updateById(order);
 
         priOnlineService.insert(priOnline);
         return R.ok();
@@ -146,9 +171,11 @@
         priOnline.setUpdateUserId(getUserId());
         //鐘舵�侊紝鏈畬鎴�
         priOnline.setStatus(0);
+        priOnline.setDeptId(getDeptId());
         //涓氬姟鍛�
-        Item item = itemService.selectById(priOnline.getItemId());
-        priOnline.setMemberId(item.getMember());
+//        Item item = itemService.selectById(priOnline.getItemId());
+        Order order = orderService.selectById(priOnline.getItemId());
+        priOnline.setMemberId(order.getUserId());
 
         priOnlineService.insert(priOnline);
         return R.ok();
@@ -285,7 +312,7 @@
         for (PriOnline priOnline : page.getRecords()){
             Map<String, Object> map = new HashMap<>();
             map.put("id", priOnline.getId());
-            map.put("value", priOnline.getOrderNum() + "/" + priOnline.getItemId$() + "/" + priOnline.getMemberId$());
+            map.put("value", priOnline.getOrderNum() + "/" + priOnline.getOrderId$() + "/" + priOnline.getMemberId$());
             result.add(map);
         }
         return R.ok(result);

--
Gitblit v1.9.1