|
@@ -24,7 +24,10 @@ import com.ytpm.app.model.YtDyzUser;
|
|
|
import com.ytpm.app.param.AppUserParam;
|
|
import com.ytpm.app.param.AppUserParam;
|
|
|
import com.ytpm.config.mq.ReliableMessageSender;
|
|
import com.ytpm.config.mq.ReliableMessageSender;
|
|
|
import com.ytpm.custom.CustomField;
|
|
import com.ytpm.custom.CustomField;
|
|
|
-import com.ytpm.dao.*;
|
|
|
|
|
|
|
+import com.ytpm.dao.AgentAppMapper;
|
|
|
|
|
+import com.ytpm.dao.AgentDictMapper;
|
|
|
|
|
+import com.ytpm.dao.AppMapper;
|
|
|
|
|
+import com.ytpm.dao.RiskMapper;
|
|
|
import com.ytpm.general.RepMessage;
|
|
import com.ytpm.general.RepMessage;
|
|
|
import com.ytpm.general.Result;
|
|
import com.ytpm.general.Result;
|
|
|
import com.ytpm.general.ResultTable;
|
|
import com.ytpm.general.ResultTable;
|
|
@@ -71,8 +74,6 @@ public class RiskServiceImpl implements RiskService {
|
|
|
private FeignClientInvoker feignInvoker;
|
|
private FeignClientInvoker feignInvoker;
|
|
|
@Resource
|
|
@Resource
|
|
|
private ReliableMessageSender reliableMessageSender;
|
|
private ReliableMessageSender reliableMessageSender;
|
|
|
- @Resource
|
|
|
|
|
- private DitchShareMapper ditchShareMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 风控锁定用户
|
|
* 风控锁定用户
|
|
@@ -304,12 +305,16 @@ public class RiskServiceImpl implements RiskService {
|
|
|
List<YtDyzUser> data = new ArrayList<>();
|
|
List<YtDyzUser> data = new ArrayList<>();
|
|
|
List<String> collect = issuedAppList.stream().map(YtPlatformUserApp::getServiceName).distinct().collect(Collectors.toList());
|
|
List<String> collect = issuedAppList.stream().map(YtPlatformUserApp::getServiceName).distinct().collect(Collectors.toList());
|
|
|
for (String serviceName : collect) {
|
|
for (String serviceName : collect) {
|
|
|
- Object o = feignInvoker.invoke(serviceName, "getUserList", appUserParam);
|
|
|
|
|
- String jsonString = JSON.toJSONString(o);
|
|
|
|
|
- JSONObject object = JSONObject.parseObject(jsonString);
|
|
|
|
|
- List<YtDyzUser> dyzUsers = JSONArray.parseArray(object.getString("data"), YtDyzUser.class);
|
|
|
|
|
- if (CollUtil.isNotEmpty(dyzUsers)) {
|
|
|
|
|
- data.addAll(dyzUsers.stream().distinct().collect(Collectors.toList()));
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ Object o = feignInvoker.invoke(serviceName, "getUserList", appUserParam);
|
|
|
|
|
+ String jsonString = JSON.toJSONString(o);
|
|
|
|
|
+ JSONObject object = JSONObject.parseObject(jsonString);
|
|
|
|
|
+ List<YtDyzUser> dyzUsers = JSONArray.parseArray(object.getString("data"), YtDyzUser.class);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dyzUsers)) {
|
|
|
|
|
+ data.addAll(dyzUsers.stream().distinct().collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("调用服务[{}]查询信息失败", serviceName);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return data;
|
|
return data;
|
|
@@ -461,9 +466,9 @@ public class RiskServiceImpl implements RiskService {
|
|
|
/**
|
|
/**
|
|
|
* 新增模版和关联配置
|
|
* 新增模版和关联配置
|
|
|
*/
|
|
*/
|
|
|
- private void addTemplateAndRelative(RiskConfigParam param,String content,List<YtRiskConfig> configs) {
|
|
|
|
|
|
|
+ private void addTemplateAndRelative(RiskConfigParam param, String content, List<YtRiskConfig> configs) {
|
|
|
YtRiskTemplate template = new YtRiskTemplate();
|
|
YtRiskTemplate template = new YtRiskTemplate();
|
|
|
- BeanUtil.copyProperties(param,template);
|
|
|
|
|
|
|
+ BeanUtil.copyProperties(param, template);
|
|
|
template.setTemplateId(IdUtil.fastSimpleUUID());
|
|
template.setTemplateId(IdUtil.fastSimpleUUID());
|
|
|
template.setTemplateContent(content);
|
|
template.setTemplateContent(content);
|
|
|
template.setEnabled(0);
|
|
template.setEnabled(0);
|
|
@@ -472,7 +477,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
riskMapper.saveTemplate(template);
|
|
riskMapper.saveTemplate(template);
|
|
|
riskMapper.addRelease(template.getTemplateId(),
|
|
riskMapper.addRelease(template.getTemplateId(),
|
|
|
configs.stream().map(YtRiskConfig::getConfigId).collect(Collectors.toList()),
|
|
configs.stream().map(YtRiskConfig::getConfigId).collect(Collectors.toList()),
|
|
|
- param.getOperator(),param.getOperatorName()
|
|
|
|
|
|
|
+ param.getOperator(), param.getOperatorName()
|
|
|
);
|
|
);
|
|
|
//传入消息队列通知子服务更新
|
|
//传入消息队列通知子服务更新
|
|
|
reliableMessageSender.sendRiskChangeToMq(template.getTemplateId());
|
|
reliableMessageSender.sendRiskChangeToMq(template.getTemplateId());
|
|
@@ -573,27 +578,6 @@ public class RiskServiceImpl implements RiskService {
|
|
|
return ResultTable.resultTableOk(new PageInfo<>(configList));
|
|
return ResultTable.resultTableOk(new PageInfo<>(configList));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 添加配置项
|
|
|
|
|
- */
|
|
|
|
|
- private void addConfigItem(Field[] fields, List<RiskConfigView> configList, Integer effectNode) {
|
|
|
|
|
- RiskConfigView view;
|
|
|
|
|
- for (Field field : fields) {
|
|
|
|
|
- field.setAccessible(true);
|
|
|
|
|
- if ((Objects.nonNull(effectNode) && field.getAnnotation(CustomField.class).node() != 99 &&
|
|
|
|
|
- field.getAnnotation(CustomField.class).node() != effectNode) ||
|
|
|
|
|
- !field.isAnnotationPresent(CustomField.class)
|
|
|
|
|
- ) continue;
|
|
|
|
|
- view = new RiskConfigView();
|
|
|
|
|
- view.setFieldName(field.getName());
|
|
|
|
|
- if (CharSequenceUtil.isNotBlank(field.getAnnotation(CustomField.class).value())) {
|
|
|
|
|
- view.setDictList(dictMapper.getByTypeCode(field.getAnnotation(CustomField.class).value()));
|
|
|
|
|
- }
|
|
|
|
|
- view.setFieldDesc(field.getAnnotation(ApiModelProperty.class).value());
|
|
|
|
|
- configList.add(view);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 风控配置启用关闭
|
|
* 风控配置启用关闭
|
|
@@ -639,24 +623,6 @@ public class RiskServiceImpl implements RiskService {
|
|
|
return Result.resultObjOk(riskMapper.getTemplateView(templateId, channelId));
|
|
return Result.resultObjOk(riskMapper.getTemplateView(templateId, channelId));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据业务节点查询配置项
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public ResultTable<RiskConfigView> getFieldConfigByNode(Integer effectNode) {
|
|
|
|
|
- List<AgentAppClassView> viewList = riskMapper.getAppClazz("");
|
|
|
|
|
- List<RiskConfigView> configList = new ArrayList<>();
|
|
|
|
|
- Set<String> clazzSet = viewList.stream().map(AgentAppClassView::getFullName).collect(Collectors.toSet());
|
|
|
|
|
- try{
|
|
|
|
|
- for (String fullName : clazzSet) {
|
|
|
|
|
- addConfigItem(Class.forName(fullName).getDeclaredFields(),configList,effectNode);
|
|
|
|
|
- }
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
- log.error(e.getMessage());
|
|
|
|
|
- throw new CustomerException(e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- return ResultTable.resultTableOk(new PageInfo<RiskConfigView>(configList));
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 添加配置项
|
|
* 添加配置项
|
|
@@ -672,7 +638,7 @@ public class RiskServiceImpl implements RiskService {
|
|
|
}
|
|
}
|
|
|
view = new RiskConfigView();
|
|
view = new RiskConfigView();
|
|
|
view.setFieldName(field.getName());
|
|
view.setFieldName(field.getName());
|
|
|
- if(CharSequenceUtil.isNotBlank(field.getAnnotation(CustomField.class).value())){
|
|
|
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(field.getAnnotation(CustomField.class).value())) {
|
|
|
view.setDictList(dictMapper.getByTypeCode(field.getAnnotation(CustomField.class).value()));
|
|
view.setDictList(dictMapper.getByTypeCode(field.getAnnotation(CustomField.class).value()));
|
|
|
}
|
|
}
|
|
|
view.setFieldDesc(field.getAnnotation(ApiModelProperty.class).value());
|
|
view.setFieldDesc(field.getAnnotation(ApiModelProperty.class).value());
|
|
@@ -680,122 +646,6 @@ public class RiskServiceImpl implements RiskService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 修改用户信息
|
|
|
|
|
- */
|
|
|
|
|
- private void modifyAppUserInfo(String userId, RiskUserStatusParam param, AgentUserInfo curUser) {
|
|
|
|
|
- YtDyzUser appUser = new YtDyzUser();
|
|
|
|
|
- appUser.setUserId(param.getUserId());
|
|
|
|
|
- appUser.setUserStatus(param.getUserStatus());
|
|
|
|
|
- switch (param.getUserStatus()){
|
|
|
|
|
- case 2:
|
|
|
|
|
- appUser.setRiskReason(param.getReason());
|
|
|
|
|
- //1s锁定用户,并设置 24小时后进行解锁
|
|
|
|
|
- redisService.setTimeOutStr("lock_"+userId,param.getAppId(),1000);
|
|
|
|
|
- redisService.setTimeOutHoursStr("unlock_"+userId,param.getAppId(),24);
|
|
|
|
|
- break;
|
|
|
|
|
- case 3: //增加封禁记录
|
|
|
|
|
- appUser.setRiskReason(param.getReason());
|
|
|
|
|
- addBannedRecord(userId,curUser,param.getAppId(),param.getBannedLimit()*24, param.getReason());
|
|
|
|
|
- //1s锁定用户,并设置 24小时后进行解锁
|
|
|
|
|
- redisService.setTimeOutStr("lock_"+userId,param.getAppId(),1000);
|
|
|
|
|
- redisService.setTimeOutHoursStr("unlock_"+userId,param.getAppId(),param.getBannedLimit()*24L);
|
|
|
|
|
- break;
|
|
|
|
|
- default: //解禁
|
|
|
|
|
- YtPlatformBanned banned = riskMapper.getLastBanned(userId);
|
|
|
|
|
- if(Objects.nonNull(banned)){
|
|
|
|
|
- addDeblockingRecord(banned,param);
|
|
|
|
|
- }
|
|
|
|
|
- redisService.setTimeOutStr("unlock_"+userId,param.getAppId(),1000);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据应用远程调用获取数据
|
|
|
|
|
- */
|
|
|
|
|
- private List<YtDyzUser> dealWithFeignData(List<YtPlatformUserApp> issuedAppList, AppUserParam appUserParam) {
|
|
|
|
|
- List<YtDyzUser> data = new ArrayList<>();
|
|
|
|
|
- List<String> collect = issuedAppList.stream().map(YtPlatformUserApp::getServiceName).distinct().collect(Collectors.toList());
|
|
|
|
|
- for (String serviceName : collect) {
|
|
|
|
|
- Object o;
|
|
|
|
|
- try {
|
|
|
|
|
- o = feignInvoker.invoke(serviceName, "getUserList", appUserParam);
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
- log.error("{}服务调用失败: {}", serviceName, e.getMessage());
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- String jsonString = JSON.toJSONString(o);
|
|
|
|
|
- JSONObject object = JSONObject.parseObject(jsonString);
|
|
|
|
|
- List<YtDyzUser> dyzUsers = JSONArray.parseArray(object.getString("data"), YtDyzUser.class);
|
|
|
|
|
- if(CollUtil.isNotEmpty(dyzUsers)){
|
|
|
|
|
- data.addAll(dyzUsers.stream().distinct().collect(Collectors.toList()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return data;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 增加解禁记录
|
|
|
|
|
- */
|
|
|
|
|
- private void addDeblockingRecord(YtPlatformBanned banned, RiskUserStatusParam param) {
|
|
|
|
|
- YtPlatformDeblocking deblocking = new YtPlatformDeblocking();
|
|
|
|
|
- deblocking.setDeblockingId(IdUtil.fastSimpleUUID());
|
|
|
|
|
- deblocking.setUserId(banned.getUserId());
|
|
|
|
|
- deblocking.setAppId(banned.getAppId());
|
|
|
|
|
- deblocking.setAgentId(param.getAgentId());
|
|
|
|
|
- deblocking.setOperator(param.getOperator());
|
|
|
|
|
- deblocking.setOperatorName(param.getOperatorName());
|
|
|
|
|
- deblocking.setBannedId(banned.getBannedId());
|
|
|
|
|
- deblocking.setDeblockingReason(param.getReason());
|
|
|
|
|
- deblocking.setDeblockingTime(new Date());
|
|
|
|
|
- riskMapper.addDeblockingRecord(deblocking);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 设置解封用户信息
|
|
|
|
|
- */
|
|
|
|
|
- private void setDeblockLoginInfo(List<RiskDeblockingListView> deblockingList,List<YtDyzUser> data) {
|
|
|
|
|
- Map<String, YtDyzUser> collect = data.stream().collect(Collectors.toMap(YtDyzUser::getUserId, o->o));
|
|
|
|
|
- for (RiskDeblockingListView view : deblockingList) {
|
|
|
|
|
- if(!collect.containsKey(view.getUserId())) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- YtDyzUser dyzUser = collect.get(view.getUserId());
|
|
|
|
|
- view.setPlatformId(dyzUser.getPlatformId());
|
|
|
|
|
- view.setChannelId(dyzUser.getUserId());
|
|
|
|
|
- view.setUserId(dyzUser.getUserId());
|
|
|
|
|
- view.setNickName(dyzUser.getNickName());
|
|
|
|
|
- view.setRegistryTime(dyzUser.getRegistryTime());
|
|
|
|
|
- view.setLastLoginTime(dyzUser.getLastLoginTime());
|
|
|
|
|
- view.setUserStatus(dyzUser.getUserStatus());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- /**
|
|
|
|
|
- * 设置封禁用户信息
|
|
|
|
|
- */
|
|
|
|
|
- private void setBannedLoginInfo(List<RiskBannedListView> bannedList, List<YtDyzUser> data) {
|
|
|
|
|
- Map<String, YtDyzUser> collectMap = data.stream().collect(Collectors.toMap(
|
|
|
|
|
- item-> StrUtil.format("{}_{}", item.getAppId(), item.getUserId()), o -> o));
|
|
|
|
|
- for (RiskBannedListView view : bannedList) {
|
|
|
|
|
- String key = StrUtil.format("{}_{}", view.getAppId(), view.getUserId());
|
|
|
|
|
- if(!collectMap.containsKey(key))continue;
|
|
|
|
|
- YtDyzUser dyzUser = collectMap.get(key);
|
|
|
|
|
- List<YtDyzLoginRecord> recordList = dyzUser.getLoginRecordList();
|
|
|
|
|
- if(CollUtil.isNotEmpty(recordList)){
|
|
|
|
|
- view.setPhoneModel(recordList.get(0).getDeviceModel());
|
|
|
|
|
- view.setPhoneBrand(recordList.get(0).getDeviceBrand());
|
|
|
|
|
- view.setIpAddr(recordList.get(0).getIpAddr());
|
|
|
|
|
- view.setCommunicationOperator(recordList.get(0).getOperator());
|
|
|
|
|
- }
|
|
|
|
|
- view.setPlatformId(dyzUser.getPlatformId());
|
|
|
|
|
- view.setChannelId(dyzUser.getUserId());
|
|
|
|
|
- view.setUserId(dyzUser.getUserId());
|
|
|
|
|
- view.setNickName(dyzUser.getNickName());
|
|
|
|
|
- view.setRegistryTime(dyzUser.getRegistryTime());
|
|
|
|
|
- view.setLastLoginIp(dyzUser.getLastLoginIp());
|
|
|
|
|
- view.setLastLoginTime(dyzUser.getLastLoginTime());
|
|
|
|
|
- view.setUserStatus(dyzUser.getUserStatus());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 增加封禁记录
|
|
* 增加封禁记录
|