From 3cdf5c0c5c7dbb27d193a1f443b81822944ce8a7 Mon Sep 17 00:00:00 2001 From: Kurisu Date: Fri, 22 Oct 2021 15:45:09 +0800 Subject: [PATCH] :fire: 新增档案新增校验 --- fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java index 30cacca..8988a47 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java @@ -23,6 +23,7 @@ import cn.fw.valhalla.domain.vo.setting.SettingVO; import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO; import cn.fw.valhalla.rpc.cas.CasRpcService; import cn.fw.valhalla.rpc.cas.dto.SubstituteDTO; +import cn.fw.valhalla.rpc.erp.dto.PostUserDTO; import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO; import cn.fw.valhalla.rpc.member.MemberRpcService; @@ -574,10 +575,14 @@ public class CustomerBizService extends AbstractCustomerService { */ @Transactional(rollbackFor = Exception.class) public Boolean save4api(final CustomerParams customerParams) { - String plateNo = customerParams.getPlateNo(); - Long groupId = customerParams.getGroupId(); + final String plateNo = customerParams.getPlateNo(); + final String frameNo = customerParams.getFrameNo(); + final Long groupId = customerParams.getGroupId(); + Customer customer = customerService.queryByPlateNo(plateNo, groupId); BV.isNull(customer, "该车牌号对应的档案已存在"); + customer = customerService.queryByFrameNo(frameNo, groupId); + BV.isNull(customer, "该车辆已存在档案"); CustomerBaseInfo baseInfo = new CustomerBaseInfo(); BeanUtils.copyProperties(customerParams, baseInfo); @@ -587,6 +592,18 @@ public class CustomerBizService extends AbstractCustomerService { baseInfo.setUpdateTime(new Date()); customer = new Customer(); + ShopDTO shop = oopService.shop(customerParams.getShopId()); + BV.notNull(shop, () -> "shop信息有误,请检查"); + Long casShopId = shop.getCasShopId(); + Long adviserId = customerParams.getAdviserId(); + List userByRole = userService.getUserByRole(casShopId, RoleCode.FWGW); + BV.isNotEmpty(userByRole, () -> "门店暂无服务顾问,无法新增档案"); + boolean match = userByRole.stream().anyMatch(u -> u.getUserId().equals(adviserId)); + if (!match) { + Long newUserId = userByRole.parallelStream().findAny().map(PostUserDTO::getUserId).orElse(-1L); + BV.isTrue(newUserId > 0 && !newUserId.equals(adviserId), () -> "服务顾问获取失败"); + customerParams.setAdviserId(newUserId); + } BeanUtils.copyProperties(customerParams, customer); customer.setSpecCode(customerParams.getSpecCode()); customer.setCreateTime(new Date()); @@ -594,9 +611,7 @@ public class CustomerBizService extends AbstractCustomerService { customer.setYn(Boolean.TRUE); final SpecDTO spec = oopService.spec(customerParams.getSpecId()); customer.setCarImage(Optional.ofNullable(spec).orElse(new SpecDTO()).getThumbnail()); - ShopDTO shop = oopService.shop(customerParams.getShopId()); - BV.notNull(shop, () -> "shop信息有误,请检查"); - customer.setShopId(shop.getCasShopId()); + customer.setShopId(casShopId); Long cid = saveNewOne(customer, baseInfo, true); CustomerParams.LoanInfo loanInfo = customerParams.getLoanInfo(); if (Objects.nonNull(loanInfo)) { -- libgit2 0.22.2