|
|
@@ -15,13 +15,14 @@ import cn.com.taiji.core.entity.dict.basic.CardStatus; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.ObuStatus; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.SourceType; |
|
|
|
import cn.com.taiji.core.entity.dict.log.OperateType; |
|
|
|
import cn.com.taiji.core.entity.dict.ygz.DataSourceEnum; |
|
|
|
import cn.com.taiji.core.entity.dict.ygz.Operation; |
|
|
|
import cn.com.taiji.core.entity.user.AccountInfo; |
|
|
|
import cn.com.taiji.core.model.comm.COSConstant; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.ygz.*; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.inss.renewalInst.RenewalInstApplyRequest; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.inss.renewalInst.RenewalInstApplyResponse; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.inss.renewalInst.RenewalInstCallBackRequest; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.inss.renewalInst.RenewalInstCallBackResponse; |
|
|
|
import cn.com.taiji.core.repo.jpa.ass.AssDeviceRenewalRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.ass.AssOrderinfoRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.ass.AssRenewalCosRecordRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.basic.QtkCardInfoRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.basic.QtkCustomerInfoRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.basic.QtkObuInfoRepo; |
|
|
@@ -58,62 +59,83 @@ public class DeviceRenewalManagerImpl extends AbstractIawManager implements Devi |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public CardRenewalResponseDTO cardRenewal(CardRenewalRequestDTO dto) throws ManagerException { |
|
|
|
//卡续期校验 |
|
|
|
assOrderInfoCardValid(dto.getCardId()); |
|
|
|
|
|
|
|
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(dto.getCardId()); |
|
|
|
//卡有效校验 |
|
|
|
cardValid(cardInfo); |
|
|
|
//保存售后订单记录 卡续期订单 |
|
|
|
AssOrderinfo orderinfo = generateAssOrderInfo(dto, cardInfo, null, true); |
|
|
|
//新增售后卡签续期信息 |
|
|
|
addAssDeviceRenewal(orderinfo, LocalDateTime.now(), true); |
|
|
|
//保存操作记录 |
|
|
|
persistOperateLog(OperateType.CARD_RENEWAL, orderinfo.getId(), dto.getOrderSource(), findOpenIdByToken(dto.getAccessToken()), "卡续期!"); |
|
|
|
public CardAndObuRenewalRenewalResponseDTO cardAndObuRenewal(CardAndObuRenewalRenewalRequestDTO dto) throws ManagerException { |
|
|
|
//参数校验 |
|
|
|
dto.validate(); |
|
|
|
|
|
|
|
QtkCardInfo cardInfo = null; |
|
|
|
QtkObuInfo obuInfo = null; |
|
|
|
if (!StringUtils.isEmpty(dto.getCardId()) && dto.getRenewalType() != 3){ |
|
|
|
cardInfo = cardInfoRepo.findByCardId(dto.getCardId()); |
|
|
|
} |
|
|
|
if (!StringUtils.isEmpty(dto.getObuId()) && dto.getRenewalType() != 2){ |
|
|
|
obuInfo = obuInfoRepo.findByObuId(dto.getObuId()); |
|
|
|
} |
|
|
|
|
|
|
|
return new CardRenewalResponseDTO(orderinfo.getOrderNo(), COSConstant.selectAndRead0015WithRandom); |
|
|
|
//卡签校验 |
|
|
|
cardAndObuValid(dto.getRenewalType() ,cardInfo, obuInfo); |
|
|
|
|
|
|
|
RenewalInstApplyRequest request = new RenewalInstApplyRequest(); |
|
|
|
request.setCardId(dto.getCardId()); |
|
|
|
request.setObuId(dto.getObuId()); |
|
|
|
RenewalInstApplyResponse response = null; |
|
|
|
try { |
|
|
|
response = jsonPostRepeat(request); |
|
|
|
} catch (ManagerException e) { |
|
|
|
logger.error("获取申请卡签续期指令异常信息:"+e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
throw new ManagerException("获取申请卡签续期指令异常"); |
|
|
|
} |
|
|
|
if (response == null) { |
|
|
|
throw new ManagerException("未获取申请卡签续期指令"); |
|
|
|
} |
|
|
|
//反白给前端 |
|
|
|
return copyProperties(response, new CardAndObuRenewalRenewalResponseDTO()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ObuRenewalResponseDTO obuRenewal(ObuRenewalRequestDTO dto) throws ManagerException { |
|
|
|
//签续期校验 |
|
|
|
assOrderInfoObuValid(dto.getObuId()); |
|
|
|
|
|
|
|
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(dto.getObuId()); |
|
|
|
//签有效校验 |
|
|
|
obuValid(obuInfo); |
|
|
|
//保存售后订单记录 卡续期订单 |
|
|
|
AssOrderinfo orderinfo = generateAssOrderInfo(dto, null, obuInfo, false); |
|
|
|
//新增售后卡签续期信息 |
|
|
|
addAssDeviceRenewal(orderinfo, LocalDateTime.now(), false); |
|
|
|
//保存操作记录 |
|
|
|
persistOperateLog(OperateType.OBU_RENEWAL, orderinfo.getId(), dto.getOrderSource(), findOpenIdByToken(dto.getAccessToken()), "签续期!"); |
|
|
|
@Override |
|
|
|
public ReadAndWriteRenewalInstResponseDTO readAndWriteRenewalInst(ReadAndWriteRenewalInstRequestDTO dto) throws ManagerException { |
|
|
|
RenewalInstCallBackRequest request = new RenewalInstCallBackRequest(); |
|
|
|
copyProperties(dto, request); |
|
|
|
RenewalInstCallBackResponse response = null; |
|
|
|
try { |
|
|
|
response = jsonPostRepeat(request); |
|
|
|
} catch (ManagerException e) { |
|
|
|
logger.error("获取反馈卡签续期指令异常信息:"+e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
throw new ManagerException("获取反馈卡签续期指令异常"); |
|
|
|
} |
|
|
|
if (response == null) { |
|
|
|
throw new ManagerException("未获取反馈卡签续期指令"); |
|
|
|
} |
|
|
|
|
|
|
|
return new ObuRenewalResponseDTO(orderinfo.getOrderNo(), COSConstant.selectAndRead0015WithRandom); |
|
|
|
return copyProperties(response, new ReadAndWriteRenewalInstResponseDTO()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public RenewalConfirmResponseDTO confirm(RenewalConfirmRequestDTO dto) throws ManagerException { |
|
|
|
AssOrderinfo orderinfo = orderinfoRepo.findByOrderNo(dto.getOrderNo()); |
|
|
|
//校验 |
|
|
|
dto.validate(); |
|
|
|
|
|
|
|
if (dto.getConfirmResult()) { |
|
|
|
orderinfo.setOrderStatus(AssOrderStatus.FINISHED); |
|
|
|
orderinfo.setAuditStatus(AuditStatus.COMPLETE); |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
AssDeviceRenewal assDeviceRenewal = deviceRenewalRepo.findByOrderNo(dto.getOrderNo()); |
|
|
|
//更新卡签信息 |
|
|
|
updateCardOrObuInfo(orderinfo, now, assDeviceRenewal); |
|
|
|
//卡签信息上传部中心 |
|
|
|
ygzCardBlackUpload(orderinfo,assDeviceRenewal); |
|
|
|
} else { |
|
|
|
orderinfo.setOrderStatus(AssOrderStatus.CLOSE); |
|
|
|
orderinfo.setAuditStatus(AuditStatus.FAIL); |
|
|
|
orderinfo.setAuditReason("命令执行失败"); |
|
|
|
orderinfo.setAuditFailureCase("命令执行失败"); |
|
|
|
QtkCardInfo cardInfo = null; |
|
|
|
QtkObuInfo obuInfo = null; |
|
|
|
if (!StringUtils.isEmpty(dto.getCardId()) && dto.getRenewalType() != 3){ |
|
|
|
cardInfo = cardInfoRepo.findByCardId(dto.getCardId()); |
|
|
|
} |
|
|
|
if (!StringUtils.isEmpty(dto.getObuId()) && dto.getRenewalType() != 2){ |
|
|
|
obuInfo = obuInfoRepo.findByObuId(dto.getObuId()); |
|
|
|
} |
|
|
|
//卡签校验 |
|
|
|
cardAndObuValid(dto.getRenewalType() ,cardInfo, obuInfo); |
|
|
|
|
|
|
|
//生成售后订单 |
|
|
|
AssOrderinfo orderinfo = generateAssOrderInfo(dto, cardInfo, obuInfo); |
|
|
|
|
|
|
|
addAssDeviceRenewal(dto, orderinfo, cardInfo, obuInfo); |
|
|
|
|
|
|
|
orderinfo.setUpdateTime(LocalDateTime.now()); |
|
|
|
orderinfoRepo.save(orderinfo); |
|
|
|
|
|
|
@@ -122,128 +144,84 @@ public class DeviceRenewalManagerImpl extends AbstractIawManager implements Devi |
|
|
|
return new RenewalConfirmResponseDTO(orderinfo.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
private void ygzCardBlackUpload(AssOrderinfo orderinfo, AssDeviceRenewal assDeviceRenewal) throws ManagerException { |
|
|
|
if (assDeviceRenewal.getRenewalType() == 2) { |
|
|
|
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(orderinfo.getCardId()); |
|
|
|
YgzCardUploadRequest uploadRequest = new YgzCardUploadRequest(); |
|
|
|
uploadRequest.setCard(cardInfo); |
|
|
|
uploadRequest.setOperation(Operation.UPDATE); |
|
|
|
uploadRequest.setDataSource(DataSourceEnum.DSI_INTERFACE); |
|
|
|
try { |
|
|
|
jsonPostRepeat(uploadRequest); |
|
|
|
} catch (ManagerException e) { |
|
|
|
logger.error("同步数据到部中心异常," + e.getMessage()); |
|
|
|
throw new ManagerException("同步数据到部中心异常," + e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
} else if (assDeviceRenewal.getRenewalType() == 3) { |
|
|
|
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(orderinfo.getObuId()); |
|
|
|
YgzObuUploadRequest uploadRequest = new YgzObuUploadRequest(); |
|
|
|
uploadRequest.setObu(obuInfo); |
|
|
|
uploadRequest.setOperation(Operation.UPDATE); |
|
|
|
uploadRequest.setDataSource(DataSourceEnum.DSI_INTERFACE); |
|
|
|
try { |
|
|
|
jsonPostRepeat(uploadRequest); |
|
|
|
} catch (ManagerException e) { |
|
|
|
logger.error("同步数据到部中心异常," + e.getMessage()); |
|
|
|
throw new ManagerException("同步数据到部中心异常," + e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
throw new ManagerException("订单类型异常!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void updateCardOrObuInfo(AssOrderinfo orderinfo, LocalDateTime now, AssDeviceRenewal assDeviceRenewal) throws ManagerException { |
|
|
|
if (assDeviceRenewal.getRenewalType() == 2) { |
|
|
|
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(orderinfo.getCardId()); |
|
|
|
cardInfo.setCardExpireTime(now.plusYears(10)); |
|
|
|
cardInfo.setUpdateTime(now); |
|
|
|
cardInfoRepo.merge(cardInfo); |
|
|
|
} else if (assDeviceRenewal.getRenewalType() == 3) { |
|
|
|
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(orderinfo.getObuId()); |
|
|
|
obuInfo.setObuExpireTime(now.plusYears(10)); |
|
|
|
obuInfo.setUpdateTime(now); |
|
|
|
obuInfoRepo.merge(obuInfo); |
|
|
|
} else { |
|
|
|
throw new ManagerException("订单类型异常!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void addAssDeviceRenewal(AssOrderinfo orderinfo, LocalDateTime now, Boolean isCard) throws ManagerException { |
|
|
|
private void addAssDeviceRenewal(RenewalConfirmRequestDTO dto, AssOrderinfo orderinfo, QtkCardInfo cardInfo, QtkObuInfo obuInfo) throws ManagerException { |
|
|
|
AssDeviceRenewal deviceRenewal = copyProperties(orderinfo, new AssDeviceRenewal(), "id", "insertTime"); |
|
|
|
if (isCard) { |
|
|
|
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(orderinfo.getCardId()); |
|
|
|
deviceRenewal.setRenewalType(2); |
|
|
|
deviceRenewal.setCardExpireTime(now.plusYears(10)); |
|
|
|
deviceRenewal.setOldCardExpireTime(cardInfo.getCardExpireTime()); |
|
|
|
} else { |
|
|
|
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(orderinfo.getObuId()); |
|
|
|
deviceRenewal.setRenewalType(3); |
|
|
|
deviceRenewal.setObuExpireTime(now.plusYears(10)); |
|
|
|
deviceRenewal.setOldObuExpireTime(obuInfo.getObuExpireTime()); |
|
|
|
deviceRenewal.setRenewalType(dto.getRenewalType()); |
|
|
|
if (cardInfo != null) { |
|
|
|
deviceRenewal.setCardExpireTime(cardInfo.getCardExpireTime()); |
|
|
|
deviceRenewal.setOldCardExpireTime(dto.getOldCardExpireTime()); |
|
|
|
} |
|
|
|
if (obuInfo != null){ |
|
|
|
deviceRenewal.setObuExpireTime(obuInfo.getObuExpireTime()); |
|
|
|
deviceRenewal.setOldObuExpireTime(dto.getOldObuExpireTime()); |
|
|
|
} |
|
|
|
deviceRenewal.setVehiclePlate(orderinfo.getVehicleId().split("_")[0]); |
|
|
|
deviceRenewal.setVehiclePlateColor(Integer.valueOf(orderinfo.getVehicleId().split("_")[1])); |
|
|
|
deviceRenewal.setInsertTime(now); |
|
|
|
deviceRenewal.setInsertTime(LocalDateTime.now()); |
|
|
|
deviceRenewalRepo.save(deviceRenewal); |
|
|
|
} |
|
|
|
|
|
|
|
private void obuValid(QtkObuInfo obuInfo) throws ManagerException { |
|
|
|
//判断有效期时间 |
|
|
|
if (!obuInfo.getObuExpireTime().isAfter(LocalDateTime.now().minusYears(1))) { |
|
|
|
throw new ManagerException("当前卡有效期为:" + obuInfo.getObuExpireTime() + ",有效期剩余1年内才可以续期!"); |
|
|
|
} |
|
|
|
// 判断卡状态是否正常 |
|
|
|
if (!ObuStatus.ZC.equals(obuInfo.getObuStatus())) { |
|
|
|
throw new ManagerException("该卡状态为:" + obuInfo.getObuStatus().getValue() + ",不能进行续期操作!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void assOrderInfoObuValid(String obuId) { |
|
|
|
AssOrderinfo orderinfo = orderinfoRepo.findUnFinishOrderByCardId(obuId, AssOrderType.RENEWAL, AssOrderStatus.NORMAL); |
|
|
|
if (orderinfo != null) { |
|
|
|
orderinfo.setUpdateTime(LocalDateTime.now()); |
|
|
|
orderinfo.setOrderStatus(AssOrderStatus.CLOSE); |
|
|
|
orderinfoRepo.merge(orderinfo); |
|
|
|
private void cardAndObuValid(Integer renewalType, QtkCardInfo cardInfo, QtkObuInfo obuInfo) throws ManagerException { |
|
|
|
if (renewalType == 1){ |
|
|
|
if (cardInfo == null || obuInfo == null){ |
|
|
|
throw new ManagerException("未获取到卡签信息"); |
|
|
|
} |
|
|
|
}else if (renewalType == 2){ |
|
|
|
if (cardInfo == null){ |
|
|
|
throw new ManagerException("未获取到卡信息"); |
|
|
|
} |
|
|
|
}else if (renewalType == 3){ |
|
|
|
if (obuInfo == null){ |
|
|
|
throw new ManagerException("未获取到签信息"); |
|
|
|
} |
|
|
|
}else { |
|
|
|
throw new ManagerException("续期类型错误"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void cardValid(QtkCardInfo cardInfo) throws ManagerException { |
|
|
|
//判断有效期时间 |
|
|
|
if (!cardInfo.getCardExpireTime().isAfter(LocalDateTime.now().minusYears(1))) { |
|
|
|
throw new ManagerException("当前卡有效期为:" + cardInfo.getCardExpireTime() + ",有效期剩余1年内才可以续期!"); |
|
|
|
if (cardInfo != null){ |
|
|
|
if (!cardInfo.getCardExpireTime().isAfter(LocalDateTime.now().minusYears(1))) { |
|
|
|
throw new ManagerException("当前卡有效期为:" + cardInfo.getCardExpireTime() + ",有效期剩余1年内才可以续期!"); |
|
|
|
} |
|
|
|
// 判断卡状态是否正常 |
|
|
|
if (!CardStatus.ZC.equals(cardInfo.getCardStatus())) { |
|
|
|
throw new ManagerException("该卡状态为:" + cardInfo.getCardStatus().getValue() + ",不能进行续期操作!"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 判断卡状态是否正常 |
|
|
|
if (!CardStatus.ZC.equals(cardInfo.getCardStatus())) { |
|
|
|
throw new ManagerException("该卡状态为:" + cardInfo.getCardStatus().getValue() + ",不能进行续期操作!"); |
|
|
|
if(obuInfo != null){ |
|
|
|
if (!obuInfo.getObuExpireTime().isAfter(LocalDateTime.now().minusYears(1))) { |
|
|
|
throw new ManagerException("当前卡有效期为:" + obuInfo.getObuExpireTime() + ",有效期剩余1年内才可以续期!"); |
|
|
|
} |
|
|
|
// 判断卡状态是否正常 |
|
|
|
if (!ObuStatus.ZC.equals(obuInfo.getObuStatus())) { |
|
|
|
throw new ManagerException("该卡状态为:" + obuInfo.getObuStatus().getValue() + ",不能进行续期操作!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void assOrderInfoCardValid(String cardId) throws ManagerException { |
|
|
|
AssOrderinfo orderinfo = orderinfoRepo.findUnFinishOrderByCardId(cardId, AssOrderType.RENEWAL, AssOrderStatus.NORMAL); |
|
|
|
if (orderinfo != null) { |
|
|
|
orderinfo.setUpdateTime(LocalDateTime.now()); |
|
|
|
orderinfo.setOrderStatus(AssOrderStatus.CLOSE); |
|
|
|
orderinfoRepo.merge(orderinfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private AssOrderinfo generateAssOrderInfo(AbstractBizRequestDTO dto, QtkCardInfo cardInfo, QtkObuInfo obuInfo, boolean isCard) throws ServiceHandleException { |
|
|
|
String customerId = isCard ? cardInfo.getCustomerId() : obuInfo.getCustomerId(); |
|
|
|
private AssOrderinfo generateAssOrderInfo(AbstractBizRequestDTO dto, QtkCardInfo cardInfo, QtkObuInfo obuInfo) throws ServiceHandleException { |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
AssOrderinfo orderinfo = new AssOrderinfo(); |
|
|
|
|
|
|
|
String customerId = ""; |
|
|
|
String vehicleId = ""; |
|
|
|
if (cardInfo != null){ |
|
|
|
orderinfo.setCardId(cardInfo.getCardId()); |
|
|
|
customerId = cardInfo.getCustomerId(); |
|
|
|
vehicleId =cardInfo.getVehicleId(); |
|
|
|
}else { |
|
|
|
customerId = obuInfo.getCustomerId(); |
|
|
|
vehicleId = obuInfo.getVehicleId(); |
|
|
|
orderinfo.setObuId(obuInfo.getObuId()); |
|
|
|
} |
|
|
|
orderinfo.setOrderNo(createOrderNo(findAgencyIdByToken(dto.getAccessToken()))); |
|
|
|
orderinfo.setOrderSource(dto.getOrderSource()); |
|
|
|
orderinfo.setOrderStatus(AssOrderStatus.NORMAL); |
|
|
|
orderinfo.setOrderStatus(AssOrderStatus.FINISHED); |
|
|
|
orderinfo.setAuditStatus(AuditStatus.COMPLETE); |
|
|
|
orderinfo.setOrderType(AssOrderType.RENEWAL); |
|
|
|
orderinfo.setAuditStatus(AuditStatus.AUDIT); |
|
|
|
orderinfo.setChannelId(cardInfo.getChannelId()); |
|
|
|
orderinfo.setApplyTime(now); |
|
|
|
String openId = findOpenIdByToken(dto.getAccessToken()); |
|
|
@@ -275,12 +253,8 @@ public class DeviceRenewalManagerImpl extends AbstractIawManager implements Devi |
|
|
|
} |
|
|
|
orderinfo.setInsertTime(now); |
|
|
|
orderinfo.setUpdateTime(now); |
|
|
|
orderinfo.setVehicleId(isCard ? cardInfo.getVehicleId() : obuInfo.getVehicleId()); |
|
|
|
if (isCard) { |
|
|
|
orderinfo.setCardId(cardInfo.getCardId()); |
|
|
|
} else { |
|
|
|
orderinfo.setObuId(obuInfo.getObuId()); |
|
|
|
} |
|
|
|
orderinfo.setVehicleId(vehicleId); |
|
|
|
|
|
|
|
orderinfoRepo.save(orderinfo); |
|
|
|
return orderinfo; |
|
|
|
} |