瀏覽代碼

渠道权限控制校验公共方法

master
zouhantao 1 月之前
父節點
當前提交
51317caa22

+ 23
- 0
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/dict/AgencyConfigType.java 查看文件

package cn.com.taiji.ias.dict;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum AgencyConfigType {

DEVICE_CHANGE("支持设备更换"),
VEHICLE_CHANGE("支持车牌变更"),
DEVICE_CANCEL("支持设备注销"),
SIGN_CHANGE("支持签约代扣信息变更"),
QT_SIGN("是否黔通代扣签约"),
CHANNEL_SIGN_URL("渠道签约地址"),
CHANNEL_SIGN_APP_ID("渠道签约小程序id"),
QT_USER_SIGN("是否黔通产品签约"),
;

private final String value;


}

+ 65
- 0
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/agencyConfig/AgencyConfigManager.java 查看文件

package cn.com.taiji.ias.manager.agencyConfig;

import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.core.entity.ass.AssAgencyConfig;
import cn.com.taiji.core.entity.dict.EnableStatus;
import cn.com.taiji.core.manager.cache.RedisCacheManager;
import cn.com.taiji.core.repo.jpa.ass.AssAgencyConfigRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkCardInfoRepo;
import cn.com.taiji.ias.dict.AgencyConfigType;

@Service
public class AgencyConfigManager extends RedisCacheManager {

@Autowired
protected QtkCardInfoRepo cardInfoRepo;
@Autowired
protected AssAgencyConfigRepo agencyConfigRepo;

/**
* 获取渠道权限配置
* @param agencyId 渠道id
* @return
* @throws ManagerException
*/
public AssAgencyConfig queryAgencyAuthConfig(String agencyId) throws ServiceHandleException {
AssAgencyConfig agencyAuthConfig = agencyConfigRepo.findByAgencyId(agencyId);
if (agencyAuthConfig == null){
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("渠道未配置权限");
}
if (agencyAuthConfig.getStatus().equals(EnableStatus.DISABLE)){
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("渠道状态异常");
}
return agencyAuthConfig;
}

// 校验渠道权限
public boolean checkAgencyConfig(String agencyId, AgencyConfigType configType) throws ServiceHandleException {
AssAgencyConfig config = queryAgencyAuthConfig(agencyId);
if (configType == null) return false;
if (configType.equals(AgencyConfigType.DEVICE_CHANGE)){
return config.getDeviceChange();
} else if (configType.equals(AgencyConfigType.VEHICLE_CHANGE)) {
return config.getVehicleChange();
} else if (configType.equals(AgencyConfigType.DEVICE_CANCEL)) {
return config.getDeviceChange();
} else if (configType.equals(AgencyConfigType.SIGN_CHANGE)) {
return config.getSignChange();
} else if (configType.equals(AgencyConfigType.QT_SIGN)) {
return config.getQtSign();
} else if (configType.equals(AgencyConfigType.CHANNEL_SIGN_URL)) {
return config.getChannelSignUrl();
} else if (configType.equals(AgencyConfigType.CHANNEL_SIGN_APP_ID)) {
return config.getChannelSignAppId();
} else if (configType.equals(AgencyConfigType.QT_USER_SIGN)) {
return config.getQtUserSign();
}
return false;
}

}

+ 3
- 3
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/vehicleInfoChange/VehicleChangeArtificialManager.java 查看文件



import java.time.LocalDateTime; import java.time.LocalDateTime;


import cn.com.taiji.common.pub.BeanTools;
import cn.com.taiji.core.entity.ass.AssDeviceUpgrade;
import cn.com.taiji.core.repo.jpa.ass.AssDeviceUpgradeRepo;
import cn.com.taiji.ias.manager.agencyConfig.AgencyConfigManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


private VehicleInfoChangeManager infoChangeManager; private VehicleInfoChangeManager infoChangeManager;
@Autowired @Autowired
private VehiclePlateChangeManager plateChangeManager; private VehiclePlateChangeManager plateChangeManager;
@Autowired
private AgencyConfigManager configManager;


@Override @Override
public void doSaveLog(VehicleChangeArtificialRequest request, VehicleChangeArtificialResponse response, public void doSaveLog(VehicleChangeArtificialRequest request, VehicleChangeArtificialResponse response,

+ 11
- 7
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/vehicleInfoChange/VehicleInfoChangeManager.java 查看文件

import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;


import cn.com.taiji.ias.dict.AgencyConfigType;
import cn.com.taiji.ias.manager.agencyConfig.AgencyConfigManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
private VerificationRuleManager verificationRuleManager; private VerificationRuleManager verificationRuleManager;
@Autowired @Autowired
private IasInterfaceLogRepo logRepo; private IasInterfaceLogRepo logRepo;
@Autowired
private AgencyConfigManager configManager;


/** /**
* 车辆信息变更申请 * 车辆信息变更申请
public VehicleInfoChangeResponse vehicleInfoChangeInfoApply(VehicleInfoChangeRequest req) public VehicleInfoChangeResponse vehicleInfoChangeInfoApply(VehicleInfoChangeRequest req)
throws ServiceHandleException { throws ServiceHandleException {
VehicleInfoChangeResponse res = new VehicleInfoChangeResponse(); VehicleInfoChangeResponse res = new VehicleInfoChangeResponse();
// todo 卡渠道是否支持车辆信息变更
// if (checkAgencyAuthConfig(req.getCardId(), AgencyAuthConfigType.VEHICLE_INFO_CHANGE)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
// }
// 卡渠道是否支持车辆信息变更
if (configManager.checkAgencyConfig(req.getAgencyId(), AgencyConfigType.VEHICLE_CHANGE)) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
}
// 校验DTO参数 // 校验DTO参数
if (!req.ifMyselfHandle()) { if (!req.ifMyselfHandle()) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("非自主办理,请上传委托书及经办人信息!"); throw GlyServiceError.RESPONSE_ERROR.toHandleException("非自主办理,请上传委托书及经办人信息!");
// 发生车型从大到小变更 转入人工审核 // 发生车型从大到小变更 转入人工审核
if (newVehicleType >= vehicleInfo.getType()) { if (newVehicleType >= vehicleInfo.getType()) {
// todo 校验是否支持小改大 // todo 校验是否支持小改大
// if (checkAgencyAuthConfig(req.getCardId(), AgencyAuthConfigType.SMALL_TO_BIG)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("该渠道不支持收费车型小改大!");
// }
// if (configManager.checkAgencyConfig(req.getAgencyId(), AgencyConfigType.SMALL_TO_BIG)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("该渠道不支持收费车型小改大!");
// }
return true; return true;
} else { } else {
manualReview(assOrderinfo, "车辆信息变更自动审核失败原因:车辆收费类型从大改小!"); manualReview(assOrderinfo, "车辆信息变更自动审核失败原因:车辆收费类型从大改小!");

+ 8
- 4
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/vehicleInfoChange/VehiclePlateChangeManager.java 查看文件



import cn.com.taiji.core.manager.tools.issue.IssueTools; import cn.com.taiji.core.manager.tools.issue.IssueTools;
import cn.com.taiji.core.model.comm.protocol.ias.ygz.*; import cn.com.taiji.core.model.comm.protocol.ias.ygz.*;
import cn.com.taiji.ias.dict.AgencyConfigType;
import cn.com.taiji.ias.manager.agencyConfig.AgencyConfigManager;
import cn.com.taiji.ias.manager.ygz.YgzCardUploadManager; import cn.com.taiji.ias.manager.ygz.YgzCardUploadManager;
import cn.com.taiji.ias.manager.ygz.YgzObuUploadManager; import cn.com.taiji.ias.manager.ygz.YgzObuUploadManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
private AssVehicleInfoChangeRepo vehicleInfoChangeRepo; private AssVehicleInfoChangeRepo vehicleInfoChangeRepo;
@Autowired @Autowired
private VehicleInfoChangeManager infoChangeManager; private VehicleInfoChangeManager infoChangeManager;
@Autowired
private AgencyConfigManager configManager;


@Transactional @Transactional
public VehiclePlateChangeResponse vehiclePlateChangeInfoApply(VehiclePlateChangeRequest req) public VehiclePlateChangeResponse vehiclePlateChangeInfoApply(VehiclePlateChangeRequest req)
throws ServiceHandleException { throws ServiceHandleException {
VehiclePlateChangeResponse res = new VehiclePlateChangeResponse(); VehiclePlateChangeResponse res = new VehiclePlateChangeResponse();
// todo 渠道是否支持车牌变更
// if (checkAgencyAuthConfig(req.getCardId(), AgencyAuthConfigType.VEHICLE_PLATE_CHANGE)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
// }
// 渠道是否支持车牌变更
if (configManager.checkAgencyConfig(req.getAgencyId(), AgencyConfigType.VEHICLE_CHANGE)) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
}
// 校验DTO参数 // 校验DTO参数
if (!req.ifMyselfHandle()) { if (!req.ifMyselfHandle()) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("非自主办理,请上传委托书及经办人信息!"); throw GlyServiceError.RESPONSE_ERROR.toHandleException("非自主办理,请上传委托书及经办人信息!");

Loading…
取消
儲存