商家版注册与登录接口
This commit is contained in:
parent
8c650e5dc0
commit
6400672c49
@ -180,7 +180,7 @@ public class LoginController extends BaseControllerImpl {
|
||||
@ApiOperation(value = "商家版注册与登录")
|
||||
@RequestMapping(value = "/doMerchSmsRegisterAndLogin", method = RequestMethod.POST)
|
||||
public CommonResult doMerchSmsRegisterAndLogin(@RequestParam(name = "user_mobile") String user_mobile,
|
||||
@RequestParam(name = "rand_key") String rand_key,
|
||||
@RequestParam(name = "rand_key", required = false) String rand_key,
|
||||
@RequestParam(name = "verify_code") String verify_code) {
|
||||
return accountUserBaseService.doMerchSmsRegisterAndLogin(user_mobile, rand_key, verify_code);
|
||||
}
|
||||
|
||||
@ -1605,7 +1605,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
String user_account = (String) userInfo.get("user_account");
|
||||
String user_mobile = (String) userInfo.get("user_mobile");
|
||||
String rand_key = (String) userInfo.get("rand_key");
|
||||
String verificationCode = (String) userInfo.get("verify_code");
|
||||
String verifyCode = (String) userInfo.get("verify_code");
|
||||
String verify_token = (String) userInfo.get("verify_token");
|
||||
|
||||
String user_intl = "";
|
||||
@ -1613,6 +1613,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
// todo 支持国外手机号 isMobile() 方法
|
||||
String currency_id = "+" + getParameter("currency_id", "");
|
||||
if (StrUtil.isNotBlank(user_mobile) || (CheckUtil.isMobile(user_account, currency_id) && StrUtil.equals(user_account, user_mobile))) {
|
||||
// 是否为手机号码的注册
|
||||
// 拆分手机号码为intl + code
|
||||
// todo 优化根据电话号码查询地区码(+86)
|
||||
if (StrUtil.startWith(user_mobile, currency_id)) {
|
||||
@ -1635,18 +1636,19 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(user_account) && StrUtil.isNotBlank(verificationCode) && StrUtil.isNotEmpty(verify_token) && null == userInfo.get("user_email")) {
|
||||
if (StrUtil.isNotBlank(verificationCode)) {
|
||||
if (StrUtil.isNotBlank(user_account) && StrUtil.isNotBlank(verifyCode) && StrUtil.isNotEmpty(verify_token) && null == userInfo.get("user_email")) {
|
||||
// 是否为账号的注册
|
||||
if (StrUtil.isNotBlank(verifyCode)) {
|
||||
// 验证码校验
|
||||
Boolean hasKey = redisService.hasKey(VERIFY_CODE_KEY + user_account);
|
||||
if (!hasKey) {
|
||||
//兼容字符串注册
|
||||
hasKey = redisService.hasKey(RedisConstant.Verifycode_NameSpace + verify_token + verificationCode);
|
||||
hasKey = redisService.hasKey(RedisConstant.Verifycode_NameSpace + verify_token + verifyCode);
|
||||
if (!hasKey) {
|
||||
throw new ApiException(ResultCode.VERIFYCODE_FAILED);
|
||||
}
|
||||
} else {
|
||||
if (checkVerifyCode(user_account, verificationCode)) {
|
||||
if (checkVerifyCode(user_account, verifyCode)) {
|
||||
redisService.del(VERIFY_CODE_KEY + user_account);
|
||||
} else {
|
||||
throw new ApiException(_("验证码异常!"));
|
||||
@ -1688,14 +1690,14 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
throw new ApiException(_("请输入密码"));
|
||||
}
|
||||
|
||||
verifyPwd(user_password);
|
||||
verifyPwd(user_password); // 忽略密码校验
|
||||
|
||||
AccountUserBase user_base_row = getByAccount(user_account);
|
||||
if (user_base_row != null) {
|
||||
throw new ApiException(_("用户已经存在,请更换用户名"));
|
||||
} else {
|
||||
// 用户尚未注册,立即新增用户基本信息和用户附加信息
|
||||
String user_nickname = Convert.toStr(userInfo.get("user_nickname"), "");
|
||||
String user_nickname = Convert.toStr(userInfo.get("user_nickname"), user_account);
|
||||
Integer user_state = Convert.toInt(userInfo.get("user_state"), 2);
|
||||
Integer user_is_admin = Convert.toInt(userInfo.get("is_admin"), CommonConstant.USER_TYPE_NORMAL);
|
||||
String user_key = IdUtil.simpleUUID();
|
||||
@ -1708,9 +1710,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
user_base_reg_row.setUser_password(SecureUtil.md5(user_salt + SecureUtil.md5(user_password)));
|
||||
// user_base_reg_row.setUser_password((BCrypt.hashpw(user_password)));
|
||||
|
||||
if (StrUtil.isBlank(user_nickname)) {
|
||||
user_nickname = user_account;
|
||||
}
|
||||
user_base_reg_row.setUser_nickname(user_nickname);
|
||||
user_base_reg_row.setUser_state(user_state);
|
||||
user_base_reg_row.setUser_key(user_key);
|
||||
@ -2731,30 +2730,37 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
AccountUserBindConnect bind_row = bindConnectService.get(user_mobile);
|
||||
AccountUserBase accountUserBase = null;
|
||||
if (bind_row != null && ObjectUtil.equal(BindCode.MOBILE, bind_row.getBind_type())) {
|
||||
// 绑定了手机的情况,
|
||||
// 已经注册账号的,绑定了手机的情况,
|
||||
Integer user_id = bind_row.getUser_id();
|
||||
accountUserBase = get(user_id);
|
||||
if (accountUserBase == null) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
} else {
|
||||
// 手机号码未绑定的情况,直接去注册一个账号
|
||||
Map<String, Object> userInfo = new HashMap<>();
|
||||
userInfo.put("user_mobile", user_mobile);
|
||||
// 密码要随机数
|
||||
String user_password = com.suisung.mall.common.utils.StringUtils.random(6, com.suisung.mall.common.utils.StringUtils.RandomType.STRING);
|
||||
userInfo.put("user_password", user_password);
|
||||
userInfo.put("is_admin", CommonConstant.USER_TYPE_MCH); // 商家入驻注册
|
||||
|
||||
accountUserBase = register(userInfo);
|
||||
if (accountUserBase == null) {
|
||||
throw new ApiException(_("账号注册失败!"));
|
||||
if (ObjectUtil.notEqual(CommonConstant.USER_TYPE_MCH, accountUserBase.getUser_is_admin())) {
|
||||
// 不是入驻商家的情况
|
||||
throw new ApiException(_("已被注册,请换一个手机号码!"));
|
||||
}
|
||||
|
||||
// TODO 发送短信通知用户,告知用户随机密码
|
||||
// 尊敬的商家用户,你们刚注册账号的账号密码为:" + user_password + ",请妥善保管,以免丢失。
|
||||
}
|
||||
|
||||
// 手机号码未绑定的情况,直接去注册一个账号
|
||||
Map<String, Object> userInfo = new HashMap<>();
|
||||
userInfo.put("user_account", com.suisung.mall.common.utils.StringUtils.genLklOrderNo(4));// 时间 yyyyMMddHHmmss + 4位随机数
|
||||
userInfo.put("user_mobile", user_mobile);
|
||||
// 密码要随机数
|
||||
String user_password = com.suisung.mall.common.utils.StringUtils.random(6, com.suisung.mall.common.utils.StringUtils.RandomType.STRING);
|
||||
userInfo.put("user_password", user_password);
|
||||
userInfo.put("is_admin", CommonConstant.USER_TYPE_MCH); // 商家入驻注册
|
||||
|
||||
// 注:注册商家账号,都是需要手机号绑定的。
|
||||
accountUserBase = register(userInfo);
|
||||
if (accountUserBase == null) {
|
||||
throw new ApiException(_("账号注册失败!"));
|
||||
}
|
||||
|
||||
// TODO 发送短信通知用户,告知用户随机密码:尊敬的商家用户,你们刚注册账号的账号密码为:" + user_password + ",请妥善保管,以免丢失。
|
||||
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", isMerch ? AuthConstant.MCH_CLIENT_ID : AuthConstant.MOBILE_CLIENT_ID);
|
||||
params.put("client_secret", AuthConstant.AUTHORITY_MOBILE_SECRET);
|
||||
@ -2762,7 +2768,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
params.put("verify_pwd", "1001"); // 是否验证密码 1001:不验证;1002:验证(内部登录没有用户明文密码,只能不验证)
|
||||
params.put("username", accountUserBase.getUser_account());
|
||||
params.put("password", "");
|
||||
// params.put("is_merch", "1"); // 是否为商家入驻 1-是;其他-否
|
||||
params.put("is_merch", "1"); // 是否为商家入驻 1-是;其他-否
|
||||
|
||||
return login(params);
|
||||
}
|
||||
|
||||
@ -39,7 +39,8 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(removeProvinceCityDistrict("广西壮族自治区贵港市桂平市西山镇新安街粤桂花城1102号"));
|
||||
// System.out.println(removeProvinceCityDistrict("广西壮族自治区贵港市桂平市西山镇新安街粤桂花城1102号"));
|
||||
System.out.println(genLklOrderNo(4));
|
||||
}
|
||||
|
||||
public static String encode(String str) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user