From 07b20a1bd9c7e639cda27e6b2f982bd4066842e4 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期三, 06 九月 2023 13:05:11 +0800 Subject: [PATCH] # --- src/main/java/com/zy/crm/manager/controller/BusinessTripController.java | 89 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 87 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zy/crm/manager/controller/BusinessTripController.java b/src/main/java/com/zy/crm/manager/controller/BusinessTripController.java index f76e35b..5ec6e3d 100644 --- a/src/main/java/com/zy/crm/manager/controller/BusinessTripController.java +++ b/src/main/java/com/zy/crm/manager/controller/BusinessTripController.java @@ -10,9 +10,13 @@ import com.core.common.Cools; import com.core.common.DateUtils; import com.core.common.R; +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.BusinessTrip; +import com.zy.crm.manager.entity.PlanType; +import com.zy.crm.manager.entity.ProcessPermissions; +import com.zy.crm.manager.entity.ReimburseOnline; import com.zy.crm.manager.service.BusinessTripService; import com.zy.crm.manager.utils.CarNumberUtils; import com.zy.crm.manager.utils.TimeCalculatorUtils; @@ -34,7 +38,12 @@ @RequestMapping(value = "/businessTrip/{id}/auth") @ManagerAuth public R get(@PathVariable("id") String id) { - return R.ok(businessTripService.selectById(String.valueOf(id))); + BusinessTrip businessTrip = businessTripService.selectById(String.valueOf(id)); + assert businessTrip != null; + JSONObject resultObj = JSON.parseObject(JSON.toJSONString(businessTrip)); + // 姝ラ鏉$浉鍏� + resultObj.put("step", businessTrip.getSettle() == 3 ? 0 : businessTrip.getSettle() + 1); + return R.ok().add(resultObj); } @RequestMapping(value = "/businessTrip/list/auth") @@ -47,27 +56,53 @@ EntityWrapper<BusinessTrip> wrapper = new EntityWrapper<>(); excludeTrash(param); convert(param, wrapper); +// wrapper.or().eq("member_id",getUserId()); if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} return R.ok(businessTripService.selectPage(new Page<>(curr, limit), wrapper)); } private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ + Long deptId = getDeptId(); + boolean signUserId = false; + boolean signDeptId = false; + boolean signHostId = false; + for (Map.Entry<String, Object> entry : map.entrySet()){ + if (entry.getKey().equals("dept_id")){ + signDeptId = true; + if (String.valueOf(entry.getValue()).equals("19")){ + signHostId = 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()); + } + if (signHostId){ + wrapper.or().eq("host_id",1); } } @RequestMapping(value = "/businessTrip/add/auth") @ManagerAuth public R add(BusinessTrip businessTrip) { - if (Cools.isEmpty(businessTrip) || null==businessTrip.getId()){ + if (Cools.isEmpty(businessTrip)){ return R.error(); } Date now = new Date(); @@ -79,6 +114,7 @@ } }else { businessTrip.setCarNumber("鏃�"); + businessTrip.setKilometers("鏃�"); } businessTrip.setBusinessPeersId(System.currentTimeMillis()); @@ -198,4 +234,53 @@ return R.ok(); } + @PostMapping(value = "/businessTrip/approval/auth") + @ManagerAuth + public R approvalBusinessTrip(@RequestParam Long planId, + @RequestParam(required = false) Long plannerId){ + BusinessTrip businessTrip = businessTripService.selectById(planId); + assert businessTrip != null; + Date now = new Date(); + switch (businessTrip.getSettle()) { + case 1: + // 鏈儴闂ㄧ粡鐞嗗鏍� + User user = userService.selectById(businessTrip.getUserId()); + User manager = userService.getDeptManager(getHostId(), user.getDeptId()); + if (manager.getId().equals(getUserId())) { + + // 淇敼 settle 姝ラ鏁版嵁 + List<SettleDto> list = JSON.parseArray(businessTrip.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; + } + } + businessTrip.setSettleMsg(JSON.toJSONString(list)); + + // 淇敼瑙勫垝鍗曠姸鎬� + businessTrip.setSettle(2); // 鐢宠閫氳繃 + businessTrip.setUpdateId(getUserId()); + businessTrip.setUpdateTime(now); + if (!businessTripService.updateById(businessTrip)) { + throw new CoolException("瀹℃牳澶辫触锛岃鑱旂郴绠$悊鍛�"); + } + } else { + return R.error("鎶辨瓑锛屾偍娌℃湁鎵瑰噯鐨勬潈闄愶紒锛侊紒"); + } + break; + default: + return R.error(); + } + return R.ok("瀹℃壒鎴愬姛"); + } + } -- Gitblit v1.9.1