商家注册增加邀请码可选参数

This commit is contained in:
Jack 2026-01-24 15:35:56 +08:00
parent c7a7e041e7
commit a7f2d2a02c
5 changed files with 62 additions and 52 deletions

View File

@ -257,8 +257,9 @@ public class LoginController extends BaseControllerImpl {
String osType = paramJSON.getStr("os_type"); String osType = paramJSON.getStr("os_type");
// 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商 // 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商
Integer userType = paramJSON.getInt("user_type"); Integer userType = paramJSON.getInt("user_type");
String inviteCode = paramJSON.getStr("invite_code", "");
return accountUserBaseService.doMerchSmsRegisterAndLogin(userMobile, randKey, verifyCode, userType, cid, osType); return accountUserBaseService.doMerchSmsRegisterAndLogin(userMobile, randKey, verifyCode, userType, cid, osType, inviteCode);
} }
@ApiOperation(value = "微信用户一键登录与注册") @ApiOperation(value = "微信用户一键登录与注册")
@ -294,7 +295,9 @@ public class LoginController extends BaseControllerImpl {
paramJSON.getStr("rand_key"), paramJSON.getStr("rand_key"),
paramJSON.getStr("verify_code"), paramJSON.getStr("verify_code"),
paramJSON.getInt("user_type"), paramJSON.getInt("user_type"),
paramJSON.getStr("cid"), paramJSON.getStr("os_type")); paramJSON.getStr("cid"),
paramJSON.getStr("os_type"),
paramJSON.getStr("invite_code"));
} }
@ApiOperation("退出登录") @ApiOperation("退出登录")

View File

@ -145,9 +145,10 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
* @param userType 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商 * @param userType 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商
* @param cid 推送 cid * @param cid 推送 cid
* @param osType 手机系统类型 1-Android2-iOS3-微信小程序 * @param osType 手机系统类型 1-Android2-iOS3-微信小程序
* @param inviteCode 代理商邀请码
* @return * @return
*/ */
CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code, Integer userType, String cid, String osType); CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code, Integer userType, String cid, String osType, String inviteCode);
/** /**
* 微信小程序一键登录注册接口 * 微信小程序一键登录注册接口

View File

@ -87,9 +87,10 @@ public interface AccountUserBindConnectService extends IBaseService<AccountUserB
* @param bindType * @param bindType
* @param userId * @param userId
* @param userType * @param userType
* @param inviteCode
* @return * @return
*/ */
AccountUserBindConnect initAccountUserBindConnect(String bindId, Integer bindType, Integer userId, Integer userType); AccountUserBindConnect initAccountUserBindConnect(String bindId, Integer bindType, Integer userId, Integer userType, String inviteCode);
List<AccountUserBindConnect> getAllBindPage(String bindTmpl, Integer pageNum, Integer pageSize); List<AccountUserBindConnect> getAllBindPage(String bindTmpl, Integer pageNum, Integer pageSize);

View File

@ -1685,6 +1685,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
Integer userType = userIsAdmin; // 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商 Integer userType = userIsAdmin; // 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商
String user_email = (String) userInfo.get("user_email"); String user_email = (String) userInfo.get("user_email");
Integer bind_type = getParameter("bind_type", BindCode.MOBILE); Integer bind_type = getParameter("bind_type", BindCode.MOBILE);
String inviteCode = Convert.toStr("invite_code", "");
if (StrUtil.isBlank(user_account)) { if (StrUtil.isBlank(user_account)) {
throw new ApiException(_("请输入账号")); throw new ApiException(_("请输入账号"));
@ -1719,7 +1720,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
throw new ApiException(_("账号已存在,请用另一账号名注册!")); throw new ApiException(_("账号已存在,请用另一账号名注册!"));
} }
// 有手机参数优先手机注册 // 有手机参数优先手机注册
if (StrUtil.isNotBlank(user_mobile) && CheckUtil.isMobile(user_mobile, user_intl)) { if (StrUtil.isNotBlank(user_mobile) && CheckUtil.isMobile(user_mobile, user_intl)) {
@ -1800,7 +1800,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
if (user_base_row != null) { if (user_base_row != null) {
// 检测到 account_user_base 用户已经存在是因为账号没有绑定这时绑定账号即可 // 检测到 account_user_base 用户已经存在是因为账号没有绑定这时绑定账号即可
// 绑定基本关系 // 绑定基本关系
AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.initAccountUserBindConnect(user_mobile, bind_type, user_base_row.getUser_id(), userIsAdmin); AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.initAccountUserBindConnect(user_mobile, bind_type, user_base_row.getUser_id(), userIsAdmin, inviteCode);
if (accountUserBindConnect == null) { if (accountUserBindConnect == null) {
throw new ApiException(_("绑定账号失败")); throw new ApiException(_("绑定账号失败"));
} }
@ -1884,7 +1884,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
if (addUserBindConnect) { if (addUserBindConnect) {
// 初始化绑用户定关系 // 初始化绑用户定关系
AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.initAccountUserBindConnect(user_mobile, bind_type, user_id, userIsAdmin); AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.initAccountUserBindConnect(user_mobile, bind_type, user_id, userIsAdmin, inviteCode);
if (accountUserBindConnect == null) { if (accountUserBindConnect == null) {
throw new ApiException(_("绑定账号失败")); throw new ApiException(_("绑定账号失败"));
} }
@ -2962,10 +2962,11 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
* @param userType 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商 * @param userType 用户类型:0-普通买家; 1-管理员2-入驻商家3-代理商
* @param cid 推送 cid * @param cid 推送 cid
* @param osType 手机系统类型 1-Android2-iOS3-微信小程序 * @param osType 手机系统类型 1-Android2-iOS3-微信小程序
* @param inviteCode 代理商邀请码
* @return * @return
*/ */
@Override @Override
public CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code, Integer userType, String cid, String osType) { public CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code, Integer userType, String cid, String osType, String inviteCode) {
// 流程通过手机号检查是否有绑定关系没有就直接注册有就直接登录返回登录后的所有信息附加是否已经申请入驻标记 // 流程通过手机号检查是否有绑定关系没有就直接注册有就直接登录返回登录后的所有信息附加是否已经申请入驻标记
// 商家入驻账号都是需要手机号绑定的账号组成1000000+(数字加法)自增ID密码随机6位数 // 商家入驻账号都是需要手机号绑定的账号组成1000000+(数字加法)自增ID密码随机6位数
if (StrUtil.isBlank(user_mobile) || StrUtil.isBlank(verify_code)) { if (StrUtil.isBlank(user_mobile) || StrUtil.isBlank(verify_code)) {
@ -3000,7 +3001,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
// 找出手机对应的绑定用户 // 找出手机对应的绑定用户
// 是否为手机号注册密码6位随机数 // 是否为手机号注册密码6位随机数
return doMobileBindLogin(verifyMobile, userType, cid, osType); return doMobileBindLogin(verifyMobile, userType, cid, osType, inviteCode);
} }
/** /**
@ -3263,13 +3264,14 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
* 商家版app入驻商家手机号绑定登录 * 商家版app入驻商家手机号绑定登录
* *
* @param user_mobile +86的中国号码 * @param user_mobile +86的中国号码
* @param userType 用户类型0-普通用户1-管理员2-入驻商户 * @param userType 用户类型0-普通用户1-管理员2-入驻商户3-代理商
* @param cid 推送 cid * @param cid 推送 cid
* @param osType 手机系统类型 1-Android2-iOS3-微信小程序 * @param osType 手机系统类型 1-Android2-iOS3-微信小程序
* @param inviteCode 代理商的邀请码商家注册时才用
* @return * @return
*/ */
public CommonResult doMobileBindLogin(String user_mobile, Integer userType, String cid, String osType) { public CommonResult doMobileBindLogin(String user_mobile, Integer userType, String cid, String osType, String inviteCode) {
return doMobileBindLogin(user_mobile, "", userType, cid, osType); return doMobileBindLogin(user_mobile, "", userType, cid, osType, inviteCode);
} }
/** /**
@ -3282,7 +3284,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
* @param osType * @param osType
* @return * @return
*/ */
public CommonResult doMobileBindLogin(String user_mobile, String regPwd, Integer userType, String cid, String osType) { public CommonResult doMobileBindLogin(String user_mobile, String regPwd, Integer userType, String cid, String osType, String inviteCode) {
if (StrUtil.isBlank(user_mobile) || userType == null) { if (StrUtil.isBlank(user_mobile) || userType == null) {
return CommonResult.failed("缺少必要参数!"); return CommonResult.failed("缺少必要参数!");
} }
@ -3317,6 +3319,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
} }
userInfo.put("user_password", user_password); userInfo.put("user_password", user_password);
userInfo.put("is_admin", userType); // 商家入驻注册 userInfo.put("is_admin", userType); // 商家入驻注册
userInfo.put("invite_code", StrUtil.isNotBlank(inviteCode) ? inviteCode : ""); // 商家注册代理商的邀请码
// 注册商家账号都是需要手机号绑定的 // 注册商家账号都是需要手机号绑定的
accountUserBase = register(userInfo); accountUserBase = register(userInfo);
@ -3373,7 +3376,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
} }
// 4. 执行手机号绑定登录注册商家账号 // 4. 执行手机号绑定登录注册商家账号
CommonResult result = doMobileBindLogin(convertedMobile, regPwd, CommonConstant.USER_TYPE_MCH, null, null); CommonResult result = doMobileBindLogin(convertedMobile, regPwd, CommonConstant.USER_TYPE_MCH, null, null, "");
// 5. 检查注册结果 // 5. 检查注册结果
if (result == null || result.getCode() != ResultCode.SUCCESS.getCode()) { if (result == null || result.getCode() != ResultCode.SUCCESS.getCode()) {

View File

@ -38,6 +38,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
@ -600,9 +601,10 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
* @param bindType 绑定类型 * @param bindType 绑定类型
* @param userId 用户ID * @param userId 用户ID
* @param userType 用户类型 * @param userType 用户类型
* @param inviteCode 代理商邀请码
* @return 账户用户绑定连接对象如果初始化失败则返回null * @return 账户用户绑定连接对象如果初始化失败则返回null
*/ */
public AccountUserBindConnect initAccountUserBindConnect(String bindId, Integer bindType, Integer userId, Integer userType) { public AccountUserBindConnect initAccountUserBindConnect(String bindId, Integer bindType, Integer userId, Integer userType, String inviteCode) {
// 1. 校验入参任何一个为空直接返回null // 1. 校验入参任何一个为空直接返回null
if (StrUtil.isBlank(bindId) if (StrUtil.isBlank(bindId)
|| ObjectUtil.isNull(bindType) || ObjectUtil.isNull(bindType)
@ -624,7 +626,7 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
.eq("user_id", userId) .eq("user_id", userId)
.eq("bind_active", CommonConstant.Enable).orderByAsc("bind_time"); .eq("bind_active", CommonConstant.Enable).orderByAsc("bind_time");
AccountUserBindConnect existingBindConnect = findOne(queryWrapper); AccountUserBindConnect existingBindConnect = getOne(queryWrapper, false);
if (existingBindConnect != null) { if (existingBindConnect != null) {
log.info("账户用户绑定信息已存在bindId={}, bindType={}, userId={}, userType={}", bindId, bindType, userId, userType); log.info("账户用户绑定信息已存在bindId={}, bindType={}, userId={}, userType={}", bindId, bindType, userId, userType);
return existingBindConnect; return existingBindConnect;
@ -642,6 +644,7 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
newBindConnect.setBind_token_ttl(0); newBindConnect.setBind_token_ttl(0);
newBindConnect.setBind_level(0); newBindConnect.setBind_level(0);
newBindConnect.setBind_vip(0); newBindConnect.setBind_vip(0);
newBindConnect.setInvite_code(inviteCode); // 代理商邀请码
// log.debug("准备创建新的账户用户绑定信息: {}", JSONUtil.toJsonStr(newBindConnect)); // log.debug("准备创建新的账户用户绑定信息: {}", JSONUtil.toJsonStr(newBindConnect));
@ -749,7 +752,6 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
} }
/** /**
* 封装相同参数的调用方法 * 封装相同参数的调用方法
* *