Commit 3cdf5c0c5c7dbb27d193a1f443b81822944ce8a7
1 parent
f5f1e803
新增档案新增校验
Showing
1 changed file
with
20 additions
and
5 deletions
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; | @@ -23,6 +23,7 @@ import cn.fw.valhalla.domain.vo.setting.SettingVO; | ||
23 | import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO; | 23 | import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO; |
24 | import cn.fw.valhalla.rpc.cas.CasRpcService; | 24 | import cn.fw.valhalla.rpc.cas.CasRpcService; |
25 | import cn.fw.valhalla.rpc.cas.dto.SubstituteDTO; | 25 | import cn.fw.valhalla.rpc.cas.dto.SubstituteDTO; |
26 | +import cn.fw.valhalla.rpc.erp.dto.PostUserDTO; | ||
26 | import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; | 27 | import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; |
27 | import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO; | 28 | import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO; |
28 | import cn.fw.valhalla.rpc.member.MemberRpcService; | 29 | import cn.fw.valhalla.rpc.member.MemberRpcService; |
@@ -574,10 +575,14 @@ public class CustomerBizService extends AbstractCustomerService { | @@ -574,10 +575,14 @@ public class CustomerBizService extends AbstractCustomerService { | ||
574 | */ | 575 | */ |
575 | @Transactional(rollbackFor = Exception.class) | 576 | @Transactional(rollbackFor = Exception.class) |
576 | public Boolean save4api(final CustomerParams customerParams) { | 577 | public Boolean save4api(final CustomerParams customerParams) { |
577 | - String plateNo = customerParams.getPlateNo(); | ||
578 | - Long groupId = customerParams.getGroupId(); | 578 | + final String plateNo = customerParams.getPlateNo(); |
579 | + final String frameNo = customerParams.getFrameNo(); | ||
580 | + final Long groupId = customerParams.getGroupId(); | ||
581 | + | ||
579 | Customer customer = customerService.queryByPlateNo(plateNo, groupId); | 582 | Customer customer = customerService.queryByPlateNo(plateNo, groupId); |
580 | BV.isNull(customer, "该车牌号对应的档案已存在"); | 583 | BV.isNull(customer, "该车牌号对应的档案已存在"); |
584 | + customer = customerService.queryByFrameNo(frameNo, groupId); | ||
585 | + BV.isNull(customer, "该车辆已存在档案"); | ||
581 | 586 | ||
582 | CustomerBaseInfo baseInfo = new CustomerBaseInfo(); | 587 | CustomerBaseInfo baseInfo = new CustomerBaseInfo(); |
583 | BeanUtils.copyProperties(customerParams, baseInfo); | 588 | BeanUtils.copyProperties(customerParams, baseInfo); |
@@ -587,6 +592,18 @@ public class CustomerBizService extends AbstractCustomerService { | @@ -587,6 +592,18 @@ public class CustomerBizService extends AbstractCustomerService { | ||
587 | baseInfo.setUpdateTime(new Date()); | 592 | baseInfo.setUpdateTime(new Date()); |
588 | 593 | ||
589 | customer = new Customer(); | 594 | customer = new Customer(); |
595 | + ShopDTO shop = oopService.shop(customerParams.getShopId()); | ||
596 | + BV.notNull(shop, () -> "shop信息有误,请检查"); | ||
597 | + Long casShopId = shop.getCasShopId(); | ||
598 | + Long adviserId = customerParams.getAdviserId(); | ||
599 | + List<PostUserDTO> userByRole = userService.getUserByRole(casShopId, RoleCode.FWGW); | ||
600 | + BV.isNotEmpty(userByRole, () -> "门店暂无服务顾问,无法新增档案"); | ||
601 | + boolean match = userByRole.stream().anyMatch(u -> u.getUserId().equals(adviserId)); | ||
602 | + if (!match) { | ||
603 | + Long newUserId = userByRole.parallelStream().findAny().map(PostUserDTO::getUserId).orElse(-1L); | ||
604 | + BV.isTrue(newUserId > 0 && !newUserId.equals(adviserId), () -> "服务顾问获取失败"); | ||
605 | + customerParams.setAdviserId(newUserId); | ||
606 | + } | ||
590 | BeanUtils.copyProperties(customerParams, customer); | 607 | BeanUtils.copyProperties(customerParams, customer); |
591 | customer.setSpecCode(customerParams.getSpecCode()); | 608 | customer.setSpecCode(customerParams.getSpecCode()); |
592 | customer.setCreateTime(new Date()); | 609 | customer.setCreateTime(new Date()); |
@@ -594,9 +611,7 @@ public class CustomerBizService extends AbstractCustomerService { | @@ -594,9 +611,7 @@ public class CustomerBizService extends AbstractCustomerService { | ||
594 | customer.setYn(Boolean.TRUE); | 611 | customer.setYn(Boolean.TRUE); |
595 | final SpecDTO spec = oopService.spec(customerParams.getSpecId()); | 612 | final SpecDTO spec = oopService.spec(customerParams.getSpecId()); |
596 | customer.setCarImage(Optional.ofNullable(spec).orElse(new SpecDTO()).getThumbnail()); | 613 | customer.setCarImage(Optional.ofNullable(spec).orElse(new SpecDTO()).getThumbnail()); |
597 | - ShopDTO shop = oopService.shop(customerParams.getShopId()); | ||
598 | - BV.notNull(shop, () -> "shop信息有误,请检查"); | ||
599 | - customer.setShopId(shop.getCasShopId()); | 614 | + customer.setShopId(casShopId); |
600 | Long cid = saveNewOne(customer, baseInfo, true); | 615 | Long cid = saveNewOne(customer, baseInfo, true); |
601 | CustomerParams.LoanInfo loanInfo = customerParams.getLoanInfo(); | 616 | CustomerParams.LoanInfo loanInfo = customerParams.getLoanInfo(); |
602 | if (Objects.nonNull(loanInfo)) { | 617 | if (Objects.nonNull(loanInfo)) { |