From affbba0568f48d558ad84fb5247c135d7be96bde Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期五, 11 八月 2023 16:23:14 +0800
Subject: [PATCH] #报价单审核机制
---
src/main/java/com/zy/crm/manager/controller/PriQuoteController.java | 64 ++++++++++++++++++++++++++-----
1 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/zy/crm/manager/controller/PriQuoteController.java b/src/main/java/com/zy/crm/manager/controller/PriQuoteController.java
index 1de6b71..f261d0b 100644
--- a/src/main/java/com/zy/crm/manager/controller/PriQuoteController.java
+++ b/src/main/java/com/zy/crm/manager/controller/PriQuoteController.java
@@ -1,5 +1,6 @@
package com.zy.crm.manager.controller;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
@@ -11,13 +12,15 @@
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.domain.KeyValueVo;
+import com.zy.crm.common.model.SettleDto;
import com.zy.crm.common.web.BaseController;
-import com.zy.crm.manager.entity.Item;
-import com.zy.crm.manager.entity.PriQuote;
-import com.zy.crm.manager.entity.PriQuoteBudget;
+import com.zy.crm.manager.entity.*;
import com.zy.crm.manager.service.ItemService;
+import com.zy.crm.manager.service.PlanService;
import com.zy.crm.manager.service.PriQuoteBudgetService;
import com.zy.crm.manager.service.PriQuoteService;
+import com.zy.crm.system.entity.User;
+import com.zy.crm.system.service.UserService;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +40,10 @@
private PriQuoteService priQuoteService;
@Autowired
- private ItemService itemService;
+ private PlanService planService;
+
+ @Autowired
+ private UserService userService;
@Autowired
private PriQuoteBudgetService priQuoteBudgetService;
@@ -45,7 +51,19 @@
@RequestMapping(value = "/priQuote/{id}/auth")
@ManagerAuth
public R get(@PathVariable("id") String id) {
- return R.ok(priQuoteService.selectById(String.valueOf(id)));
+ PriQuote priQuote = priQuoteService.selectById(String.valueOf(id));
+ assert priQuote != null;
+ JSONObject resultObj = JSON.parseObject(JSON.toJSONString(priQuote));
+ if (!Cools.isEmpty(priQuote.getForm())) {
+ JSONObject formObj = JSON.parseObject(priQuote.getForm());
+ formObj.forEach(resultObj::putIfAbsent);
+ }
+
+ // 姝ラ鏉$浉鍏�
+ resultObj.put("step", priQuote.getSettle() == 5 ? 0 : priQuote.getSettle() + 1);
+
+ return R.ok().add(resultObj);
+// return R.ok(priQuoteService.selectById(String.valueOf(id)));
}
@RequestMapping(value = "/priQuote/list/auth")
@@ -67,15 +85,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());
}
}
@@ -102,12 +138,18 @@
priQuote.setUpdateTime(new Date());
//涓氬姟鍛�
- Item item = itemService.selectById(priQuote.getItemId());
- priQuote.setMemberId(item.getMember());
+ Plan plan = planService.selectById(priQuote.getItemId());
+ priQuote.setMemberId(plan.getUserId());
//璁剧疆椤圭洰娴佺▼
- item.setStep(5);
- itemService.updateById(item);
+ plan.setStep(5);
+
+ priQuote.setForm(JSON.toJSONString(map)); // 鑷畾涔夎〃鍗曞唴瀹�
+ priQuote.setSettle(1); // 1.寮�濮�
+ User manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 鑾峰彇閮ㄩ棬棰嗗
+ priQuote.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager)));
+
+ planService.updateById(plan);
priQuoteService.insert(priQuote);
return R.ok();
@@ -137,8 +179,8 @@
priQuote.setUpdateTime(new Date());
//涓氬姟鍛�
- Item item = itemService.selectById(priQuote.getItemId());
- priQuote.setMemberId(item.getMember());
+ Plan plan = planService.selectById(priQuote.getItemId());
+ priQuote.setMemberId(plan.getUserId());
priQuoteService.insert(priQuote);
return R.ok();
--
Gitblit v1.9.1