Blame view

fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java 50.3 KB
9e476657   张志伟   :art:
1
2
  package cn.fw.valhalla.service.bus.cust;
  
5f212858   张志伟   ✨ 公共池接口 100%
3
  import cn.fw.common.exception.BusinessException;
67ad6e9a   张志伟   :art:
4
  import cn.fw.common.page.AppPage;
8a272b22   张志伟   :sparkles:
5
  import cn.fw.common.web.annotation.DisLock;
67ad6e9a   张志伟   :art:
6
  import cn.fw.common.web.auth.LoginAuthBean;
5f212858   张志伟   ✨ 公共池接口 100%
7
  import cn.fw.valhalla.common.constant.RoleCode;
ede61714   夏天   新增会员认证车辆接口
8
  import cn.fw.valhalla.common.utils.BeanUtils;
612d25d9   张志伟   :art:
9
  import cn.fw.valhalla.common.utils.DateUtil;
1331548a   张志伟   :sparkles:
10
11
12
  import cn.fw.valhalla.domain.db.CompanyWechatJoin;
  import cn.fw.valhalla.domain.db.MemberVehicle;
  import cn.fw.valhalla.domain.db.WechatSubscribe;
abc1b038   张志伟   :art:
13
  import cn.fw.valhalla.domain.db.customer.*;
1331548a   张志伟   :sparkles:
14
15
16
17
18
19
  import cn.fw.valhalla.domain.db.follow.ClueTask;
  import cn.fw.valhalla.domain.db.follow.FollowClue;
  import cn.fw.valhalla.domain.db.follow.FollowRecord;
  import cn.fw.valhalla.domain.db.pool.PublicCluePool;
  import cn.fw.valhalla.domain.db.pool.PublicPool;
  import cn.fw.valhalla.domain.db.pool.StammkundePool;
9de0e2d7   张志伟   feature(*): 公共池线索...
20
  import cn.fw.valhalla.domain.db.pub.PubCluePool;
67ad6e9a   张志伟   :art:
21
  import cn.fw.valhalla.domain.dto.CustomerDetailDto;
dac2e8b1   张志伟   :art:
22
  import cn.fw.valhalla.domain.enums.*;
1331548a   张志伟   :sparkles:
23
24
25
  import cn.fw.valhalla.domain.query.CustomCustomerQuery;
  import cn.fw.valhalla.domain.query.CustomerQueryVO;
  import cn.fw.valhalla.domain.query.StammkundeAnalyseQueryVO;
6c848e1d   张志伟   :art:
26
  import cn.fw.valhalla.domain.vo.customer.*;
d9ece85a   张志伟   :sparkles:
27
  import cn.fw.valhalla.domain.vo.setting.SettingVO;
6c848e1d   张志伟   :art:
28
  import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO;
1331548a   张志伟   :sparkles:
29
30
31
  import cn.fw.valhalla.rpc.erp.dto.PostUserDTO;
  import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
  import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO;
6c848e1d   张志伟   :art:
32
33
  import cn.fw.valhalla.rpc.member.MemberRpcService;
  import cn.fw.valhalla.rpc.member.dto.MemberUserDTO;
e729660d   夏天   新增sdk接口
34
  import cn.fw.valhalla.rpc.oop.OopService;
612d25d9   张志伟   :art:
35
  import cn.fw.valhalla.rpc.oop.dto.ShopDTO;
758162a4   张志伟   :art:
36
  import cn.fw.valhalla.rpc.oop.dto.SpecDTO;
93b833c9   夏天   新增会员认证车辆接口
37
  import cn.fw.valhalla.sdk.enums.CusTypeEnum;
1331548a   张志伟   :sparkles:
38
39
40
41
42
43
44
  import cn.fw.valhalla.sdk.param.ChangeSpecCodeReq;
  import cn.fw.valhalla.sdk.param.CustomerParams;
  import cn.fw.valhalla.sdk.param.CustomerQueryReq;
  import cn.fw.valhalla.sdk.result.BasicsCustomerDTO;
  import cn.fw.valhalla.sdk.result.CustomerInfoDto;
  import cn.fw.valhalla.sdk.result.MemberVehicleDTO;
  import cn.fw.valhalla.sdk.result.ReceptionResultDto;
66271e22   张志伟   :sparkles:
45
  import cn.fw.valhalla.service.bus.StammkundeBizService;
d9ece85a   张志伟   :sparkles:
46
  import cn.fw.valhalla.service.bus.setting.SettingBizService;
abc1b038   张志伟   :art:
47
  import cn.fw.valhalla.service.data.*;
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
48
  import cn.fw.valhalla.service.event.PublicPoolEvent;
27223d59   张志伟   :bug:
49
  import cn.fw.valhalla.service.event.StopTaskEvent;
67ad6e9a   张志伟   :art:
50
51
  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
d9ece85a   张志伟   :sparkles:
52
  import lombok.Getter;
8587e21d   张志伟   :art:
53
  import lombok.RequiredArgsConstructor;
9e476657   张志伟   :art:
54
  import lombok.extern.slf4j.Slf4j;
d9ece85a   张志伟   :sparkles:
55
  import org.springframework.beans.factory.annotation.Value;
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
56
  import org.springframework.context.ApplicationEventPublisher;
9e476657   张志伟   :art:
57
  import org.springframework.stereotype.Service;
6c848e1d   张志伟   :art:
58
  import org.springframework.transaction.annotation.Transactional;
9e476657   张志伟   :art:
59
  
37a9df0d   张志伟   :bug:
60
  import java.time.LocalDate;
612d25d9   张志伟   :art:
61
  import java.time.LocalDateTime;
6c848e1d   张志伟   :art:
62
  import java.util.*;
67ad6e9a   张志伟   :art:
63
64
65
  import java.util.stream.Collectors;
  
  import static cn.fw.common.businessvalidator.Validator.BV;
e729660d   夏天   新增sdk接口
66
  import static cn.fw.common.businessvalidator.Validator.V;
8b00f03a   张志伟   :sparkles:
67
  import static cn.fw.valhalla.service.bus.setting.strategy.SettingStrategy.COMMON_BRAND_ID;
67ad6e9a   张志伟   :art:
68
  
9e476657   张志伟   :art:
69
70
71
72
73
74
75
76
  /**
   * @author : kurisu
   * @className : CustomerBizService
   * @description : 档案
   * @date: 2020-08-12 13:57
   */
  @Service
  @Slf4j
8587e21d   张志伟   :art:
77
  @RequiredArgsConstructor
a4bb750a   张志伟   :art:
78
  public class CustomerBizService extends AbstractCustomerService {
67ad6e9a   张志伟   :art:
79
      /**
a4bb750a   张志伟   :art:
80
       * 关注公众号服务
67ad6e9a   张志伟   :art:
81
       */
a4bb750a   张志伟   :art:
82
83
      private final WechatSubscribeService wechatSubscribeService;
  
52e0b048   张志伟   :art:
84
      /**
a4bb750a   张志伟   :art:
85
       * 加入企业微信服务
52e0b048   张志伟   :art:
86
       */
a4bb750a   张志伟   :art:
87
      private final CompanyWechatJoinService companyWechatJoinService;
6c848e1d   张志伟   :art:
88
      private final MemberRpcService memberRpcService;
612d25d9   张志伟   :art:
89
      private final AffiliationRecordService affiliationRecordService;
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
90
91
      private final PublicPoolService publicPoolService;
      private final ApplicationEventPublisher eventPublisher;
abc1b038   张志伟   :art:
92
      private final CustomerReachLogService customerReachLogService;
d9ece85a   张志伟   :sparkles:
93
      private final SettingBizService settingBizService;
258779e5   张志伟   :sparkles:
94
      private final FollowRecordService followRecordService;
66271e22   张志伟   :sparkles:
95
      private final StammkundeBizService stammkundeBizService;
e729660d   夏天   新增sdk接口
96
      private final OopService oopService;
93b833c9   夏天   新增会员认证车辆接口
97
      private final MemberVehicleService memberVehicleService;
55003764   张志伟   feature(*): 售后crm...
98
      private final FollowClueService followClueService;
d9ece85a   张志伟   :sparkles:
99
100
101
102
  
      @Value("${spring.cache.custom.global-prefix}:customer")
      @Getter
      private String keyPrefix;
6c848e1d   张志伟   :art:
103
  
67ad6e9a   张志伟   :art:
104
105
106
      /**
       * app分页查询档案
       *
67ad6e9a   张志伟   :art:
107
108
109
       * @param queryVO
       * @return
       */
29c2dade   张志伟   :alien:
110
      public AppPage<CustomerListVO> getList(CustomerQueryVO queryVO) {
67ad6e9a   张志伟   :art:
111
112
          queryVO.setCurrent(queryVO.getCurrent() > 0 ? queryVO.getCurrent() : 1);
          Integer startIndex = (queryVO.getCurrent() - 1) * queryVO.getPageSize();
66271e22   张志伟   :sparkles:
113
114
115
116
          if (Boolean.TRUE.equals(queryVO.getFromReport())) {
              StammkundeAnalyseQueryVO analyseQueryVO = new StammkundeAnalyseQueryVO();
              analyseQueryVO.setTimeHorizon(queryVO.getTimeHorizon());
              analyseQueryVO.setFollowType(queryVO.getFollowType());
872d062f   张志伟   :sparkles:
117
              analyseQueryVO.setUnderway(queryVO.getUnderway());
66271e22   张志伟   :sparkles:
118
119
120
              analyseQueryVO.setLat(queryVO.getLat());
              analyseQueryVO.setLng(queryVO.getLng());
              analyseQueryVO.setRadius(queryVO.getRadius());
872d062f   张志伟   :sparkles:
121
              analyseQueryVO.setGroupId(queryVO.getGroupId());
66271e22   张志伟   :sparkles:
122
123
124
125
126
127
128
              analyseQueryVO.setShopIds(queryVO.getShopIdStr());
              List<StammkundeAnalyseVO> vos = stammkundeBizService.stammkundeList(analyseQueryVO);
              if (CollectionUtils.isNotEmpty(vos)) {
                  List<Long> longList = vos.stream().map(StammkundeAnalyseVO::getCustomerId).collect(Collectors.toList());
                  queryVO.setCustomerIdList(longList);
              }
          }
67ad6e9a   张志伟   :art:
129
130
131
132
133
134
135
136
          List<CustomerListVO> appPageList = customerService.getAppPageList(startIndex, queryVO.getPageSize(), queryVO);
          AppPage<CustomerListVO> page = AppPage.empty(queryVO);
          page.setData(appPageList);
          return page;
      }
  
      /**
       * 根据档案id查询详情
52e0b048   张志伟   :art:
137
       *
67ad6e9a   张志伟   :art:
138
139
140
141
       * @param cusId
       * @return
       */
      public CustomerDetailVO getDetailById(final Long cusId) {
91c29e23   张志伟   :fire:
142
          CustomerDetailDto detailDto = queryById(cusId);
ce8f48d3   张志伟   :art:
143
          BV.notNull(detailDto, () -> "查无此档案");
23d2554b   张志伟   :sparkles:
144
          BV.isTrue(detailDto.getYn(), () -> "此档案已经作废,无法再继续查看");
67ad6e9a   张志伟   :art:
145
          CustomerDetailVO vo = new CustomerDetailVO();
67ad6e9a   张志伟   :art:
146
          BeanUtils.copyProperties(detailDto, vo);
bbd11506   张志伟   :art:
147
          vo.setRealMobile(detailDto.getMobile());
3ed89012   张志伟   :art:
148
          vo.setOrgCode(detailDto.getIdCode());
b27b4375   张志伟   :sparkles:
149
150
151
152
153
154
          if (Objects.nonNull(detailDto.getBuyDate())) {
              LocalDate buyDate = DateUtil.date2LocalDate(detailDto.getBuyDate());
              long days = LocalDate.now().toEpochDay() - buyDate.toEpochDay();
              double years = Math.ceil(days / 365.0);
              vo.setAgeLimit(Math.round(years));
          }
67ad6e9a   张志伟   :art:
155
156
157
158
          return vo;
      }
  
      /**
8b050f87   张志伟   fix(*): 优化逻辑
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
       * 根据vin查询详情
       *
       * @param vin
       * @param groupId
       * @return
       */
      public CustomerDetailVO getDetailByVin(final String vin, final Long groupId) {
          Customer customer = customerService.queryByFrameNo(vin, groupId);
          BV.notNull(customer, () -> "档案不存在");
          CustomerDetailDto detailDto = queryById(customer.getId());
          BV.isTrue(detailDto.getYn(), () -> "此档案已经作废,无法再继续查看");
          CustomerDetailVO vo = new CustomerDetailVO();
          BeanUtils.copyProperties(detailDto, vo);
          vo.setRealMobile(detailDto.getMobile());
          vo.setOrgCode(detailDto.getIdCode());
          if (Objects.nonNull(detailDto.getBuyDate())) {
              LocalDate buyDate = DateUtil.date2LocalDate(detailDto.getBuyDate());
              long days = LocalDate.now().toEpochDay() - buyDate.toEpochDay();
              double years = Math.ceil(days / 365.0);
              vo.setAgeLimit(Math.round(years));
          }
          return vo;
      }
  
      /**
a4bb750a   张志伟   :art:
184
       * 根据ID查询档案基本信息
52e0b048   张志伟   :art:
185
       *
a4bb750a   张志伟   :art:
186
       * @param id
67ad6e9a   张志伟   :art:
187
188
       * @return
       */
a4bb750a   张志伟   :art:
189
      public VehicleRecordVO getCarInfoById(Long id) {
6c848e1d   张志伟   :art:
190
          final VehicleRecordVO vo = new VehicleRecordVO();
a4bb750a   张志伟   :art:
191
          Customer customer = customerService.queryById(id);
ce8f48d3   张志伟   :art:
192
          BV.notNull(customer, () -> "查无此档案");
a4bb750a   张志伟   :art:
193
194
          CustomerDetailDto detailDto = renderDto(customer);
          BeanUtils.copyProperties(detailDto, vo);
6c848e1d   张志伟   :art:
195
196
197
198
199
200
          Optional<InsuranceDTO> dtoOptional = queryInsuInfo(customer.getId());
          dtoOptional.ifPresent(t -> {
              vo.setInsurCompanyId(t.getInsurerId());
              vo.setInsurCompanyName(t.getInsurerName());
              vo.setInsurExpireDate(t.getExpiryDate());
          });
468d72b7   张志伟   :sparkles:
201
202
203
204
205
206
          if (Objects.nonNull(customer.getBuyDate())) {
              LocalDate buyDate = DateUtil.date2LocalDate(customer.getBuyDate());
              long days = LocalDate.now().toEpochDay() - buyDate.toEpochDay();
              double years = Math.ceil(days / 365.0);
              vo.setAgeLimit(Math.round(years));
          }
a4bb750a   张志伟   :art:
207
208
          return vo;
      }
67ad6e9a   张志伟   :art:
209
  
a4bb750a   张志伟   :art:
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
      /**
       * 根据id查询车辆所有人信息
       *
       * @param id
       * @return
       */
      public OwnerVO getOwnerInfo(Long id) {
          OwnerVO vo = new OwnerVO();
          Customer customer = customerService.queryById(id);
          BV.notNull(customer, "查无此档案");
          CustomerDetailDto detailDto = renderDto(customer);
          BeanUtils.copyProperties(detailDto, vo);
          vo.setIdNum(detailDto.getIdCode());
          vo.setId(id);
          // 是否关注微信公众号
          vo.setSubscribed(wechatSubscribeService.count(Wrappers.<WechatSubscribe>lambdaQuery()
                  .eq(WechatSubscribe::getSubscribed, Boolean.TRUE)
                  .eq(WechatSubscribe::getMemberId, detailDto.getMemberId())) > 0);
          vo.setJoined(companyWechatJoinService.count(Wrappers.<CompanyWechatJoin>lambdaQuery()
                  .eq(CompanyWechatJoin::getJoined, Boolean.TRUE)
                  .eq(CompanyWechatJoin::getMemberId, detailDto.getMemberId())) > 0);
          return vo;
67ad6e9a   张志伟   :art:
232
233
      }
  
6c848e1d   张志伟   :art:
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
      /**
       * 根据memberId查询该客户的更多车辆
       *
       * @param id
       * @param groupId
       * @return
       */
      public List<MoreVehicleVO> getMoreArchive(Long id, Long groupId) {
          Customer customer = customerService.queryById(id);
          if (Objects.isNull(customer)) {
              return new ArrayList<>();
          }
          List<MoreVehicleVO> list = new ArrayList<>();
          List<Customer> customerList = customerService.getBaseMapper().selectList(Wrappers.<Customer>lambdaQuery()
                  .eq(Customer::getBaseId, customer.getBaseId())
                  .ne(Customer::getId, customer.getId())
                  .eq(Customer::getGroupId, groupId)
                  .eq(Customer::getYn, Boolean.TRUE)
          );
          if (!CollectionUtils.isEmpty(customerList)) {
              for (Customer cust : customerList) {
                  MoreVehicleVO vo = new MoreVehicleVO();
                  BeanUtils.copyProperties(cust, vo);
                  vo.setId(cust.getId());
                  list.add(vo);
              }
          }
          return list;
      }
  
      /**
67ad6e9a   张志伟   :art:
265
266
267
268
269
270
271
272
273
274
275
       * 批量查询保有客档案
       *
       * @param customerIds 保有客档案id集合
       * @return 保有客档案
       */
      public List<CustomerInfoDto> queryBatch(final Long[] customerIds) {
          final List<Customer> customers = customerService.list(Wrappers.<Customer>lambdaQuery()
                  .in(Customer::getId, Arrays.asList(customerIds)));
          if (CollectionUtils.isEmpty(customers)) {
              return Collections.emptyList();
          }
e857bc1b   夏天   fix-bug
276
277
278
279
280
281
282
  
          List<Long> baseIdList = customers.stream().filter(i -> Objects.nonNull(i.getBaseId()))
                  .map(Customer::getBaseId).distinct().collect(Collectors.toList());
  
          final List<CustomerBaseInfo> customerBaseInfoList = customerBaseInfoService.listByIds(baseIdList);
          Map<Long, Long> baseInfoMap = customerBaseInfoList.stream()
                  .collect(Collectors.toMap(CustomerBaseInfo::getId, CustomerBaseInfo::getMemberId));
67ad6e9a   张志伟   :art:
283
284
285
          return customers.stream().map(customer -> {
              CustomerInfoDto customerInfoDto = new CustomerInfoDto();
              BeanUtils.copyProperties(customer, customerInfoDto);
e857bc1b   夏天   fix-bug
286
287
288
289
              customerInfoDto.setId(customer.getId());
              if (Objects.nonNull(customer.getBaseId())) {
                  customerInfoDto.setMemberId(baseInfoMap.getOrDefault(customer.getBaseId(), null));
              }
67ad6e9a   张志伟   :art:
290
291
292
293
294
295
              customerInfoDto.setCreateTime(customer.getCreateTime());
              customerInfoDto.setConsultantId(customer.getAdviserId());
              return customerInfoDto;
          }).collect(Collectors.toList());
      }
  
67ad6e9a   张志伟   :art:
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
      /**
       * 查询会员对应保有客的商家id
       *
       * @param memberId 会员id
       * @param groupId  集团id
       * @return 商家id集合
       */
      public List<Long> getCustomerDealerId(Long groupId, Long memberId) {
          CustomerBaseInfo baseInfo = customerBaseInfoService.getOne(Wrappers.<CustomerBaseInfo>lambdaQuery()
                  .eq(CustomerBaseInfo::getGroupId, groupId)
                  .eq(CustomerBaseInfo::getMemberId, memberId)
                  .eq(CustomerBaseInfo::getYn, Boolean.TRUE)
                  .last("limit 1")
          );
          if (Objects.isNull(baseInfo)) {
              return Collections.emptyList();
          }
  
          final List<Customer> customers = customerService.list(Wrappers.<Customer>lambdaQuery()
                  .eq(Customer::getGroupId, groupId)
                  .eq(Customer::getBaseId, baseInfo.getId())
                  .eq(Customer::getYn, Boolean.TRUE)
          );
          if (CollectionUtils.isEmpty(customers)) {
              return Collections.emptyList();
          }
          return customers.stream().map(Customer::getShopId).distinct().collect(Collectors.toList());
      }
6c848e1d   张志伟   :art:
324
  
758162a4   张志伟   :art:
325
      /**
7dcb5c8d   张志伟   🚑 新增修改车型代码SDK接口
326
327
328
329
330
       * 修改车型代码
       *
       * @param customerId
       * @param specCode
       * @return
e5880775   张志伟   :rocket:
331
       * @deprecated
7dcb5c8d   张志伟   🚑 新增修改车型代码SDK接口
332
       */
e5880775   张志伟   :rocket:
333
      @Deprecated
7dcb5c8d   张志伟   🚑 新增修改车型代码SDK接口
334
335
336
337
338
339
340
341
      public boolean modifySpecCode(Long customerId, String specCode) {
          Customer customer = customerService.queryById(customerId);
          BV.notNull(customer, () -> "档案不存在");
          customer.setSpecCode(specCode);
          return customerService.updateById(customer);
      }
  
      /**
e5880775   张志伟   :rocket:
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
       * 修改车型代码
       *
       * @param req
       * @return
       */
      public boolean fixSpecCode(ChangeSpecCodeReq req) {
          Customer customer = customerService.queryById(req.getCustomerId());
          BV.notNull(customer, () -> "档案不存在");
          customer.setBrandId(req.getBrandId());
          customer.setBrandName(req.getBrandName());
          customer.setSeriesId(req.getSeriesId());
          customer.setSeriesName(req.getSeriesName());
          customer.setSpecId(req.getSpecId());
          customer.setSpecName(req.getSpecName());
          customer.setSpecCode(req.getSpecCode());
          return customerService.updateById(customer);
      }
  
      /**
fd45b634   张志伟   :bug:
361
362
363
       * 查询能否接车
       *
       * @param userId
7c9f5c47   张志伟   :art:
364
       * @param plateNo
fd45b634   张志伟   :bug:
365
366
       * @return
       */
7c9f5c47   张志伟   :art:
367
      public ReceptionResultDto queryReceivable(Long userId, String plateNo) {
3fc19e59   张志伟   升级erpsdk
368
          UserInfoDTO userInfo = ehrRpcService.user(userId);
7c9f5c47   张志伟   :art:
369
370
371
          if (Objects.isNull(userInfo)) {
              return new ReceptionResultDto(false, "非服务顾问无法接待");
          }
fd45b634   张志伟   :bug:
372
373
374
375
          List<UserRoleDataRangeDTO> dataRange = userService.getUserRoleDataRange(userId, RoleCode.FWGW);
          if (CollectionUtils.isEmpty(dataRange)) {
              return new ReceptionResultDto(false, "非服务顾问无法接待");
          }
7c9f5c47   张志伟   :art:
376
377
378
379
380
381
382
383
          Customer customer = customerService.queryByPlateNo(plateNo, userInfo.getGroupId());
          if (Objects.isNull(customer)) {
              return new ReceptionResultDto(true, "");
          }
          ShopDTO shop = oopService.shop(dataRange.get(0).getRangeValue());
          if (Objects.isNull(shop)) {
              return new ReceptionResultDto(false, "服务顾问服务站信息不正确");
          }
6296398b   夏天   fix bug
384
  
fd45b634   张志伟   :bug:
385
386
387
          boolean bool = affiliationRecordService.count(Wrappers.<AffiliationRecord>lambdaQuery()
                  .eq(AffiliationRecord::getType, CustomerChangeTypeEnum.DEFEAT)
                  .eq(AffiliationRecord::getOriginUserId, userId)
7c9f5c47   张志伟   :art:
388
389
                  .eq(AffiliationRecord::getCustomerId, customer.getId())
                  .ge(AffiliationRecord::getDefeatTime, DateUtil.getNowExpiredMonth(-12))
fd45b634   张志伟   :bug:
390
391
392
393
          ) > 0;
          if (bool) {
              return new ReceptionResultDto(false, "无法接待由你战败的客户");
          }
fd45b634   张志伟   :bug:
394
395
396
          return new ReceptionResultDto(true, "");
      }
  
e729660d   夏天   新增sdk接口
397
      public List<Long> queryIllegalAdviser(Long cusId) {
7ad0be67   夏天   新增sdk接口
398
399
400
401
          List<AffiliationRecord> list = affiliationRecordService.list(Wrappers.<AffiliationRecord>lambdaQuery()
                  .eq(AffiliationRecord::getType, CustomerChangeTypeEnum.DEFEAT)
                  .eq(AffiliationRecord::getCustomerId, cusId)
                  .ge(AffiliationRecord::getDefeatTime, DateUtil.getNowExpiredMonth(-12)));
e729660d   夏天   新增sdk接口
402
          if (CollectionUtils.isEmpty(list)) {
7ad0be67   夏天   新增sdk接口
403
404
405
406
407
              return Collections.emptyList();
          }
          return list.stream().map(AffiliationRecord::getOriginUserId).distinct().collect(Collectors.toList());
      }
  
fd45b634   张志伟   :bug:
408
      /**
758162a4   张志伟   :art:
409
410
411
412
413
       * 根据档案id查询详情
       *
       * @param cusId
       * @return
       */
91c29e23   张志伟   :fire:
414
415
      public CustomerDetailDto queryById(final Long cusId) {
          Customer customer = customerService.queryById(cusId);
758162a4   张志伟   :art:
416
417
418
419
420
421
422
          if (Objects.isNull(customer)) {
              return null;
          }
          return renderDto(customer);
      }
  
      /**
03c1a9b3   张志伟   :sparkles:
423
       * 根据自定义条件查询保有客档案
5b538595   张志伟   feature(*): 新增查询线...
424
       * 市场活动用
03c1a9b3   张志伟   :sparkles:
425
426
427
428
429
       *
       * @param queryReq
       * @return
       */
      public List<CustomerDetailDto> queryCustomList(final CustomerQueryReq queryReq) {
03c1a9b3   张志伟   :sparkles:
430
          CustomCustomerQuery query = fillParams(queryReq);
03c1a9b3   张志伟   :sparkles:
431
432
433
434
          return customerService.queryCustomList(query);
      }
  
      /**
1ca0a771   张志伟   新增查询档案数量接口
435
436
437
438
439
440
441
442
443
444
445
       * 根据自定义条件查询保有客档案数量
       *
       * @param queryReq
       * @return
       */
      public Long queryCustomCount(final CustomerQueryReq queryReq) {
          CustomCustomerQuery query = fillParams(queryReq);
          return customerService.queryCustomListCount(query);
      }
  
      /**
758162a4   张志伟   :art:
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
       * 根据手机号查询所有档案
       *
       * @param mobile
       * @param groupId
       * @return
       */
      public List<CustomerDetailDto> queryByMobile(final String mobile, final Long groupId) {
          CustomerBaseInfo baseInfo = customerBaseInfoService.queryByMobile(mobile, groupId);
          if (Objects.isNull(baseInfo)) {
              return new ArrayList<>();
          }
          List<Customer> customerList = customerService.queryByBaseId(baseInfo.getId());
          if (CollectionUtils.isEmpty(customerList)) {
              return new ArrayList<>();
          }
          List<CustomerDetailDto> list = new ArrayList<>();
          for (Customer customer : customerList) {
              list.add(renderDto(customer, baseInfo));
          }
          return list;
      }
  
      /**
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
469
470
471
472
473
474
475
       * 放弃客户
       *
       * @param customerId
       * @param reason
       */
      @Transactional(rollbackFor = Exception.class)
      public void abandon(final Long customerId, final String reason) {
91c29e23   张志伟   :fire:
476
          CustomerDetailDto detailDto = queryById(customerId);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
477
          BV.notNull(detailDto, () -> "档案不存在");
33a55d43   张志伟   feature(*): bug修复
478
479
          PublicPool publicData = publicPoolService.queryByVin(detailDto.getFrameNo(), detailDto.getGroupId());
          if (Objects.nonNull(publicData)) {
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
480
481
482
483
484
485
486
487
488
489
490
              return;
          }
          PublicPool publicPool = createPublicPool(detailDto, PublicPoolTypeEnum.AD, reason);
          boolean updated = customerService.update(Wrappers.<Customer>lambdaUpdate()
                  .set(Customer::getAdviserId, null)
                  .set(Customer::getShopId, null)
                  .eq(Customer::getId, customerId));
          if (!updated) {
              return;
          }
          AffiliationRecord entity = createEntity(detailDto);
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
491
          entity.setReason(DefeatReasonEnum.GU.getName());
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
492
          affiliationRecordService.save(entity);
27223d59   张志伟   :bug:
493
          publicPoolService.save(publicPool);
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
494
          stammkundePoolService.reject(customerId, detailDto.getGroupId(), DefeatReasonEnum.GU);
d9ece85a   张志伟   :sparkles:
495
          publicCluePoolService.removeClue(customerId, detailDto.getAdviserId());
55003764   张志伟   feature(*): 售后crm...
496
          PublicPoolEvent poolEvent = new PublicPoolEvent(detailDto.getFrameNo(), detailDto.getGroupId());
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
497
          eventPublisher.publishEvent(poolEvent);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
498
499
500
      }
  
      /**
55003764   张志伟   feature(*): 售后crm...
501
       * 审批通过客户档案处理
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
502
503
504
       *
       * @param task
       */
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
505
      @Transactional(rollbackFor = Exception.class)
55003764   张志伟   feature(*): 售后crm...
506
      public void abandon(final ClueTask task) {
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
507
508
509
          List<FollowTypeEnum> typeList = Arrays.asList(FollowTypeEnum.AC, FollowTypeEnum.IR);
          HashSet<FollowTypeEnum> set = new HashSet<>(typeList);
          if (set.contains(task.getType())) {
27223d59   张志伟   :bug:
510
511
              StopTaskEvent stopTaskEvent = new StopTaskEvent(task);
              eventPublisher.publishEvent(stopTaskEvent);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
512
513
              return;
          }
55003764   张志伟   feature(*): 售后crm...
514
515
516
517
518
          FollowClue followClue = followClueService.getById(task.getClueId());
          if (Objects.isNull(followClue)) {
              return;
          }
          CustomerDetailDto detailDto = queryByFrameNo(followClue.getVin(), followClue.getGroupId());
36815308   张志伟   :bug:
519
520
521
          if (Objects.isNull(detailDto)) {
              return;
          }
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
522
523
524
525
          PublicPoolTypeEnum type = PublicPoolTypeEnum.FM;
          if (FollowTypeEnum.RM.equals(task.getType())) {
              type = PublicPoolTypeEnum.RM;
          }
33a55d43   张志伟   feature(*): bug修复
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
          abandon(detailDto.getFrameNo(), detailDto.getGroupId(), type);
      }
  
      /**
       * 审批通过客户档案处理
       *
       * @param vin
       * @param groupId
       * @param type
       */
      @Transactional(rollbackFor = Exception.class)
      public void abandon(String vin, final Long groupId, PublicPoolTypeEnum type) {
          CustomerDetailDto detailDto = queryByFrameNo(vin, groupId);
          if (Objects.isNull(detailDto)) {
              return;
          }
          PublicPool publicData = publicPoolService.queryByVin(detailDto.getFrameNo(), detailDto.getGroupId());
          if (Objects.nonNull(publicData)) {
2f6cb7a3   张志伟   :bug:
544
545
              return;
          }
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
546
547
548
549
          PublicPool publicPool = createPublicPool(detailDto, type, "系统判定");
          boolean updated = customerService.update(Wrappers.<Customer>lambdaUpdate()
                  .set(Customer::getAdviserId, null)
                  .set(Customer::getShopId, null)
55003764   张志伟   feature(*): 售后crm...
550
                  .eq(Customer::getId, detailDto.getId()));
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
551
552
553
          if (!updated) {
              return;
          }
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
554
          AffiliationRecord entity = createEntity(detailDto);
55003764   张志伟   feature(*): 售后crm...
555
          entity.setReason(DefeatReasonEnum.GU.getName());
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
556
          affiliationRecordService.save(entity);
27223d59   张志伟   :bug:
557
          publicPoolService.save(publicPool);
33a55d43   张志伟   feature(*): bug修复
558
          stammkundePoolService.reject(detailDto.getId(), groupId, DefeatReasonEnum.GU);
55003764   张志伟   feature(*): 售后crm...
559
          publicCluePoolService.removeClue(detailDto.getId(), detailDto.getAdviserId());
18a818bd   张志伟   :construction:
560
  
33a55d43   张志伟   feature(*): bug修复
561
          PublicPoolEvent poolEvent = new PublicPoolEvent(detailDto.getFrameNo(), groupId);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
562
          eventPublisher.publishEvent(poolEvent);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
563
564
565
      }
  
      /**
b62ab7af   张志伟   feature(*): 公共池跟进联调
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
       * 任务结束战败客户到公共池
       *
       * @param task
       * @param followClue
       */
      @Transactional(rollbackFor = Exception.class)
      public void taskEndAbandon(final ClueTask task, final FollowClue followClue) {
          CustomerDetailDto detailDto = queryByFrameNo(followClue.getVin(), followClue.getGroupId());
          if (Objects.isNull(detailDto)) {
              return;
          }
          PublicPoolTypeEnum type = PublicPoolTypeEnum.FM;
          if (FollowTypeEnum.RM.equals(task.getType())) {
              type = PublicPoolTypeEnum.RM;
          }
          boolean updated = customerService.update(Wrappers.<Customer>lambdaUpdate()
                  .set(Customer::getAdviserId, null)
                  .set(Customer::getShopId, null)
ccee7886   张志伟   feature(*): 修复bug
584
                  .set(Customer::getTemporary, null)
b62ab7af   张志伟   feature(*): 公共池跟进联调
585
586
587
588
589
590
591
592
                  .eq(Customer::getId, detailDto.getId()));
          if (!updated) {
              return;
          }
          stammkundePoolService.reject(detailDto.getId(), task.getGroupId(), FollowTypeEnum.RM.equals(task.getType()) ? DefeatReasonEnum.RM : DefeatReasonEnum.FM);
          publicCluePoolService.removeClue(detailDto.getId(), detailDto.getAdviserId());
          AffiliationRecord entity = createEntity(detailDto);
          entity.setReason("跟进超期");
399fba25   张志伟   feature(*): bug修复
593
594
595
596
597
598
          if (Objects.isNull(entity.getOriginUserId())) {
              entity.setOriginUserId(task.getFollowUser());
          }
          if (Objects.isNull(entity.getOriginShopId())) {
              entity.setOriginShopId(task.getFollowShop());
          }
b62ab7af   张志伟   feature(*): 公共池跟进联调
599
          affiliationRecordService.save(entity);
33a55d43   张志伟   feature(*): bug修复
600
601
          PublicPool publicData = publicPoolService.queryByVin(detailDto.getFrameNo(), detailDto.getGroupId());
          if (Objects.nonNull(publicData)) {
b62ab7af   张志伟   feature(*): 公共池跟进联调
602
603
604
605
606
607
608
              return;
          }
          PublicPool publicPool = createPublicPool(detailDto, type, "跟进超期");
          publicPoolService.save(publicPool);
      }
  
      /**
9de0e2d7   张志伟   feature(*): 公共池线索...
609
610
611
612
613
614
615
616
617
618
619
620
621
622
       * 公共池跟进任务结束战败客户到公共池
       *
       * @param pubCluePool
       */
      @Transactional(rollbackFor = Exception.class)
      public void pubTaskEndAbandon(PubCluePool pubCluePool) {
          Long groupId = pubCluePool.getGroupId();
          CustomerDetailDto detailDto = queryByFrameNo(pubCluePool.getVin(), groupId);
          if (Objects.isNull(detailDto)) {
              return;
          }
          boolean updated = customerService.update(Wrappers.<Customer>lambdaUpdate()
                  .set(Customer::getAdviserId, null)
                  .set(Customer::getShopId, null)
ccee7886   张志伟   feature(*): 修复bug
623
                  .set(Customer::getTemporary, null)
9de0e2d7   张志伟   feature(*): 公共池线索...
624
625
626
627
628
629
630
631
632
                  .eq(Customer::getId, detailDto.getId()));
          if (!updated) {
              return;
          }
          stammkundePoolService.reject(detailDto.getId(), groupId, DefeatReasonEnum.CD);
          publicCluePoolService.removeClue(detailDto.getId(), detailDto.getAdviserId());
          AffiliationRecord entity = createEntity(detailDto);
          entity.setReason("跟进超期");
          affiliationRecordService.save(entity);
33a55d43   张志伟   feature(*): bug修复
633
634
          PublicPool publicData = publicPoolService.queryByVin(detailDto.getFrameNo(), detailDto.getGroupId());
          if (Objects.nonNull(publicData)) {
9de0e2d7   张志伟   feature(*): 公共池线索...
635
636
637
638
639
640
641
              return;
          }
          PublicPool publicPool = createPublicPool(detailDto, PublicPoolTypeEnum.PD, PublicPoolTypeEnum.PD.getName());
          publicPoolService.save(publicPool);
      }
  
      /**
c4fb2fa5   张志伟   ✨ 公共池接口 100%
642
       * 继续跟进
9de0e2d7   张志伟   feature(*): 公共池线索...
643
       *
c4fb2fa5   张志伟   ✨ 公共池接口 100%
644
645
       * @param currentUser
       * @param customerId
9de0e2d7   张志伟   feature(*): 公共池线索...
646
       * @deprecated
c4fb2fa5   张志伟   ✨ 公共池接口 100%
647
       */
8a272b22   张志伟   :sparkles:
648
      @DisLock(prefix = "#this.getKeyPrefix()", key = "'continueFollow:' + #customerId", message = "请勿重复提交")
c4fb2fa5   张志伟   ✨ 公共池接口 100%
649
650
651
652
653
      public void continueFollow(LoginAuthBean currentUser, final Long customerId) {
          List<UserRoleDataRangeDTO> dataRange = userService.getUserRoleDataRange(currentUser.getUserId(), RoleCode.FWGW);
          BV.isFalse(CollectionUtils.isEmpty(dataRange), () -> "非服务顾问无法进行操作");
          Customer customer = customerService.queryById(customerId);
          if (Objects.isNull(customer)) {
27291f56   张志伟   :bug:
654
              publicPoolService.removeByCustomerId(customerId, currentUser.getGroupId());
c4fb2fa5   张志伟   ✨ 公共池接口 100%
655
656
              throw new BusinessException("档案信息有误,请刷新后重试");
          }
8a272b22   张志伟   :sparkles:
657
658
659
660
661
662
          boolean bool = affiliationRecordService.count(Wrappers.<AffiliationRecord>lambdaQuery()
                  .eq(AffiliationRecord::getType, CustomerChangeTypeEnum.DEFEAT)
                  .eq(AffiliationRecord::getOriginUserId, currentUser.getUserId())
                  .eq(AffiliationRecord::getCustomerId, customerId)
          ) > 0;
          BV.isFalse(bool, () -> "无法继续跟进由你战败的客户");
8b00f03a   张志伟   :sparkles:
663
          Optional<SettingVO> voOptional = settingBizService.querySettingByType(FollowTypeEnum.OT, SettingTypeEnum.PUBLIC_VALID_DAY, currentUser.getGroupId(), COMMON_BRAND_ID);
1943d0bc   张志伟   feature(*): 公共线索池
664
665
666
          SettingVO settingVO = voOptional.orElse(null);
          BV.notNull(settingVO, () -> "设置获取失败");
          UserRoleDataRangeDTO rangeDTO = dataRange.get(0);
8a272b22   张志伟   :sparkles:
667
          publicPoolService.removeByCustomerId(customerId, currentUser.getGroupId());
1943d0bc   张志伟   feature(*): 公共线索池
668
669
670
          if (Objects.isNull(customer.getAdviserId()) && Objects.isNull(customer.getShopId())) {
              Date deadline = DateUtil.localDateTime2Date(LocalDate.now().plusDays(settingVO.getDetailValue()).atStartOfDay());
              createPublicPoolClue(customer, currentUser, rangeDTO, deadline);
fd4c7e8e   张志伟   :sparkles:
671
          }
c4fb2fa5   张志伟   ✨ 公共池接口 100%
672
673
674
      }
  
      /**
ad93e14a   张志伟   :art:
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
       * 根据车牌号查询所有档案
       *
       * @param plateNo
       * @param groupId
       * @return
       */
      public CustomerDetailDto queryByPlateNo(final String plateNo, final Long groupId) {
          Customer customer = customerService.queryByPlateNo(plateNo, groupId);
          if (Objects.isNull(customer)) {
              return null;
          }
          return renderDto(customer);
      }
  
      /**
ca13c864   张志伟   :art:
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
       * 根据车架号号查询所有档案
       *
       * @param frameNo
       * @param groupId
       * @return
       */
      public CustomerDetailDto queryByFrameNo(final String frameNo, final Long groupId) {
          Customer customer = customerService.queryByFrameNo(frameNo, groupId);
          if (Objects.isNull(customer)) {
              return null;
          }
          return renderDto(customer);
      }
  
      /**
93b833c9   夏天   新增会员认证车辆接口
705
       * 根据车架号号查询车辆信息
e729660d   夏天   新增sdk接口
706
707
       *
       * @param frameNo 车架号
ede61714   夏天   新增会员认证车辆接口
708
       * @param shopId  门店id
93b833c9   夏天   新增会员认证车辆接口
709
       * @return 车辆信息
e729660d   夏天   新增sdk接口
710
       */
93b833c9   夏天   新增会员认证车辆接口
711
      public CustomerDetailDto queryVehicleByFrameNo(final String frameNo, final Long shopId) {
e729660d   夏天   新增sdk接口
712
          ShopDTO shop = oopService.shop(shopId);
93b833c9   夏天   新增会员认证车辆接口
713
          V.notNull(shop, String.format("未查询到门店%d信息", shopId));
e729660d   夏天   新增sdk接口
714
          Customer customer = customerService.queryByFrameNo(frameNo, shop.getGroupId());
93b833c9   夏天   新增会员认证车辆接口
715
          if (Objects.isNull(customer)) {
9eeda572   夏天   新增会员认证车辆接口
716
              MemberVehicle memberVehicle = memberVehicleService.getVehicle(frameNo);
93b833c9   夏天   新增会员认证车辆接口
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
              if (Objects.isNull(memberVehicle)) {
                  return null;
              }
              if (CusTypeEnum.PERSONAL.equals(memberVehicle.getCusType())) {
                  //查询该会员的其他车辆是否有档案
                  List<Long> customerBaseInfoList = customerBaseInfoService
                          .list(Wrappers.<CustomerBaseInfo>lambdaQuery()
                                  .eq(CustomerBaseInfo::getYn, Boolean.TRUE)
                                  .eq(CustomerBaseInfo::getCusType, CusTypeEnum.PERSONAL)
                                  .eq(CustomerBaseInfo::getMemberId, memberVehicle.getMemberId()))
                          .stream().map(CustomerBaseInfo::getId).collect(Collectors.toList());
                  if (CollectionUtils.isEmpty(customerBaseInfoList)) {
                      return CustomerDetailDto.with(memberVehicle);
                  }
                  final List<Customer> customers = customerService.list(Wrappers.<Customer>lambdaQuery()
                          .in(Customer::getBaseId, customerBaseInfoList).eq(Customer::getYn, true)
ede61714   夏天   新增会员认证车辆接口
733
                          .eq(Customer::getGroupId, shop.getGroupId()).eq(Customer::getShopId, shopId)
93b833c9   夏天   新增会员认证车辆接口
734
735
736
737
738
739
740
                          .isNotNull(Customer::getAdviserId)
                          .orderByDesc(Customer::getUpdateTime));
                  if (CollectionUtils.isEmpty(customers)) {
                      return CustomerDetailDto.with(memberVehicle);
                  }
                  CustomerDetailDto dto = CustomerDetailDto.with(memberVehicle);
                  dto.setAdviserId(customers.get(0).getAdviserId());
3fc19e59   张志伟   升级erpsdk
741
                  UserInfoDTO user = ehrRpcService.user(customers.get(0).getAdviserId());
93b833c9   夏天   新增会员认证车辆接口
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
                  if (Objects.nonNull(user)) {
                      dto.setAdviserName(user.getUserName());
                  }
                  return dto;
              } else {
                  //查询该单位是否有其他档案
                  List<Long> customerBaseInfoList = customerBaseInfoService
                          .list(Wrappers.<CustomerBaseInfo>lambdaQuery()
                                  .eq(CustomerBaseInfo::getYn, Boolean.TRUE)
                                  .eq(CustomerBaseInfo::getCusType, CusTypeEnum.COMPANY)
                                  .eq(CustomerBaseInfo::getName, memberVehicle.getName()))
                          .stream().map(CustomerBaseInfo::getId).collect(Collectors.toList());
                  if (CollectionUtils.isEmpty(customerBaseInfoList)) {
                      return CustomerDetailDto.with(memberVehicle);
                  }
                  final List<Customer> customers = customerService.list(Wrappers.<Customer>lambdaQuery()
                          .in(Customer::getBaseId, customerBaseInfoList).eq(Customer::getYn, true)
ede61714   夏天   新增会员认证车辆接口
759
                          .eq(Customer::getGroupId, shop.getGroupId()).eq(Customer::getShopId, shopId)
93b833c9   夏天   新增会员认证车辆接口
760
761
762
763
764
765
766
                          .isNotNull(Customer::getAdviserId)
                          .orderByDesc(Customer::getUpdateTime));
                  if (CollectionUtils.isEmpty(customers)) {
                      return CustomerDetailDto.with(memberVehicle);
                  }
                  CustomerDetailDto dto = CustomerDetailDto.with(memberVehicle);
                  dto.setAdviserId(customers.get(0).getAdviserId());
3fc19e59   张志伟   升级erpsdk
767
                  UserInfoDTO user = ehrRpcService.user(customers.get(0).getAdviserId());
93b833c9   夏天   新增会员认证车辆接口
768
769
770
771
772
                  if (Objects.nonNull(user)) {
                      dto.setAdviserName(user.getUserName());
                  }
                  return dto;
              }
e729660d   夏天   新增sdk接口
773
          }
93b833c9   夏天   新增会员认证车辆接口
774
775
776
777
778
          CustomerDetailDto dto = renderDto(customer);
          if (!Objects.equals(customer.getShopId(), shopId)) {
              dto.setShopId(null);
              dto.setAdviserId(null);
              dto.setAdviserName(null);
e729660d   夏天   新增sdk接口
779
          }
2fe30da1   夏天   fix-bug
780
781
782
783
          if (Objects.nonNull(customer) && Objects.isNull(customer.getRegDate())) {
              MemberVehicle memberVehicle = memberVehicleService.getVehicle(frameNo);
              customer.setRegDate(Objects.nonNull(memberVehicle) ? memberVehicle.getRegDate() : null);
          }
93b833c9   夏天   新增会员认证车辆接口
784
          return dto;
e729660d   夏天   新增sdk接口
785
786
787
788
      }
  
  
      /**
3145890c   张志伟   :alien:
789
790
791
792
793
794
795
796
797
798
799
800
801
802
       * 根据发动机号查询所有档案
       *
       * @param engineNo
       * @param groupId
       * @return
       */
      public CustomerDetailDto queryByEngineNo(final String engineNo, final Long groupId) {
          Customer customer = customerService.queryByEngineNo(engineNo, groupId);
          if (Objects.isNull(customer)) {
              return null;
          }
          return renderDto(customer);
      }
  
d1deb950   张志伟   :bug:
803
  
3145890c   张志伟   :alien:
804
      /**
758162a4   张志伟   :art:
805
806
807
808
809
       * 是否关联了档案
       *
       * @param customerParams
       * @return
       */
08704989   张志伟   :art:
810
      @Transactional(rollbackFor = Exception.class)
758162a4   张志伟   :art:
811
      public Boolean save4api(final CustomerParams customerParams) {
3cdf5c0c   张志伟   :fire:
812
813
814
815
          final String plateNo = customerParams.getPlateNo();
          final String frameNo = customerParams.getFrameNo();
          final Long groupId = customerParams.getGroupId();
  
758162a4   张志伟   :art:
816
          Customer customer = customerService.queryByPlateNo(plateNo, groupId);
e56e5bb4   张志伟   :art:
817
          BV.isNull(customer, "该车牌号对应的档案已存在");
3cdf5c0c   张志伟   :fire:
818
819
          customer = customerService.queryByFrameNo(frameNo, groupId);
          BV.isNull(customer, "该车辆已存在档案");
758162a4   张志伟   :art:
820
821
822
  
          CustomerBaseInfo baseInfo = new CustomerBaseInfo();
          BeanUtils.copyProperties(customerParams, baseInfo);
a36ab512   张志伟   :bug:
823
          baseInfo.setContact(customerParams.getName());
758162a4   张志伟   :art:
824
825
826
827
828
          baseInfo.setYn(Boolean.TRUE);
          baseInfo.setCreateTime(new Date());
          baseInfo.setUpdateTime(new Date());
  
          customer = new Customer();
3cdf5c0c   张志伟   :fire:
829
830
831
832
833
834
835
836
837
838
839
840
          ShopDTO shop = oopService.shop(customerParams.getShopId());
          BV.notNull(shop, () -> "shop信息有误,请检查");
          Long casShopId = shop.getCasShopId();
          Long adviserId = customerParams.getAdviserId();
          List<PostUserDTO> 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);
          }
758162a4   张志伟   :art:
841
          BeanUtils.copyProperties(customerParams, customer);
2cb94832   张志伟   :sparkles:
842
          customer.setSpecCode(customerParams.getSpecCode());
758162a4   张志伟   :art:
843
844
845
          customer.setCreateTime(new Date());
          customer.setUpdateTime(new Date());
          customer.setYn(Boolean.TRUE);
ccee7886   张志伟   feature(*): 修复bug
846
          customer.setTemporary(Boolean.FALSE);
758162a4   张志伟   :art:
847
848
          final SpecDTO spec = oopService.spec(customerParams.getSpecId());
          customer.setCarImage(Optional.ofNullable(spec).orElse(new SpecDTO()).getThumbnail());
3cdf5c0c   张志伟   :fire:
849
          customer.setShopId(casShopId);
b27b4375   张志伟   :sparkles:
850
          Long cid = saveNewOne(customer, baseInfo, true);
7c9f5c47   张志伟   :art:
851
852
853
854
          CustomerParams.LoanInfo loanInfo = customerParams.getLoanInfo();
          if (Objects.nonNull(loanInfo)) {
              saveLoanInfo(customer.getGroupId(), customer.getFrameNo(), loanInfo.getPeriods(), loanInfo.getExpires());
          }
376d3231   张志伟   ✨ 主动放弃跟进 100%
855
          return Objects.nonNull(cid);
758162a4   张志伟   :art:
856
857
      }
  
d1deb950   张志伟   :bug:
858
859
      /**
       * 更新购车日期
a78dc8be   张志伟   feature(*): 查询的bug修复
860
       *
d1deb950   张志伟   :bug:
861
862
863
864
865
866
867
868
869
870
871
872
873
874
       * @param vin
       * @param date
       * @param groupId
       */
      @Transactional(rollbackFor = Exception.class)
      public void updateCustomerBuyDate(final String vin, final Date date, final Long groupId) {
          Customer customer = customerService.queryByFrameNo(vin, groupId);
          if (Objects.isNull(customer)) {
              return;
          }
          customer.setBuyDate(date);
          customerService.updateById(customer);
      }
  
b082ac54   张志伟   :rocket:
875
876
877
878
879
880
881
882
883
      public List<CarArchiveVO> memberCarList(final Long memberId, final Long groupId) {
          BV.notNull(groupId, () -> "集团ID不能为空");
          List<CarArchiveVO> list = this.defaultCustomer(memberId);
          if (CollectionUtils.isEmpty(list)) {
              return list;
          }
          return list.stream().filter(r -> Objects.equals(r.getGroupId(), groupId)).collect(Collectors.toList());
      }
  
612d25d9   张志伟   :art:
884
      /**
8f9a8d4d   张志伟   :art:
885
886
887
888
889
890
891
       * 查询所有字段
       *
       * @param memberId
       * @return
       */
      public List<CarArchiveVO> defaultCustomer(final Long memberId) {
          if (Objects.isNull(memberId)) {
4af3c6d3   张志伟   :art:
892
              return new ArrayList<>();
8f9a8d4d   张志伟   :art:
893
894
895
          }
          final MemberUserDTO user = memberRpcService.user(memberId);
          if (Objects.isNull(user)) {
4af3c6d3   张志伟   :art:
896
              return new ArrayList<>();
8f9a8d4d   张志伟   :art:
897
898
899
          }
          List<CustomerBaseInfo> baseList = this.customerBaseInfoService.list(Wrappers.<CustomerBaseInfo>lambdaQuery()
                  .eq(CustomerBaseInfo::getMemberId, memberId)
8f9a8d4d   张志伟   :art:
900
901
902
903
                  .eq(CustomerBaseInfo::getYn, Boolean.TRUE)
          );
          List<Long> baseIds = Optional.ofNullable(baseList).map(l -> l.stream().map(CustomerBaseInfo::getId).collect(Collectors.toList())).orElse(null);
          if (CollectionUtils.isEmpty(baseIds)) {
4af3c6d3   张志伟   :art:
904
              return new ArrayList<>();
8f9a8d4d   张志伟   :art:
905
906
907
908
909
910
911
912
913
914
915
          }
  
          final List<Customer> customers = this.customerService.list(Wrappers.<Customer>lambdaQuery()
                  .in(Customer::getBaseId, baseIds)
                  .eq(Customer::getYn, Boolean.TRUE)
                  .orderByDesc(Customer::getCreateTime));
          if (CollectionUtils.isNotEmpty(customers)) {
              return customers.stream()
                      .map(CarArchiveVO::with)
                      .filter(Objects::nonNull)
                      .peek(vo -> {
3fc19e59   张志伟   升级erpsdk
916
                          UserInfoDTO dto = ehrRpcService.user(vo.getAdviserId());
b6d1888d   张志伟   :art:
917
918
919
                          if (Objects.nonNull(dto)) {
                              vo.setAdviserName(dto.getUserName());
                          }
0702edee   张志伟   :sparkles:
920
921
922
923
                          ShopDTO shop = oopService.shop(vo.getShopId());
                          if (Objects.nonNull(shop)) {
                              vo.setShopName(shop.getShortName());
                          }
8f9a8d4d   张志伟   :art:
924
925
926
                          vo.setDealerInfoVO(createDeal(vo.getShopId()));
                          vo.setOwner(true);
                          vo.setOwnerName(user.getRealName());
37a9df0d   张志伟   :bug:
927
                          loanCustomer(vo);
8f9a8d4d   张志伟   :art:
928
929
                      }).collect(Collectors.toList());
          }
4af3c6d3   张志伟   :art:
930
          return new ArrayList<>();
8f9a8d4d   张志伟   :art:
931
932
      }
  
1331548a   张志伟   :sparkles:
933
      /**
1331548a   张志伟   :sparkles:
934
935
936
937
       * @param customer
       * @param currentUser
       * @param rangeDTO
       * @param deadline
9de0e2d7   张志伟   feature(*): 公共池线索...
938
       * @deprecated 已弃用 sclie 2.0
1331548a   张志伟   :sparkles:
939
       */
1943d0bc   张志伟   feature(*): 公共线索池
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
      @Transactional(rollbackFor = Exception.class)
      public void createPublicPoolClue(Customer customer, LoginAuthBean currentUser, UserRoleDataRangeDTO rangeDTO, Date deadline) {
          customer.setAdviserId(currentUser.getUserId());
          customer.setShopId(rangeDTO.getRangeValue());
          customerService.updateById(customer);
          StammkundePool stammkundePool = createSimpleInfo(customer);
          stammkundePool.setAdviserId(currentUser.getUserId());
          stammkundePool.setAdviserName(currentUser.getUserName());
          stammkundePool.setSources(StammkundeSourcesEnum.PUBLIC_POOL);
          stammkundePool.setPoolStatus(StammkundeStatusEnum.PUBLIC);
          stammkundePoolService.save(stammkundePool);
          createPublicCluePool(customer.getId(), deadline, currentUser, rangeDTO);
      }
  
      /**
       * 创建公共池线索跟进
9de0e2d7   张志伟   feature(*): 公共池线索...
956
       *
1943d0bc   张志伟   feature(*): 公共线索池
957
958
959
960
       * @param customerId
       * @param deadline
       * @param currentUser
       * @param rangeDTO
9de0e2d7   张志伟   feature(*): 公共池线索...
961
       * @deprecated 已弃用 sclie 2.0
1943d0bc   张志伟   feature(*): 公共线索池
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
       */
      private void createPublicCluePool(Long customerId, Date deadline, LoginAuthBean currentUser, UserRoleDataRangeDTO rangeDTO) {
          final PublicCluePool publicCluePool = new PublicCluePool();
          publicCluePool.setCustomerId(customerId);
          publicCluePool.setDeadline(deadline);
          publicCluePool.setState(PublicClueStateEnum.ONGOING);
          publicCluePool.setAdviserId(currentUser.getUserId());
          publicCluePool.setAdviserName(currentUser.getUserName());
          publicCluePool.setShopId(rangeDTO.getRangeValue());
          publicCluePool.setShopName(rangeDTO.getRangeName());
          ShopDTO shop = oopService.shop(rangeDTO.getRangeValue());
          if (Objects.nonNull(shop)) {
              publicCluePool.setShopName(shop.getShortName());
          }
          publicCluePool.setGroupId(currentUser.getGroupId());
          publicCluePoolService.save(publicCluePool);
  
          final FollowRecord record = new FollowRecord();
          record.setTaskId(publicCluePool.getId());
          record.setCustomerId(publicCluePool.getCustomerId());
          record.setType(FollowTypeEnum.OT);
          record.setUserId(publicCluePool.getAdviserId());
          record.setUserName(publicCluePool.getAdviserName());
          Date planTime = DateUtil.localDateTime2Date(LocalDateTime.now());
          record.setPlanTime(planTime);
          record.setAddTodo(Boolean.TRUE);
          record.setDeadline(publicCluePool.getDeadline());
          record.setOutTime(Boolean.FALSE);
          record.setGroupId(publicCluePool.getGroupId());
          record.setShopId(publicCluePool.getShopId());
          record.setCreateTime(DateUtil.localDateTime2Date(LocalDateTime.now()));
          followRecordService.save(record);
      }
  
bebe7030   张志伟   :sparkles:
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
      /**
       * 创建公共池对象
       *
       * @param dto
       * @param type
       * @param reason
       * @return
       */
      public PublicPool createPublicPool(CustomerDetailDto dto, PublicPoolTypeEnum type, String reason) {
          PublicPool pool = new PublicPool();
          pool.setCustomerId(dto.getId());
          pool.setCustomerName(dto.getName());
          pool.setPlateNo(dto.getPlateNo());
          pool.setFrameNo(dto.getFrameNo());
          pool.setBrandId(dto.getBrandId());
          pool.setBrandName(dto.getBrandName());
          pool.setSeriesId(dto.getSeriesId());
          pool.setSeriesName(dto.getSeriesName());
          pool.setSpecId(dto.getSpecId());
          pool.setSpecName(dto.getSpecName());
          pool.setAddress(dto.getAddress());
          pool.setCompany(dto.getCompanyName());
          pool.setType(type);
          pool.setReason(reason);
9de0e2d7   张志伟   feature(*): 公共池线索...
1020
1021
1022
          Long shopId = Optional.ofNullable(dto.getLastArrivalShop()).orElse(dto.getShopId());
          pool.setShopId(shopId);
          ShopDTO shop = oopService.shop(shopId);
bebe7030   张志伟   :sparkles:
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
          if (Objects.nonNull(shop)) {
              pool.setShopName(shop.getShortName());
          }
          int times = customerReachLogService.count(Wrappers.<CustomerReachLog>lambdaQuery()
                  .eq(CustomerReachLog::getFrameNo, dto.getFrameNo())
          );
          pool.setTimes(times);
          pool.setGroupId(dto.getGroupId());
          return pool;
      }
  
      /**
       * 档案批量移动到公共池
8a272b22   张志伟   :sparkles:
1036
       *
bebe7030   张志伟   :sparkles:
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
       * @param customerIdList
       */
      @Transactional(rollbackFor = Exception.class)
      public void move2PublicPool(List<Long> customerIdList) {
          if (CollectionUtils.isEmpty(customerIdList)) {
              return;
          }
          customerService.update(Wrappers.<Customer>lambdaUpdate()
                  .set(Customer::getAdviserId, null)
                  .set(Customer::getShopId, null)
ccee7886   张志伟   feature(*): 修复bug
1047
                  .set(Customer::getTemporary, null)
bebe7030   张志伟   :sparkles:
1048
1049
1050
                  .in(Customer::getId, customerIdList));
      }
  
322823a4   张志伟   feature(*): 公共池跟进联调
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
  
      /**
       * 档案批量移动到公共池
       *
       * @param customerId
       */
      @Transactional(rollbackFor = Exception.class)
      public void move2PublicPool(Long customerId) {
          customerService.update(Wrappers.<Customer>lambdaUpdate()
                  .set(Customer::getAdviserId, null)
                  .set(Customer::getShopId, null)
ccee7886   张志伟   feature(*): 修复bug
1062
                  .set(Customer::getTemporary, null)
322823a4   张志伟   feature(*): 公共池跟进联调
1063
1064
1065
                  .eq(Customer::getId, customerId));
      }
  
1983befb   张志伟   feat(api): :spark...
1066
      public List<BasicsCustomerDTO> queryByKeyword(String keyword, Long groupId) {
0a9893ad   夏天   fix-bug
1067
  
a78dc8be   张志伟   feature(*): 查询的bug修复
1068
1069
          List<BasicsCustomerDTO> list = fromCustomer(keyword, groupId);
          if (CollectionUtils.isNotEmpty(list)) {
0a9893ad   夏天   fix-bug
1070
1071
1072
1073
1074
1075
              return list;
          }
          return fromVehicle(keyword);
      }
  
  
a78dc8be   张志伟   feature(*): 查询的bug修复
1076
      private List<BasicsCustomerDTO> fromCustomer(String keyword, Long groupId) {
1983befb   张志伟   feat(api): :spark...
1077
1078
          List<BasicsCustomerDTO> list = customerService.queryByKeyword(keyword, groupId);
          for (BasicsCustomerDTO dto : list) {
3fc19e59   张志伟   升级erpsdk
1079
              UserInfoDTO user = ehrRpcService.user(dto.getAdviserId());
1983befb   张志伟   feat(api): :spark...
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
              if (Objects.nonNull(user)) {
                  dto.setAdviserName(user.getUserName());
              }
              ShopDTO shop = oopService.shop(dto.getShopId());
              if (Objects.nonNull(shop)) {
                  dto.setShopName(shop.getShortName());
              }
          }
          return list;
      }
  
a78dc8be   张志伟   feature(*): 查询的bug修复
1091
      private List<BasicsCustomerDTO> fromVehicle(String keyword) {
0a9893ad   夏天   fix-bug
1092
1093
          return memberVehicleService.queryByKeyword(keyword);
      }
a78dc8be   张志伟   feature(*): 查询的bug修复
1094
  
ede61714   夏天   新增会员认证车辆接口
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
      public List<MemberVehicleDTO> queryVehicleByMemberId(Long memberId) {
          List<MemberVehicle> memberVehicleList = memberVehicleService.getMemberVehicle(memberId);
          if (CollectionUtils.isEmpty(memberVehicleList)) {
              return Collections.emptyList();
          }
          return memberVehicleList.stream().map(v -> {
              MemberVehicleDTO dto = BeanUtils.copy(v, MemberVehicleDTO.class);
              dto.setCusType(v.getCusType().getValue());
              dto.setUseType(v.getUseType().getValue());
              return dto;
          }).collect(Collectors.toList());
  
      }
  
2b5a0035   夏天   调整车辆认证逻辑
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
      public MemberVehicleDTO queryVehicleByVin(String vin) {
          MemberVehicle memberVehicle = memberVehicleService.getVehicle(vin);
          if (Objects.isNull(memberVehicle)) {
              return null;
          }
          MemberVehicleDTO dto = BeanUtils.copy(memberVehicle, MemberVehicleDTO.class);
          dto.setCusType(memberVehicle.getCusType().getValue());
          dto.setUseType(memberVehicle.getUseType().getValue());
          MemberUserDTO member = memberRpcService.user(memberVehicle.getMemberId());
          dto.setMemberPhone(Objects.nonNull(member) ? member.getPhone() : null);
          return dto;
      }
  
1983befb   张志伟   feat(api): :spark...
1122
  
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
1123
      private AffiliationRecord createEntity(CustomerDetailDto customer) {
612d25d9   张志伟   :art:
1124
1125
1126
1127
          AffiliationRecord record = new AffiliationRecord();
          record.setCustomerId(customer.getId());
          record.setType(CustomerChangeTypeEnum.DEFEAT);
          record.setDefeatTime(DateUtil.localDateTime2Date(LocalDateTime.now()));
612d25d9   张志伟   :art:
1128
1129
          record.setOriginUserId(customer.getAdviserId());
          record.setOriginShopId(customer.getShopId());
612d25d9   张志伟   :art:
1130
1131
1132
          record.setCreateTime(DateUtil.localDateTime2Date(LocalDateTime.now()));
          return record;
      }
8f9a8d4d   张志伟   :art:
1133
  
4a791946   张志伟   :bug:
1134
1135
1136
1137
1138
1139
      private CarArchiveVO.DealerItem createDeal(Long shopId) {
          //没有商家这个概念 这里主要是兼容之前的小程序代码
          ShopDTO shop = oopService.shop(shopId);
          if (Objects.isNull(shop)) {
              return null;
          }
8f9a8d4d   张志伟   :art:
1140
          CarArchiveVO.DealerItem vo = CarArchiveVO.createDealerItem();
4af298c8   张志伟   :bug:
1141
1142
          vo.setId(shop.getDealerId());
          vo.setName(shop.getDealerName());
8f9a8d4d   张志伟   :art:
1143
1144
1145
1146
1147
1148
1149
1150
          vo.setLogo(shop.getShopLogo());
          vo.setPhone(shop.getTel());
          vo.setAddr(shop.getAddr());
          vo.setLat(shop.getLat());
          vo.setLng(shop.getLng());
          vo.setDistance(0.0);
          return vo;
      }
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
1151
  
7c9f5c47   张志伟   :art:
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
      private void saveLoanInfo(Long groupId, String vin, int periods, Date expires) {
          try {
              CustomerLoanInfo loanInfo = customerLoanInfoService.getOne(Wrappers.<CustomerLoanInfo>lambdaQuery()
                      .eq(CustomerLoanInfo::getFrameNo, vin)
                      .eq(CustomerLoanInfo::getGroupId, groupId)
                      .last(" limit 1")
              );
              if (Objects.nonNull(loanInfo)) {
                  return;
              }
              loanInfo = new CustomerLoanInfo();
              loanInfo.setFrameNo(vin);
              loanInfo.setPeriods(periods);
              loanInfo.setExpires(expires);
              loanInfo.setGroupId(groupId);
              customerLoanInfoService.save(loanInfo);
          } catch (Exception e) {
              log.error("新增客户贷款信息失败:", e);
          }
      }
37a9df0d   张志伟   :bug:
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
  
      private void loanCustomer(CarArchiveVO vo) {
          CustomerLoanInfo loanInfo = customerLoanInfoService.getOne(Wrappers.<CustomerLoanInfo>lambdaQuery()
                  .eq(CustomerLoanInfo::getGroupId, vo.getGroupId())
                  .eq(CustomerLoanInfo::getFrameNo, vo.getFrameNo())
                  .last(" limit 1 ")
          );
          if (Objects.nonNull(loanInfo)) {
              vo.setLoanCustomer(LocalDate.now().isBefore(DateUtil.date2LocalDate(loanInfo.getExpires())));
              vo.setExpires(loanInfo.getExpires());
              vo.setPeriods(loanInfo.getPeriods());
          }
      }
03c1a9b3   张志伟   :sparkles:
1185
1186
  
      private CustomCustomerQuery fillParams(final CustomerQueryReq queryReq) {
499f5f26   张志伟   :sparkles:
1187
          BV.notNull(queryReq.getGroupId(), () -> "集团id不能为空");
03c1a9b3   张志伟   :sparkles:
1188
1189
          CustomCustomerQuery query = new CustomCustomerQuery();
          BeanUtils.copyProperties(queryReq, query);
5b538595   张志伟   feature(*): 新增查询线...
1190
          query.setIncludePublic(Boolean.TRUE.equals(queryReq.getIncludePublic()));
03c1a9b3   张志伟   :sparkles:
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
          if (queryReq.getArrivalMileage() != null && queryReq.getArrivalMileage().length > 0) {
              for (int i = 0; i < queryReq.getArrivalMileage().length; i++) {
                  if (i == 0) {
                      query.setMinMileage(queryReq.getArrivalMileage()[i]);
                  }
                  if (i == 1) {
                      query.setMaxMileage(queryReq.getArrivalMileage()[i]);
                  }
              }
          }
  
          if (queryReq.getAgeLimit() != null && queryReq.getAgeLimit().length > 0) {
              for (int i = 0; i < queryReq.getAgeLimit().length; i++) {
                  if (i == 0) {
                      query.setMaxBuyDate(LocalDate.now().plusYears(-1L * queryReq.getAgeLimit()[i]));
                  }
                  if (i == 1) {
                      query.setMinBuyDate(LocalDate.now().plusYears(-1L * queryReq.getAgeLimit()[i]));
                  }
              }
          }
  
          if (Objects.nonNull(queryReq.getFollowType())) {
              query.setFollowType(queryReq.getFollowType().getValue());
          }
a78dc8be   张志伟   feature(*): 查询的bug修复
1216
1217
1218
1219
1220
1221
          boolean b = (Objects.nonNull(query.getMinMileage()) && Objects.nonNull(query.getMaxMileage()))
                  || (Objects.nonNull(query.getMinBuyDate()) && Objects.nonNull(query.getMaxBuyDate()))
                  || Objects.nonNull(query.getLevel());
          if (!b) {
              query.setAndCondition(true);
          }
03c1a9b3   张志伟   :sparkles:
1222
1223
1224
  
          return query;
      }
9e476657   张志伟   :art:
1225
  }