Blame view

fw-valhalla-service/src/main/java/cn/fw/valhalla/component/producer/RenewalSwitchProducer.kt 2.07 KB
2a40e3f8   张志伟   feature(*): 续保跟进调整
1
2
3
4
5
6
  package cn.fw.valhalla.component.producer
  
  import cn.fw.valhalla.common.utils.DateUtil
  import cn.fw.valhalla.domain.enums.FollowTypeEnum
  import cn.fw.valhalla.domain.enums.SettingTypeEnum
  import cn.fw.valhalla.domain.vo.setting.SettingVO
2a40e3f8   张志伟   feature(*): 续保跟进调整
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  import cn.fw.valhalla.sdk.result.RenewalSwitchMQ
  import cn.fw.valhalla.service.bus.setting.SettingBizService
  import cn.fw.valhalla.service.bus.setting.strategy.SettingStrategy
  import org.apache.rocketmq.spring.core.RocketMQTemplate
  import org.slf4j.Logger
  import org.slf4j.LoggerFactory
  import org.springframework.stereotype.Component
  import org.springframework.web.bind.annotation.RequestMapping
  import java.time.LocalDate
  import java.util.*
  
  /**
   * 续保跟进切换mq生产者
   *
   * @author : kurisu
   * @version : 1.0
   * @className : RenewalSwitchProducer
   * @description : 续保跟进切换mq生产者
   * @date : 2023-03-15 15:37
   */
  @Component
  class RenewalSwitchProducer(
      private val rocketMQTemplate: RocketMQTemplate,
      private val settingBizService: SettingBizService
  ) {
      private val log: Logger = LoggerFactory.getLogger(this.javaClass)
  
      @RequestMapping(value = ["send"])
      fun send(vin: String, deadline: LocalDate, groupId: Long) {
          val settingVO: Optional<SettingVO?> = settingBizService.querySettingByType(
              FollowTypeEnum.IR,
              SettingTypeEnum.MODE,
              groupId,
              SettingStrategy.COMMON_BRAND_ID
          )
          // 模式 1、续保角色 2、续保角色+服务接待/新车销售
          val mode = settingVO.map { obj: SettingVO? -> obj?.detailValue }.orElse(1)
          if (mode == 1) {
              return
          }
9c86aa21   张志伟   feature(*): 线索到期后...
47
          if (!LocalDate.now().plusDays(2L).isBefore(deadline)) {
2a40e3f8   张志伟   feature(*): 续保跟进调整
48
49
50
51
              return
          }
          log.info("发送续保跟进切换mq消息。vin:{}", vin)
          try {
33d5653d   张志伟   feature(*): 修复bug
52
              val mq = RenewalSwitchMQ(FollowTypeEnum.IR.value, vin, DateUtil.localDate2Date(deadline), groupId)
bdbae7e3   张志伟   :bug:
53
              rocketMQTemplate.syncSend(RenewalSwitchMQ.TOPIC + ":*", mq)
2a40e3f8   张志伟   feature(*): 续保跟进调整
54
55
56
57
58
          } catch (e: Exception) {
              log.info("发送保有客分配结束mq消息失败!", e)
          }
      }
  }