Commit c17ca44c authored by yexiong.wang's avatar yexiong.wang

Merge branch 'master' into offlineRepayClear_20220115

parents 7c75febc c8632e52
...@@ -26,7 +26,7 @@ import java.util.Objects; ...@@ -26,7 +26,7 @@ import java.util.Objects;
* @Desc 鉴权过滤器 * @Desc 鉴权过滤器
* @Update * @Update
*/ */
@WebFilter(filterName = "operatePermitFilter",urlPatterns = {"/operate/sys/*"}) @WebFilter(filterName = "operatePermitFilter",urlPatterns = {"/operate/sys/*","/repay/earlySettleOperate"})
@Slf4j @Slf4j
public class ValidOperatePermitFilter implements Filter { public class ValidOperatePermitFilter implements Filter {
@Autowired @Autowired
......
...@@ -2,6 +2,8 @@ package cn.quantgroup.customer.model.xyqbuser; ...@@ -2,6 +2,8 @@ package cn.quantgroup.customer.model.xyqbuser;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
/** /**
* 信用钱包用户基本展示信息 * 信用钱包用户基本展示信息
* *
...@@ -41,6 +43,24 @@ public class UserBasicInfo { ...@@ -41,6 +43,24 @@ public class UserBasicInfo {
* 手机号(明文) * 手机号(明文)
*/ */
private String phoneNumber; private String phoneNumber;
/**
*客户权益
*/
private String levelBenefit;
/**
* 等级
*/
private Integer level;
/**
* 等级名称
*/
private String levelName;
/**
* 积分
*/
private BigDecimal point;
/**
* 有效期
*/
private String levelValidityTerm;
} }
package cn.quantgroup.customer.rest; package cn.quantgroup.customer.rest;
import cn.quantgroup.customer.aop.OperateLog;
import cn.quantgroup.customer.enums.ErrorCodeEnum; import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.rest.param.card.ModifyCardsQuery; import cn.quantgroup.customer.rest.param.card.ModifyCardsQuery;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateQueryReq;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateReq;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IRepayService; import cn.quantgroup.customer.service.IRepayService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Objects;
import static cn.quantgroup.customer.constant.Constant.GSON; import static cn.quantgroup.customer.constant.Constant.GSON;
@Slf4j @Slf4j
...@@ -66,4 +69,20 @@ public class RepayRest { ...@@ -66,4 +69,20 @@ public class RepayRest {
log.info("[查询还款操作记录],请求参数:businessFlowNo={}", businessFlowNo); log.info("[查询还款操作记录],请求参数:businessFlowNo={}", businessFlowNo);
return repayService.queryRepayOptRecords(businessFlowNo); return repayService.queryRepayOptRecords(businessFlowNo);
} }
@PostMapping("/earlySettleOperateQuery")
public JsonResult earlySettleOperateQuery(@Valid EarlySettleOperateQueryReq req) {
log.info("[earlySettleOperateQuery],请求参数: {}", JSONObject.toJSONString(req));
return repayService.settleOperateQuery(req);
}
@PostMapping("/earlySettleOperate")
@OperateLog(moduleName = "中台提前结清操作")
public JsonResult earlySettleOperate(@Valid EarlySettleOperateReq req) {
if (Objects.isNull(req) || StringUtils.isBlank(req.getCardNo()) || Objects.isNull(req.getLoanId())) {
return JsonResult.buildErrorStateResult(ErrorCodeEnum.PARAM_ERROR.getMessage(), ErrorCodeEnum.PARAM_ERROR.getCode());
}
return repayService.earlySettleOperate(req);
}
} }
...@@ -23,13 +23,14 @@ import org.apache.commons.lang3.StringUtils; ...@@ -23,13 +23,14 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
import java.security.Principal; import java.security.Principal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import static cn.quantgroup.customer.constant.Constant.GSON; import static cn.quantgroup.customer.constant.Constant.GSON;
...@@ -246,8 +247,56 @@ public class UserRest { ...@@ -246,8 +247,56 @@ public class UserRest {
} }
return JsonResult.buildSuccessResult("success", result); return JsonResult.buildSuccessResult("success", result);
} }
//add by wuq 2022-01-14 begin
/**
* 积分类型初始化
* @return
*/
@PostMapping(value = "/search/getRewardPointsType")
public JsonResult getRewardPointsTypeInit() {
MoResult<String> result = userService.getRewardPointsType();
if(!"0000".equals(result.getCode())){
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
}
return JsonResult.buildSuccessResult("success", result.getData());
}
/**
*根据userId和phoneNo查询基本信息
*/
@PostMapping(value = "/search/userInfo")
public JsonResult getBasicUserInfo(UserQueryParam userQueryParam) {
JsonResult result = userService.findUserInfoByUserParam(userQueryParam);
if(!result.isSuccess()){
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
}
return JsonResult.buildSuccessResult("success",result);
}
/**
*根据userId查询优惠券信息(详情)
*/
@RequestMapping(value = "/search/getUserCouponInfo")
public JsonResult getUserCouponInfo(UserQueryParam userQueryParam) {
MoResult<String> result = userService.queryUserCouponInfoByUserParam(userQueryParam);
if(!"0000".equals(result.getCode())){
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
}
return JsonResult.buildSuccessResult("success",result);
}
/**
*根据积分类型和操作时间查询积分明细
*/
@PostMapping(value = "/search/queryPointDetailByPage")
public JsonResult queryPointDetailByPage(UserQueryParam userQueryParam) {
if(Objects.isNull(userQueryParam.getUserId())){
return JsonResult.buildErrorStateResult("userId不能为空",null);
}
MoResult<String> result = userService.queryPointDetailByPage(userQueryParam);
if(result == null || !"0000".equals(result.getCode())){
return JsonResult.buildErrorStateResult(result.getMsg(),result.getData());
}
return JsonResult.buildSuccessResult("success", result.getData());
}
} }
package cn.quantgroup.customer.rest.param.repay;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EarlySettleOperateQueryReq implements Serializable {
@NotNull(message = "借款订单号不能为空")
private Long loanId;
}
package cn.quantgroup.customer.rest.param.repay;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EarlySettleOperateQueryResp implements Serializable {
private Long userId;
private String name;
private String phoneNo;
private String uuid;
private Long loanId;
private BigDecimal earlySettleTotalAmount;
private Boolean supportEarlySettle;
private String orderStatus;
private String orderStatusDesc;
private String cardNo;
}
package cn.quantgroup.customer.rest.param.repay;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EarlySettleOperateReq implements Serializable {
@NotNull(message = "借款订单号不能为空")
private Long loanId;
@NotNull(message = "银行卡号不能为空")
private String cardNo;
}
...@@ -22,4 +22,22 @@ public class UserQueryParam { ...@@ -22,4 +22,22 @@ public class UserQueryParam {
private Long userId; private Long userId;
private String uuid; private String uuid;
/**
* 积分类型
*/
private Integer eventType;
/**
* 操作时间
*/
private String operationTime;
/**
* 当前页数
*/
private Integer pageNo;
/**
* 每页多少条数据
*/
private Integer pageSize;
private String status;
} }
package cn.quantgroup.customer.service;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateQueryReq;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateQueryResp;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateReq;
import cn.quantgroup.customer.rest.vo.JsonResult;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
public interface IKoalaService {
JsonResult<List<EarlySettleOperateQueryResp>> settleOperateQuery(EarlySettleOperateQueryReq req);
JsonResult<JSONObject> earlySettleOperate(EarlySettleOperateReq req);
}
package cn.quantgroup.customer.service; package cn.quantgroup.customer.service;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateQueryReq;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateReq;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
...@@ -10,4 +12,8 @@ public interface IRepayService { ...@@ -10,4 +12,8 @@ public interface IRepayService {
JsonResult queryRepayInfo(RepayOrderInfoQuery repayOrderQuery); JsonResult queryRepayInfo(RepayOrderInfoQuery repayOrderQuery);
JsonResult queryRepayOptRecords(String businessFlowNo); JsonResult queryRepayOptRecords(String businessFlowNo);
JsonResult settleOperateQuery(EarlySettleOperateQueryReq req);
JsonResult earlySettleOperate(EarlySettleOperateReq req);
} }
...@@ -68,4 +68,11 @@ public interface IUserService extends UserDetailsService { ...@@ -68,4 +68,11 @@ 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> getRewardPointsType();
JsonResult<UserBasicInfo> findUserInfoByUserParam(UserQueryParam userQueryParam);
MoResult<String> queryPointDetailByPage(UserQueryParam userQueryParam);
MoResult<String> queryUserCouponInfoByUserParam(UserQueryParam userQueryParam);
} }
package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateQueryReq;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateQueryResp;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateReq;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.service.IKoalaService;
import cn.quantgroup.customer.service.http.IHttpService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Slf4j
@Service("koalaService")
public class KoalaServiceImpl implements IKoalaService {
@Value("${koala.https}")
private String koalaSysUrl;
private final IHttpService httpService;
private final UserSdkImpl userSdk;
@Autowired
public KoalaServiceImpl(IHttpService httpService, UserSdkImpl userSdk) {
this.httpService = httpService;
this.userSdk = userSdk;
}
@Override
public JsonResult<List<EarlySettleOperateQueryResp>> settleOperateQuery(EarlySettleOperateQueryReq req) {
JsonResult<List<EarlySettleOperateQueryResp>> jsonResult = null;
String url = koalaSysUrl + "/v1/repayment/early_settlement/earlySettleOperateQuery";
Map<String, Object> param = Maps.newHashMap();
param.put("loanId",req.getLoanId());
String response = httpService.get(url, param);
log.info("[KoalaServiceImpl][settleOperateQuery] param:{},请求业务系统返回值:{}", param, response);
if (StringUtils.isBlank(response)) {
return JsonResult.buildErrorStateResult("查询失败", null);
}
JSONObject jsonObject = JSONObject.parseObject(response);
if (jsonObject.getBoolean("success")) {
JSONArray data = jsonObject.getJSONArray("data");
jsonResult = JsonResult.buildSuccessResult("查询成功",data.toJavaList(EarlySettleOperateQueryResp.class));
} else {
jsonResult = JsonResult.buildErrorStateResult(jsonObject.getString("msg"));
}
return jsonResult;
}
@Override
public JsonResult<JSONObject> earlySettleOperate(EarlySettleOperateReq req) {
JsonResult<JSONObject> jsonResult = null;
String url = koalaSysUrl + "/v1/repayment/early_settlement/simpleCallPay";
Map<String, Object> param = Maps.newHashMap();
param.put("loanId",req.getLoanId());
param.put("cardNo",req.getCardNo());
param.put("noncestr","ceshikoalanoncestr");
String response = httpService.post(url, param);
log.info("[KoalaServiceImpl][earlySettleOperate] param:{},请求业务系统返回值:{}", param, response);
if (StringUtils.isBlank(response)) {
return JsonResult.buildErrorStateResult("请求失败", null);
}
JSONObject jsonObject = JSONObject.parseObject(response);
if (jsonObject.getBoolean("success")) {
jsonResult = JsonResult.buildSuccessResult("已操作",response);
} else {
jsonResult = JsonResult.buildErrorStateResult(jsonObject.getString("msg"));
}
return jsonResult;
}
}
...@@ -3,6 +3,8 @@ package cn.quantgroup.customer.service.impl; ...@@ -3,6 +3,8 @@ package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.constant.Constant; import cn.quantgroup.customer.constant.Constant;
import cn.quantgroup.customer.enums.ErrorCodeEnum; import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.exception.BusinessException; import cn.quantgroup.customer.exception.BusinessException;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateQueryReq;
import cn.quantgroup.customer.rest.param.repay.EarlySettleOperateReq;
import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderInfoQuery;
import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery; import cn.quantgroup.customer.rest.param.repay.RepayOrderQuery;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
...@@ -10,10 +12,7 @@ import cn.quantgroup.customer.rest.vo.MoResult; ...@@ -10,10 +12,7 @@ import cn.quantgroup.customer.rest.vo.MoResult;
import cn.quantgroup.customer.rest.vo.repay.RepayInfoResult; import cn.quantgroup.customer.rest.vo.repay.RepayInfoResult;
import cn.quantgroup.customer.rest.vo.repay.RepayOptRecord; import cn.quantgroup.customer.rest.vo.repay.RepayOptRecord;
import cn.quantgroup.customer.rest.vo.repay.XyqbRepayInfo; import cn.quantgroup.customer.rest.vo.repay.XyqbRepayInfo;
import cn.quantgroup.customer.service.IRepayService; import cn.quantgroup.customer.service.*;
import cn.quantgroup.customer.service.ISidecarService;
import cn.quantgroup.customer.service.IUserService;
import cn.quantgroup.customer.service.IXyqbService;
import cn.quantgroup.user.retbean.XUser; import cn.quantgroup.user.retbean.XUser;
import cn.quantgroup.user.vo.UserSysResult; import cn.quantgroup.user.vo.UserSysResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -33,13 +32,15 @@ public class RepayServiceImpl implements IRepayService { ...@@ -33,13 +32,15 @@ public class RepayServiceImpl implements IRepayService {
private final UserSdkImpl userSdk; private final UserSdkImpl userSdk;
private final IXyqbService xyqbService; private final IXyqbService xyqbService;
private final ISidecarService sidecarService; private final ISidecarService sidecarService;
private final IKoalaService koalaService;
@Autowired @Autowired
public RepayServiceImpl(IUserService userService, UserSdkImpl userSdk, IXyqbService xyqbService, ISidecarService sidecarService) { public RepayServiceImpl(IUserService userService, UserSdkImpl userSdk, IXyqbService xyqbService, ISidecarService sidecarService, IKoalaService koalaService) {
this.userService = userService; this.userService = userService;
this.userSdk = userSdk; this.userSdk = userSdk;
this.xyqbService = xyqbService; this.xyqbService = xyqbService;
this.sidecarService = sidecarService; this.sidecarService = sidecarService;
this.koalaService = koalaService;
} }
@Override @Override
...@@ -154,4 +155,16 @@ public class RepayServiceImpl implements IRepayService { ...@@ -154,4 +155,16 @@ public class RepayServiceImpl implements IRepayService {
log.info("[查询还款操作记录],返回 repayOptRecordResult={}", repayOptRecordResult); log.info("[查询还款操作记录],返回 repayOptRecordResult={}", repayOptRecordResult);
return JsonResult.buildSuccessResult("处理成功", repayOptRecordResult.getData()); return JsonResult.buildSuccessResult("处理成功", repayOptRecordResult.getData());
} }
@Override
public JsonResult settleOperateQuery(EarlySettleOperateQueryReq req) {
return koalaService.settleOperateQuery(req);
}
@Override
public JsonResult earlySettleOperate(EarlySettleOperateReq req) {
req.setCardNo(req.getCardNo().trim());
return koalaService.earlySettleOperate(req);
}
} }
...@@ -48,13 +48,14 @@ import org.springframework.data.domain.PageImpl; ...@@ -48,13 +48,14 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.quantgroup.customer.constant.Constant.GSON; import static cn.quantgroup.customer.constant.Constant.GSON;
...@@ -69,6 +70,9 @@ public class UserServiceImpl implements IUserService { ...@@ -69,6 +70,9 @@ public class UserServiceImpl implements IUserService {
private String sidecarUrl; private String sidecarUrl;
@Value("${kdsp.http.api}") @Value("${kdsp.http.api}")
private String kdspUrl; private String kdspUrl;
@Value("${kdsp-operation}")
private String kdspOperationUrl;
...@@ -352,6 +356,7 @@ public class UserServiceImpl implements IUserService { ...@@ -352,6 +356,7 @@ public class UserServiceImpl implements IUserService {
log.error(" 用户不存在 userSysResult={}", xUserData); log.error(" 用户不存在 userSysResult={}", xUserData);
return JsonResult.buildErrorStateResult("用户不存在", xUserData); return JsonResult.buildErrorStateResult("用户不存在", xUserData);
} }
if (xUserData instanceof XUser) { if (xUserData instanceof XUser) {
XUser xUser = (XUser) xUserData; XUser xUser = (XUser) xUserData;
userBasicInfo.setUserId(xUser.getId()); userBasicInfo.setUserId(xUser.getId());
...@@ -763,5 +768,213 @@ public class UserServiceImpl implements IUserService { ...@@ -763,5 +768,213 @@ public class UserServiceImpl implements IUserService {
throw new BusinessException(ErrorCodeEnum.NET_ERROR); throw new BusinessException(ErrorCodeEnum.NET_ERROR);
} }
} }
//add by wuq 2022-01-15 begin
@Override
public MoResult<String> getRewardPointsType(){
String url = kdspOperationUrl + "/api/kdsp/op/userBenefits/center/getEventType";
//String url = "http://192.168.28.55:8033/api/kdsp/op/userBenefits/center/getEventType";
try {
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
String result = httpService.post(url, header);
MoResult moResult = GSON.fromJson(result, MoResult.class);
log.info("[user][getRewardPointsType] 请求业务系统返回值:{}", result);
return moResult;
} catch (Exception e) {
log.error("[user][modifyUserDetail] 网络通讯异常,userId:{},ex:{}",ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR);
}
}
@Override
public JsonResult findUserInfoByUserParam(UserQueryParam userQueryParam) {
final String LOG_PRE = "UserServiceImpl.findUserInfoByUserParam";
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.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 || userDetailByUserId ==null || userByUserId.getData() ==null || userDetailByUserId.getData() ==null){
return JsonResult.buildErrorStateResult("用户不存在", null);
}
}
if (StringUtils.isNotBlank(userQueryParam.getPhoneNo())) {
if(userByPhoneNo == null || userDetailByPhone ==null || userByPhoneNo.getData() ==null || userDetailByPhone.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 url= "http://192.168.28.55:8033/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][findUserInfoByUserParam] 网络通讯异常,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
public MoResult<String> queryUserCouponInfoByUserParam(UserQueryParam userQueryParam) {
final String LOG_PRE = "UserServiceImpl.getUserCouponInfoByUserParam";
log.info("{} 查询用户信息 UserQueryParam={}", LOG_PRE, userQueryParam);
//调用kdsp接口获取会员优惠券相关信息
String url= kdspOperationUrl +"/api/kdsp/op/coupon/receiver/pickup-list";
//String url= "http://192.168.28.55:8033/api/kdsp/op/coupon/receiver/pickup-list";
try {
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
header.put("qg-tenant-id","560761");
Map param = Maps.newHashMap();
if (Objects.nonNull(userQueryParam.getUserId())) {
param.put("userId", String.valueOf(userQueryParam.getUserId()));
}
if (Objects.nonNull(userQueryParam.getStatus())) {
param.put("status", userQueryParam.getStatus());
}
if (Objects.nonNull(userQueryParam.getPageNo())) {
param.put("pageNo", userQueryParam.getPageNo());
}
if (Objects.nonNull(userQueryParam.getPageSize())) {
param.put("pageSize", userQueryParam.getPageSize());
}
String result = httpService.get(url, header, param);
MoResult moResult = GSON.fromJson(result, MoResult.class);
log.info("[user][queryUserCouponInfoByUserParam] 请求业务系统返回值:{}", result);
return moResult;
} catch (Exception e) {
log.error("[userServiceImpl][queryUserCouponInfoByUserParam] 网络通讯异常,userId:{},ex:{}",ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR);
}
}
/**
*根据userid和phoneNo获取基本信息
* @param xUserUserSysResult
* @param detailUserSysResult
* @return
*/
private JsonResult getUserBasicInfoResultAndUserBenefits
(UserSysResult<XUser> xUserUserSysResult, UserSysResult<XUserDetail> detailUserSysResult,String result) {
UserBasicInfo userBasicInfo = new UserBasicInfo();
//处理json字符串
JSONObject json =JSONObject.parseObject(result);
String jsonResult = json.getString("data");
if(jsonResult != null){
JSONObject jsonObject = JSONObject.parseObject(jsonResult);
userBasicInfo.setLevelBenefit(jsonObject.getString("levelBenefit"));
userBasicInfo.setLevel(Integer.valueOf(jsonObject.getString("level")));
userBasicInfo.setLevelName(jsonObject.getString("levelName"));
userBasicInfo.setPoint(new BigDecimal(jsonObject.getString("point")));
userBasicInfo.setLevelValidityTerm(jsonObject.getString("levelValidityTerm"));
}
Object detailUser = getJsonResultData(detailUserSysResult);
Object xUserData = getJsonResultData(xUserUserSysResult);
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;
}
if (detailUser instanceof XUserDetail) {
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
*/
public MoResult<String> queryPointDetailByPage(UserQueryParam userQueryParam) {
String url = kdspOperationUrl + "/api/kdsp/op/userBenefits/user-benefits-detail/queryPointDetailByPage";
//String url = "http://192.168.28.55:8033/api/kdsp/op/userBenefits/user-benefits-detail/queryPointDetailByPage";
try {
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/json");
Map param = Maps.newHashMap();
param.put("userId",userQueryParam.getUserId());
param.put("operationTime",userQueryParam.getOperationTime());
param.put("eventType",userQueryParam.getEventType());
param.put("pageNo",userQueryParam.getPageNo());
param.put("pageSize",userQueryParam.getPageSize());
String result = httpService.post(url, header, param);
MoResult<String> moResult = GSON.fromJson(result, MoResult.class);
return moResult;
} catch (Exception e) {
log.error("[userServiceImpl][queryPointDetailByPage] 网络通讯异常,userId:{},ex:{}", ExceptionUtils.getStackTrace(e));
throw new BusinessException(ErrorCodeEnum.NET_ERROR);
}
}
} }
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