@@ -70,6 +70,12 @@ public class CustomerInfoChangeApplyRequest extends AbstractIasRequest<CommCusto | |||
private String staffId; | |||
// 客户Id | |||
@NotBlank | |||
private String customerId; | |||
//是否添加单位ETC账户 1-否 2-是 | |||
@NotBlank | |||
private String isAddEtc; | |||
//小程序添加单位ETC时传的登录人的openId | |||
private String openId; | |||
} |
@@ -37,6 +37,10 @@ public interface AssOrderinfoRepo extends AbstractJpaRepo<AssOrderinfo, String>{ | |||
@Query(" from AssOrderinfo where customerId = ?1 and orderType = ?2 and orderStatus = ?3 ") | |||
List<AssOrderinfo> findByCustomerIdAndOrderTypeStatus(String customerId, AssOrderType orderType, AssOrderStatus orderStatus); | |||
//根据客户证件号,订单类型,订单状态查询订单 | |||
@Query(" from AssOrderinfo where customerIdNum = ?1 and orderType = ?2 and orderStatus = ?3 ") | |||
List<AssOrderinfo> findByCustomerIdNumAndOrderTypeStatus(String customerIdNum, AssOrderType orderType, AssOrderStatus orderStatus); | |||
@Query(" from AssOrderinfo where vehicleId = ?1 and orderType in ?2") | |||
List<AssOrderinfo> listByVehicleId(String vehicleId,List<AssOrderType> list); | |||
@@ -23,7 +23,7 @@ public interface QtkCustomerInfoRepo extends AbstractJpaRepo<QtkCustomerInfo, St | |||
@Query("select customerId from QtkCustomerInfo where customerIdNum = ?1") | |||
List<String> findCustomerIdByIdNum(String customerIdNum); | |||
@Query("select customerId from QtkCustomerInfo where customerIdNum = ?1 and customerIdType =?2") | |||
@Query("select customerId from QtkCustomerInfo where customerIdNum = ?1 and customerIdType =?2 order by updateTime desc") | |||
List<String> findCustomerIdByIdNumAndIdType(String customerIdNum, IdType customerIdType); | |||
@Query(" from QtkCustomerInfo where agentIdType = ?1 and agentIdNum =?2 order by customerId") |
@@ -71,9 +71,11 @@ public class CustomerInfoChangeApplyDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "员工Id app时必填") | |||
private String staffId; | |||
@ApiModelProperty(value = "是否为添加单位ETC账户 1-否 2-是") | |||
private String isAddEtc; | |||
@Override | |||
protected void validate(ViolationValidator validator) { | |||
validator.validFieldNotBlank("customerId", getCustomerId()); | |||
if(("2").equals(type)){ | |||
validator.validFieldNotBlank("agentName", agentName); | |||
validator.validFieldNotBlank("agentIdNo", agentIdNo); | |||
@@ -89,6 +91,14 @@ public class CustomerInfoChangeApplyDTO extends AbstractBizRequestDTO { | |||
} | |||
if (getOrderSource() == SourceType.SERVICE_HALL) { | |||
validator.validFieldNotBlank("staffId", staffId); | |||
validator.validFieldNotBlank("customerId", getCustomerId()); | |||
} | |||
if (getOrderSource() == SourceType.WECHAT) { | |||
validator.validFieldNotBlank("isAddEtc", isAddEtc); | |||
} | |||
if(!"2".equals(isAddEtc)){ | |||
validator.validFieldNotBlank("customerId", getCustomerId()); | |||
validator.validFieldNotBlank("verifyCode", verifyCode); | |||
} | |||
} | |||
} |
@@ -5,6 +5,8 @@ import cn.com.taiji.core.entity.ass.AssOrderinfo; | |||
import cn.com.taiji.core.entity.basic.QtkCustomerInfo; | |||
import cn.com.taiji.core.entity.dict.ass.AssOrderStatus; | |||
import cn.com.taiji.core.entity.dict.ass.AssOrderType; | |||
import cn.com.taiji.core.entity.dict.basic.IdType; | |||
import cn.com.taiji.core.entity.dict.basic.SourceType; | |||
import cn.com.taiji.core.entity.dict.log.OperateType; | |||
import cn.com.taiji.core.manager.cache.RedisKeyGenerator; | |||
import cn.com.taiji.core.manager.tools.minio.MinioUtil; | |||
@@ -62,6 +64,9 @@ public class CustomerInfoChangeMangerImpl extends AbstractIawManager implements | |||
CustomerInfoChangeApplyRequest request = copyProperties(reqDto, new CustomerInfoChangeApplyRequest()); | |||
request.setLoginSource(reqDto.getOrderSource()); | |||
CommCustomerInfoChangeResponse response = jsonPostRepeat(request); | |||
if(SourceType.WECHAT == reqDto.getOrderSource() && "2".equals(reqDto.getIsAddEtc())){ | |||
request.setOpenId(findOpenIdByToken(reqDto.getAccessToken())); | |||
} | |||
//记录日志 | |||
persistOperateLog(("1").equals(reqDto.getType()) ? OperateType.CUSTOMER_INFO_CHANGE_APPLY_SELF : OperateType.CUSTOMER_INFO_CHANGE_APPLY_UNIT, response.getOrderNo()!=null?response.getOrderNo():"-1", reqDto.getOrderSource(), findOpenIdByToken(reqDto.getAccessToken()), "用户信息变更申请" + response.getMsg()); | |||
//响应 | |||
@@ -75,23 +80,41 @@ public class CustomerInfoChangeMangerImpl extends AbstractIawManager implements | |||
// 校验 | |||
private void valid(CustomerInfoChangeApplyDTO reqDto) throws ManagerException { | |||
reqDto.validate(); | |||
List<AssOrderinfo> order = orderInfoRepo.findByCustomerIdAndOrderTypeStatus(reqDto.getCustomerId(), AssOrderType.USER_UPDATE, AssOrderStatus.NORMAL); | |||
if (!order.isEmpty()) { | |||
throw new ManagerException("正在处理中,请勿重复提交!"); | |||
} | |||
QtkCustomerInfo customer = customerInfoRepo.findByCustomerId(reqDto.getCustomerId()); | |||
if (customer == null) { | |||
throw new ManagerException("客户不存在!"); | |||
} | |||
if (!customer.getCustomerIdNum().equals(reqDto.getIdNo())) { | |||
throw new ManagerException("证件号码不允许修改,请核对证件号码是否正确!"); | |||
} | |||
if(!customer.getCustomerTel().equals(reqDto.getTel())){ | |||
if(SourceType.WECHAT == reqDto.getOrderSource() && ("2").equals(reqDto.getIsAddEtc())){ | |||
if(!"2".equals(reqDto.getType())){ | |||
throw new ManagerException("添加单位ETC账号业务类型错误!"); | |||
} | |||
if(!hasText(reqDto.getVerifyCode())){ | |||
throw new ManagerException("手机号发生变更,请输入手机验证码!"); | |||
throw new ManagerException("请输入手机验证码!"); | |||
} | |||
List<AssOrderinfo> order = orderInfoRepo.findByCustomerIdNumAndOrderTypeStatus(reqDto.getIdNo(), AssOrderType.USER_UPDATE, AssOrderStatus.NORMAL); | |||
if (!order.isEmpty()) { | |||
throw new ManagerException("本单位存在正在变更的信息,请勿重复提交!"); | |||
} | |||
List<String> customerIds = customerInfoRepo.findCustomerIdByIdNumAndIdType(reqDto.getIdNo(), IdType.YYZZ); | |||
if(customerIds.isEmpty()){ | |||
throw new ManagerException("本单位未查询到注册信息,请核对证件号是否正确!"); | |||
} | |||
reqDto.setCustomerId(customerIds.get(0)); | |||
}else { | |||
List<AssOrderinfo> order = orderInfoRepo.findByCustomerIdAndOrderTypeStatus(reqDto.getCustomerId(), AssOrderType.USER_UPDATE, AssOrderStatus.NORMAL); | |||
if (!order.isEmpty()) { | |||
throw new ManagerException("正在处理中,请勿重复提交!"); | |||
} | |||
QtkCustomerInfo customer = customerInfoRepo.findByCustomerId(reqDto.getCustomerId()); | |||
if (customer == null) { | |||
throw new ManagerException("客户不存在!"); | |||
} | |||
if (!customer.getCustomerIdNum().equals(reqDto.getIdNo())) { | |||
throw new ManagerException("证件号码不允许修改,请核对证件号码是否正确!"); | |||
} | |||
if (!customer.getCustomerTel().equals(reqDto.getTel())) { | |||
if (!hasText(reqDto.getVerifyCode())) { | |||
throw new ManagerException("手机号发生变更,请输入手机验证码!"); | |||
} | |||
} | |||
} | |||
if (("2").equals(reqDto.getMobileChange())) { | |||
if ("2".equals(reqDto.getMobileChange()) || (SourceType.WECHAT == reqDto.getOrderSource() && "2".equals(reqDto.getIsAddEtc()))) { | |||
String smsCode = redisManager.get(RedisKeyGenerator.getSmsCodeKey(reqDto.getTel(), reqDto.getOrderSource().name(), 3)); | |||
if (!hasText(smsCode)) { | |||
throw new ManagerException("短信验证码已过期,请重新发送!"); |
@@ -113,20 +113,24 @@ public class CustomerInfoChangeApplyManager extends AbstractCustomerInfoChangeMa | |||
} | |||
order.setStaffOpenId(staff.getOpenId()); | |||
} | |||
String idNum = customerInfo.getCustomerIdNum(); | |||
IdType idType = customerInfo.getCustomerIdType(); | |||
if("2".equals(request.getType())){ | |||
idNum = customerInfo.getAgentIdNum(); | |||
idType = customerInfo.getAgentIdType(); | |||
} | |||
AccountInfo accountInfo = accountInfoRepo.findByIdNumAndIdType(idNum, idType); | |||
if (accountInfo != null) { | |||
if (!hasText(accountInfo.getOpenId())) { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("客户openId不存在"); | |||
if(request.getLoginSource() == SourceType.WECHAT && "2".equals(request.getIsAddEtc())){ | |||
order.setOpenId(request.getOpenId()); | |||
}else { | |||
String idNum = customerInfo.getCustomerIdNum(); | |||
IdType idType = customerInfo.getCustomerIdType(); | |||
if ("2".equals(request.getType())) { | |||
idNum = customerInfo.getAgentIdNum(); | |||
idType = customerInfo.getAgentIdType(); | |||
} | |||
AccountInfo accountInfo = accountInfoRepo.findByIdNumAndIdType(idNum, idType); | |||
if (accountInfo != null) { | |||
if (!hasText(accountInfo.getOpenId())) { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("客户openId不存在"); | |||
} | |||
order.setOpenId(accountInfo.getOpenId()); | |||
} else { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("客户不存在"); | |||
} | |||
order.setOpenId(accountInfo.getOpenId()); | |||
} else { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("客户不存在"); | |||
} | |||
order.setCustomerId(request.getCustomerId()); | |||
order.setCustomerTel(customerInfo.getCustomerTel()); | |||
@@ -235,11 +239,11 @@ public class CustomerInfoChangeApplyManager extends AbstractCustomerInfoChangeMa | |||
orderInfo.setAuditOpenId("-1"); | |||
// orderInfo.setAuditStatus(AuditStatus.NO_AUDIT); | |||
orderInfo.setOrderStep(AssOrderStep.WAITING_UPGRADE); | |||
orderInfo.setArtificialStatus(2); | |||
orderInfo.setAuditReason("机审成功!"); | |||
orderInfo.setAuditTime(LocalDateTime.now()); | |||
orderInfo.setUpdateTime(LocalDateTime.now()); | |||
} | |||
orderInfo.setArtificialStatus(2); | |||
orderInfo.setAutoAuditTime(LocalDateTime.now()); | |||
} else if ("2".equals(request.getType())) { | |||
@@ -300,11 +304,18 @@ public class CustomerInfoChangeApplyManager extends AbstractCustomerInfoChangeMa | |||
orderInfo.setAuditOpenId("-1"); | |||
// orderInfo.setAuditStatus(AuditStatus.NO_AUDIT); | |||
orderInfo.setOrderStep(AssOrderStep.WAITING_UPGRADE); | |||
orderInfo.setArtificialStatus(2); | |||
orderInfo.setAuditReason("机审成功!"); | |||
orderInfo.setAuditTime(LocalDateTime.now()); | |||
orderInfo.setUpdateTime(LocalDateTime.now()); | |||
} | |||
//小程序添加单位ETC账号时必须人工审核 | |||
if(request.getIsAddEtc().equals("2")){ | |||
orderInfo.setOrderStep(AssOrderStep.WAITING_AUDIT); | |||
orderInfo.setAuditReason("客户通过小程序进行添加变更单位账户信息,请核对;"+orderInfo.getAuditReason()); | |||
} | |||
orderInfo.setArtificialStatus(2); | |||
orderInfo.setAutoAuditTime(LocalDateTime.now()); | |||
} else { | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("不支持的修改类型"); |