Blame view

parking-module-pay/src/main/java/com/zteits/pay/biz/VipCardPushServiceImpl.java 6.76 KB
55f68655   王彪总   新项目
1
2
3
4
5
6
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  package com.zteits.pay.biz;
  
  import org.apache.commons.collections4.CollectionUtils;
  import com.clouds.common.utils.ResultUtils;
  import com.zteits.clouds.api.apibase.bean.BizResult;
  import com.zteits.clouds.api.apibase.constants.BasicEnum;
  import com.zteits.clouds.api.apibase.constants.ErrorType;
  import com.zteits.clouds.api.apibase.exception.BizException;
  import com.zteits.clouds.api.dto.bill.vipcard.VipNoPushCardCustInfoDTO;
  import com.zteits.clouds.api.dto.bill.vipcard.param.VipPushRequest;
  import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO;
  import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest;
  import com.zteits.clouds.api.service.bill.viparea.TVipAreaCardCustInfoService;
  import com.zteits.clouds.api.service.bill.vipcard.VipCardService;
  import com.zteits.clouds.api.service.park.ParkingLotQueryService;
  import com.zteits.clouds.api.service.pay.VipCardPushService;
  import com.zteits.pay.job.vipcardpush.route.VipCardPushRoute;
  import com.zteits.pay.job.vipcardpush.vo.VipNoPushCardCustInfoVO;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.BeanUtils;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import java.util.List;
  
  /**
   * Copyright: Copyright (c) 2018  ZTE-ITS
   *
   * @ClassName: AppOrgServiceImpl
   * @Description:
   * @version: v1.0.0
   * @author: wangbiao
   * @date: 2018/11/20 10:05
   * Modification History:
   * Date         Author          Version         Description
   * ---------------------------------------------------------*
   * 2018/11/20    wangbiao         v1.0.0          创建
   */
  @Service
  public class VipCardPushServiceImpl implements VipCardPushService {
      private static final Logger logger = LoggerFactory.getLogger(VipCardPushServiceImpl.class);
      @Autowired
      private VipCardService vipCardService;
      @Autowired
      private TVipAreaCardCustInfoService tVipAreaCardCustInfoService;
      @Autowired
      private ParkingLotQueryService parkingLotQueryService;
      @Autowired
      private VipCardPushRoute vipCardPushRoute;
      @Override
      public BizResult<Integer> pushVipCardCustInfo(VipPushRequest request) {
          if(request.getId() == null){
              throw new BizException(ErrorType.PARAMM_NULL,"id");
          }
          request.setSysCode("1001");
          BizResult<List<VipNoPushCardCustInfoDTO>> rsList = vipCardService.queryPustVipCardCustInfo(request);
          if(CollectionUtils.isEmpty(rsList.getData())){
              throw new BizException(ErrorType.BIZ_ERROR,"该会员卡信息未查询到!");
          }
          VipNoPushCardCustInfoDTO cardInfo = rsList.getData().get(0);
  
  
          QueryParkLotInfoByPkNoRequest queryParkLotInfoByPkNoRequest = new QueryParkLotInfoByPkNoRequest();
          queryParkLotInfoByPkNoRequest.setPklNo(cardInfo.getPlNo());
          queryParkLotInfoByPkNoRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
          BizResult<ParkingLotDTO> parkingLotDTOBizResult = parkingLotQueryService.QueryParkingLotByPkNo(queryParkLotInfoByPkNoRequest);
          if (!ResultUtils.isSuccess(parkingLotDTOBizResult) || parkingLotDTOBizResult.getData() == null) {
              throw new BizException(ErrorType.BIZ_ERROR,"未查询到当前车场信息!");
          }
          ParkingLotDTO parkingLotDTO = parkingLotDTOBizResult.getData();
          /**
           * 哎润道闸不合作,导致无法处理推送,去掉不在推送哎润
           */
          if(null != parkingLotDTO && parkingLotDTO.getSourceType().equals(1)){
              throw new BizException(ErrorType.BIZ_ERROR,"当前道闸厂商不支持推送!");
          }
  
  
          com.zteits.pay.job.vipcardpush.service.VipCardPushService route = vipCardPushRoute.getRoute(parkingLotDTO.getSourceType());
          if (route == null) {
              throw new BizException(ErrorType.BIZ_ERROR,"会员卡同步路由服务失败,未找到sourceType:" + parkingLotDTO.getSourceType() + "对应的服务");
          }
          VipNoPushCardCustInfoVO vipNoPushCardCustInfoVO = new VipNoPushCardCustInfoVO();
          BeanUtils.copyProperties(cardInfo, vipNoPushCardCustInfoVO);
          vipNoPushCardCustInfoVO.setParkingLotDTO(parkingLotDTO);
          try {
              Integer updateCount = route.pushVIPCard(vipNoPushCardCustInfoVO,false);
          } catch (Exception e) {
              logger.error(vipNoPushCardCustInfoVO.getCarNumber()+":会员卡同步路由服务失败:" + e);
          }
  
          return new BizResult<Integer>(1);
      }
  
      @Override
      public BizResult<Integer> pushVipAreaCardCustInfo(VipPushRequest request) {
          if(request.getId() == null){
              throw new BizException(ErrorType.PARAMM_NULL,"id");
          }
          request.setSysCode("1001");
          BizResult<List<VipNoPushCardCustInfoDTO>> rsList = tVipAreaCardCustInfoService.queryPustVipCardCustInfo(request);
          if(CollectionUtils.isEmpty(rsList.getData())){
              throw new BizException(ErrorType.BIZ_ERROR,"该会员卡信息未查询到!");
          }
          VipNoPushCardCustInfoDTO cardInfo = rsList.getData().get(0);
  
  
          QueryParkLotInfoByPkNoRequest queryParkLotInfoByPkNoRequest = new QueryParkLotInfoByPkNoRequest();
          queryParkLotInfoByPkNoRequest.setPklNo(cardInfo.getPlNo());
          queryParkLotInfoByPkNoRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
          BizResult<ParkingLotDTO> parkingLotDTOBizResult = parkingLotQueryService.QueryParkingLotByPkNo(queryParkLotInfoByPkNoRequest);
          if (!ResultUtils.isSuccess(parkingLotDTOBizResult) || parkingLotDTOBizResult.getData() == null) {
              throw new BizException(ErrorType.BIZ_ERROR,"未查询到当前车场信息!");
          }
          ParkingLotDTO parkingLotDTO = parkingLotDTOBizResult.getData();
          /**
           * 哎润道闸不合作,导致无法处理推送,去掉不在推送哎润
           */
          if(null != parkingLotDTO && parkingLotDTO.getSourceType().equals(1)){
              throw new BizException(ErrorType.BIZ_ERROR,"当前道闸厂商不支持推送!");
          }
  
  
          com.zteits.pay.job.vipcardpush.service.VipCardPushService route = vipCardPushRoute.getRoute(parkingLotDTO.getSourceType());
          if (route == null) {
              throw new BizException(ErrorType.BIZ_ERROR,"会员卡同步路由服务失败,未找到sourceType:" + parkingLotDTO.getSourceType() + "对应的服务");
          }
          VipNoPushCardCustInfoVO vipNoPushCardCustInfoVO = new VipNoPushCardCustInfoVO();
          BeanUtils.copyProperties(cardInfo, vipNoPushCardCustInfoVO);
          vipNoPushCardCustInfoVO.setParkingLotDTO(parkingLotDTO);
          try {
              Integer updateCount = route.pushVIPCard(vipNoPushCardCustInfoVO,true);
          } catch (Exception e) {
              logger.error(vipNoPushCardCustInfoVO.getCarNumber()+":会员卡同步路由服务失败:" + e);
          }
  
          return new BizResult<Integer>(1);
      }
  
  }