Commit f1294daa authored by Java-刘 彧阳's avatar Java-刘 彧阳

根据用户手机号查用户id接口增加

parent ecaabda9
...@@ -171,7 +171,8 @@ public class UserController implements IBaseController { ...@@ -171,7 +171,8 @@ public class UserController implements IBaseController {
*/ */
@RequestMapping("/register/fast") @RequestMapping("/register/fast")
public JsonResult registerFast(@RequestParam String phoneNo, @RequestParam String verificationCode, @RequestParam(required = false) Long channelId, public JsonResult registerFast(@RequestParam String phoneNo, @RequestParam String verificationCode, @RequestParam(required = false) Long channelId,
@RequestParam(required = false) Long registerFrom, @RequestParam(required = false, defaultValue = "") String appChannel) { @RequestParam(required = false) Long registerFrom, @RequestParam(required = false, defaultValue = "") String appChannel,
@RequestParam(required = false)Long btRegisterChannelId) {
String password = genRandomPwd(); String password = genRandomPwd();
LOGGER.info("用户快速注册, phoneNo:{}, verificationCode:{}, channelId:{}, registerFrom:{},appChannel:{}", phoneNo, verificationCode, channelId, registerFrom, appChannel); LOGGER.info("用户快速注册, phoneNo:{}, verificationCode:{}, channelId:{}, registerFrom:{},appChannel:{}", phoneNo, verificationCode, channelId, registerFrom, appChannel);
if (!ValidationUtil.validatePhoneNo(phoneNo)) { if (!ValidationUtil.validatePhoneNo(phoneNo)) {
...@@ -197,7 +198,7 @@ public class UserController implements IBaseController { ...@@ -197,7 +198,7 @@ public class UserController implements IBaseController {
LOGGER.info("用户快速注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode); LOGGER.info("用户快速注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode);
return JsonResult.buildErrorStateResult("短信验证码错误", null); return JsonResult.buildErrorStateResult("短信验证码错误", null);
} }
if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId)) { if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId,btRegisterChannelId)) {
LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null); return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null);
} }
...@@ -220,7 +221,8 @@ public class UserController implements IBaseController { ...@@ -220,7 +221,8 @@ public class UserController implements IBaseController {
@RequestMapping("/register") @RequestMapping("/register")
public JsonResult register(@RequestParam String phoneNo, @RequestParam String password, public JsonResult register(@RequestParam String phoneNo, @RequestParam String password,
@RequestParam String verificationCode, @RequestParam(required = false) Long channelId, @RequestParam String verificationCode, @RequestParam(required = false) Long channelId,
@RequestParam(required = false) Long registerFrom) { @RequestParam(required = false) Long registerFrom,
@RequestParam(required = false)Long btRegisterChannelId) {
LOGGER.info("用户注册, phoneNo:{}, verificationCode:{}, channelId:{}, registerFrom:{}", phoneNo, verificationCode, channelId, registerFrom); LOGGER.info("用户注册, phoneNo:{}, verificationCode:{}, channelId:{}, registerFrom:{}", phoneNo, verificationCode, channelId, registerFrom);
if (!ValidationUtil.validatePhoneNo(phoneNo)) { if (!ValidationUtil.validatePhoneNo(phoneNo)) {
LOGGER.info("用户注册失败,手机号错误, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户注册失败,手机号错误, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
...@@ -245,7 +247,7 @@ public class UserController implements IBaseController { ...@@ -245,7 +247,7 @@ public class UserController implements IBaseController {
LOGGER.info("用户注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode); LOGGER.info("用户注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode);
return JsonResult.buildErrorStateResult("短信验证码错误", null); return JsonResult.buildErrorStateResult("短信验证码错误", null);
} }
if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId)) { if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId,btRegisterChannelId)) {
LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null); return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null);
} }
......
...@@ -32,4 +32,5 @@ public interface IUserService { ...@@ -32,4 +32,5 @@ public interface IUserService {
User findById(Long userId); User findById(Long userId);
boolean register(String phoneNo, String password, Long registerFrom, String ip, Long channelId, Long btRegisterChannelId);
} }
...@@ -2,9 +2,11 @@ package cn.quantgroup.xyqb.service.user.impl; ...@@ -2,9 +2,11 @@ package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserBtRegister;
import cn.quantgroup.xyqb.repository.IUserRepository; import cn.quantgroup.xyqb.repository.IUserRepository;
import cn.quantgroup.xyqb.service.sms.ISmsService; import cn.quantgroup.xyqb.service.sms.ISmsService;
import cn.quantgroup.xyqb.service.user.ILkbUserService; import cn.quantgroup.xyqb.service.user.ILkbUserService;
import cn.quantgroup.xyqb.service.user.IUserBtRegisterService;
import cn.quantgroup.xyqb.service.user.IUserService; import cn.quantgroup.xyqb.service.user.IUserService;
import cn.quantgroup.xyqb.util.PasswordUtil; import cn.quantgroup.xyqb.util.PasswordUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
...@@ -42,6 +44,9 @@ public class UserServiceImpl implements IUserService { ...@@ -42,6 +44,9 @@ public class UserServiceImpl implements IUserService {
@Autowired @Autowired
private ISmsService smsService; private ISmsService smsService;
@Autowired
private IUserBtRegisterService userBtRegisterService;
@Override @Override
public User findByPhoneInDb(String phone) { public User findByPhoneInDb(String phone) {
return userRepository.findByPhoneNo(phone); return userRepository.findByPhoneNo(phone);
...@@ -88,6 +93,37 @@ public class UserServiceImpl implements IUserService { ...@@ -88,6 +93,37 @@ public class UserServiceImpl implements IUserService {
return userRepository.findById(userId); return userRepository.findById(userId);
} }
@Override
public boolean register(String phoneNo, String password, Long registerFrom, String ip, Long channelId, Long btRegisterChannelId) {
String uuid = lkbUserService.registerApp(phoneNo, password);
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
User user = new User();
user.setEnable(true);
user.setPhoneNo(phoneNo);
user.setUpdatedAt(currentTime);
user.setCreatedAt(currentTime);
user.setUuid(uuid);
user.setPassword(PasswordUtil.MD5(password.toLowerCase() + Constants.PASSWORD_SALT));
//解决线上白条registerFrom为1的问题
if (channelId == 222L) {
user.setRegisteredFrom(channelId);
} else {
user.setRegisteredFrom(registerFrom);
}
//user.setRegisteredFrom(registerFrom);
user = userRepository.save(user);
if(null != user){
UserBtRegister userBtRegister = new UserBtRegister();
userBtRegister.setUserId(user.getId());
userBtRegister.setRegisterBtMerchantId(btRegisterChannelId);
userBtRegisterService.save(userBtRegister);
}
smsService.sendAfterRegister(phoneNo);
return user != null;
}
@Override @Override
public User registerAndReturn(String phoneNo, String password, Long registerFrom) { public User registerAndReturn(String phoneNo, String password, Long registerFrom) {
......
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