商家版注册与登录接口
This commit is contained in:
parent
dd70d27c39
commit
8c650e5dc0
@ -73,7 +73,7 @@ public class LoginController extends BaseControllerImpl {
|
||||
|
||||
CommonResult result = accountUserBaseService.login(params);
|
||||
|
||||
//user_account判断是否手机号
|
||||
// user_account 判断是否绑定了手机号
|
||||
if (result != null && result.getStatus() != 200L && Validator.isNumber(user_account)) {
|
||||
user_account = CommonConstant.IDD_ZH_CN + user_account;
|
||||
if (PhoneNumberUtils.isValidNumber(user_account)) {
|
||||
@ -116,6 +116,18 @@ public class LoginController extends BaseControllerImpl {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册后直接登录
|
||||
*
|
||||
* @param user_account
|
||||
* @param user_email
|
||||
* @param user_mobile
|
||||
* @param verify_code
|
||||
* @param rand_key
|
||||
* @param verify_token
|
||||
* @param user_password
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/register", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public CommonResult register(
|
||||
@RequestParam(name = "user_account", required = false) String user_account,
|
||||
@ -149,6 +161,30 @@ public class LoginController extends BaseControllerImpl {
|
||||
return accountUserBaseService.login(params);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "手机验证码登录")
|
||||
@RequestMapping(value = "/doSmsLogin", method = RequestMethod.GET)
|
||||
public CommonResult doSmsLogin(@RequestParam(name = "user_mobile") String user_mobile,
|
||||
@RequestParam(name = "rand_key") String rand_key,
|
||||
@RequestParam(name = "verify_code") String verify_code) {
|
||||
return accountUserBaseService.doSmsLogin(user_mobile, rand_key, verify_code);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "APP互联登录")
|
||||
@RequestMapping(value = "/doAppConnectLogin", method = RequestMethod.GET)
|
||||
public CommonResult doAppConnectLogin(@RequestParam(name = "bind_name") String bind_name,
|
||||
@RequestParam(name = "code") String code) {
|
||||
return CommonResult.success(accountUserBaseService.doAppConnectLogin(bind_name, code));
|
||||
}
|
||||
|
||||
@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 = "verify_code") String verify_code) {
|
||||
return accountUserBaseService.doMerchSmsRegisterAndLogin(user_mobile, rand_key, verify_code);
|
||||
}
|
||||
|
||||
@ApiOperation("退出登录")
|
||||
@RequestMapping(value = "/doLogout", method = RequestMethod.GET)
|
||||
public CommonResult doLogout() {
|
||||
@ -199,19 +235,5 @@ public class LoginController extends BaseControllerImpl {
|
||||
return CommonResult.success(accountUserBaseService.setNewPassword(channel_verify_key, channel_verify_code, pwd, channel));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "手机验证码登录")
|
||||
@RequestMapping(value = "/doSmsLogin", method = RequestMethod.GET)
|
||||
public CommonResult doSmsLogin(@RequestParam(name = "user_mobile") String user_mobile,
|
||||
@RequestParam(name = "rand_key") String rand_key,
|
||||
@RequestParam(name = "verify_code") String verify_code) {
|
||||
return accountUserBaseService.doSmsLogin(user_mobile, rand_key, verify_code);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "APP互联登录")
|
||||
@RequestMapping(value = "/doAppConnectLogin", method = RequestMethod.GET)
|
||||
public CommonResult doAppConnectLogin(@RequestParam(name = "bind_name") String bind_name,
|
||||
@RequestParam(name = "code") String code) {
|
||||
return CommonResult.success(accountUserBaseService.doAppConnectLogin(bind_name, code));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
/**
|
||||
* 绑定手机号操作
|
||||
*
|
||||
* @param user_intl 手机区号
|
||||
* @param user_intl 手机区号
|
||||
* @param currentUser 用户登录信息
|
||||
*/
|
||||
Integer doBindMobile(String user_intl, String mobile, UserDto currentUser);
|
||||
@ -87,6 +87,16 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
|
||||
CommonResult doSmsLogin(String user_mobile, String rand_key, String verify_code);
|
||||
|
||||
/**
|
||||
* 入驻商家注册和登录一体接口
|
||||
*
|
||||
* @param user_mobile
|
||||
* @param rand_key 防机器人刷验证码
|
||||
* @param verify_code
|
||||
* @return
|
||||
*/
|
||||
CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code);
|
||||
|
||||
Map<String, Object> doAppConnectLogin(String bind_name, String code);
|
||||
|
||||
CommonResult doMobileBindLogin(String user_mobile, String verify_code);
|
||||
@ -125,6 +135,7 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
|
||||
/**
|
||||
* google互联登录 - 回调登录
|
||||
*
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
@ -132,12 +143,14 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
|
||||
/**
|
||||
* 跳转登录
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
void googleLogin(HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* google互联登录 - 回调
|
||||
*
|
||||
* @param response
|
||||
* @param code
|
||||
*/
|
||||
@ -147,6 +160,7 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
|
||||
/**
|
||||
* 判断店铺某个昵称是否存在
|
||||
*
|
||||
* @param nickname
|
||||
* @param storeId
|
||||
* @return
|
||||
|
||||
@ -56,7 +56,6 @@ import com.suisung.mall.common.utils.*;
|
||||
import com.suisung.mall.common.utils.constbank.RSAUtil;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
import com.suisung.mall.common.utils.pojo.dto.EmailDTO;
|
||||
import com.suisung.mall.core.web.service.CloundService;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import io.seata.common.util.StringUtils;
|
||||
@ -133,67 +132,66 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
@Autowired
|
||||
private AccountUserChannelCodeService accountUserChannelCodeService;
|
||||
@Autowired
|
||||
private AccountUserChannelService accountUserChannelService;
|
||||
@Autowired
|
||||
private AccountUserBaseMapper accountUserBaseMapper;
|
||||
@Autowired
|
||||
private CloundService cloundService;
|
||||
|
||||
@Override
|
||||
public CommonResult login(Map<String, String> params) {
|
||||
Boolean hasKey = false;
|
||||
String verificationCode = params.get("verify_code");
|
||||
if (StrUtil.isNotBlank(verificationCode)) {
|
||||
hasKey = redisService.hasKey(verificationCode);
|
||||
// 短信验证码
|
||||
String verifyCode = params.get("verify_code");
|
||||
if (StrUtil.isNotBlank(verifyCode)) {
|
||||
hasKey = redisService.hasKey(verifyCode);
|
||||
if (!hasKey) {
|
||||
//验证码错误
|
||||
throw new ApiException(ResultCode.VERIFYCODE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
// JWT Oauth2 生成用户登录 token
|
||||
// 返回:token、refreshToken、tokenHead、expireIn
|
||||
CommonResult restResult = authService.getAccessToken(params);
|
||||
|
||||
// if (restResult.getStatus() != 200 && restResult.getMsg().contains(I18nUtil._("用户名或密码"))) {
|
||||
// throw new ApiException(ResultCode.USERPWD_FAILED);
|
||||
// }
|
||||
|
||||
if (restResult.getStatus() != 200) {
|
||||
return restResult;
|
||||
}
|
||||
|
||||
//成功使用,删除验证码
|
||||
// 鉴权成功,删除短信验证码
|
||||
if (hasKey) {
|
||||
redisService.del(verificationCode);
|
||||
redisService.del(verifyCode);
|
||||
}
|
||||
|
||||
// 解析获取user 信息
|
||||
Map data = (Map) restResult.getData();
|
||||
String token = (String) data.get("token");
|
||||
JWSObject jwsObject = null;
|
||||
|
||||
String JWSObjectPayload = "";
|
||||
try {
|
||||
jwsObject = JWSObject.parse(token);
|
||||
JWSObjectPayload = jwsObject.getPayload().toString();
|
||||
logger.debug("jwsObject记录:{}", JWSObjectPayload);
|
||||
} catch (ParseException e) {
|
||||
logger.error("解析token信息异常:{} {}", e.getMessage(), e);
|
||||
}
|
||||
|
||||
UserDto userDto = JSONUtil.toBean(jwsObject.getPayload().toString(), UserDto.class);
|
||||
// 填充登录用户信息
|
||||
UserDto userDto = JSONUtil.toBean(JWSObjectPayload, UserDto.class);
|
||||
Integer user_id = userDto.getId();
|
||||
Integer rid = userDto.getRole_id();
|
||||
|
||||
// 获取用户信息
|
||||
Map<String, Object> userInfo = getUserInfo(user_id);
|
||||
Map bind = bindConnectService.getBind(user_id, BindCode.MOBILE);
|
||||
if (userInfo == null) {
|
||||
throw new ApiException(_("无法获取用户信息!"));
|
||||
}
|
||||
|
||||
data.putAll(userInfo);
|
||||
data.put("id", user_id);
|
||||
data.put("k", token);
|
||||
data.put("key", token);
|
||||
data.put("rid", rid);
|
||||
data.put("rid", rid); // 用户角色 rid:0-用户;2-商家;3-门店;9-平台;
|
||||
|
||||
if (null != bind) {
|
||||
CookieUtils.setCookie("as", "1");
|
||||
data.put("as", 1);
|
||||
} else {
|
||||
CookieUtils.setCookie("as", "0");
|
||||
data.put("as", 0);
|
||||
}
|
||||
String as = bindConnectService.getBind(user_id, BindCode.MOBILE) == null ? "0" : "1";
|
||||
data.put("as", as);
|
||||
CookieUtils.setCookie("as", as);
|
||||
|
||||
// IM连接配置信息
|
||||
try {
|
||||
@ -203,6 +201,14 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
}
|
||||
|
||||
data.put("callback_url", "");
|
||||
|
||||
if (params.get("is_merch") != null && params.get("is_merch").equals("1")) {
|
||||
// 商家版app,显示申请入驻的状态
|
||||
data.put("is_merch", 1);
|
||||
//入驻商家的审批状态:1-已通过;2-未通过;3-待审核;4-未申请;
|
||||
data.put("merch_approval_status", 4);
|
||||
}
|
||||
|
||||
return restResult;
|
||||
}
|
||||
|
||||
@ -317,7 +323,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
*/
|
||||
private void setIdentityByUser(UserDto userDTO, AccountUserBase user) {
|
||||
Integer user_is_admin = user.getUser_is_admin();
|
||||
if (user_is_admin == 1) {
|
||||
if (user_is_admin == CommonConstant.USER_TYPE_ADMIN) {
|
||||
setIdentity(RoleIdEnum.PLATFORM.getState(), null, null, userDTO);
|
||||
return;
|
||||
}
|
||||
@ -340,7 +346,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
private void setIdentityByUser(AccountUserBase user) {
|
||||
if (user == null) return;
|
||||
Integer user_is_admin = user.getUser_is_admin();
|
||||
if (ObjectUtil.equal(user_is_admin, 1)) {
|
||||
if (ObjectUtil.equal(user_is_admin, CommonConstant.USER_TYPE_ADMIN)) {
|
||||
user.setRid(RoleIdEnum.PLATFORM.getState());
|
||||
return;
|
||||
}
|
||||
@ -959,9 +965,9 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
}
|
||||
|
||||
if (sys != null && sys.equals("sys")) {
|
||||
param.put("user_is_admin", 1);
|
||||
param.put("user_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
} else if (sys == null || sys.equals("")) {
|
||||
param.put("user_is_admin", 0);
|
||||
param.put("user_is_admin", CommonConstant.USER_TYPE_NORMAL);
|
||||
}
|
||||
|
||||
String user_account = getParameter("user_account");
|
||||
@ -1328,13 +1334,13 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
// 修改为普通用户
|
||||
AccountUserBase is_admin_data = new AccountUserBase();
|
||||
|
||||
Boolean user_is_admin = Convert.toBool(getParameter("user_is_admin"), false);
|
||||
Boolean user_is_admin = getParameter("user_is_admin") != null && Convert.toInt(getParameter("user_is_admin")) == CommonConstant.USER_TYPE_ADMIN;
|
||||
is_admin_data.setUser_id(user_id);
|
||||
|
||||
if (user_is_admin) {
|
||||
is_admin_data.setUser_is_admin(1);
|
||||
is_admin_data.setUser_is_admin(CommonConstant.USER_TYPE_ADMIN);
|
||||
} else {
|
||||
is_admin_data.setUser_is_admin(0);
|
||||
is_admin_data.setUser_is_admin(CommonConstant.USER_TYPE_NORMAL);
|
||||
is_admin_data.setRights_group_id("0");
|
||||
}
|
||||
|
||||
@ -1408,10 +1414,10 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
|
||||
|
||||
if (CheckUtil.isNotEmpty(is_admin)) {
|
||||
base.put("user_is_admin", 1);
|
||||
base.put("user_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
base.put("rights_group_id", 1);
|
||||
} else {
|
||||
base.put("user_is_admin", 0);
|
||||
base.put("user_is_admin", CommonConstant.USER_TYPE_NORMAL);
|
||||
base.put("rights_group_id", 0);
|
||||
}
|
||||
|
||||
@ -1688,14 +1694,14 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
if (user_base_row != null) {
|
||||
throw new ApiException(_("用户已经存在,请更换用户名"));
|
||||
} else {
|
||||
|
||||
// 用户尚未注册,立即新增用户基本信息和用户附加信息
|
||||
String user_nickname = Convert.toStr(userInfo.get("user_nickname"), "");
|
||||
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();
|
||||
String user_salt = IdUtil.simpleUUID();
|
||||
String user_token = IdUtil.simpleUUID();
|
||||
String rights_group_id = Convert.toStr(userInfo.get("rights_group_id"), "0");
|
||||
Integer user_is_admin = Convert.toInt(userInfo.get("user_is_admin"), 0);
|
||||
String store_ids = Convert.toStr(userInfo.get("store_ids"), "");
|
||||
|
||||
user_base_reg_row.setUser_account(user_account);
|
||||
@ -2151,6 +2157,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer doBindMobile(String user_intl, String mobile, UserDto currentUser) {
|
||||
// 国家码+ 手机号
|
||||
String bind_id = user_intl + mobile;
|
||||
Integer user_id = null;
|
||||
|
||||
@ -2646,7 +2653,44 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行手机号登陆操作
|
||||
* 入驻商家注册和登录一体接口
|
||||
*
|
||||
* @param user_mobile
|
||||
* @param rand_key 防机器人刷验证码
|
||||
* @param verify_code
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code) {
|
||||
// 流程:通过手机号检查是否有绑定关系?没有就直接注册,有就直接登录,返回登录后的所有信息,附加是否已经申请入驻标记?
|
||||
// 商家入驻账号,都是需要手机号绑定的。账号组成:1000000+(数字加法)自增ID,密码随机6位数
|
||||
if (StrUtil.isBlank(user_mobile) || StrUtil.isBlank(verify_code)) {
|
||||
throw new ApiException(_("缺少必要参数!"));
|
||||
}
|
||||
|
||||
if (!PhoneNumberUtils.isValidNumber(user_mobile)) {
|
||||
throw new ApiException(_("请输入正确的手机号!"));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(rand_key)) {
|
||||
throw new ApiException(_("程序非法请求, 检测验证码键值!"));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(verify_code)) {
|
||||
throw new ApiException(_("请输入验证码!"));
|
||||
}
|
||||
|
||||
if (ObjectUtil.notEqual(user_mobile, rand_key)) {
|
||||
throw new ApiException(_("非法数据,或者提交超时,请刷新页面重新提交!"));
|
||||
}
|
||||
|
||||
// 找出手机对应的绑定用户
|
||||
// 是否为手机号注册,密码6位随机数
|
||||
return doMobileBindLogin(user_mobile, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号登陆操作
|
||||
*
|
||||
* @param user_mobile
|
||||
* @return
|
||||
@ -2654,8 +2698,8 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
public CommonResult doMobileBindLogin(String user_mobile, String password) {
|
||||
AccountUserBindConnect bind_row = bindConnectService.get(user_mobile);
|
||||
|
||||
if (bind_row != null && ObjectUtil.equal(1, bind_row.getBind_type())) {
|
||||
// 正确,登录
|
||||
if (bind_row != null && ObjectUtil.equal(BindCode.MOBILE, bind_row.getBind_type())) {
|
||||
// 绑定了手机的情况,
|
||||
Integer user_id = bind_row.getUser_id();
|
||||
AccountUserBase user_base_row = get(user_id);
|
||||
if (user_base_row == null) {
|
||||
@ -2671,11 +2715,58 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
params.put("password", password);
|
||||
return login(params);
|
||||
} else {
|
||||
// 错误,注册, 不自动注册。
|
||||
// 手机号码未绑定的情况, 直接抛出异常
|
||||
throw new ApiException(_("手机尚未注册,请先注册!"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (商家版app)入驻商家手机号绑定登录
|
||||
*
|
||||
* @param user_mobile
|
||||
* @param isMerch
|
||||
* @return
|
||||
*/
|
||||
public CommonResult doMobileBindLogin(String user_mobile, boolean isMerch) {
|
||||
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(_("账号注册失败!"));
|
||||
}
|
||||
|
||||
// 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);
|
||||
params.put("grant_type", "password");
|
||||
params.put("verify_pwd", "1001"); // 是否验证密码 1001:不验证;1002:验证(内部登录没有用户明文密码,只能不验证)
|
||||
params.put("username", accountUserBase.getUser_account());
|
||||
params.put("password", "");
|
||||
// params.put("is_merch", "1"); // 是否为商家入驻 1-是;其他-否
|
||||
|
||||
return login(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> doAppConnectLogin(String bind_name, String code) {
|
||||
String id_prefix = "";
|
||||
|
||||
@ -14,9 +14,9 @@ import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -83,7 +83,6 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
} else if (bind_row == null) {
|
||||
|
||||
// todo 头像会变动, 需要本地缓存, 生成新网址.
|
||||
user_info_row.setBind_id(bind_id);
|
||||
user_info_row.setBind_type(bind_type);
|
||||
@ -218,7 +217,7 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
|
||||
if (reg_flag) {
|
||||
Map reg_info = new HashMap();
|
||||
reg_info.put("user_account", bind_id);
|
||||
reg_info.put("user_password", "Ss@123" + UUID.randomUUID().toString());
|
||||
reg_info.put("user_password", "Ss@123" + UUID.randomUUID());
|
||||
reg_info.put("user_nickname", user_info_row.getBind_nickname());
|
||||
reg_info.put("activity_id", activity_id);
|
||||
|
||||
|
||||
@ -25,6 +25,11 @@ public class AuthConstant {
|
||||
*/
|
||||
public static final String MOBILE_CLIENT_ID = "mobile-app";
|
||||
|
||||
/**
|
||||
* 商家版移动端client_id
|
||||
*/
|
||||
public static final String MCH_CLIENT_ID = "mch-app";
|
||||
|
||||
/**
|
||||
* 微信client_ID
|
||||
*/
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
|
||||
package com.suisung.mall.common.constant;
|
||||
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
public class CommonConstant {
|
||||
|
||||
public static final Integer Enable = 1; // 状态:1-有效;2-无效;0-无效
|
||||
@ -21,6 +19,13 @@ public class CommonConstant {
|
||||
public static final Integer Delivery_Amount_Comput_Type_Discounted = 2;
|
||||
public static final Integer Delivery_Amount_Comput_Type_Payment = 3;
|
||||
|
||||
/**
|
||||
* 用户类型:0-普通用户;1-管理员;2-商户
|
||||
*/
|
||||
public static final Integer USER_TYPE_NORMAL = 0;
|
||||
public static final Integer USER_TYPE_ADMIN = 1;
|
||||
public static final Integer USER_TYPE_MCH = 2;
|
||||
|
||||
// 国际电话区号
|
||||
public static final String IDD_ZH_CN = "+86"; //中国
|
||||
|
||||
|
||||
@ -19,16 +19,14 @@ public class UserDto {
|
||||
private Integer id;
|
||||
private String user_account;
|
||||
private String user_password;
|
||||
private String user_nickname;
|
||||
private Integer user_state;
|
||||
private String client_id; // 客户端 :后台管理-admin-app,移动端-mobile-app
|
||||
private String client_id; // 客户端 :后台管理-admin-app,移动端-mobile-app,入驻商家移动端-mch-app
|
||||
private String user_salt;
|
||||
private List<String> roles;
|
||||
|
||||
// 服务端返回rid 角色编号 0-用户;2-商家;3-门店;9-平台;
|
||||
private Integer role_id;
|
||||
private Integer site_id = 0; //分站编号
|
||||
|
||||
private String user_nickname;
|
||||
private String store_id;
|
||||
private String chain_id;
|
||||
|
||||
@ -56,5 +54,12 @@ public class UserDto {
|
||||
return ObjectUtil.equal(client_id, AuthConstant.MOBILE_CLIENT_ID);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 入驻商家端
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isMerchant() {
|
||||
return ObjectUtil.equal(client_id, AuthConstant.MCH_CLIENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +101,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
@ -1369,7 +1368,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
if (CheckUtil.isNotEmpty(distributor_id)) {
|
||||
// 读取分销商编号
|
||||
QueryWrapper<ShopStoreEmployee> employeeQueryWrapper = new QueryWrapper<>();
|
||||
employeeQueryWrapper.eq("store_id", distributor_id).eq("employee_is_admin", 1);
|
||||
employeeQueryWrapper.eq("store_id", distributor_id).eq("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
ShopStoreEmployee epl_row = storeEmployeeService.findOne(employeeQueryWrapper);
|
||||
|
||||
if (epl_row != null && ObjectUtil.equal(epl_row.getUser_id(), distributor_user_id)) {
|
||||
@ -3346,7 +3345,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
//根据user_id 计算 store_id
|
||||
QueryWrapper<ShopStoreEmployee> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("user_id", user_id);
|
||||
wrapper.eq("employee_is_admin", 1);
|
||||
wrapper.eq("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
List<ShopStoreEmployee> rows = shopStoreEmployeeService.find(wrapper);
|
||||
|
||||
BigDecimal waiting_withdraw_order_payment_amount = BigDecimal.ZERO;
|
||||
|
||||
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.AccountService;
|
||||
@ -173,7 +174,7 @@ public class ShopPlantformSubsiteServiceImpl extends BaseServiceImpl<ShopPlantfo
|
||||
AccountUserBase accountUserBase = new AccountUserBase();
|
||||
accountUserBase.setUser_id(user_id_old);
|
||||
accountUserBase.setRights_group_id("");
|
||||
accountUserBase.setUser_is_admin(0);
|
||||
accountUserBase.setUser_is_admin(CommonConstant.USER_TYPE_NORMAL);
|
||||
if (!accountService.saveOrUpdateUserBase(accountUserBase)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
@ -190,7 +191,7 @@ public class ShopPlantformSubsiteServiceImpl extends BaseServiceImpl<ShopPlantfo
|
||||
AccountUserBase accountUserBase = new AccountUserBase();
|
||||
accountUserBase.setUser_id(user_id);
|
||||
accountUserBase.setRights_group_id("20");
|
||||
accountUserBase.setUser_is_admin(1);
|
||||
accountUserBase.setUser_is_admin(CommonConstant.USER_TYPE_ADMIN);
|
||||
if (!accountService.saveOrUpdateUserBase(accountUserBase)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.constant.ConfigConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
@ -1543,7 +1544,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
|
||||
QueryWrapper<ShopStoreEmployee> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("store_id", store_id);
|
||||
wrapper.eq("employee_is_admin", 1);
|
||||
wrapper.eq("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
ShopStoreEmployee epl_row = shopStoreEmployeeService.findOne(wrapper);
|
||||
|
||||
if (epl_row != null) {
|
||||
@ -1642,7 +1643,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
|
||||
QueryWrapper<ShopStoreEmployee> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("user_id", user_id);
|
||||
wrapper.eq("employee_is_admin", 1);
|
||||
wrapper.eq("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
//判断店铺是否存在。
|
||||
ShopStoreEmployee epl_row = shopStoreEmployeeService.findOne(wrapper);
|
||||
|
||||
@ -1863,7 +1864,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
shopStoreEmployee.setUser_id(user_id);
|
||||
shopStoreEmployee.setStore_id(store_id);
|
||||
shopStoreEmployee.setRights_group_id(CollUtil.join(rights_group_id, ","));
|
||||
shopStoreEmployee.setEmployee_is_admin(1);
|
||||
shopStoreEmployee.setEmployee_is_admin(CommonConstant.USER_TYPE_ADMIN);
|
||||
|
||||
if (!shopStoreEmployeeService.saveOrUpdate(shopStoreEmployee)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
@ -2054,7 +2055,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
|
||||
QueryWrapper<ShopStoreEmployee> employeeQueryWrapper = new QueryWrapper<>();
|
||||
employeeQueryWrapper.eq("user_id", user_id).eq("employee_is_admin", 1);
|
||||
employeeQueryWrapper.eq("user_id", user_id).eq("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
ShopStoreEmployee epl_row = shopStoreEmployeeService.findOne(employeeQueryWrapper);
|
||||
|
||||
Integer store_id = 0;
|
||||
@ -2787,7 +2788,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
public Integer getStoreId(Integer user_id) {
|
||||
|
||||
QueryWrapper<ShopStoreEmployee> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", user_id).eq("employee_is_admin", 1);
|
||||
queryWrapper.eq("user_id", user_id).eq("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
ShopStoreEmployee epl_row = shopStoreEmployeeService.findOne(queryWrapper);
|
||||
|
||||
if (epl_row != null) {
|
||||
|
||||
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.AccountService;
|
||||
@ -27,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -135,7 +135,7 @@ public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl<ShopStoreEmplo
|
||||
|
||||
QueryWrapper<ShopStoreEmployee> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("store_id", store_id);
|
||||
queryWrapper.eq("employee_is_admin", 1);
|
||||
queryWrapper.eq("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
ShopStoreEmployee row = findOne(queryWrapper);
|
||||
|
||||
return row.getUser_id();
|
||||
@ -152,7 +152,7 @@ public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl<ShopStoreEmplo
|
||||
if (user.isStore() && employee_id == null) {
|
||||
userInfo.put("auto_login", false);
|
||||
userInfo.put("rights_group_id", 1);
|
||||
userInfo.put("user_is_admin", 0);
|
||||
userInfo.put("user_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
userInfo.put("store_ids", store_id);
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl<ShopStoreEmplo
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<ShopStoreEmployee> employeeOptional = employeeList.stream().filter(s -> s.getEmployee_is_admin() == 1).findFirst();
|
||||
Optional<ShopStoreEmployee> employeeOptional = employeeList.stream().filter(s -> s.getEmployee_is_admin() == CommonConstant.USER_TYPE_ADMIN).findFirst();
|
||||
if (employeeOptional.isPresent()) {
|
||||
throw new ApiException(I18nUtil._("不可移除店铺管理员!"));
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
newProductType.setType_name(o.getStr("product_type"));
|
||||
newProductType.setType_buildin(0);
|
||||
|
||||
if(productTypeService.save(newProductType)){
|
||||
if (productTypeService.save(newProductType)) {
|
||||
typeId = newProductType.getType_id();
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
firstCate.setStore_id(storeId);
|
||||
firstCate.setType_id(typeId);
|
||||
firstCate.setData_source(2);
|
||||
if (productCategoryService.saveOrUpdate(firstCate)){
|
||||
if (productCategoryService.saveOrUpdate(firstCate)) {
|
||||
// 当前子分类的父类id
|
||||
firstParentId = firstCate.getId();
|
||||
list.get(i).setParent_id(firstParentId);
|
||||
@ -172,7 +172,7 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
secondCate.setStore_id(storeId);
|
||||
secondCate.setType_id(typeId);
|
||||
secondCate.setData_source(2);
|
||||
if (productCategoryService.saveOrUpdate(secondCate)){
|
||||
if (productCategoryService.saveOrUpdate(secondCate)) {
|
||||
// 当前子分类的第二级父类id
|
||||
list.get(i).setParent_id(secondCate.getId());
|
||||
}
|
||||
@ -423,7 +423,7 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
accountUserBase.setUser_account(StringUtils.generateUniqueCode(8));
|
||||
accountUserBase.setUser_nickname(member.getUser_nickname());
|
||||
accountUserBase.setUser_state(2);// 状态(ENUM):0-锁定;1-未激活;2-已激活;
|
||||
accountUserBase.setUser_is_admin(0);
|
||||
accountUserBase.setUser_is_admin(CommonConstant.USER_TYPE_NORMAL);
|
||||
accountUserBase.setStore_ids(storeId);
|
||||
accountUserBase.setRights_group_id("0");// 普通用户,不是商家
|
||||
accountUserBase.setUser_type("0");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user