Commit 4293ad11 authored by 吴琼's avatar 吴琼

将mo-sidecar接口挪至customer-service

parent ea3b1979
...@@ -156,11 +156,8 @@ public class UserRest { ...@@ -156,11 +156,8 @@ public class UserRest {
public JsonResult modifyUserDetail(@RequestParam(required = true) Long userId, public JsonResult modifyUserDetail(@RequestParam(required = true) Long userId,
@RequestParam(required = true) String realName, @RequestParam(required = true) String realName,
@RequestParam(required = true) String idNO) { @RequestParam(required = true) String idNO) {
MoResult<String> result = userService.modifyUserDetail(userId, realName, idNO); //MoResult<String> result = userService.modifyUserDetail(userId, realName, idNO);
if(!result.isSuccess()){ return userService.modifyUserDetailNew(userId, realName, idNO);
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
}
return JsonResult.buildSuccessResult(result.getMsg(),result.getData());
} }
/** /**
...@@ -170,26 +167,29 @@ public class UserRest { ...@@ -170,26 +167,29 @@ public class UserRest {
*/ */
@PostMapping(value = "/pwd/reset") @PostMapping(value = "/pwd/reset")
public JsonResult passwordReset(@RequestParam(required = true) String phone) { public JsonResult passwordReset(@RequestParam(required = true) String phone) {
MoResult<String> result = userService.passwordRest(phone); //MoResult<String> result = userService.passwordRest(phone);
if(!result.isSuccess()){ return userService.passwordRestNew(phone);
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
}
return JsonResult.buildSuccessResult(result.getMsg(),result.getData());
} }
/** /**
* 修改用户账户状态(注销) * 修改用户账户状态(注销)--更新为禁用
* *
* @return * @return
*/ */
@PostMapping(value = "/modify/account/status/disable") @PostMapping(value = "/modify/account/status/disable")
public JsonResult modifyAccountStatusDisable(@RequestParam(required = true) Long userId) { public JsonResult modifyAccountStatusDisable(@RequestParam(required = true) Long userId) {
//MoResult<Boolean> result = userService.modifyAccountStatusDisable(userId); //MoResult<Boolean> result = userService.modifyAccountStatusDisable(userId);
MoResult<Boolean> result = userService.modifyAccountStatusDisableNew(userId); return userService.modifyAccountStatusDisableNew(userId);
if(!result.isSuccess()){ }
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
} /**
return JsonResult.buildSuccessResult(result.getMsg(),result.getData()); * 新增接口
* 注销账户,删除账户信息
* @return
*/
@PostMapping(value = "/modify/account/delete")
public JsonResult deleteAccount(@RequestParam(required = true) Long userId) {
return userService.deleteAccount(userId);
} }
/** /**
...@@ -199,11 +199,8 @@ public class UserRest { ...@@ -199,11 +199,8 @@ public class UserRest {
*/ */
@PostMapping(value = "/modify/account/status/active") @PostMapping(value = "/modify/account/status/active")
public JsonResult modifyAccountStatusActive(@RequestParam(required = true) Long userId) { public JsonResult modifyAccountStatusActive(@RequestParam(required = true) Long userId) {
MoResult<Boolean> result = userService.modifyAccountStatusActive(userId); //MoResult<Boolean> result = userService.modifyAccountStatusActive(userId);
if(!result.isSuccess()){ return userService.modifyAccountStatusActiveNew(userId);
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
}
return JsonResult.buildSuccessResult(result.getMsg(),result.getData());
} }
...@@ -267,6 +264,7 @@ public class UserRest { ...@@ -267,6 +264,7 @@ public class UserRest {
@PostMapping(value = "/search/userInfo") @PostMapping(value = "/search/userInfo")
public JsonResult getBasicUserInfo(UserQueryParam userQueryParam) { public JsonResult getBasicUserInfo(UserQueryParam userQueryParam) {
JsonResult result = userService.findUserInfoByUserParam(userQueryParam); JsonResult result = userService.findUserInfoByUserParam(userQueryParam);
//JsonResult result = userService.findUserInfoByUserParamNew(userQueryParam);
if(!result.isSuccess()){ if(!result.isSuccess()){
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData()); return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
} }
......
...@@ -49,7 +49,7 @@ public interface IUserService extends UserDetailsService { ...@@ -49,7 +49,7 @@ public interface IUserService extends UserDetailsService {
* @param phoneNo * @param phoneNo
* @return * @return
*/ */
MoResult<String> passwordRestNew(String phoneNo); JsonResult passwordRestNew(String phoneNo);
/** /**
* 注销账户 * 注销账户
...@@ -57,12 +57,19 @@ public interface IUserService extends UserDetailsService { ...@@ -57,12 +57,19 @@ public interface IUserService extends UserDetailsService {
* @return * @return
*/ */
MoResult<Boolean> modifyAccountStatusDisable(Long userId); MoResult<Boolean> modifyAccountStatusDisable(Long userId);
/**
* 注销账户新逻辑--冻结账户
* @param userId
* @return
*/
JsonResult modifyAccountStatusDisableNew(Long userId);
/** /**
* 注销账户新逻辑 * 注销账户新逻辑
* @param userId * @param userId
* @return * @return
*/ */
MoResult<Boolean> modifyAccountStatusDisableNew(Long userId); JsonResult deleteAccount(Long userId);
/** /**
* 激活账户 * 激活账户
...@@ -75,7 +82,7 @@ public interface IUserService extends UserDetailsService { ...@@ -75,7 +82,7 @@ public interface IUserService extends UserDetailsService {
* @param userId * @param userId
* @return * @return
*/ */
MoResult<Boolean> modifyAccountStatusActiveNew(Long userId); JsonResult modifyAccountStatusActiveNew(Long userId);
/** /**
* 修改用户姓名、身份证 * 修改用户姓名、身份证
...@@ -86,12 +93,14 @@ public interface IUserService extends UserDetailsService { ...@@ -86,12 +93,14 @@ public interface IUserService extends UserDetailsService {
*/ */
MoResult<String> modifyUserDetail(Long userId, String realName, String idNO); MoResult<String> modifyUserDetail(Long userId, String realName, String idNO);
MoResult<String> modifyUserDetailNew(Long userId, String realName, String idNO); JsonResult modifyUserDetailNew(Long userId, String realName, String idNO);
MoResult<String> getRewardPointsType(); MoResult<String> getRewardPointsType();
JsonResult<UserBasicInfo> findUserInfoByUserParam(UserQueryParam userQueryParam); JsonResult<UserBasicInfo> findUserInfoByUserParam(UserQueryParam userQueryParam);
JsonResult<UserBasicInfo> findUserInfoByUserParamNew(UserQueryParam userQueryParam);
MoResult<String> queryPointDetailByPage(UserQueryParam userQueryParam); MoResult<String> queryPointDetailByPage(UserQueryParam userQueryParam);
MoResult<String> queryUserCouponInfoByUserParam(UserQueryParam userQueryParam); MoResult<String> queryUserCouponInfoByUserParam(UserQueryParam userQueryParam);
......
...@@ -352,6 +352,31 @@ public class UserServiceImpl implements IUserService { ...@@ -352,6 +352,31 @@ public class UserServiceImpl implements IUserService {
} }
private JsonResult getUserBasicInfoResultNew(UserSysResult<XUser> xUserUserSysResult) {
Object xUserData = getJsonResultData(xUserUserSysResult);
UserBasicInfo userBasicInfo = new UserBasicInfo();
if (Objects.isNull(xUserData)) {
log.error(" 用户不存在 userSysResult={}", xUserData);
return JsonResult.buildErrorStateResult("用户不存在", xUserData);
}
if (xUserData instanceof XUser) {
XUser xUser = (XUser) xUserData;
userBasicInfo.setUserId(xUser.getId());
userBasicInfo.setPhoneNo(DesensitizeUtil.phoneMark(xUser.getPhoneNo()));
userBasicInfo.setPhoneNumber(xUser.getPhoneNo());
String createAt = DateUtil.format(xUser.getCreatedAt(), DateUtil.DATE_FORMAT_1);
userBasicInfo.setCreatedAt(createAt);
Boolean enable = xUser.getEnable();
userBasicInfo.setStatus(enable == null ? "未知" : (enable ? "正常" : "封禁"));
}else{
log.error("查询用户失败 user={}",xUserData);
return (JsonResult) xUserData;
}
return JsonResult.buildSuccessResult(null, userBasicInfo);
}
private JsonResult getUserBasicInfoResult(UserSysResult<XUser> xUserUserSysResult, UserSysResult<XUserDetail> detailUserSysResult) { private JsonResult getUserBasicInfoResult(UserSysResult<XUser> xUserUserSysResult, UserSysResult<XUserDetail> detailUserSysResult) {
Object detailUser = getJsonResultData(detailUserSysResult); Object detailUser = getJsonResultData(detailUserSysResult);
Object xUserData = getJsonResultData(xUserUserSysResult); Object xUserData = getJsonResultData(xUserUserSysResult);
...@@ -719,27 +744,26 @@ public class UserServiceImpl implements IUserService { ...@@ -719,27 +744,26 @@ public class UserServiceImpl implements IUserService {
} }
//新逻辑,直接调用用户中心,不经过sidecar系统 //新逻辑,直接调用用户中心,不经过sidecar系统
@Override @Override
public MoResult<String> passwordRestNew(String phone) { public JsonResult passwordRestNew(String phone) {
try { try {
MoResult moResult = null;
Map<String, String> header = Maps.newHashMap(); Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded"); header.put("Content-type", "application/x-www-form-urlencoded");
Map param = Maps.newHashMap(); Map param = Maps.newHashMap();
param.put("phone", phone); param.put("phone", phone);
String userUrl = userSysUrl + "/innerapi/user/password/reset"; String userUrl = userSysUrl + "/innerapi/user/password/reset";
String userResult = httpService.post(userUrl, header, param); String userResult = httpService.post(userUrl, header, param);
JSONObject userJsonObject =null;
if(userResult != null){ if(userResult != null){
JSONObject userJsonObject = JSONObject.parseObject(userResult); userJsonObject = JSONObject.parseObject(userResult);
String userBusinessCode = userJsonObject.getString("businessCode"); String userBusinessCode = userJsonObject.getString("businessCode");
if("0000".equals(userBusinessCode)){ if("0000".equals(userBusinessCode)){
moResult = GSON.fromJson(userResult, MoResult.class); return JsonResult.buildSuccessResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
}else{ }else{
moResult = GSON.fromJson("调用用户中心接口报错", MoResult.class); return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
} }
}else{ }else{
moResult = GSON.fromJson("调用用户中心接口报错", MoResult.class); return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
} }
return moResult;
} catch (Exception e) { } catch (Exception e) {
log.error("[user][passwordRestNew] 网络通讯异常,phone:{},ex:{}", phone, ExceptionUtils.getStackTrace(e)); log.error("[user][passwordRestNew] 网络通讯异常,phone:{},ex:{}", phone, ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR); throw new BusinessException(ErrorCodeEnum.NET_ERROR);
...@@ -765,11 +789,7 @@ public class UserServiceImpl implements IUserService { ...@@ -765,11 +789,7 @@ public class UserServiceImpl implements IUserService {
} }
//新逻辑 //新逻辑
@Override @Override
public MoResult<Boolean> modifyAccountStatusDisableNew(Long userId) { public JsonResult modifyAccountStatusDisableNew(Long userId) {
//String url = sidecarUrl + "/middle_office/kefu/user/disable";
//修改为调用vcc_talos
//判断是否有在途业务
MoResult moResult = null;
try { try {
//调用天津自牧finance-gateway接口,将电商userid,转换为金融userid //调用天津自牧finance-gateway接口,将电商userid,转换为金融userid
String url = talosHttp + "/api/inner/kdsp/hasBusiness"; String url = talosHttp + "/api/inner/kdsp/hasBusiness";
...@@ -779,39 +799,69 @@ public class UserServiceImpl implements IUserService { ...@@ -779,39 +799,69 @@ public class UserServiceImpl implements IUserService {
param.put("userId", userId); param.put("userId", userId);
String result = httpService.get(url,header,param); String result = httpService.get(url,header,param);
if(result!=null){ if(result!=null){
JSONObject jsonObject = JSONObject.parseObject(result); JSONObject jsonObject = JSONObject.parseObject(result);;
//String dataStr = jsonObject.getString("data");
String businessCode = jsonObject.getString("businessCode"); String businessCode = jsonObject.getString("businessCode");
//返回信息c //返回信息
String msg = jsonObject.getString("msg"); JSONObject userJsonObject = null;
if("0000".equals(businessCode) && StringUtils.isBlank(msg)){ if("0000".equals(businessCode)){
//如果不存在则调用用户中心去注销 //调用用户中心,将账户状态更新为冻结
//调用用户中心
Map param1 = Maps.newHashMap(); Map param1 = Maps.newHashMap();
param1.put("userId", userId.toString()); param1.put("userId", userId.toString());
String userUrl = userSysUrl + "/innerapi/user/disable"; String userUrl = userSysUrl + "/innerapi/user/disable";
String userResult = httpService.post(userUrl, header, param1); String userResult = httpService.post(userUrl, header, param1);
JSONObject userJsonObject = JSONObject.parseObject(userResult); userJsonObject = JSONObject.parseObject(userResult);
//String userDataStr = userJsonObject.getString("data");
String userBusinessCode = userJsonObject.getString("businessCode"); String userBusinessCode = userJsonObject.getString("businessCode");
if("0000".equals(userBusinessCode)){ if("0000".equals(userBusinessCode)){
moResult = GSON.fromJson(result, MoResult.class); return JsonResult.buildSuccessResult(userJsonObject.getString("msg"),jsonObject.get("data"));
}else{
return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),jsonObject.get("data"));
} }
}else{ }else{
//如果存在则不能注销 return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),jsonObject.get("data"));
moResult = GSON.fromJson(result, MoResult.class);
} }
}else{ }else{
moResult = GSON.fromJson("调用第三方接口报错", MoResult.class); return JsonResult.buildErrorStateResult("",null);
} }
log.info("[user][modifyAccountStatusDisableNew] 请求业务系统返回值:{}", result);
return moResult;
} catch (Exception e) { } catch (Exception e) {
log.error("[user][modifyAccountStatusDisableNew] 网络通讯异常,userId:{},ex:{}", userId, ExceptionUtils.getStackTrace(e)); log.error("[user][modifyAccountStatusDisableNew] 网络通讯异常,userId:{},ex:{}", userId, ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR); throw new BusinessException(ErrorCodeEnum.NET_ERROR);
} }
} }
/**
* 真正的注销账户,删除账户信息
* @param userId
* @return
*/
@Override
public JsonResult deleteAccount(Long userId) {
//调用kdsp接口
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
header.put("qg-tenant-id", "560761");
String kdspUrl = kdspOperationUrl + "/api/kdsp/customer/logged-off";
Map param = Maps.newHashMap();
param.put("userId", userId.toString());
String result = httpService.post(kdspUrl, header, param);
JSONObject jsonObject = JSONObject.parseObject(result);;
String businessCode = jsonObject.getString("businessCode");
if(!"0000".equals(businessCode)){
return JsonResult.buildErrorStateResult(jsonObject.getString("msg"),jsonObject.get("data"));
}
//删除用户相关信息
String userUrl = userSysUrl + "/innerapi/user/delete/"+userId;
String userResult = httpService.get(userUrl, header);
if(userResult!=null){
JSONObject userJsonObject = JSONObject.parseObject(userResult);;
String userBusinessCode = jsonObject.getString("businessCode");
if("0000".equals(userBusinessCode)){
return JsonResult.buildSuccessResult(userJsonObject.getString("msg"),jsonObject.get("data"));
}else{
return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),jsonObject.get("data"));
}
}
return JsonResult.buildSuccessResult("",null);
}
@Override @Override
public MoResult<Boolean> modifyAccountStatusActive(Long userId) { public MoResult<Boolean> modifyAccountStatusActive(Long userId) {
...@@ -832,12 +882,10 @@ public class UserServiceImpl implements IUserService { ...@@ -832,12 +882,10 @@ public class UserServiceImpl implements IUserService {
} }
//新逻辑,不通过sidecar,直接调用用户中心 //新逻辑,不通过sidecar,直接调用用户中心
@Override @Override
public MoResult<Boolean> modifyAccountStatusActiveNew(Long userId) { public JsonResult modifyAccountStatusActiveNew(Long userId) {
try { try {
MoResult moResult = null;
if(userId == null || "0".equals(userId.toString())){ if(userId == null || "0".equals(userId.toString())){
moResult = GSON.fromJson("userId非法", MoResult.class); return JsonResult.buildErrorStateResult("userId非法",null);
return moResult;
} }
Map<String, String> header = Maps.newHashMap(); Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded"); header.put("Content-type", "application/x-www-form-urlencoded");
...@@ -845,18 +893,18 @@ public class UserServiceImpl implements IUserService { ...@@ -845,18 +893,18 @@ public class UserServiceImpl implements IUserService {
param.put("userId", userId); param.put("userId", userId);
String userUrl = userSysUrl + "/innerapi/user/active"; String userUrl = userSysUrl + "/innerapi/user/active";
String userResult = httpService.post(userUrl, header, param); String userResult = httpService.post(userUrl, header, param);
JSONObject userJsonObject = null;
if(userResult != null){ if(userResult != null){
JSONObject userJsonObject = JSONObject.parseObject(userResult); userJsonObject = JSONObject.parseObject(userResult);
String userBusinessCode = userJsonObject.getString("businessCode"); String userBusinessCode = userJsonObject.getString("businessCode");
if("0000".equals(userBusinessCode)){ if("0000".equals(userBusinessCode)){
moResult = GSON.fromJson(userResult, MoResult.class); return JsonResult.buildSuccessResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
}else{ }else{
moResult = GSON.fromJson("调用用户中心接口报错", MoResult.class); return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
} }
}else{ }else{
moResult = GSON.fromJson("调用用户中心接口报错", MoResult.class); return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
} }
return moResult;
} catch (Exception e) { } catch (Exception e) {
log.error("[user][modifyAccountStatusActiveNew] 网络通讯异常,userId:{},ex:{}", userId, ExceptionUtils.getStackTrace(e)); log.error("[user][modifyAccountStatusActiveNew] 网络通讯异常,userId:{},ex:{}", userId, ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR); throw new BusinessException(ErrorCodeEnum.NET_ERROR);
...@@ -864,33 +912,30 @@ public class UserServiceImpl implements IUserService { ...@@ -864,33 +912,30 @@ public class UserServiceImpl implements IUserService {
} }
@Override @Override
public MoResult<String> modifyUserDetailNew(Long userId, String realName, String idNO) { public JsonResult modifyUserDetailNew(Long userId, String realName, String idNO) {
try { try {
MoResult moResult = null;
if(userId == null || "0".equals(userId.toString())){ if(userId == null || "0".equals(userId.toString())){
moResult = GSON.fromJson("userId非法", MoResult.class); return JsonResult.buildErrorStateResult("userId非法",null);
return moResult;
} }
Map<String, String> header = Maps.newHashMap(); Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded"); header.put("Content-type", "application/x-www-form-urlencoded");
Map param = Maps.newHashMap(); Map param = Maps.newHashMap();
param.put("userId", userId);
param.put("name", realName); param.put("name", realName);
param.put("idNo", idNO); param.put("idNo", idNO);
String userUrl = userSysUrl + "/innerapi/userDetail/reset/"+userId; String userUrl = userSysUrl + "/innerapi/userDetail/reset/"+userId;
String userResult = httpService.post(userUrl, header, param); String userResult = httpService.post(userUrl, header, param);
JSONObject userJsonObject = null;
if(userResult != null){ if(userResult != null){
JSONObject userJsonObject = JSONObject.parseObject(userResult); userJsonObject = JSONObject.parseObject(userResult);
String userBusinessCode = userJsonObject.getString("businessCode"); String userBusinessCode = userJsonObject.getString("businessCode");
if("0000".equals(userBusinessCode)){ if("0000".equals(userBusinessCode)){
moResult = GSON.fromJson(userResult, MoResult.class); return JsonResult.buildSuccessResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
}else{ }else{
moResult = GSON.fromJson("调用用户中心接口报错", MoResult.class); return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
} }
}else{ }else{
moResult = GSON.fromJson("调用用户中心接口报错", MoResult.class); return JsonResult.buildErrorStateResult(userJsonObject.getString("msg"),userJsonObject.get("data"));
} }
return moResult;
} catch (Exception e) { } catch (Exception e) {
log.error("[user][modifyUserDetailNew] 网络通讯异常,userId:{},ex:{}", userId, ExceptionUtils.getStackTrace(e)); log.error("[user][modifyUserDetailNew] 网络通讯异常,userId:{},ex:{}", userId, ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR); throw new BusinessException(ErrorCodeEnum.NET_ERROR);
...@@ -920,7 +965,6 @@ public class UserServiceImpl implements IUserService { ...@@ -920,7 +965,6 @@ public class UserServiceImpl implements IUserService {
@Override @Override
public MoResult<String> getRewardPointsType(){ public MoResult<String> getRewardPointsType(){
String url = kdspOperationUrl + "/api/kdsp/op/userBenefits/center/getEventType"; String url = kdspOperationUrl + "/api/kdsp/op/userBenefits/center/getEventType";
//String url = "http://192.168.28.55:8033/api/kdsp/op/userBenefits/center/getEventType";
try { try {
Map<String, String> header = Maps.newHashMap(); Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded"); header.put("Content-type", "application/x-www-form-urlencoded");
...@@ -933,6 +977,7 @@ public class UserServiceImpl implements IUserService { ...@@ -933,6 +977,7 @@ public class UserServiceImpl implements IUserService {
throw new BusinessException(ErrorCodeEnum.NET_ERROR); throw new BusinessException(ErrorCodeEnum.NET_ERROR);
} }
} }
//旧逻辑
@Override @Override
public JsonResult findUserInfoByUserParam(UserQueryParam userQueryParam) { public JsonResult findUserInfoByUserParam(UserQueryParam userQueryParam) {
final String LOG_PRE = "UserServiceImpl.findUserInfoByUserParam"; final String LOG_PRE = "UserServiceImpl.findUserInfoByUserParam";
...@@ -1014,6 +1059,87 @@ public class UserServiceImpl implements IUserService { ...@@ -1014,6 +1059,87 @@ public class UserServiceImpl implements IUserService {
return null; return null;
} }
//新逻辑
@Override
public JsonResult findUserInfoByUserParamNew(UserQueryParam userQueryParam) {
final String LOG_PRE = "UserServiceImpl.findUserInfoByUserParamNew";
log.info("{} 查询用户信息 UserQueryParam={}", LOG_PRE, userQueryParam);
//通过userId查询
UserSysResult<XUser> userByUserId = null;
UserSysResult<XUserDetail> userDetailByUserId= null;
if (Objects.nonNull(userQueryParam.getUserId())) {
log.info("{} 通过userId查询 userId={}", LOG_PRE, userQueryParam.getUserId());
userByUserId = userSdk.getService().findUserByUserId(userQueryParam.getUserId());
userDetailByUserId = userSdk.getService().findUserDetailByUserId(userQueryParam.getUserId());
}
UserSysResult<XUser> userByPhoneNo = null;
UserSysResult<XUserDetail> userDetailByPhone = null;
if (StringUtils.isNotBlank(userQueryParam.getPhoneNo())) {
log.info("{} 通过phoneNo查询 phoneNo={}", LOG_PRE, userQueryParam.getPhoneNo());
userByPhoneNo = userSdk.getService().findUserByPhoneNo(userQueryParam.getPhoneNo());
userDetailByPhone = userSdk.getService().findUserDetailByPhone(userQueryParam.getPhoneNo());
//根据传入的身份证和查询出的用户信息中身份证进行比较,如果不一致返回查询失败
if (StringUtils.isNotEmpty(userQueryParam.getIdNo()) && userDetailByPhone != null && userDetailByPhone.getData() != null) {
XUserDetail xUserDetail = userDetailByPhone.getData();
String idNo = xUserDetail.getIdNo();
if (StringUtils.isNotEmpty(idNo)) {
idNo = idNo.trim().toUpperCase();
}
String paramIdNo = userQueryParam.getIdNo().trim().toUpperCase();
if (!paramIdNo.equals(idNo)) {
return JsonResult.buildErrorStateResult("无有效查询参数", null);
}
}
}
//校验手机号查不到用户的情况
if (Objects.nonNull(userQueryParam.getUserId())) {
if(userByUserId == null || userByUserId.getData() ==null){
return JsonResult.buildErrorStateResult("用户不存在", null);
}
}
if (StringUtils.isNotBlank(userQueryParam.getPhoneNo())) {
if(userByPhoneNo == null || userByPhoneNo.getData() ==null){
return JsonResult.buildErrorStateResult("用户不存在", null);
}
}
//校验手机号和userid不是一个人
if(Objects.nonNull(userQueryParam.getUserId()) && StringUtils.isNotBlank(userQueryParam.getPhoneNo())){
if(userByUserId != null && userDetailByUserId != null && userByPhoneNo != null && userDetailByPhone != null){
if(userByUserId.getData() != null && userByPhoneNo.getData() != null
&& !userByUserId.getData().getId().equals(userByPhoneNo.getData().getId())){
return JsonResult.buildErrorStateResult("用户不存在", null);
}
}
}
//调用kdsp接口获取会员权益相关信息
String url= kdspOperationUrl +"/api/kdsp/op/userBenefits/user-benefits-point/getUserBenefit";
String result = "";
try {
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
Map param = Maps.newHashMap();
if (Objects.nonNull(userQueryParam.getUserId())) {
param.put("userId", String.valueOf(userQueryParam.getUserId()));
}
if (StringUtils.isNotBlank(userQueryParam.getPhoneNo())) {
param.put("userId", String.valueOf(userByPhoneNo.getData().getId()));
}
result = httpService.post(url, header,param);
} catch (Exception e) {
log.error("[userServiceImpl][findUserInfoByUserParamNew] 网络通讯异常,userId:{},ex:{}",ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR);
}
if (Objects.nonNull(userQueryParam.getUserId())) {
return getUserBasicInfoResultAndUserBenefits(userByUserId, userDetailByUserId,result);
}
if (StringUtils.isNotBlank(userQueryParam.getPhoneNo())) {
return getUserBasicInfoResultAndUserBenefits(userByPhoneNo, userDetailByPhone,result);
}
return null;
}
@Override @Override
public MoResult<String> queryUserCouponInfoByUserParam(UserQueryParam userQueryParam) { public MoResult<String> queryUserCouponInfoByUserParam(UserQueryParam userQueryParam) {
...@@ -1072,7 +1198,6 @@ public class UserServiceImpl implements IUserService { ...@@ -1072,7 +1198,6 @@ public class UserServiceImpl implements IUserService {
userBasicInfo.setLevelValidityTerm(jsonObject.getString("levelValidityTerm")); userBasicInfo.setLevelValidityTerm(jsonObject.getString("levelValidityTerm"));
} }
Object detailUser = getJsonResultData(detailUserSysResult);
Object xUserData = getJsonResultData(xUserUserSysResult); Object xUserData = getJsonResultData(xUserUserSysResult);
if (Objects.isNull(xUserData)) { if (Objects.isNull(xUserData)) {
log.error(" 用户不存在 userSysResult={}", xUserData); log.error(" 用户不存在 userSysResult={}", xUserData);
...@@ -1092,11 +1217,15 @@ public class UserServiceImpl implements IUserService { ...@@ -1092,11 +1217,15 @@ public class UserServiceImpl implements IUserService {
log.error("查询用户失败 user={}",xUserData); log.error("查询用户失败 user={}",xUserData);
return (JsonResult) xUserData; return (JsonResult) xUserData;
} }
if (detailUser instanceof XUserDetail) {
XUserDetail userDetail = (XUserDetail) detailUser; if(detailUserSysResult != null){
userBasicInfo.setGender(userDetail.getGender().getName()); Object detailUser = getJsonResultData(detailUserSysResult);
userBasicInfo.setIdNo(DesensitizeUtil.idNoMark(userDetail.getIdNo())); if (detailUser instanceof XUserDetail) {
userBasicInfo.setName(userDetail.getName()); XUserDetail userDetail = (XUserDetail) detailUser;
userBasicInfo.setGender(userDetail.getGender().getName());
userBasicInfo.setIdNo(DesensitizeUtil.idNoMark(userDetail.getIdNo()));
userBasicInfo.setName(userDetail.getName());
}
} }
return JsonResult.buildSuccessResult(null, userBasicInfo); return JsonResult.buildSuccessResult(null, userBasicInfo);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment