@@ -126,6 +126,9 @@ public class DeviceCancelApplyRequest extends AbstractSignTypeRequest<CommDevice | |||
//退费金额 | |||
private Integer refundFee; | |||
//能否连接设备 | |||
private Boolean hasDevice; | |||
public void relatedValid(ErrorMsgBuilder builder) { | |||
if (SourceType.CHANNEL.equals(orderSource)) { | |||
builder.validFieldNotBlank("vehiclePlate", vehiclePlate); |
@@ -18,4 +18,6 @@ public class DeviceCancelInstApplyRequest extends AbstractSignTypeRequest<Device | |||
private String obuId;//签号 | |||
private String cancelOrRestore;//注销/恢复 1-注销 2-恢复 | |||
} |
@@ -129,6 +129,10 @@ public class DeviceCancelApplyRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "注销原因") | |||
private String reason; | |||
//能否连接设备 | |||
@ApiModelProperty(value = "能否连接设备") | |||
@NotNull(message = "能否连接设备不能为空") | |||
private Boolean hasDevice; | |||
@Override | |||
public void validate(ViolationValidator validator) { | |||
if(CardType.STORED_VALUE_CARD.equals(cardType)){ |
@@ -7,7 +7,6 @@ import lombok.Getter; | |||
import lombok.Setter; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
@Getter | |||
@Setter | |||
@@ -19,4 +18,8 @@ public class DeviceCancelInstApplyRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "签号") | |||
private String obuId; | |||
@ApiModelProperty(value = "注销/恢复 1-注销 2-恢复") | |||
@NotBlank | |||
private String cancelOrRestore; | |||
} |
@@ -1,7 +1,6 @@ | |||
package cn.com.taiji.iaw.manager.ass; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.core.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.core.entity.ass.AssOrderinfo; | |||
import cn.com.taiji.core.entity.basic.QtkCardInfo; | |||
@@ -83,7 +82,7 @@ public class DeviceCancelManagerImpl extends AbstractIawManager implements Devic | |||
public DeviceCancelQueryResponseDTO query(DeviceCancelQueryRequestDTO request) throws ManagerException { | |||
QtkVehicleInfo vehicle = Optional.ofNullable(vehicleInfoRepo.findByVehicleId(request.getVehicleId())) | |||
.orElseThrow(() -> new ManagerException("车辆信息不存在")); | |||
QtkCustomerInfo customer = Optional.ofNullable(customerInfoRepo.findByCustomerId(request.getCustomerId())) | |||
QtkCustomerInfo customer = Optional.ofNullable(customerInfoRepo.findByCustomerId(vehicle.getCustomerId())) | |||
.orElseThrow(() -> new ManagerException("客户信息不存在")); | |||
QtkCardInfo card = Optional.ofNullable(cardInfoRepo.findByCardId(request.getCardId())) | |||
.orElseThrow(() -> new ManagerException("卡信息不存在")); | |||
@@ -312,8 +311,8 @@ public class DeviceCancelManagerImpl extends AbstractIawManager implements Devic | |||
return copyProperties(response, new DeviceCancelInstResponseDTO()); | |||
} catch (Exception e) { | |||
logger.error("获取指令出错", e); | |||
saveLog(OperateType.DEVICE_CANCEL_APPLY_INST_APPLY, "-1", reqDto, "失败"); | |||
throw new ManagerException("获取指令出错,请重试"); | |||
saveLog(OperateType.DEVICE_CANCEL_APPLY_INST_APPLY, "-1", reqDto, "失败:" + e.getMessage()); | |||
throw new ManagerException(e.getMessage()); | |||
} | |||
} | |||
@@ -330,8 +329,8 @@ public class DeviceCancelManagerImpl extends AbstractIawManager implements Devic | |||
return copyProperties(response, new DeviceCancelInstResponseDTO()); | |||
} catch (Exception e) { | |||
logger.error("获取指令出错", e); | |||
saveLog(OperateType.DEVICE_CANCEL_APPLY_INST_CALLBACK, "-1", reqDto, "失败"); | |||
throw new ManagerException("获取指令出错,请重试"); | |||
saveLog(OperateType.DEVICE_CANCEL_APPLY_INST_CALLBACK, "-1", reqDto, "失败:" + e.getMessage()); | |||
throw new ManagerException(e.getMessage()); | |||
} | |||
} | |||
@@ -11,12 +11,16 @@ import cn.com.taiji.core.entity.dict.ass.AssOrderStatus; | |||
import cn.com.taiji.core.entity.dict.ass.AssOrderStep; | |||
import cn.com.taiji.core.entity.dict.ass.AssOrderType; | |||
import cn.com.taiji.core.entity.dict.basic.*; | |||
import cn.com.taiji.core.entity.dict.issue.FeeCategory; | |||
import cn.com.taiji.core.entity.dict.issue.OrderPayType; | |||
import cn.com.taiji.core.entity.dict.issue.OrderType; | |||
import cn.com.taiji.core.entity.issue.IssueProduct; | |||
import cn.com.taiji.core.entity.issue.IssueProductPay; | |||
import cn.com.taiji.core.entity.log.IasInterfaceLog; | |||
import cn.com.taiji.core.entity.user.AccountInfo; | |||
import cn.com.taiji.core.entity.user.Staff; | |||
import cn.com.taiji.core.manager.comm.LogManager; | |||
import cn.com.taiji.core.manager.tools.issue.PayTools; | |||
import cn.com.taiji.core.manager.tools.issue.QdCallUtil; | |||
import cn.com.taiji.core.manager.tools.minio.MinioUtil; | |||
import cn.com.taiji.core.model.comm.protocol.ats.model.DeviceCancelChannelNoticeModel; | |||
@@ -28,15 +32,16 @@ import cn.com.taiji.core.model.comm.protocol.bls.ObuQueryResponse; | |||
import cn.com.taiji.core.model.comm.protocol.ias.ass.CommDeviceCancelApplyResponse; | |||
import cn.com.taiji.core.model.comm.protocol.ias.ass.DeviceCancelApplyRequest; | |||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||
import cn.com.taiji.core.repo.jpa.issue.IssueProductPayRepo; | |||
import cn.com.taiji.ias.manager.audit.VerificationRuleManager; | |||
import cn.com.taiji.ias.model.MyFinals; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.time.LocalDateTime; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
@Service | |||
@@ -46,8 +51,12 @@ public class DeviceCancelApplyManager extends CommDeviceCancelManager implements | |||
private QdCallUtil qdCallUtil; | |||
@Autowired | |||
private MinioUtil minioUtil; | |||
@Autowired | |||
private PayTools payTools; | |||
@Autowired | |||
private IssueProductPayRepo issueProductPayRepo; | |||
// @Value("${deviceCancel.noticeUrl}") | |||
// @Value("${deviceCancel.noticeUrl}") | |||
private String noticeUrl; | |||
@Autowired | |||
@@ -77,13 +86,17 @@ public class DeviceCancelApplyManager extends CommDeviceCancelManager implements | |||
//检测是否有未完成的订单 | |||
handleNormalOrder(customer.getCustomerId()); | |||
// 生成售后订单 | |||
AssOrderinfo orderInfo = initOrderInfo(request, customer); | |||
// 生成注销明细 | |||
AssDeviceCancel cancelInfo = initCancelInfo(request, orderInfo, dataStream); | |||
// ocr信息对比 | |||
ocrCompare(request, orderInfo); | |||
// 生成支付单 | |||
createOrder(orderInfo, cancelInfo, dataStream); | |||
// 通知渠道 | |||
noticeQd(orderInfo, cancelInfo); | |||
// 保存 | |||
saveOrderInfo(orderInfo); | |||
saveCancelInfo(cancelInfo); | |||
@@ -209,7 +222,7 @@ public class DeviceCancelApplyManager extends CommDeviceCancelManager implements | |||
cancel.setAgentIdType(IdType.findByCode(request.getAgentIdType())); | |||
cancel.setOrderNo(orderInfo.getOrderNo()); | |||
cancel.setCancelType(1); | |||
cancel.setHasDevice(false); | |||
cancel.setHasDevice(request.getHasDevice()); | |||
cancel.setCardExpireTime(card.getCardExpireTime()); | |||
cancel.setObuExpireTime(obu.getObuExpireTime()); | |||
@@ -251,8 +264,27 @@ public class DeviceCancelApplyManager extends CommDeviceCancelManager implements | |||
orderInfo.setAuditReason(builder.toString()); | |||
} | |||
// 生成支付单 | |||
public void createOrder(AssOrderinfo orderInfo, AssDeviceCancel cancelInfo, Map<String, Object> dataStream) throws ServiceHandleException { | |||
QtkCardInfo cardInfo = (QtkCardInfo) dataStream.get("cardInfo"); | |||
if (cancelInfo.getFee() == 0 || !hasText(orderInfo.getCardId()) || !hasText(cardInfo.getCardId())) { | |||
return; | |||
} | |||
// 查询支付配置 | |||
List<IssueProductPay> productPays = issueProductPayRepo.findByFeeCategoryAndReleaseId(FeeCategory.ZX_DEFAULT, cardInfo.getPackageId()); | |||
if (isEmpty(productPays)) { | |||
logger.info("卡号:{}的产品未配置注销违约金支付配置", cardInfo.getCardId()); | |||
return; | |||
} | |||
String payConfigId = productPays.get(0).getPayConfigId(); | |||
if (hasText(payConfigId)) { | |||
payTools.createPayOrder(orderInfo.getOrderNo(), OrderType.AFTERSALE, Long.valueOf(cancelInfo.getFee()), payConfigId, OrderPayType.CANCEL_AMOUNT, orderInfo.getAgencyId()); | |||
} | |||
} | |||
// 通知 | |||
public void noticeQd(AssOrderinfo orderInfo, AssDeviceCancel cancelInfo) throws ServiceHandleException { | |||
public void noticeQd(AssOrderinfo orderInfo, AssDeviceCancel cancelInfo) { | |||
// 判断是否需要渠道处理 | |||
if (!MyFinals.QTZL_AGENCY_ID.equals(orderInfo.getAgencyId()) && hasText(noticeUrl)) { | |||
DeviceCancelChannelNoticeModel model = new DeviceCancelChannelNoticeModel(); |
@@ -20,7 +20,7 @@ import java.time.LocalDateTime; | |||
import java.util.Map; | |||
import java.util.concurrent.TimeUnit; | |||
import static cn.com.taiji.inss.manager.model.MyFinals.ASS_RENEWAL_KEY; | |||
import static cn.com.taiji.inss.manager.model.MyFinals.ASS_DEVICE_CANCEL_KEY; | |||
import static cn.com.taiji.inss.manager.model.inst.InstConstant.CMD_SUCCESS; | |||
@@ -48,7 +48,7 @@ public abstract class AbstractDeviceCancelCallBackManager extends AbstractCommMa | |||
AbstractDeviceCancelCommandHandler cmdHandler = cmdHandlers.get(request.getStepNo()); | |||
if (cmdHandler == null) | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("未找到处理模块,请联系管理员"); | |||
logger.info("执行在线激活命令第{}步",request.getStepNo()); | |||
logger.info("执行注销命令第{}步",request.getStepNo()); | |||
Integer nextStep = nextStep(vo, request); | |||
vo.setNextStep(nextStep); | |||
DeviceCancelInstCallBackResponse response = cmdHandler.doHandle(request, vo); | |||
@@ -57,7 +57,7 @@ public abstract class AbstractDeviceCancelCallBackManager extends AbstractCommMa | |||
writeCache(cmdHandler.getOrderVo()); | |||
return onSuccess(request, response, InssInterfaceLog.class, System.currentTimeMillis() - begin); | |||
} catch (Exception e) { | |||
logger.error("续期异常", e); | |||
logger.error("注销异常", e); | |||
throw exception(request, InssInterfaceLog.class, e.getMessage()); | |||
} | |||
@@ -70,15 +70,15 @@ public abstract class AbstractDeviceCancelCallBackManager extends AbstractCommMa | |||
abstract void saveData(DeviceCancelInstVO vo) throws ServiceHandleException; | |||
private DeviceCancelInstVO readCache(String transOrderId) throws ServiceHandleException { | |||
DeviceCancelInstVO vo = redisWrapManager.findObj(DeviceCancelInstVO.class, ASS_RENEWAL_KEY + transOrderId); | |||
DeviceCancelInstVO vo = redisWrapManager.findObj(DeviceCancelInstVO.class, ASS_DEVICE_CANCEL_KEY + transOrderId); | |||
if (vo == null){ | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("未查询到缓存续期信息"); | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("未查询到缓存注销信息"); | |||
} | |||
return vo; | |||
} | |||
private void writeCache(DeviceCancelInstVO vo) { | |||
redisWrapManager.set(ASS_RENEWAL_KEY + vo.getTransOrderId(), vo.toJson(), 3000000, TimeUnit.SECONDS); | |||
redisWrapManager.set(ASS_DEVICE_CANCEL_KEY + vo.getTransOrderId(), vo.toJson(), 3000000, TimeUnit.SECONDS); | |||
} | |||
private void valid(DeviceCancelInstCallBackRequest request, DeviceCancelInstVO vo) throws ServiceHandleException { |
@@ -55,10 +55,10 @@ public class DeviceCancelInstApplyManager extends RedisCacheManager implements L | |||
throw GlyServiceError.FORMAT_VALIDATE_ERR.toHandleException("未查询到卡签信息"); | |||
} | |||
// 业务校验 | |||
businessValidate(cardInfo, obuInfo); | |||
businessValidate(cardInfo, obuInfo, request); | |||
//组装VO | |||
DeviceCancelInstVO vo = handleRenewalInstVO(cardInfo, obuInfo); | |||
DeviceCancelInstVO vo = handleDeviceCancelInstVO(cardInfo, obuInfo, request); | |||
//保存命令记录 | |||
AssDeviceCancelCosRecord record = saveAssDeviceCancelCosRecord(vo); | |||
@@ -106,7 +106,7 @@ public class DeviceCancelInstApplyManager extends RedisCacheManager implements L | |||
return record; | |||
} | |||
private DeviceCancelInstVO handleRenewalInstVO(QtkCardInfo cardInfo, QtkObuInfo obuInfo) { | |||
private DeviceCancelInstVO handleDeviceCancelInstVO(QtkCardInfo cardInfo, QtkObuInfo obuInfo, DeviceCancelInstApplyRequest request) { | |||
String transOrderId = UUID.randomUUID().toString().replace("-", ""); | |||
DeviceCancelInstVO vo = new DeviceCancelInstVO(); | |||
vo.setTransOrderId(transOrderId); | |||
@@ -118,7 +118,7 @@ public class DeviceCancelInstApplyManager extends RedisCacheManager implements L | |||
vo.setCardVersion(cardInfo.getCardVersion()); | |||
vo.setCardStatus(cardInfo.getCardStatus()); | |||
vo.setCardEnableTime(cardInfo.getCardEnableTime()); | |||
vo.setCardExpireTime(expireTime); | |||
vo.setCardExpireTime("2".equals(request.getCancelOrRestore()) ? cardInfo.getCardExpireTime() : expireTime); | |||
} | |||
if (obuInfo != null) { | |||
vo.setIsCancelObu(true); | |||
@@ -126,24 +126,43 @@ public class DeviceCancelInstApplyManager extends RedisCacheManager implements L | |||
vo.setObuVersion(obuInfo.getObuVersion()); | |||
vo.setObuStatus(obuInfo.getObuStatus()); | |||
vo.setObuEnableTime(obuInfo.getObuEnableTime()); | |||
vo.setObuExpireTime(expireTime); | |||
vo.setObuExpireTime("2".equals(request.getCancelOrRestore()) ? obuInfo.getObuExpireTime() : expireTime); | |||
} | |||
return vo; | |||
} | |||
private void businessValidate(QtkCardInfo cardInfo, QtkObuInfo obuInfo) throws ServiceHandleException { | |||
//判断有效期时间 | |||
private void businessValidate(QtkCardInfo cardInfo, QtkObuInfo obuInfo, DeviceCancelInstApplyRequest request) throws ServiceHandleException { | |||
if (cardInfo != null) { | |||
// 判断卡状态 | |||
if (CardStatus.WKZX.equals(cardInfo.getCardStatus()) || CardStatus.YKZX.equals(cardInfo.getCardStatus())) { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该卡状态为:" + cardInfo.getCardStatus().getValue() + ",不能进行注销操作!"); | |||
if("1".equals(request.getCancelOrRestore())) { | |||
// 判断卡状态 | |||
if (CardStatus.WKZX.equals(cardInfo.getCardStatus()) | |||
|| CardStatus.YKZX.equals(cardInfo.getCardStatus()) | |||
|| CardStatus.DELETE.equals(cardInfo.getCardStatus())) { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该卡状态为:" + cardInfo.getCardStatus().getValue() + ",不能进行注销操作!"); | |||
} | |||
}else { | |||
if (!(CardStatus.WKZX.equals(cardInfo.getCardStatus()) | |||
|| CardStatus.YKZX.equals(cardInfo.getCardStatus()) | |||
|| CardStatus.DELETE.equals(cardInfo.getCardStatus()))) { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该卡状态为:" + cardInfo.getCardStatus().getValue() + ",不用恢复注销操作!"); | |||
} | |||
} | |||
} | |||
if (obuInfo != null) { | |||
// 判断卡状态是否正常 | |||
if (ObuStatus.YQZX.equals(obuInfo.getObuStatus()) || ObuStatus.WQZX.equals(obuInfo.getObuStatus()) || ObuStatus.DELETE.equals(obuInfo.getObuStatus())) { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该OBU状态为:" + obuInfo.getObuStatus().getValue() + ",不能进行注销操作!"); | |||
// 判断签状态 | |||
if("1".equals(request.getCancelOrRestore())) { | |||
if (ObuStatus.YQZX.equals(obuInfo.getObuStatus()) | |||
|| ObuStatus.WQZX.equals(obuInfo.getObuStatus()) | |||
|| ObuStatus.DELETE.equals(obuInfo.getObuStatus())) { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该OBU状态为:" + obuInfo.getObuStatus().getValue() + ",不能进行注销操作!"); | |||
}else { | |||
if(!(ObuStatus.YQZX.equals(obuInfo.getObuStatus()) | |||
|| ObuStatus.WQZX.equals(obuInfo.getObuStatus()) | |||
|| ObuStatus.DELETE.equals(obuInfo.getObuStatus()))){ | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该OBU状态为:" + obuInfo.getObuStatus().getValue() + ",不用恢复注销操作!"); | |||
} | |||
} | |||
} | |||
} | |||
} |