Blame view

fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java 50.2 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;
3bddceac   夏天   查询保有客档案sdk
38
39
  import cn.fw.valhalla.sdk.param.*;
  import cn.fw.valhalla.sdk.result.*;
66271e22   张志伟   :sparkles:
40
  import cn.fw.valhalla.service.bus.StammkundeBizService;
d9ece85a   张志伟   :sparkles:
41
  import cn.fw.valhalla.service.bus.setting.SettingBizService;
abc1b038   张志伟   :art:
42
  import cn.fw.valhalla.service.data.*;
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
43
  import cn.fw.valhalla.service.event.PublicPoolEvent;
27223d59   张志伟   :bug:
44
  import cn.fw.valhalla.service.event.StopTaskEvent;
67ad6e9a   张志伟   :art:
45
46
  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
d9ece85a   张志伟   :sparkles:
47
  import lombok.Getter;
8587e21d   张志伟   :art:
48
  import lombok.RequiredArgsConstructor;
9e476657   张志伟   :art:
49
  import lombok.extern.slf4j.Slf4j;
d9ece85a   张志伟   :sparkles:
50
  import org.springframework.beans.factory.annotation.Value;
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
51
  import org.springframework.context.ApplicationEventPublisher;
9e476657   张志伟   :art:
52
  import org.springframework.stereotype.Service;
6c848e1d   张志伟   :art:
53
  import org.springframework.transaction.annotation.Transactional;
9e476657   张志伟   :art:
54
  
37a9df0d   张志伟   :bug:
55
  import java.time.LocalDate;
612d25d9   张志伟   :art:
56
  import java.time.LocalDateTime;
6c848e1d   张志伟   :art:
57
  import java.util.*;
67ad6e9a   张志伟   :art:
58
59
60
  import java.util.stream.Collectors;
  
  import static cn.fw.common.businessvalidator.Validator.BV;
e729660d   夏天   新增sdk接口
61
  import static cn.fw.common.businessvalidator.Validator.V;
8b00f03a   张志伟   :sparkles:
62
  import static cn.fw.valhalla.service.bus.setting.strategy.SettingStrategy.COMMON_BRAND_ID;
67ad6e9a   张志伟   :art:
63
  
9e476657   张志伟   :art:
64
65
66
67
68
69
70
71
  /**
   * @author : kurisu
   * @className : CustomerBizService
   * @description : 档案
   * @date: 2020-08-12 13:57
   */
  @Service
  @Slf4j
8587e21d   张志伟   :art:
72
  @RequiredArgsConstructor
a4bb750a   张志伟   :art:
73
  public class CustomerBizService extends AbstractCustomerService {
67ad6e9a   张志伟   :art:
74
      /**
a4bb750a   张志伟   :art:
75
       * 关注公众号服务
67ad6e9a   张志伟   :art:
76
       */
a4bb750a   张志伟   :art:
77
78
      private final WechatSubscribeService wechatSubscribeService;
  
52e0b048   张志伟   :art:
79
      /**
a4bb750a   张志伟   :art:
80
       * 加入企业微信服务
52e0b048   张志伟   :art:
81
       */
a4bb750a   张志伟   :art:
82
      private final CompanyWechatJoinService companyWechatJoinService;
6c848e1d   张志伟   :art:
83
      private final MemberRpcService memberRpcService;
612d25d9   张志伟   :art:
84
      private final AffiliationRecordService affiliationRecordService;
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
85
86
      private final PublicPoolService publicPoolService;
      private final ApplicationEventPublisher eventPublisher;
abc1b038   张志伟   :art:
87
      private final CustomerReachLogService customerReachLogService;
d9ece85a   张志伟   :sparkles:
88
      private final SettingBizService settingBizService;
258779e5   张志伟   :sparkles:
89
      private final FollowRecordService followRecordService;
66271e22   张志伟   :sparkles:
90
      private final StammkundeBizService stammkundeBizService;
e729660d   夏天   新增sdk接口
91
      private final OopService oopService;
93b833c9   夏天   新增会员认证车辆接口
92
      private final MemberVehicleService memberVehicleService;
55003764   张志伟   feature(*): 售后crm...
93
      private final FollowClueService followClueService;
d9ece85a   张志伟   :sparkles:
94
95
96
97
  
      @Value("${spring.cache.custom.global-prefix}:customer")
      @Getter
      private String keyPrefix;
6c848e1d   张志伟   :art:
98
  
67ad6e9a   张志伟   :art:
99
100
101
      /**
       * app分页查询档案
       *
67ad6e9a   张志伟   :art:
102
103
104
       * @param queryVO
       * @return
       */
29c2dade   张志伟   :alien:
105
      public AppPage<CustomerListVO> getList(CustomerQueryVO queryVO) {
67ad6e9a   张志伟   :art:
106
107
          queryVO.setCurrent(queryVO.getCurrent() > 0 ? queryVO.getCurrent() : 1);
          Integer startIndex = (queryVO.getCurrent() - 1) * queryVO.getPageSize();
66271e22   张志伟   :sparkles:
108
109
110
111
          if (Boolean.TRUE.equals(queryVO.getFromReport())) {
              StammkundeAnalyseQueryVO analyseQueryVO = new StammkundeAnalyseQueryVO();
              analyseQueryVO.setTimeHorizon(queryVO.getTimeHorizon());
              analyseQueryVO.setFollowType(queryVO.getFollowType());
872d062f   张志伟   :sparkles:
112
              analyseQueryVO.setUnderway(queryVO.getUnderway());
66271e22   张志伟   :sparkles:
113
114
115
              analyseQueryVO.setLat(queryVO.getLat());
              analyseQueryVO.setLng(queryVO.getLng());
              analyseQueryVO.setRadius(queryVO.getRadius());
872d062f   张志伟   :sparkles:
116
              analyseQueryVO.setGroupId(queryVO.getGroupId());
66271e22   张志伟   :sparkles:
117
118
119
120
121
122
123
              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:
124
125
126
127
128
129
130
131
          List<CustomerListVO> appPageList = customerService.getAppPageList(startIndex, queryVO.getPageSize(), queryVO);
          AppPage<CustomerListVO> page = AppPage.empty(queryVO);
          page.setData(appPageList);
          return page;
      }
  
      /**
       * 根据档案id查询详情
52e0b048   张志伟   :art:
132
       *
67ad6e9a   张志伟   :art:
133
134
135
136
       * @param cusId
       * @return
       */
      public CustomerDetailVO getDetailById(final Long cusId) {
91c29e23   张志伟   :fire:
137
          CustomerDetailDto detailDto = queryById(cusId);
ce8f48d3   张志伟   :art:
138
          BV.notNull(detailDto, () -> "查无此档案");
23d2554b   张志伟   :sparkles:
139
          BV.isTrue(detailDto.getYn(), () -> "此档案已经作废,无法再继续查看");
67ad6e9a   张志伟   :art:
140
          CustomerDetailVO vo = new CustomerDetailVO();
67ad6e9a   张志伟   :art:
141
          BeanUtils.copyProperties(detailDto, vo);
bbd11506   张志伟   :art:
142
          vo.setRealMobile(detailDto.getMobile());
3ed89012   张志伟   :art:
143
          vo.setOrgCode(detailDto.getIdCode());
b27b4375   张志伟   :sparkles:
144
145
146
147
148
149
          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:
150
151
152
153
          return vo;
      }
  
      /**
8b050f87   张志伟   fix(*): 优化逻辑
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
       * 根据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:
179
       * 根据ID查询档案基本信息
52e0b048   张志伟   :art:
180
       *
a4bb750a   张志伟   :art:
181
       * @param id
67ad6e9a   张志伟   :art:
182
183
       * @return
       */
a4bb750a   张志伟   :art:
184
      public VehicleRecordVO getCarInfoById(Long id) {
6c848e1d   张志伟   :art:
185
          final VehicleRecordVO vo = new VehicleRecordVO();
a4bb750a   张志伟   :art:
186
          Customer customer = customerService.queryById(id);
ce8f48d3   张志伟   :art:
187
          BV.notNull(customer, () -> "查无此档案");
a4bb750a   张志伟   :art:
188
189
          CustomerDetailDto detailDto = renderDto(customer);
          BeanUtils.copyProperties(detailDto, vo);
6c848e1d   张志伟   :art:
190
191
192
193
194
195
          Optional<InsuranceDTO> dtoOptional = queryInsuInfo(customer.getId());
          dtoOptional.ifPresent(t -> {
              vo.setInsurCompanyId(t.getInsurerId());
              vo.setInsurCompanyName(t.getInsurerName());
              vo.setInsurExpireDate(t.getExpiryDate());
          });
468d72b7   张志伟   :sparkles:
196
197
198
199
200
201
          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:
202
203
          return vo;
      }
67ad6e9a   张志伟   :art:
204
  
a4bb750a   张志伟   :art:
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
      /**
       * 根据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:
227
228
      }
  
6c848e1d   张志伟   :art:
229
230
231
232
233
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
      /**
       * 根据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:
260
261
262
263
264
265
266
267
268
269
270
       * 批量查询保有客档案
       *
       * @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
271
272
273
274
275
276
277
  
          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:
278
279
280
          return customers.stream().map(customer -> {
              CustomerInfoDto customerInfoDto = new CustomerInfoDto();
              BeanUtils.copyProperties(customer, customerInfoDto);
e857bc1b   夏天   fix-bug
281
282
283
284
              customerInfoDto.setId(customer.getId());
              if (Objects.nonNull(customer.getBaseId())) {
                  customerInfoDto.setMemberId(baseInfoMap.getOrDefault(customer.getBaseId(), null));
              }
67ad6e9a   张志伟   :art:
285
286
287
288
289
290
              customerInfoDto.setCreateTime(customer.getCreateTime());
              customerInfoDto.setConsultantId(customer.getAdviserId());
              return customerInfoDto;
          }).collect(Collectors.toList());
      }
  
67ad6e9a   张志伟   :art:
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
      /**
       * 查询会员对应保有客的商家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:
319
  
758162a4   张志伟   :art:
320
      /**
7dcb5c8d   张志伟   🚑 新增修改车型代码SDK接口
321
322
323
324
325
       * 修改车型代码
       *
       * @param customerId
       * @param specCode
       * @return
e5880775   张志伟   :rocket:
326
       * @deprecated
7dcb5c8d   张志伟   🚑 新增修改车型代码SDK接口
327
       */
e5880775   张志伟   :rocket:
328
      @Deprecated
7dcb5c8d   张志伟   🚑 新增修改车型代码SDK接口
329
330
331
332
333
334
335
336
      public boolean modifySpecCode(Long customerId, String specCode) {
          Customer customer = customerService.queryById(customerId);
          BV.notNull(customer, () -> "档案不存在");
          customer.setSpecCode(specCode);
          return customerService.updateById(customer);
      }
  
      /**
e5880775   张志伟   :rocket:
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
       * 修改车型代码
       *
       * @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:
356
357
358
       * 查询能否接车
       *
       * @param userId
7c9f5c47   张志伟   :art:
359
       * @param plateNo
fd45b634   张志伟   :bug:
360
361
       * @return
       */
7c9f5c47   张志伟   :art:
362
      public ReceptionResultDto queryReceivable(Long userId, String plateNo) {
3fc19e59   张志伟   升级erpsdk
363
          UserInfoDTO userInfo = ehrRpcService.user(userId);
7c9f5c47   张志伟   :art:
364
365
366
          if (Objects.isNull(userInfo)) {
              return new ReceptionResultDto(false, "非服务顾问无法接待");
          }
fd45b634   张志伟   :bug:
367
368
369
370
          List<UserRoleDataRangeDTO> dataRange = userService.getUserRoleDataRange(userId, RoleCode.FWGW);
          if (CollectionUtils.isEmpty(dataRange)) {
              return new ReceptionResultDto(false, "非服务顾问无法接待");
          }
7c9f5c47   张志伟   :art:
371
372
373
374
375
376
377
378
          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
379
  
fd45b634   张志伟   :bug:
380
381
382
          boolean bool = affiliationRecordService.count(Wrappers.<AffiliationRecord>lambdaQuery()
                  .eq(AffiliationRecord::getType, CustomerChangeTypeEnum.DEFEAT)
                  .eq(AffiliationRecord::getOriginUserId, userId)
7c9f5c47   张志伟   :art:
383
384
                  .eq(AffiliationRecord::getCustomerId, customer.getId())
                  .ge(AffiliationRecord::getDefeatTime, DateUtil.getNowExpiredMonth(-12))
fd45b634   张志伟   :bug:
385
386
387
388
          ) > 0;
          if (bool) {
              return new ReceptionResultDto(false, "无法接待由你战败的客户");
          }
fd45b634   张志伟   :bug:
389
390
391
          return new ReceptionResultDto(true, "");
      }
  
e729660d   夏天   新增sdk接口
392
      public List<Long> queryIllegalAdviser(Long cusId) {
7ad0be67   夏天   新增sdk接口
393
394
395
396
          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接口
397
          if (CollectionUtils.isEmpty(list)) {
7ad0be67   夏天   新增sdk接口
398
399
400
401
402
              return Collections.emptyList();
          }
          return list.stream().map(AffiliationRecord::getOriginUserId).distinct().collect(Collectors.toList());
      }
  
fd45b634   张志伟   :bug:
403
      /**
758162a4   张志伟   :art:
404
405
406
407
408
       * 根据档案id查询详情
       *
       * @param cusId
       * @return
       */
91c29e23   张志伟   :fire:
409
410
      public CustomerDetailDto queryById(final Long cusId) {
          Customer customer = customerService.queryById(cusId);
758162a4   张志伟   :art:
411
412
413
414
415
416
417
          if (Objects.isNull(customer)) {
              return null;
          }
          return renderDto(customer);
      }
  
      /**
03c1a9b3   张志伟   :sparkles:
418
       * 根据自定义条件查询保有客档案
5b538595   张志伟   feature(*): 新增查询线...
419
       * 市场活动用
03c1a9b3   张志伟   :sparkles:
420
421
422
423
424
       *
       * @param queryReq
       * @return
       */
      public List<CustomerDetailDto> queryCustomList(final CustomerQueryReq queryReq) {
03c1a9b3   张志伟   :sparkles:
425
          CustomCustomerQuery query = fillParams(queryReq);
03c1a9b3   张志伟   :sparkles:
426
427
428
429
          return customerService.queryCustomList(query);
      }
  
      /**
1ca0a771   张志伟   新增查询档案数量接口
430
431
432
433
434
435
436
437
438
439
440
       * 根据自定义条件查询保有客档案数量
       *
       * @param queryReq
       * @return
       */
      public Long queryCustomCount(final CustomerQueryReq queryReq) {
          CustomCustomerQuery query = fillParams(queryReq);
          return customerService.queryCustomListCount(query);
      }
  
      /**
758162a4   张志伟   :art:
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
       * 根据手机号查询所有档案
       *
       * @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%
464
465
466
467
468
469
470
       * 放弃客户
       *
       * @param customerId
       * @param reason
       */
      @Transactional(rollbackFor = Exception.class)
      public void abandon(final Long customerId, final String reason) {
91c29e23   张志伟   :fire:
471
          CustomerDetailDto detailDto = queryById(customerId);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
472
          BV.notNull(detailDto, () -> "档案不存在");
33a55d43   张志伟   feature(*): bug修复
473
474
          PublicPool publicData = publicPoolService.queryByVin(detailDto.getFrameNo(), detailDto.getGroupId());
          if (Objects.nonNull(publicData)) {
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
475
476
477
478
479
480
481
482
483
484
485
              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 调整保有客池查...
486
          entity.setReason(DefeatReasonEnum.GU.getName());
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
487
          affiliationRecordService.save(entity);
27223d59   张志伟   :bug:
488
          publicPoolService.save(publicPool);
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
489
          stammkundePoolService.reject(customerId, detailDto.getGroupId(), DefeatReasonEnum.GU);
d9ece85a   张志伟   :sparkles:
490
          publicCluePoolService.removeClue(customerId, detailDto.getAdviserId());
55003764   张志伟   feature(*): 售后crm...
491
          PublicPoolEvent poolEvent = new PublicPoolEvent(detailDto.getFrameNo(), detailDto.getGroupId());
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
492
          eventPublisher.publishEvent(poolEvent);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
493
494
495
      }
  
      /**
55003764   张志伟   feature(*): 售后crm...
496
       * 审批通过客户档案处理
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
497
498
499
       *
       * @param task
       */
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
500
      @Transactional(rollbackFor = Exception.class)
55003764   张志伟   feature(*): 售后crm...
501
      public void abandon(final ClueTask task) {
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
502
503
504
          List<FollowTypeEnum> typeList = Arrays.asList(FollowTypeEnum.AC, FollowTypeEnum.IR);
          HashSet<FollowTypeEnum> set = new HashSet<>(typeList);
          if (set.contains(task.getType())) {
27223d59   张志伟   :bug:
505
506
              StopTaskEvent stopTaskEvent = new StopTaskEvent(task);
              eventPublisher.publishEvent(stopTaskEvent);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
507
508
              return;
          }
55003764   张志伟   feature(*): 售后crm...
509
510
511
512
513
          FollowClue followClue = followClueService.getById(task.getClueId());
          if (Objects.isNull(followClue)) {
              return;
          }
          CustomerDetailDto detailDto = queryByFrameNo(followClue.getVin(), followClue.getGroupId());
36815308   张志伟   :bug:
514
515
516
          if (Objects.isNull(detailDto)) {
              return;
          }
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
517
518
519
520
          PublicPoolTypeEnum type = PublicPoolTypeEnum.FM;
          if (FollowTypeEnum.RM.equals(task.getType())) {
              type = PublicPoolTypeEnum.RM;
          }
33a55d43   张志伟   feature(*): bug修复
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
          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:
539
540
              return;
          }
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
541
542
543
544
          PublicPool publicPool = createPublicPool(detailDto, type, "系统判定");
          boolean updated = customerService.update(Wrappers.<Customer>lambdaUpdate()
                  .set(Customer::getAdviserId, null)
                  .set(Customer::getShopId, null)
55003764   张志伟   feature(*): 售后crm...
545
                  .eq(Customer::getId, detailDto.getId()));
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
546
547
548
          if (!updated) {
              return;
          }
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
549
          AffiliationRecord entity = createEntity(detailDto);
55003764   张志伟   feature(*): 售后crm...
550
          entity.setReason(DefeatReasonEnum.GU.getName());
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
551
          affiliationRecordService.save(entity);
27223d59   张志伟   :bug:
552
          publicPoolService.save(publicPool);
33a55d43   张志伟   feature(*): bug修复
553
          stammkundePoolService.reject(detailDto.getId(), groupId, DefeatReasonEnum.GU);
55003764   张志伟   feature(*): 售后crm...
554
          publicCluePoolService.removeClue(detailDto.getId(), detailDto.getAdviserId());
18a818bd   张志伟   :construction:
555
  
33a55d43   张志伟   feature(*): bug修复
556
          PublicPoolEvent poolEvent = new PublicPoolEvent(detailDto.getFrameNo(), groupId);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
557
          eventPublisher.publishEvent(poolEvent);
03b7b995   张志伟   ✨ 公共池后端逻辑 100%
558
559
560
      }
  
      /**
b62ab7af   张志伟   feature(*): 公共池跟进联调
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
       * 任务结束战败客户到公共池
       *
       * @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
579
                  .set(Customer::getTemporary, null)
b62ab7af   张志伟   feature(*): 公共池跟进联调
580
581
582
583
584
585
586
587
                  .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修复
588
589
590
591
592
593
          if (Objects.isNull(entity.getOriginUserId())) {
              entity.setOriginUserId(task.getFollowUser());
          }
          if (Objects.isNull(entity.getOriginShopId())) {
              entity.setOriginShopId(task.getFollowShop());
          }
b62ab7af   张志伟   feature(*): 公共池跟进联调
594
          affiliationRecordService.save(entity);
33a55d43   张志伟   feature(*): bug修复
595
596
          PublicPool publicData = publicPoolService.queryByVin(detailDto.getFrameNo(), detailDto.getGroupId());
          if (Objects.nonNull(publicData)) {
b62ab7af   张志伟   feature(*): 公共池跟进联调
597
598
599
600
601
602
603
              return;
          }
          PublicPool publicPool = createPublicPool(detailDto, type, "跟进超期");
          publicPoolService.save(publicPool);
      }
  
      /**
9de0e2d7   张志伟   feature(*): 公共池线索...
604
605
606
607
608
609
610
611
612
613
614
615
616
617
       * 公共池跟进任务结束战败客户到公共池
       *
       * @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
618
                  .set(Customer::getTemporary, null)
9de0e2d7   张志伟   feature(*): 公共池线索...
619
620
621
622
623
624
625
626
627
                  .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修复
628
629
          PublicPool publicData = publicPoolService.queryByVin(detailDto.getFrameNo(), detailDto.getGroupId());
          if (Objects.nonNull(publicData)) {
9de0e2d7   张志伟   feature(*): 公共池线索...
630
631
632
633
634
635
636
              return;
          }
          PublicPool publicPool = createPublicPool(detailDto, PublicPoolTypeEnum.PD, PublicPoolTypeEnum.PD.getName());
          publicPoolService.save(publicPool);
      }
  
      /**
c4fb2fa5   张志伟   ✨ 公共池接口 100%
637
       * 继续跟进
9de0e2d7   张志伟   feature(*): 公共池线索...
638
       *
c4fb2fa5   张志伟   ✨ 公共池接口 100%
639
640
       * @param currentUser
       * @param customerId
9de0e2d7   张志伟   feature(*): 公共池线索...
641
       * @deprecated
c4fb2fa5   张志伟   ✨ 公共池接口 100%
642
       */
8a272b22   张志伟   :sparkles:
643
      @DisLock(prefix = "#this.getKeyPrefix()", key = "'continueFollow:' + #customerId", message = "请勿重复提交")
c4fb2fa5   张志伟   ✨ 公共池接口 100%
644
645
646
647
648
      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:
649
              publicPoolService.removeByCustomerId(customerId, currentUser.getGroupId());
c4fb2fa5   张志伟   ✨ 公共池接口 100%
650
651
              throw new BusinessException("档案信息有误,请刷新后重试");
          }
8a272b22   张志伟   :sparkles:
652
653
654
655
656
657
          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:
658
          Optional<SettingVO> voOptional = settingBizService.querySettingByType(FollowTypeEnum.OT, SettingTypeEnum.PUBLIC_VALID_DAY, currentUser.getGroupId(), COMMON_BRAND_ID);
1943d0bc   张志伟   feature(*): 公共线索池
659
660
661
          SettingVO settingVO = voOptional.orElse(null);
          BV.notNull(settingVO, () -> "设置获取失败");
          UserRoleDataRangeDTO rangeDTO = dataRange.get(0);
8a272b22   张志伟   :sparkles:
662
          publicPoolService.removeByCustomerId(customerId, currentUser.getGroupId());
1943d0bc   张志伟   feature(*): 公共线索池
663
664
665
          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:
666
          }
c4fb2fa5   张志伟   ✨ 公共池接口 100%
667
668
669
      }
  
      /**
ad93e14a   张志伟   :art:
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
       * 根据车牌号查询所有档案
       *
       * @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:
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
       * 根据车架号号查询所有档案
       *
       * @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   夏天   新增会员认证车辆接口
700
       * 根据车架号号查询车辆信息
e729660d   夏天   新增sdk接口
701
702
       *
       * @param frameNo 车架号
ede61714   夏天   新增会员认证车辆接口
703
       * @param shopId  门店id
93b833c9   夏天   新增会员认证车辆接口
704
       * @return 车辆信息
e729660d   夏天   新增sdk接口
705
       */
93b833c9   夏天   新增会员认证车辆接口
706
      public CustomerDetailDto queryVehicleByFrameNo(final String frameNo, final Long shopId) {
e729660d   夏天   新增sdk接口
707
          ShopDTO shop = oopService.shop(shopId);
93b833c9   夏天   新增会员认证车辆接口
708
          V.notNull(shop, String.format("未查询到门店%d信息", shopId));
e729660d   夏天   新增sdk接口
709
          Customer customer = customerService.queryByFrameNo(frameNo, shop.getGroupId());
93b833c9   夏天   新增会员认证车辆接口
710
          if (Objects.isNull(customer)) {
9eeda572   夏天   新增会员认证车辆接口
711
              MemberVehicle memberVehicle = memberVehicleService.getVehicle(frameNo);
93b833c9   夏天   新增会员认证车辆接口
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
              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   夏天   新增会员认证车辆接口
728
                          .eq(Customer::getGroupId, shop.getGroupId()).eq(Customer::getShopId, shopId)
93b833c9   夏天   新增会员认证车辆接口
729
730
731
732
733
734
735
                          .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
736
                  UserInfoDTO user = ehrRpcService.user(customers.get(0).getAdviserId());
93b833c9   夏天   新增会员认证车辆接口
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
                  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   夏天   新增会员认证车辆接口
754
                          .eq(Customer::getGroupId, shop.getGroupId()).eq(Customer::getShopId, shopId)
93b833c9   夏天   新增会员认证车辆接口
755
756
757
758
759
760
761
                          .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
762
                  UserInfoDTO user = ehrRpcService.user(customers.get(0).getAdviserId());
93b833c9   夏天   新增会员认证车辆接口
763
764
765
766
767
                  if (Objects.nonNull(user)) {
                      dto.setAdviserName(user.getUserName());
                  }
                  return dto;
              }
e729660d   夏天   新增sdk接口
768
          }
93b833c9   夏天   新增会员认证车辆接口
769
770
771
772
773
          CustomerDetailDto dto = renderDto(customer);
          if (!Objects.equals(customer.getShopId(), shopId)) {
              dto.setShopId(null);
              dto.setAdviserId(null);
              dto.setAdviserName(null);
e729660d   夏天   新增sdk接口
774
          }
2fe30da1   夏天   fix-bug
775
776
777
778
          if (Objects.nonNull(customer) && Objects.isNull(customer.getRegDate())) {
              MemberVehicle memberVehicle = memberVehicleService.getVehicle(frameNo);
              customer.setRegDate(Objects.nonNull(memberVehicle) ? memberVehicle.getRegDate() : null);
          }
93b833c9   夏天   新增会员认证车辆接口
779
          return dto;
e729660d   夏天   新增sdk接口
780
781
782
783
      }
  
  
      /**
3145890c   张志伟   :alien:
784
785
786
787
788
789
790
791
792
793
794
795
796
797
       * 根据发动机号查询所有档案
       *
       * @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:
798
  
3145890c   张志伟   :alien:
799
      /**
758162a4   张志伟   :art:
800
801
802
803
804
       * 是否关联了档案
       *
       * @param customerParams
       * @return
       */
08704989   张志伟   :art:
805
      @Transactional(rollbackFor = Exception.class)
758162a4   张志伟   :art:
806
      public Boolean save4api(final CustomerParams customerParams) {
3cdf5c0c   张志伟   :fire:
807
808
809
810
          final String plateNo = customerParams.getPlateNo();
          final String frameNo = customerParams.getFrameNo();
          final Long groupId = customerParams.getGroupId();
  
758162a4   张志伟   :art:
811
          Customer customer = customerService.queryByPlateNo(plateNo, groupId);
e56e5bb4   张志伟   :art:
812
          BV.isNull(customer, "该车牌号对应的档案已存在");
3cdf5c0c   张志伟   :fire:
813
814
          customer = customerService.queryByFrameNo(frameNo, groupId);
          BV.isNull(customer, "该车辆已存在档案");
758162a4   张志伟   :art:
815
816
817
  
          CustomerBaseInfo baseInfo = new CustomerBaseInfo();
          BeanUtils.copyProperties(customerParams, baseInfo);
a36ab512   张志伟   :bug:
818
          baseInfo.setContact(customerParams.getName());
758162a4   张志伟   :art:
819
820
821
822
823
          baseInfo.setYn(Boolean.TRUE);
          baseInfo.setCreateTime(new Date());
          baseInfo.setUpdateTime(new Date());
  
          customer = new Customer();
3cdf5c0c   张志伟   :fire:
824
825
826
827
828
829
830
831
832
833
834
835
          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:
836
          BeanUtils.copyProperties(customerParams, customer);
2cb94832   张志伟   :sparkles:
837
          customer.setSpecCode(customerParams.getSpecCode());
758162a4   张志伟   :art:
838
839
840
          customer.setCreateTime(new Date());
          customer.setUpdateTime(new Date());
          customer.setYn(Boolean.TRUE);
ccee7886   张志伟   feature(*): 修复bug
841
          customer.setTemporary(Boolean.FALSE);
758162a4   张志伟   :art:
842
843
          final SpecDTO spec = oopService.spec(customerParams.getSpecId());
          customer.setCarImage(Optional.ofNullable(spec).orElse(new SpecDTO()).getThumbnail());
3cdf5c0c   张志伟   :fire:
844
          customer.setShopId(casShopId);
b27b4375   张志伟   :sparkles:
845
          Long cid = saveNewOne(customer, baseInfo, true);
7c9f5c47   张志伟   :art:
846
847
848
849
          CustomerParams.LoanInfo loanInfo = customerParams.getLoanInfo();
          if (Objects.nonNull(loanInfo)) {
              saveLoanInfo(customer.getGroupId(), customer.getFrameNo(), loanInfo.getPeriods(), loanInfo.getExpires());
          }
376d3231   张志伟   ✨ 主动放弃跟进 100%
850
          return Objects.nonNull(cid);
758162a4   张志伟   :art:
851
852
      }
  
d1deb950   张志伟   :bug:
853
854
      /**
       * 更新购车日期
a78dc8be   张志伟   feature(*): 查询的bug修复
855
       *
d1deb950   张志伟   :bug:
856
857
858
859
860
861
862
863
864
865
866
867
868
869
       * @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:
870
871
872
873
874
875
876
877
878
      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:
879
      /**
8f9a8d4d   张志伟   :art:
880
881
882
883
884
885
886
       * 查询所有字段
       *
       * @param memberId
       * @return
       */
      public List<CarArchiveVO> defaultCustomer(final Long memberId) {
          if (Objects.isNull(memberId)) {
4af3c6d3   张志伟   :art:
887
              return new ArrayList<>();
8f9a8d4d   张志伟   :art:
888
889
890
          }
          final MemberUserDTO user = memberRpcService.user(memberId);
          if (Objects.isNull(user)) {
4af3c6d3   张志伟   :art:
891
              return new ArrayList<>();
8f9a8d4d   张志伟   :art:
892
893
894
          }
          List<CustomerBaseInfo> baseList = this.customerBaseInfoService.list(Wrappers.<CustomerBaseInfo>lambdaQuery()
                  .eq(CustomerBaseInfo::getMemberId, memberId)
8f9a8d4d   张志伟   :art:
895
896
897
898
                  .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:
899
              return new ArrayList<>();
8f9a8d4d   张志伟   :art:
900
901
902
903
904
905
906
907
908
909
910
          }
  
          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
911
                          UserInfoDTO dto = ehrRpcService.user(vo.getAdviserId());
b6d1888d   张志伟   :art:
912
913
914
                          if (Objects.nonNull(dto)) {
                              vo.setAdviserName(dto.getUserName());
                          }
0702edee   张志伟   :sparkles:
915
916
917
918
                          ShopDTO shop = oopService.shop(vo.getShopId());
                          if (Objects.nonNull(shop)) {
                              vo.setShopName(shop.getShortName());
                          }
8f9a8d4d   张志伟   :art:
919
920
921
                          vo.setDealerInfoVO(createDeal(vo.getShopId()));
                          vo.setOwner(true);
                          vo.setOwnerName(user.getRealName());
37a9df0d   张志伟   :bug:
922
                          loanCustomer(vo);
8f9a8d4d   张志伟   :art:
923
924
                      }).collect(Collectors.toList());
          }
4af3c6d3   张志伟   :art:
925
          return new ArrayList<>();
8f9a8d4d   张志伟   :art:
926
927
      }
  
1331548a   张志伟   :sparkles:
928
      /**
1331548a   张志伟   :sparkles:
929
930
931
932
       * @param customer
       * @param currentUser
       * @param rangeDTO
       * @param deadline
9de0e2d7   张志伟   feature(*): 公共池线索...
933
       * @deprecated 已弃用 sclie 2.0
1331548a   张志伟   :sparkles:
934
       */
1943d0bc   张志伟   feature(*): 公共线索池
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
      @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(*): 公共池线索...
951
       *
1943d0bc   张志伟   feature(*): 公共线索池
952
953
954
955
       * @param customerId
       * @param deadline
       * @param currentUser
       * @param rangeDTO
9de0e2d7   张志伟   feature(*): 公共池线索...
956
       * @deprecated 已弃用 sclie 2.0
1943d0bc   张志伟   feature(*): 公共线索池
957
958
959
960
961
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
       */
      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:
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
      /**
       * 创建公共池对象
       *
       * @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(*): 公共池线索...
1015
1016
1017
          Long shopId = Optional.ofNullable(dto.getLastArrivalShop()).orElse(dto.getShopId());
          pool.setShopId(shopId);
          ShopDTO shop = oopService.shop(shopId);
bebe7030   张志伟   :sparkles:
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
          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:
1031
       *
bebe7030   张志伟   :sparkles:
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
       * @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
1042
                  .set(Customer::getTemporary, null)
bebe7030   张志伟   :sparkles:
1043
1044
1045
                  .in(Customer::getId, customerIdList));
      }
  
322823a4   张志伟   feature(*): 公共池跟进联调
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
  
      /**
       * 档案批量移动到公共池
       *
       * @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
1057
                  .set(Customer::getTemporary, null)
322823a4   张志伟   feature(*): 公共池跟进联调
1058
1059
1060
                  .eq(Customer::getId, customerId));
      }
  
1983befb   张志伟   feat(api): :spark...
1061
      public List<BasicsCustomerDTO> queryByKeyword(String keyword, Long groupId) {
0a9893ad   夏天   fix-bug
1062
  
a78dc8be   张志伟   feature(*): 查询的bug修复
1063
1064
          List<BasicsCustomerDTO> list = fromCustomer(keyword, groupId);
          if (CollectionUtils.isNotEmpty(list)) {
0a9893ad   夏天   fix-bug
1065
1066
1067
1068
1069
1070
              return list;
          }
          return fromVehicle(keyword);
      }
  
  
a78dc8be   张志伟   feature(*): 查询的bug修复
1071
      private List<BasicsCustomerDTO> fromCustomer(String keyword, Long groupId) {
1983befb   张志伟   feat(api): :spark...
1072
1073
          List<BasicsCustomerDTO> list = customerService.queryByKeyword(keyword, groupId);
          for (BasicsCustomerDTO dto : list) {
3fc19e59   张志伟   升级erpsdk
1074
              UserInfoDTO user = ehrRpcService.user(dto.getAdviserId());
1983befb   张志伟   feat(api): :spark...
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
              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修复
1086
      private List<BasicsCustomerDTO> fromVehicle(String keyword) {
0a9893ad   夏天   fix-bug
1087
1088
          return memberVehicleService.queryByKeyword(keyword);
      }
a78dc8be   张志伟   feature(*): 查询的bug修复
1089
  
ede61714   夏天   新增会员认证车辆接口
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
      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   夏天   调整车辆认证逻辑
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
      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;
      }
  
3bddceac   夏天   查询保有客档案sdk
1117
1118
1119
1120
1121
      public List<CusCntResult> queryCusCnt(CusCntReq req){
          return customerService.queryCusCnt(req);
      }
  
  
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
  }