Commit 3cdf5c0c5c7dbb27d193a1f443b81822944ce8a7

Authored by 张志伟
1 parent f5f1e803

:fire: 新增档案新增校验

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 23 import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO;
24 24 import cn.fw.valhalla.rpc.cas.CasRpcService;
25 25 import cn.fw.valhalla.rpc.cas.dto.SubstituteDTO;
  26 +import cn.fw.valhalla.rpc.erp.dto.PostUserDTO;
26 27 import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
27 28 import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO;
28 29 import cn.fw.valhalla.rpc.member.MemberRpcService;
... ... @@ -574,10 +575,14 @@ public class CustomerBizService extends AbstractCustomerService {
574 575 */
575 576 @Transactional(rollbackFor = Exception.class)
576 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 582 Customer customer = customerService.queryByPlateNo(plateNo, groupId);
580 583 BV.isNull(customer, "该车牌号对应的档案已存在");
  584 + customer = customerService.queryByFrameNo(frameNo, groupId);
  585 + BV.isNull(customer, "该车辆已存在档案");
581 586  
582 587 CustomerBaseInfo baseInfo = new CustomerBaseInfo();
583 588 BeanUtils.copyProperties(customerParams, baseInfo);
... ... @@ -587,6 +592,18 @@ public class CustomerBizService extends AbstractCustomerService {
587 592 baseInfo.setUpdateTime(new Date());
588 593  
589 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 607 BeanUtils.copyProperties(customerParams, customer);
591 608 customer.setSpecCode(customerParams.getSpecCode());
592 609 customer.setCreateTime(new Date());
... ... @@ -594,9 +611,7 @@ public class CustomerBizService extends AbstractCustomerService {
594 611 customer.setYn(Boolean.TRUE);
595 612 final SpecDTO spec = oopService.spec(customerParams.getSpecId());
596 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 615 Long cid = saveNewOne(customer, baseInfo, true);
601 616 CustomerParams.LoanInfo loanInfo = customerParams.getLoanInfo();
602 617 if (Objects.nonNull(loanInfo)) {
... ...