From a25d3c16f9f9be1a1b4774402d1907a28dab06fb Mon Sep 17 00:00:00 2001 From: LSH Date: 星期二, 12 九月 2023 09:43:55 +0800 Subject: [PATCH] #核价管理完善 --- src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java | 143 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 141 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java b/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java index 6e84943..a5f868f 100644 --- a/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java +++ b/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java @@ -1,5 +1,6 @@ package com.zy.crm.manager.controller; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; @@ -10,9 +11,13 @@ import com.core.common.DateUtils; import com.core.common.R; import com.core.domain.KeyValueVo; +import com.core.exception.CoolException; +import com.zy.crm.common.model.SettleDto; import com.zy.crm.common.web.BaseController; import com.zy.crm.manager.entity.*; import com.zy.crm.manager.service.*; +import com.zy.crm.system.entity.User; +import com.zy.crm.system.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.util.ClassUtils; @@ -42,10 +47,18 @@ @Autowired private CstmrService cstmrService; + @Autowired + private UserService userService; + @RequestMapping(value = "/priOnline2/{id}/auth") @ManagerAuth public R get(@PathVariable("id") String id) { - return R.ok(priOnline2Service.selectById(String.valueOf(id))); + PriOnline2 priOnline2 = priOnline2Service.selectById(String.valueOf(id)); + assert priOnline2 != null; + JSONObject resultObj = JSON.parseObject(JSON.toJSONString(priOnline2)); + // 姝ラ鏉$浉鍏� + resultObj.put("step", priOnline2.getSettle() == 4 ? 0 : priOnline2.getSettle() + 1); + return R.ok().add(resultObj); } @RequestMapping(value = "/priOnline2/viewCheck/{id}/auth") @@ -67,7 +80,7 @@ @RequestParam(required = false)String condition, @RequestParam Map<String, Object> param){ EntityWrapper<PriOnline2> 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,dept_id as deptId,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,settle,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); @@ -128,6 +141,7 @@ priOnline2.setUpdateUserId(getUserId()); //鐘舵�侊紝鏈畬鎴� priOnline2.setStatus(0); + //涓氬姟鍛� // Item item = itemService.selectById(priOnline.getItemId()); Plan plan = planService.selectById(priOnline2.getItemId()); @@ -136,6 +150,15 @@ Cstmr cstmr = cstmrService.selectById(plan.getCstmrId()); priOnline2.setTemplateName(cstmr.getName()); //鐢叉柟鍗曚綅鍚嶇О + priOnline2.setSettle(0); + + User manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 鑾峰彇閮ㄩ棬棰嗗 + List<String> initNames = new ArrayList<>(); + initNames.add("鍒涘缓鏍镐环鍗曟ā鏉�"); + initNames.add("鎻愪氦鏍镐环"); + initNames.add("閮ㄩ棬缁忕悊瀹℃牳"); + initNames.add("涓氬姟鍛樼‘璁�"); + priOnline2.setSettleMsg(JSON.toJSONString(SettleDto.initSalesPricing(manager,getUser(),initNames,3))); //璁剧疆椤圭洰娴佺▼ plan.setStep(2); @@ -340,4 +363,120 @@ return R.ok().add(vos); } + @PostMapping(value = "/priOnline2/approval/auth") + @ManagerAuth + public R approvalBusinessTrip(@RequestParam Long priOnlineId, + @RequestParam(required = false) Long plannerId){ + PriOnline2 priOnline2 = priOnline2Service.selectById(priOnlineId); + assert priOnline2 != null; + Date now = new Date(); + switch (priOnline2.getSettle()) { + case 0: + User user2 = userService.selectById(priOnline2.getUserId()); + User manager1 = userService.getDeptManager(getHostId(), user2.getDeptId()); + + if (Cools.isEmpty(getUser())) { + return R.error("鎶辨瓑锛屾偍娌℃湁鎻愪氦鐨勬潈闄�"); + } + if (!getUserId().equals(getUser().getId())) { + return R.error("鎶辨瓑锛屾偍娌℃湁鎻愪氦鐨勬潈闄�"); + } + // 淇敼 settle 姝ラ鏁版嵁 + List<SettleDto> list1 = JSON.parseArray(priOnline2.getSettleMsg(), SettleDto.class); + for (SettleDto dto : list1) { + switch (dto.getStep()) { + case 0: + dto.setCurr(Boolean.FALSE); + break; + case 1: + dto.setCurr(Boolean.TRUE); + dto.setMsg(getUser().getNickname() + "鎻愪氦瀹屾垚"); + dto.setTime(DateUtils.convert(now)); + break; + default: + break; + } + } + priOnline2.setSettleMsg(JSON.toJSONString(list1)); + // 淇敼瑙勫垝鍗曠姸鎬� + priOnline2.setSettle(1); + priOnline2.setUpdateUserId(getUserId()); + priOnline2.setUpdateTime(now); + priOnline2.setMemberId(manager1.getId()); + + if (!priOnline2Service.updateById(priOnline2)) { + throw new CoolException("鎻愪氦澶辫触锛岃鑱旂郴绠$悊鍛�"); + } + break; + case 1: + // 鏈儴闂ㄧ粡鐞嗗鏍� + User user = userService.selectById(priOnline2.getUserId()); + User manager = userService.getDeptManager(getHostId(), user.getDeptId()); + if (manager.getId().equals(getUserId())) { + + // 淇敼 settle 姝ラ鏁版嵁 + List<SettleDto> list = JSON.parseArray(priOnline2.getSettleMsg(), SettleDto.class); + for (SettleDto dto : list) { + switch (dto.getStep()) { + case 1: + dto.setCurr(Boolean.FALSE); + break; + case 2: + dto.setCurr(Boolean.TRUE); + dto.setMsg("閮ㄩ棬缁忕悊" + manager.getNickname() + "瀹℃壒閫氳繃"); + dto.setTime(DateUtils.convert(now)); + break; + default: + break; + } + } + priOnline2.setSettleMsg(JSON.toJSONString(list)); + + // 淇敼瑙勫垝鍗曠姸鎬� + priOnline2.setSettle(2); // 鐢宠閫氳繃 + priOnline2.setUpdateTime(now); + if (!priOnline2Service.updateById(priOnline2)) { + throw new CoolException("瀹℃牳澶辫触锛岃鑱旂郴绠$悊鍛�"); + } + } else { + return R.error("鎶辨瓑锛屾偍娌℃湁瀹℃牳鐨勬潈闄愶紒锛侊紒"); + } + break; + case 2: + // 涓氬姟鍛� + User salesman0 = userService.selectById(priOnline2.getUserId()); + if (!getUserId().equals(salesman0.getId())) { + return R.error("鎶辨瓑锛屾偍鏃犻渶纭锛侊紒锛�"); + } + // 淇敼 settle 姝ラ鏁版嵁 + List<SettleDto> list2 = JSON.parseArray(priOnline2.getSettleMsg(), SettleDto.class); + for (SettleDto dto : list2) { + switch (dto.getStep()) { + case 2: + dto.setCurr(Boolean.TRUE); + break; + case 3: + dto.setCurr(Boolean.TRUE); + dto.setMsg("涓氬姟鍛�" + salesman0.getNickname() + "浠ョ‘璁�"); + dto.setTime(DateUtils.convert(new Date())); + break; + default: + break; + } + } + priOnline2.setSettleMsg(JSON.toJSONString(list2)); + // 淇敼瑙勫垝鍗曠姸鎬� + priOnline2.setSettle(3); // 瀹℃壒閫氳繃 + priOnline2.setUpdateTime(new Date()); + + if (!priOnline2Service.updateById(priOnline2)) { + throw new CoolException("纭澶辫触锛岃鑱旂郴绠$悊鍛�"); + } + break; + default: + return R.error(); + } + return R.ok("瀹℃壒鎴愬姛"); + } + } -- Gitblit v1.9.1