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 pushVipCardCustInfo(VipPushRequest request) { if(request.getId() == null){ throw new BizException(ErrorType.PARAMM_NULL,"id"); } request.setSysCode("1001"); BizResult> 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 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(1); } @Override public BizResult pushVipAreaCardCustInfo(VipPushRequest request) { if(request.getId() == null){ throw new BizException(ErrorType.PARAMM_NULL,"id"); } request.setSysCode("1001"); BizResult> 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 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(1); } }