Commit 2c45dd8f authored by 王亮's avatar 王亮

remove unused code.

parent 9e52f8e9
......@@ -681,7 +681,7 @@ public class UserController implements IBaseController {
String token = request.getHeader("x-auth-token");
if (null == token || "".equals(token)) {
if (org.apache.commons.lang3.StringUtils.isEmpty(token)) {
return JsonResult.buildErrorStateResult("服务器异常,请稍后再试", null);
}
......
package cn.quantgroup.xyqb.controller.external;
import cn.quantgroup.xyqb.controller.IBaseController;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.util.ValidationUtil;
import cn.quantgroup.xyqb.validator.ChineseName;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
/**
* Created by Miraculous on 2017/1/3.
*/
@Slf4j
@RestController
@RequestMapping("/user_detail")
@Validated
public class UserDetailController implements IBaseController {
@Autowired
private IUserDetailService userDetailService;
@Autowired
private IIdCardService idCardService;
/**
* 保存/更新用户实名信息
* 注:
* 本接口会验证用户登录状态,仅用于用户个人补全实名信息操作
* 产品逻辑是不允许用户重复设置实名信息的,但历史存在导流数据创建不完整实名信息的场景(可理解为和渠道有关)
* 故此本处保留修改逻辑,仍依赖业务端控制产品行为
*
* @param idNo
* @param name
* @return
* @yapi unknown
* @Deprecated 20210318
* @see cn.quantgroup.xyqb.controller.internal.user.InnerController#saveUserDetail(Long, String, String, String, String, String)
*/
@Deprecated
@RequestMapping("/save")
public JsonResult saveUserDetail(String idNo,
@ChineseName @RequestParam String name) {
if (!ValidationUtil.validateChinese(name)) {
log.error("姓名错误,name:{}", name);
return JsonResult.buildErrorStateResult("姓名错误", null);
}
User user = getCurrentUserFromRedis();
if (user == null) {
return JsonResult.buildErrorStateResult("系统错误", null);
}
IdCardInfo info = idCardService.getIdCardInfo(idNo);
if (info == null || !info.isValid()) {
log.error("身份证号错误,userId:{}, idNo: {}", user.getId(), idNo);
return JsonResult.buildErrorStateResult("身份证号码错误", null);
}
/* 保存或更新 */
UserDetail userDetail = userDetailService.findByUserId(user.getId());
if (Objects.isNull(userDetail)) {
userDetail = new UserDetail();
}
userDetail.setPhoneNo(user.getPhoneNo());
userDetail.setUserId(user.getId());
userDetail.setName(name);
userDetail.setGender(info.getGender());
userDetail.setIsAuthenticated(false);
log.info("UserDetailController saveUserDetail, userId:{}, phoneNo:{}, name:{}", user.getId(), user.getPhoneNo(), name);
try {
userDetailService.saveUserDetail(userDetail);
} catch (DataIntegrityViolationException ex) {
return JsonResult.buildSuccessResult("", null);
}
return JsonResult.buildSuccessResult("", null);
}
}
......@@ -162,7 +162,7 @@ public class AppController implements IBaseController {
log.info("第三方用户登录 [AppController] login --> loginFrom:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}", registerFrom, channelId, btRegisterChannelId, IpUtil.getRemoteIP(request), idNo, name);
User user = userService.findByPhoneInDb(phoneNo);
if (user == null) {
user = userRegisterService.register(registerFrom, phoneNo, idNo, name, channelId, btRegisterChannelId);
user = userRegisterService.register(registerFrom, phoneNo, name, channelId, btRegisterChannelId);
}
if (user == null) {
return JsonResult.buildErrorStateResult(USER_ERROR_OR_PASSWORD_ERROR, null);
......@@ -222,7 +222,7 @@ public class AppController implements IBaseController {
boolean isRegister=false;
if (user == null) {
try {
user = userRegisterService.register(registerFrom, phoneNo, idNo, name, channelId, btRegisterChannelId);
user = userRegisterService.register(registerFrom, phoneNo, name, channelId, btRegisterChannelId);
isRegister=true;
} catch (PersistenceException e) {
user = userService.findByPhoneInDb(phoneNo);
......@@ -349,26 +349,4 @@ public class AppController implements IBaseController {
return JsonResult.buildSuccessResult("登录成功", bean);
}
// @RequestMapping("/login33")
// public JsonResult login233() {
// User user = new User();
// user.setUuid("3213213321");
// user.setRegisteredFrom(221L);
// try {
// EventRecord userRecord = EventRecord.builder().setDistinctId(user.getUuid()).isLoginId(Boolean.TRUE)
// .setEventName("PD_WUXIEC_UserLoginVccCash")
// .addProperty("son_channel_id", user.getRegisteredFrom())
// .addProperty("parent_channel_id",-1L)
// .addProperty("vcc_uuid", user.getUuid())
// .build();
// iSensorsAnalytics.track(userRecord);
// iSensorsAnalytics.flush();
// log.info("神策上报成功");
// } catch (Exception e) {
// log.info("神策埋点出现问题", e);
// }
// return JsonResult.buildSuccessResult("登录成功", null);
//
// }
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,11 +3,8 @@ package cn.quantgroup.xyqb.controller.internal.user;
import cn.quantgroup.xyqb.aspect.accessable.IpValidator;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.UserModel;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.IUserService;
import cn.quantgroup.xyqb.util.ValidationUtil;
......@@ -38,8 +35,7 @@ public class SyncUserController {
private IUserService userService;
@Autowired
private IUserDetailService userDetailService;
@Autowired
private IIdCardService idCardService;
@RequestMapping("/save_detail")
public JsonResult saveUserDetail(String key, String phoneNo, String idNo,
......@@ -55,11 +51,7 @@ public class SyncUserController {
log.error("姓名错误,name:{}", name);
return JsonResult.buildErrorStateResult("姓名错误", name);
}
IdCardInfo info = idCardService.getIdCardInfo(idNo);
if (Objects.isNull(info) || !info.isValid()) {
log.error("身份证号错误,idNo:{}", idNo);
return JsonResult.buildErrorStateResult("身份证号码错误", idNo);
}
User user = userService.findByPhoneWithCache(phoneNo);
if (Objects.isNull(user)) {
log.error("用户不存在,phoneNo:{}", phoneNo);
......@@ -73,7 +65,6 @@ public class SyncUserController {
userDetail.setUserId(user.getId());
userDetail.setPhoneNo(phoneNo);
userDetail.setName(name);
userDetail.setGender(info.getGender());
userDetail.setIsAuthenticated(false);
log.info("SyncUserController saveUserDetail, userId:{}, phoneNo:{}, name:{}", user.getId(), phoneNo, name);
try {
......
......@@ -3,10 +3,7 @@ package cn.quantgroup.xyqb.controller.middleoffice.userdetail;
import cn.quantgroup.xyqb.controller.middleoffice.userdetail.req.UserDetailReq;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.IUserService;
import lombok.extern.slf4j.Slf4j;
......@@ -29,8 +26,6 @@ public class UserDetailController {
@Resource
private IUserService userService;
@Resource
private IIdCardService idCardService;
/**
* 修改用户实名信息
......
......@@ -2,10 +2,7 @@ package cn.quantgroup.xyqb.event;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.UserRegisterParam;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.util.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -19,8 +16,7 @@ import javax.annotation.Resource;
@Component
public class DetailRegisteredEventListener implements ApplicationListener<RegisterEvent> {
@Resource
private IIdCardService idCardService;
@Resource
private IUserDetailService userDetailService;
......@@ -29,23 +25,16 @@ public class DetailRegisteredEventListener implements ApplicationListener<Regist
UserRegisterParam userRegisterParam = event.getUserRegisterParam();
User user = userRegisterParam.getUser();
if (StringUtils.isAnyBlank(userRegisterParam.getIdNo(), userRegisterParam.getName()) ||
if (StringUtils.isAnyBlank(userRegisterParam.getName()) ||
!ValidationUtil.validateChinese(userRegisterParam.getName())) {
return;
}
String phoneNo = userRegisterParam.getPhoneNo();
String name = userRegisterParam.getName();
String idNo = userRegisterParam.getIdNo();
IdCardInfo cardInfo = idCardService.getIdCardInfo(idNo);
if (cardInfo == null || !cardInfo.isValid()) {
log.info("用户身份证号验证失败,userId:{},idNo:{}", user.getId(), idNo);
return;
}
UserDetail userDetail = new UserDetail();
userDetail.setPhoneNo(phoneNo);
userDetail.setName(name);
userDetail.setUserId(user.getId());
userDetail.setGender(cardInfo.getGender());
log.info("DetailRegisteredEventListener saveUserDetail, userId:{}, phoneNo:{}, name:{}", user.getId(), phoneNo, name);
userDetailService.saveUserDetail(userDetail);
}
......
......@@ -28,7 +28,7 @@ public class LkbRegisteredEventListener implements ApplicationListener<RegisterE
User user = userRegisterParam.getUser();
String uuid = user.getUuid();
boolean pushResult = lkbUserService.pushUser(uuid, userRegisterParam.getPhoneNo(),
userRegisterParam.getName(), userRegisterParam.getIdNo());
userRegisterParam.getName());
if (!pushResult) {
log.error("[userRegisterHandler][baseUserRegisterHandler]同步用户至Lkb出错,userRegisterParam:{}", JsonUtil.toJson(userRegisterParam));
throw new PushUserToLkbException("同步用户至Lkb出错");
......
......@@ -21,7 +21,6 @@ public class UserRegisterParam {
private Long registerFrom; // 注册渠道
private String phoneNo; // 手机号
private String password; // 密码
private String idNo; // 身份证号
private String name; // 姓名
private Long channelId; // 业务渠道
private Long btRegisterChannelId; // 白条渠道
......
package cn.quantgroup.xyqb.service.auth;
import cn.quantgroup.xyqb.model.IdCardInfo;
import java.text.ParseException;
/**
* Created by Miraculous on 15/7/10.
*/
public interface IIdCardService {
boolean isIdCardValid(String idCard) throws ParseException;
IdCardInfo getIdCardInfo(String idCardStr);
// 当身份证不合法,直接抛出异常。
IdCardInfo getIdCardInfoWithExceptions(String idCardStr) throws ParseException;
}
package cn.quantgroup.xyqb.service.auth.impl;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.exception.IdCardException;
import cn.quantgroup.xyqb.model.Gender;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by Miraculous on 15/7/10.
*/
@Slf4j
@Service
public class IdCardServiceImpl implements IIdCardService {
private String[] validCodes = {"1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2"};
private Map<String, String> areaCodes;
private int[] wi = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
private Pattern datePattern = Pattern.compile("^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))" +
"[\\-/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-/\\s]?" +
"((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-/\\s]?((((0?[13578])|(1[02]))[\\-/\\s]?" +
"((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))" +
"(\\s(((0?[0-9])|([1-2][0-3]))\\:([0-5]?[0-9])((\\s)|(:([0-5]?[0-9])))))?$");
@PostConstruct
private void init() {
areaCodes = new HashMap<>();
areaCodes.put("11", "北京");
areaCodes.put("12", "天津");
areaCodes.put("13", "河北");
areaCodes.put("14", "山西");
areaCodes.put("15", "内蒙古");
areaCodes.put("21", "辽宁");
areaCodes.put("22", "吉林");
areaCodes.put("23", "黑龙江");
areaCodes.put("31", "上海");
areaCodes.put("32", "江苏");
areaCodes.put("33", "浙江");
areaCodes.put("34", "安徽");
areaCodes.put("35", "福建");
areaCodes.put("36", "江西");
areaCodes.put("37", "山东");
areaCodes.put("41", "河南");
areaCodes.put("42", "湖北");
areaCodes.put("43", "湖南");
areaCodes.put("44", "广东");
areaCodes.put("45", "广西");
areaCodes.put("46", "海南");
areaCodes.put("50", "重庆");
areaCodes.put("51", "四川");
areaCodes.put("52", "贵州");
areaCodes.put("53", "云南");
areaCodes.put("54", "西藏");
areaCodes.put("61", "陕西");
areaCodes.put("62", "甘肃");
areaCodes.put("63", "青海");
areaCodes.put("64", "宁夏");
areaCodes.put("65", "新疆");
areaCodes.put("71", "台湾");
areaCodes.put("81", "香港");
areaCodes.put("82", "澳门");
areaCodes.put("91", "国外");
}
@Override
public boolean isIdCardValid(String idCardStr) throws ParseException {
if (idCardStr == null) {
return false;
}
String actualId;
if (idCardStr.length() == Constants.ID_NO_STANDARD_LENGTH) {
actualId = idCardStr.substring(0, Constants.ID_NO_CHECK_LENGTH);
} else if (idCardStr.length() == Constants.ID_NO_OLD_LENGTH) {
actualId = idCardStr.substring(0, 6) + "19" + idCardStr.substring(6, Constants.ID_NO_OLD_LENGTH);
} else {
return false;
}
if (!StringUtils.isNumeric(actualId)) {
return false;
}
String yearStr = actualId.substring(6, 10);
String monthStr = actualId.substring(10, 12);
String dayStr = actualId.substring(12, 14);
int year = Integer.parseInt(yearStr);
int month = Integer.parseInt(monthStr);
int day = Integer.parseInt(dayStr);
String dateStr = yearStr + "-" + monthStr + "-" + dayStr;
Matcher matcher = datePattern.matcher(dateStr);
if (!matcher.matches()) {
return false;
}
GregorianCalendar gc = new GregorianCalendar();
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
if (gc.get(Calendar.YEAR) - year > Constants.AGE_MAX || gc.getTime().getTime() - date.getTime() < 0) {
return false;
}
if (month < Constants.MONTH_NO_MIN || month > Constants.MONTH_NO_MAX) {
return false;
}
if (day < Constants.DAY_NO_MIN || day > Constants.DAY_NO_MAX) {
return false;
}
String areaCode = actualId.substring(0, Constants.ID_NO_AREA_CODE_LENGTH);
if (!areaCodes.containsKey(areaCode)) {
return false;
}
// 校验码
int acurateCode = 0;
for (int i = 0; i < Constants.ID_NO_CHECK_LENGTH; ++i) {
acurateCode += ((actualId.charAt(i) - '0') * wi[i]);
}
actualId += validCodes[acurateCode % Constants.ID_NO_CHECK_MASK];
return idCardStr.length() != Constants.ID_NO_STANDARD_LENGTH || actualId.equalsIgnoreCase(idCardStr);
}
@Override
public IdCardInfo getIdCardInfo(String idCardStr){
IdCardInfo cardInfo = new IdCardInfo();
cardInfo.setIsValid(false);
if (idCardStr == null) {
return cardInfo;
}
String actualId;
String lastChar;
if (idCardStr.length() == Constants.ID_NO_STANDARD_LENGTH) {
actualId = idCardStr.substring(0, Constants.ID_NO_CHECK_LENGTH);
lastChar = idCardStr.substring(16, Constants.ID_NO_CHECK_LENGTH).toLowerCase();
} else if (idCardStr.length() == Constants.ID_NO_OLD_LENGTH) {
actualId = idCardStr.substring(0, 6) + "19" + idCardStr.substring(6, Constants.ID_NO_OLD_LENGTH);
lastChar = idCardStr.substring(13, 14).toLowerCase();
} else {
return cardInfo;
}
if (!StringUtils.isNumeric(actualId)) {
return cardInfo;
}
String yearStr = actualId.substring(6, 10);
String monthStr = actualId.substring(10, 12);
String dayStr = actualId.substring(12, 14);
int year = Integer.parseInt(yearStr);
int month = Integer.parseInt(monthStr);
int day = Integer.parseInt(dayStr);
String dateStr = yearStr + "-" + monthStr + "-" + dayStr;
Matcher matcher = datePattern.matcher(dateStr);
if (!matcher.matches()) {
return cardInfo;
}
GregorianCalendar gc = new GregorianCalendar();
Date date;
try {
date = new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
} catch (ParseException e) {
//这里根本不会出错好么.万一哪个脑抽改了上面的, 就出错了
log.error("解析日期异常...", e);
return null;
}
if (gc.get(Calendar.YEAR) - year > Constants.AGE_MAX || gc.getTime().getTime() - date.getTime() < 0) {
return cardInfo;
}
if (month < Constants.MONTH_NO_MIN || month > Constants.MONTH_NO_MAX) {
return cardInfo;
}
if (day < Constants.DAY_NO_MIN || day > Constants.DAY_NO_MAX) {
return cardInfo;
}
String areaCode = actualId.substring(0, Constants.ID_NO_AREA_CODE_LENGTH);
if (!areaCodes.containsKey(areaCode)) {
return cardInfo;
}
// 校验码
int checkCode = 0;
for (int i = 0; i < Constants.ID_NO_CHECK_LENGTH; ++i) {
checkCode += ((actualId.charAt(i) - '0') * wi[i]);
}
actualId += validCodes[checkCode % Constants.ID_NO_CHECK_MASK];
if (idCardStr.length() == Constants.ID_NO_STANDARD_LENGTH) {
if (!actualId.equalsIgnoreCase(idCardStr)) {
return cardInfo;
}
}
cardInfo.setIsValid(true);
// 判断男女
if (Integer.parseInt(lastChar) % Constants.GENDER_MASK == 0) {
cardInfo.setGender(Gender.FEMALE);
} else {
cardInfo.setGender(Gender.MALE);
}
cardInfo.setIdNo(idCardStr);
cardInfo.setProvince(areaCodes.get(areaCode));
cardInfo.setBirthDate(date);
return cardInfo;
}
@Override
public IdCardInfo getIdCardInfoWithExceptions(String idCardStr) throws ParseException {
if (idCardStr == null) {
throw new IdCardException("身份证号码不能为空");
}
String actualId;
String lastValue;
if (idCardStr.length() == Constants.ID_NO_STANDARD_LENGTH) {
actualId = idCardStr.substring(0, Constants.ID_NO_CHECK_LENGTH);
lastValue = idCardStr.substring(16, Constants.ID_NO_CHECK_LENGTH).toLowerCase();
} else if (idCardStr.length() == Constants.ID_NO_OLD_LENGTH) {
actualId = idCardStr.substring(0, 6) + "19" + idCardStr.substring(6, Constants.ID_NO_OLD_LENGTH);
lastValue = idCardStr.substring(13, 14).toLowerCase();
} else {
throw new IdCardException("身份证号码必须为18位或15位");
}
if (!StringUtils.isNumeric(actualId)) {
throw new IdCardException("身份证格式不正确");
}
String yearStr = actualId.substring(6, 10);
String monthStr = actualId.substring(10, Constants.MONTH_NO_MAX);
String dayStr = actualId.substring(12, 14);
int year = Integer.parseInt(yearStr);
int month = Integer.parseInt(monthStr);
int day = Integer.parseInt(dayStr);
String dateStr = yearStr + "-" + monthStr + "-" + dayStr;
Matcher matcher = datePattern.matcher(dateStr);
if (!matcher.matches()) {
throw new IdCardException("身份证出生日期不正确");
}
GregorianCalendar gc = new GregorianCalendar();
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
if (gc.get(Calendar.YEAR) - year > Constants.AGE_MAX || gc.getTime().getTime() - date.getTime() < 0) {
throw new IdCardException("身份证出生年份不正确");
}
if (month < Constants.MONTH_NO_MIN || month > Constants.MONTH_NO_MAX) {
throw new IdCardException("身份证出生月份不正确");
}
if (day < Constants.DAY_NO_MIN || day > Constants.DAY_NO_MAX) {
throw new IdCardException("身份证出生日期不正确");
}
String areaCode = actualId.substring(0, Constants.ID_NO_AREA_CODE_LENGTH);
if (!areaCodes.containsKey(areaCode)) {
throw new IdCardException("身份证省份不正确");
}
// 校验码
int checkCode = 0;
for (int i = 0; i < Constants.ID_NO_CHECK_LENGTH; ++i) {
checkCode += ((actualId.charAt(i) - '0') * wi[i]);
}
actualId += validCodes[checkCode % Constants.ID_NO_CHECK_MASK];
if (idCardStr.length() == Constants.ID_NO_STANDARD_LENGTH) {
if (!actualId.equalsIgnoreCase(idCardStr)) {
throw new IdCardException("身份证校验不正确");
}
}
IdCardInfo cardInfo = new IdCardInfo();
cardInfo.setIsValid(true);
// 判断男女
if (Integer.parseInt(lastValue) % Constants.GENDER_MASK == 0) {
cardInfo.setGender(Gender.FEMALE);
} else {
cardInfo.setGender(Gender.MALE);
}
cardInfo.setIdNo(idCardStr);
cardInfo.setProvince(areaCodes.get(areaCode));
cardInfo.setBirthDate(date);
return cardInfo;
}
}
......@@ -17,15 +17,13 @@ public interface IUserRegisterService {
*
* @param registerFrom
* @param phoneNo
* @param idNo
* @param name
* @param channelId
* @param btRegisterChannelId
* @return
*/
User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId);
User register(Long registerFrom, String phoneNo,String name, Long channelId, Long btRegisterChannelId);
User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId, Integer tenantId);
User register(Long registerFrom, String phoneNo, String name, Long channelId, Long btRegisterChannelId, Integer tenantId);
......@@ -68,7 +66,7 @@ public interface IUserRegisterService {
* @author jinsong.zhu 2018年05月16日14:22:13
* 处理对address和contact的非必要兼容
*/
User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo,String contacts, Long btRegisterChannelId);
User register(Long registeredFrom, Long channelId, String phoneNo, String name,String contacts, Long btRegisterChannelId);
}
package cn.quantgroup.xyqb.service.register.impl;
import cn.quantgroup.xyqb.constant.enums.RecordType;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.constant.enums.RecordType;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDeregisterRecord;
import cn.quantgroup.xyqb.event.RegisterEvent;
......@@ -54,14 +54,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
/* 用户销户检查 */
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.channelId(registerFrom)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registerFrom).phoneNo(phoneNo).channelId(registerFrom).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
return user;
......@@ -73,14 +66,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.channelId(registerFrom)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registerFrom).phoneNo(phoneNo).channelId(registerFrom).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
if (tenantId == null || tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
......@@ -90,49 +76,16 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
@Transactional(rollbackFor = Exception.class)
@Override
public User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId) {
public User register(Long registerFrom, String phoneNo, String name, Long channelId, Long btRegisterChannelId) {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.idNo(idNo)
.name(name)
.channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registerFrom).phoneNo(phoneNo).name(name).channelId(channelId).btRegisterChannelId(btRegisterChannelId).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
return user;
}
@Transactional(rollbackFor = Exception.class)
@Override
public User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId, Integer tenantId) {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.idNo(idNo)
.name(name)
.channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
User user = saveUser(userRegisterParam);
if (tenantId == null || tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
}
return user;
}
private User saveUser(UserRegisterParam userRegisterParam) {
String uuid = UUID.randomUUID().toString();
......@@ -176,16 +129,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo).password(password)
.channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.dimension(dimension)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registerFrom).phoneNo(phoneNo).password(password).channelId(channelId).btRegisterChannelId(btRegisterChannelId).dimension(dimension).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
return user != null;
......@@ -197,16 +141,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.dimension(dimension)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registerFrom).phoneNo(phoneNo).channelId(channelId).btRegisterChannelId(btRegisterChannelId).dimension(dimension).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
return user;
......@@ -219,16 +154,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.dimension(dimension)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registerFrom).phoneNo(phoneNo).channelId(channelId).btRegisterChannelId(btRegisterChannelId).dimension(dimension).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
if (tenantId == null || tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
......@@ -238,22 +164,11 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
@Transactional(rollbackFor = Exception.class)
@Override
public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String contacts,Long btRegisterChannelId) {
public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String contacts, Long btRegisterChannelId) {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registeredFrom)
.phoneNo(phoneNo)
.idNo(idNo)
.name(name)
.channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.contacts(contacts)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registeredFrom).phoneNo(phoneNo).name(name).channelId(channelId).btRegisterChannelId(btRegisterChannelId).contacts(contacts).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
return user;
......@@ -270,8 +185,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
List<UserDeregisterRecord> deregisterRecords = userDeregisterService.queryByPhoneNo(Md5Util.build(phoneNo));
/* 获取最新销户记录 */
Optional<UserDeregisterRecord> lastOne = deregisterRecords.stream()
.max(Comparator.comparing(UserDeregisterRecord::getDeregisterTime));
Optional<UserDeregisterRecord> lastOne = deregisterRecords.stream().max(Comparator.comparing(UserDeregisterRecord::getDeregisterTime));
if (!lastOne.isPresent()) {
return;
......@@ -290,16 +204,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.name(name)
.channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
UserRegisterParam userRegisterParam = UserRegisterParam.builder().registerFrom(registerFrom).phoneNo(phoneNo).name(name).channelId(channelId).btRegisterChannelId(btRegisterChannelId).sendSuccessSms(true).sendAppSms(true).sendSuccessMq(true).build();
User user = saveUser(userRegisterParam);
if (tenantId == null || tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
......
......@@ -13,7 +13,6 @@ public interface ILkbUserService {
* @param uuid
* @param phoneNo
* @param name
* @param idNo
*/
boolean pushUser(String uuid, String phoneNo, String name, String idNo);
boolean pushUser(String uuid, String phoneNo, String name);
}
......@@ -34,7 +34,7 @@ public class LkbUserviceImpl implements ILkbUserService {
private String clientUrl;
@Override
public boolean pushUser(String uuid, String phoneNo, String name, String idNo) {
public boolean pushUser(String uuid, String phoneNo, String name) {
String timeunit = System.currentTimeMillis() + "";
String token = PasswordUtil.MD5(String.format(TOKEN_PATTERN, timeunit));
Map<String, String> parameters = Maps.newHashMap();
......@@ -46,9 +46,7 @@ public class LkbUserviceImpl implements ILkbUserService {
if (StringUtils.isNotBlank(name)) {
parameters.put("realName", name);
}
if (StringUtils.isNotBlank(idNo)) {
parameters.put("idCardNo", idNo);
}
String response = httpService.post(clientUrl + "/user/push.json", parameters);
Optional<Map> resultOptional = JsonUtil.fromJson(response, Map.class);
if (!resultOptional.isPresent() || !Constants.SUCCESS_CODE.equals(resultOptional.get().get(Constants.RESULT_CODE))) {
......
......@@ -4,11 +4,9 @@ import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.event.UserDetailUpdateEvent;
import cn.quantgroup.xyqb.model.Gender;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.repository.IUserDetailRepository;
import cn.quantgroup.xyqb.repository.IUserRepository;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.vo.UserDetailVO;
import cn.quantgroup.xyqb.util.AddressFilter;
......@@ -42,8 +40,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
private IUserDetailRepository userDetailRepository;
@Autowired
private IUserRepository userRepository;
@Autowired
private IIdCardService idCardService;
@Resource
private ApplicationEventPublisher applicationEventPublisher;
@Resource
......
......@@ -5,7 +5,10 @@ import cn.quantgroup.xyqb.aspect.lock.RedisLock;
import cn.quantgroup.xyqb.constant.enums.LoginType;
import cn.quantgroup.xyqb.controller.IBaseController;
import cn.quantgroup.xyqb.controller.internal.user.resp.UserFullResp;
import cn.quantgroup.xyqb.entity.*;
import cn.quantgroup.xyqb.entity.Merchant;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.entity.UserHashMapping;
import cn.quantgroup.xyqb.event.PhoneNoUpdateEvent;
import cn.quantgroup.xyqb.exception.DataException;
import cn.quantgroup.xyqb.exception.UserNotExistException;
......@@ -154,7 +157,6 @@ public class UserServiceImpl implements IUserService, IBaseController {
if (CollectionUtils.isEmpty(userIds)) {
return Maps.newHashMap();
}
Map<Long, String> userIdAndPhoneMap = Maps.newHashMap();
List<User> users = userRepository.findByIdIn(userIds);
//校验租户ID
if (!TenantUtil.TENANT_DEFAULT.equals(tenantId)) {
......@@ -162,8 +164,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
} else {
users = tenantService.validationTentIdByTentId(users, tenantId);
}
users.forEach(user -> userIdAndPhoneMap.put(user.getId(), user.getPhoneNo()));
return userIdAndPhoneMap;
return users.stream().collect(Collectors.toMap(User::getId, User::getPhoneNo));
}
@Override
......@@ -213,7 +214,6 @@ public class UserServiceImpl implements IUserService, IBaseController {
}
@Override
// @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public User findByPhoneWithCache(String phone) {
if (StringUtils.isBlank(phone)) {
return null;
......@@ -510,33 +510,29 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Override
public List<User> findByUuidsOrUserIds(List<String> vals, Integer type, Integer tenantId) {
if (CollectionUtils.isEmpty(vals)) {
return Collections.EMPTY_LIST;
return new ArrayList<>();
}
List<User> users;
if (type == 1) {//1是userids
List<Long> collect = vals.stream()
.map(Long::valueOf)
.collect(Collectors.toList());
List<User> users = userRepository.findByIdIn(collect);
if (!tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
return tenantService.selectUsersByTenantId(users, tenantId);
} else {
return tenantService.validationTentIdByTentId(users, tenantId);
}
users = userRepository.findByIdIn(collect);
} else { //不是1 就是 uuids
List<User> users = userRepository.findByUuidIn(vals);
if (!tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
return tenantService.selectUsersByTenantId(users, tenantId);
} else {
return tenantService.validationTentIdByTentId(users, tenantId);
}
users = userRepository.findByUuidIn(vals);
}
if (!tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
users = tenantService.selectUsersByTenantId(users, tenantId);
} else {
users = tenantService.validationTentIdByTentId(users, tenantId);
}
return users;
}
@Override
public void logout(String token) {
sessionService.deleteSession(token);
}
......@@ -616,6 +612,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
/**
* 不同渠道用户签署不同合同模板
*
* @param user
* @param loginFrom
*/
......@@ -627,7 +624,8 @@ public class UserServiceImpl implements IUserService, IBaseController {
if (Objects.nonNull(loginFrom) && Objects.equals(user.getRegisteredFrom(), loginFrom)) {
return;
}
Map<String, Long> channelMap = JSON.parseObject(channelTemplate, new TypeReference<HashMap<String, Long>>() {});
Map<String, Long> channelMap = JSON.parseObject(channelTemplate, new TypeReference<HashMap<String, Long>>() {
});
Long templateId = channelMap.get(String.valueOf(user.getRegisteredFrom()));
boolean needCheck = false;
if (Objects.nonNull(loginFrom) && !Objects.equals(user.getRegisteredFrom(), loginFrom)) {
......
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