Commit 93b833c994849b78ea69a0b556a6cc91ca1f59fc
1 parent
446b378c
新增会员认证车辆接口
Showing
5 changed files
with
102 additions
and
22 deletions
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/MemberVehicle.java
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CustomerDetailDto.java
1 | 1 | package cn.fw.valhalla.domain.dto; |
2 | 2 | |
3 | +import cn.fw.valhalla.common.utils.BeanUtils; | |
4 | +import cn.fw.valhalla.domain.db.MemberVehicle; | |
3 | 5 | import lombok.Data; |
4 | 6 | |
5 | 7 | import java.math.BigDecimal; |
... | ... | @@ -213,4 +215,11 @@ public class CustomerDetailDto { |
213 | 215 | } |
214 | 216 | return buyPrice; |
215 | 217 | } |
218 | + | |
219 | + public static CustomerDetailDto with(MemberVehicle memberVehicle){ | |
220 | + CustomerDetailDto dto = BeanUtils.copy(memberVehicle,CustomerDetailDto.class); | |
221 | + dto.setUseType(memberVehicle.getUseType().getValue()); | |
222 | + dto.setCusType(memberVehicle.getCusType().getValue()); | |
223 | + return dto; | |
224 | + } | |
216 | 225 | } |
217 | 226 | \ No newline at end of file | ... | ... |
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/api/CustomerApiService.java
... | ... | @@ -66,17 +66,15 @@ public interface CustomerApiService { |
66 | 66 | */ |
67 | 67 | @GetMapping("/query/by/frameNo") |
68 | 68 | Message<CustomerInfoDto> queryByFrameNo(@RequestParam("frameNo") String frameNo, @RequestParam("groupId") Long groupId); |
69 | - | |
70 | 69 | /** |
71 | - * 查询车辆在门店的专属顾问 | |
70 | + * 通过车架号查询车辆信息,包含无档案 | |
72 | 71 | * |
73 | 72 | * @param frameNo 车架号 |
74 | 73 | * @param shopId 门店id |
75 | - * @return 专属顾问 | |
74 | + * @return 车辆信息 | |
76 | 75 | */ |
77 | - @GetMapping("/query/adviser") | |
78 | - Message<Long> queryAdviser(@RequestParam("frameNo") String frameNo, @RequestParam("shopId") Long shopId); | |
79 | - | |
76 | + @GetMapping("/query/vehicle/by/frameNo") | |
77 | + Message<CustomerInfoDto> queryVehicleByFrameNo(@RequestParam("frameNo") String frameNo, @RequestParam("shopId") Long shopId); | |
80 | 78 | |
81 | 79 | /** |
82 | 80 | * 批量查询客户档案 | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/api/CustomerApiServiceImpl.java
... | ... | @@ -123,10 +123,18 @@ public class CustomerApiServiceImpl implements CustomerApiService { |
123 | 123 | } |
124 | 124 | |
125 | 125 | @Override |
126 | - @GetMapping("/query/adviser") | |
127 | - @ControllerMethod("查询车辆在门店的专属顾问") | |
128 | - public Message<Long> queryAdviser(@RequestParam("frameNo") final String frameNo, @RequestParam("shopId") final Long shopId) { | |
129 | - return success(customerBiz.queryAdviser(frameNo,shopId)); | |
126 | + @GetMapping("/query/vehicle/by/frameNo") | |
127 | + @ControllerMethod("通过车架号查询车辆信息,包含无档案") | |
128 | + public Message<CustomerInfoDto> queryVehicleByFrameNo(@RequestParam("frameNo") final String frameNo, @RequestParam("shopId") final Long shopId) { | |
129 | + CustomerDetailDto detailDto = customerBiz.queryVehicleByFrameNo(frameNo, shopId); | |
130 | + if (Objects.isNull(detailDto)) { | |
131 | + return success(); | |
132 | + } | |
133 | + CustomerInfoDto dto = new CustomerInfoDto(); | |
134 | + BeanUtils.copyProperties(detailDto, dto); | |
135 | + dto.setConsultantId(detailDto.getAdviserId()); | |
136 | + dto.setConsultantName(detailDto.getAdviserName()); | |
137 | + return success(dto); | |
130 | 138 | } |
131 | 139 | |
132 | 140 | @GetMapping("/query/batch") | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java
... | ... | @@ -6,8 +6,7 @@ import cn.fw.common.web.annotation.DisLock; |
6 | 6 | import cn.fw.common.web.auth.LoginAuthBean; |
7 | 7 | import cn.fw.valhalla.common.constant.RoleCode; |
8 | 8 | import cn.fw.valhalla.common.utils.DateUtil; |
9 | -import cn.fw.valhalla.domain.db.CompanyWechatJoin; | |
10 | -import cn.fw.valhalla.domain.db.WechatSubscribe; | |
9 | +import cn.fw.valhalla.domain.db.*; | |
11 | 10 | import cn.fw.valhalla.domain.db.customer.*; |
12 | 11 | import cn.fw.valhalla.domain.db.follow.FollowRecord; |
13 | 12 | import cn.fw.valhalla.domain.db.follow.FollowTask; |
... | ... | @@ -24,6 +23,7 @@ import cn.fw.valhalla.rpc.member.dto.MemberUserDTO; |
24 | 23 | import cn.fw.valhalla.rpc.oop.OopService; |
25 | 24 | import cn.fw.valhalla.rpc.oop.dto.ShopDTO; |
26 | 25 | import cn.fw.valhalla.rpc.oop.dto.SpecDTO; |
26 | +import cn.fw.valhalla.sdk.enums.CusTypeEnum; | |
27 | 27 | import cn.fw.valhalla.sdk.param.*; |
28 | 28 | import cn.fw.valhalla.sdk.result.*; |
29 | 29 | import cn.fw.valhalla.service.bus.StammkundeBizService; |
... | ... | @@ -78,6 +78,7 @@ public class CustomerBizService extends AbstractCustomerService { |
78 | 78 | private final FollowRecordService followRecordService; |
79 | 79 | private final StammkundeBizService stammkundeBizService; |
80 | 80 | private final OopService oopService; |
81 | + private final MemberVehicleService memberVehicleService; | |
81 | 82 | |
82 | 83 | @Value("${spring.cache.custom.global-prefix}:customer") |
83 | 84 | @Getter |
... | ... | @@ -592,23 +593,82 @@ public class CustomerBizService extends AbstractCustomerService { |
592 | 593 | } |
593 | 594 | |
594 | 595 | /** |
595 | - * 查询车辆在门店的专属顾问 | |
596 | + * 根据车架号号查询车辆信息 | |
596 | 597 | * |
597 | 598 | * @param frameNo 车架号 |
598 | - * @param shopId 门店id | |
599 | - * @return 专属顾问id | |
599 | + * @param shopId 门店id | |
600 | + * @return 车辆信息 | |
600 | 601 | */ |
601 | - public Long queryAdviser(final String frameNo, final Long shopId) { | |
602 | + public CustomerDetailDto queryVehicleByFrameNo(final String frameNo, final Long shopId) { | |
602 | 603 | ShopDTO shop = oopService.shop(shopId); |
603 | - V.notNull(shop,String.format("未查询到门店%d信息",shopId)); | |
604 | + V.notNull(shop, String.format("未查询到门店%d信息", shopId)); | |
604 | 605 | Customer customer = customerService.queryByFrameNo(frameNo, shop.getGroupId()); |
605 | - if(Objects.isNull(customer)){ | |
606 | - return null; | |
606 | + if (Objects.isNull(customer)) { | |
607 | + MemberVehicle memberVehicle = memberVehicleService.getMemberVehicle(frameNo); | |
608 | + if (Objects.isNull(memberVehicle)) { | |
609 | + return null; | |
610 | + } | |
611 | + if (CusTypeEnum.PERSONAL.equals(memberVehicle.getCusType())) { | |
612 | + //查询该会员的其他车辆是否有档案 | |
613 | + List<Long> customerBaseInfoList = customerBaseInfoService | |
614 | + .list(Wrappers.<CustomerBaseInfo>lambdaQuery() | |
615 | + .eq(CustomerBaseInfo::getYn, Boolean.TRUE) | |
616 | + .eq(CustomerBaseInfo::getCusType, CusTypeEnum.PERSONAL) | |
617 | + .eq(CustomerBaseInfo::getMemberId, memberVehicle.getMemberId())) | |
618 | + .stream().map(CustomerBaseInfo::getId).collect(Collectors.toList()); | |
619 | + if (CollectionUtils.isEmpty(customerBaseInfoList)) { | |
620 | + return CustomerDetailDto.with(memberVehicle); | |
621 | + } | |
622 | + final List<Customer> customers = customerService.list(Wrappers.<Customer>lambdaQuery() | |
623 | + .in(Customer::getBaseId, customerBaseInfoList).eq(Customer::getYn, true) | |
624 | + .eq(Customer::getGroupId, shop.getGroupId()).eq(Customer::getShopId,shopId) | |
625 | + .isNotNull(Customer::getAdviserId) | |
626 | + .orderByDesc(Customer::getUpdateTime)); | |
627 | + if (CollectionUtils.isEmpty(customers)) { | |
628 | + return CustomerDetailDto.with(memberVehicle); | |
629 | + } | |
630 | + CustomerDetailDto dto = CustomerDetailDto.with(memberVehicle); | |
631 | + dto.setAdviserId(customers.get(0).getAdviserId()); | |
632 | + UserInfoDTO user = userService.user(customers.get(0).getAdviserId()); | |
633 | + if (Objects.nonNull(user)) { | |
634 | + dto.setAdviserName(user.getUserName()); | |
635 | + } | |
636 | + return dto; | |
637 | + } else { | |
638 | + //查询该单位是否有其他档案 | |
639 | + List<Long> customerBaseInfoList = customerBaseInfoService | |
640 | + .list(Wrappers.<CustomerBaseInfo>lambdaQuery() | |
641 | + .eq(CustomerBaseInfo::getYn, Boolean.TRUE) | |
642 | + .eq(CustomerBaseInfo::getCusType, CusTypeEnum.COMPANY) | |
643 | + .eq(CustomerBaseInfo::getName, memberVehicle.getName())) | |
644 | + .stream().map(CustomerBaseInfo::getId).collect(Collectors.toList()); | |
645 | + if (CollectionUtils.isEmpty(customerBaseInfoList)) { | |
646 | + return CustomerDetailDto.with(memberVehicle); | |
647 | + } | |
648 | + final List<Customer> customers = customerService.list(Wrappers.<Customer>lambdaQuery() | |
649 | + .in(Customer::getBaseId, customerBaseInfoList).eq(Customer::getYn, true) | |
650 | + .eq(Customer::getGroupId, shop.getGroupId()).eq(Customer::getShopId,shopId) | |
651 | + .isNotNull(Customer::getAdviserId) | |
652 | + .orderByDesc(Customer::getUpdateTime)); | |
653 | + if (CollectionUtils.isEmpty(customers)) { | |
654 | + return CustomerDetailDto.with(memberVehicle); | |
655 | + } | |
656 | + CustomerDetailDto dto = CustomerDetailDto.with(memberVehicle); | |
657 | + dto.setAdviserId(customers.get(0).getAdviserId()); | |
658 | + UserInfoDTO user = userService.user(customers.get(0).getAdviserId()); | |
659 | + if (Objects.nonNull(user)) { | |
660 | + dto.setAdviserName(user.getUserName()); | |
661 | + } | |
662 | + return dto; | |
663 | + } | |
607 | 664 | } |
608 | - if(shopId.equals(customer.getShopId())){ | |
609 | - return customer.getAdviserId(); | |
665 | + CustomerDetailDto dto = renderDto(customer); | |
666 | + if (!Objects.equals(customer.getShopId(), shopId)) { | |
667 | + dto.setShopId(null); | |
668 | + dto.setAdviserId(null); | |
669 | + dto.setAdviserName(null); | |
610 | 670 | } |
611 | - return null; | |
671 | + return dto; | |
612 | 672 | } |
613 | 673 | |
614 | 674 | ... | ... |