改造登录体系,增加小程序一键登录接口
This commit is contained in:
parent
c3c155735b
commit
2be8344181
@ -10,6 +10,7 @@ import com.suisung.mall.common.api.CommonResult;
|
|||||||
import com.suisung.mall.common.constant.AuthConstant;
|
import com.suisung.mall.common.constant.AuthConstant;
|
||||||
import com.suisung.mall.common.constant.CommonConstant;
|
import com.suisung.mall.common.constant.CommonConstant;
|
||||||
import com.suisung.mall.common.constant.RedisConstant;
|
import com.suisung.mall.common.constant.RedisConstant;
|
||||||
|
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
import com.suisung.mall.common.utils.I18nUtil;
|
||||||
import com.suisung.mall.common.utils.UserInfoService;
|
import com.suisung.mall.common.utils.UserInfoService;
|
||||||
@ -192,13 +193,18 @@ public class LoginController extends BaseControllerImpl {
|
|||||||
return accountUserBaseService.doMerchSmsRegisterAndLogin(paramJSON.getStr("user_mobile"), paramJSON.getStr("rand_key"), paramJSON.getStr("verify_code"));
|
return accountUserBaseService.doMerchSmsRegisterAndLogin(paramJSON.getStr("user_mobile"), paramJSON.getStr("rand_key"), paramJSON.getStr("verify_code"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "微信用户一键登录和注册")
|
||||||
|
@RequestMapping(value = "/doWxUserRegisterAndLogin", method = RequestMethod.POST)
|
||||||
|
public CommonResult doWxUserRegisterAndLogin(@RequestBody WxUserInfoReq wxUserInfoReq) {
|
||||||
|
return accountUserBaseService.doWxUserRegisterAndLogin(wxUserInfoReq);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过(绑定手机的)账号、手机、email 发送短信、邮件验证码")
|
@ApiOperation(value = "通过(绑定手机的)账号、手机、email 发送短信、邮件验证码")
|
||||||
@RequestMapping(value = "/sendVerifyCode", method = RequestMethod.POST)
|
@RequestMapping(value = "/sendVerifyCode", method = RequestMethod.POST)
|
||||||
public CommonResult sendVerifyCode(@RequestBody JSONObject paramJSON) {
|
public CommonResult sendVerifyCode(@RequestBody JSONObject paramJSON) {
|
||||||
return accountUserBaseService.sendVerifyCode(paramJSON.getStr("number"));
|
return accountUserBaseService.sendVerifyCode(paramJSON.getStr("number"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "忘记密码后修改密码")
|
@ApiOperation(value = "忘记密码后修改密码")
|
||||||
@RequestMapping(value = "/doForgetPassword", method = RequestMethod.POST)
|
@RequestMapping(value = "/doForgetPassword", method = RequestMethod.POST)
|
||||||
public CommonResult doForgetPassword(@RequestBody JSONObject paramJSON) {
|
public CommonResult doForgetPassword(@RequestBody JSONObject paramJSON) {
|
||||||
|
|||||||
@ -124,8 +124,8 @@ public class AccountUserBaseController extends BaseControllerImpl {
|
|||||||
|
|
||||||
@ApiOperation("根据用户名获取通用用户信息")
|
@ApiOperation("根据用户名获取通用用户信息")
|
||||||
@RequestMapping(value = "/loadByUsername", method = RequestMethod.GET)
|
@RequestMapping(value = "/loadByUsername", method = RequestMethod.GET)
|
||||||
public UserDto loadUserByUsername(@RequestParam String user_account) {
|
public UserDto loadUserByUsername(@RequestParam String user_account, @RequestParam(name = "user_is_admin", required = false) Integer user_is_admin) {
|
||||||
return accountUserBaseService.loadUserByUsername(user_account);
|
return accountUserBaseService.loadUserByUsername(user_account, user_is_admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "后台管理员和商家登录,登录后返回token") // app 和 pc 的 登录最好分开,这样容易区分从哪个端进来,方便处理逻辑(验证码)
|
@ApiOperation(value = "后台管理员和商家登录,登录后返回token") // app 和 pc 的 登录最好分开,这样容易区分从哪个端进来,方便处理逻辑(验证码)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.suisung.mall.account.service;
|
|||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.domain.UserDto;
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||||
|
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||||
import com.suisung.mall.core.web.service.IBaseService;
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
import org.springframework.data.util.Pair;
|
import org.springframework.data.util.Pair;
|
||||||
|
|
||||||
@ -28,6 +29,8 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
|||||||
|
|
||||||
UserDto loadUserByUsername(String user_account);
|
UserDto loadUserByUsername(String user_account);
|
||||||
|
|
||||||
|
UserDto loadUserByUsername(String user_account, Integer user_is_admin);
|
||||||
|
|
||||||
boolean logout();
|
boolean logout();
|
||||||
|
|
||||||
Map getConnectInfo();
|
Map getConnectInfo();
|
||||||
@ -75,8 +78,24 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
|||||||
*/
|
*/
|
||||||
Integer doBindMobile(String user_intl, String mobile, UserDto currentUser);
|
Integer doBindMobile(String user_intl, String mobile, UserDto currentUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据账号和账号类型获取一条记录
|
||||||
|
*
|
||||||
|
* @param user_account
|
||||||
|
* @param user_is_admin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AccountUserBase getByAccount(String user_account, Integer user_is_admin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据账号获取一条记录
|
||||||
|
*
|
||||||
|
* @param user_account
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
AccountUserBase getByAccount(String user_account);
|
AccountUserBase getByAccount(String user_account);
|
||||||
|
|
||||||
|
|
||||||
boolean getVerifyCode(String number);
|
boolean getVerifyCode(String number);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,6 +125,14 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
|||||||
*/
|
*/
|
||||||
CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code);
|
CommonResult doMerchSmsRegisterAndLogin(String user_mobile, String rand_key, String verify_code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信小程序一键登录注册接口
|
||||||
|
*
|
||||||
|
* @param wxUserInfoReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CommonResult doWxUserRegisterAndLogin(WxUserInfoReq wxUserInfoReq);
|
||||||
|
|
||||||
Map<String, Object> doAppConnectLogin(String bind_name, String code);
|
Map<String, Object> doAppConnectLogin(String bind_name, String code);
|
||||||
|
|
||||||
CommonResult doMobileBindLogin(String user_mobile, String verify_code);
|
CommonResult doMobileBindLogin(String user_mobile, String verify_code);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.suisung.mall.account.service;
|
package com.suisung.mall.account.service;
|
||||||
|
|
||||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||||
|
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||||
import com.suisung.mall.core.web.service.IBaseService;
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -62,4 +63,14 @@ public interface AccountUserBindConnectService extends IBaseService<AccountUserB
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer getUserBindConnectUserIdByCondition(String bindId, Integer bindType, Integer userType);
|
Integer getUserBindConnectUserIdByCondition(String bindId, Integer bindType, Integer userType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定手机号和openid
|
||||||
|
*
|
||||||
|
* @param wxUserInfoReq
|
||||||
|
* @param userId 用户Id
|
||||||
|
* @param userType 0-普通用户;1-管理员;3-入驻商家
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AccountUserBindConnect bindMobileAndOpenId(WxUserInfoReq wxUserInfoReq, Integer userId, Integer userType);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,7 @@ import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommissi
|
|||||||
import com.suisung.mall.common.modules.pay.PayUserResource;
|
import com.suisung.mall.common.modules.pay.PayUserResource;
|
||||||
import com.suisung.mall.common.modules.plantform.ShopPlantformSubsiteUser;
|
import com.suisung.mall.common.modules.plantform.ShopPlantformSubsiteUser;
|
||||||
import com.suisung.mall.common.pojo.dto.SmsDto;
|
import com.suisung.mall.common.pojo.dto.SmsDto;
|
||||||
|
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||||
import com.suisung.mall.common.service.MessageService;
|
import com.suisung.mall.common.service.MessageService;
|
||||||
import com.suisung.mall.common.utils.*;
|
import com.suisung.mall.common.utils.*;
|
||||||
import com.suisung.mall.common.utils.constbank.RSAUtil;
|
import com.suisung.mall.common.utils.constbank.RSAUtil;
|
||||||
@ -202,9 +203,10 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
|
|
||||||
data.put("callback_url", "");
|
data.put("callback_url", "");
|
||||||
|
|
||||||
|
//user_is_admin 用户类型:0-普通用户;1-管理员;2-入驻商户;默认是普通用户
|
||||||
if (StrUtil.isNotBlank(params.get("user_mobile"))
|
if (StrUtil.isNotBlank(params.get("user_mobile"))
|
||||||
&& StrUtil.isNotBlank(params.get("is_merch"))
|
&& StrUtil.isNotBlank(params.get("user_is_admin"))
|
||||||
&& params.get("is_merch").equals("1")) {
|
&& params.get("user_is_admin").equals(CommonConstant.USER_TYPE_MCH)) {
|
||||||
// 商家版app,显示申请入驻的状态
|
// 商家版app,显示申请入驻的状态
|
||||||
data.put("is_merch", 1);
|
data.put("is_merch", 1);
|
||||||
//入驻商家的审批状态:1-已通过;2-未通过;3-待审核;4-未申请;
|
//入驻商家的审批状态:1-已通过;2-未通过;3-待审核;4-未申请;
|
||||||
@ -266,57 +268,76 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDto loadUserByUsername(String user_account) {
|
public UserDto loadUserByUsername(String user_account) {
|
||||||
//获取用户信息
|
return loadUserByUsername(user_account, CommonConstant.USER_TYPE_NORMAL);
|
||||||
AccountUserBase admin = getOne(new QueryWrapper<AccountUserBase>().eq("user_account", user_account));
|
}
|
||||||
|
|
||||||
if (admin != null) {
|
/**
|
||||||
UserDto userDTO = new UserDto();
|
* @param user_account
|
||||||
String store_ids = admin.getStore_ids();
|
* @param user_is_admin
|
||||||
if (StrUtil.isNotBlank(store_ids)) {
|
* @return
|
||||||
userDTO.setStore_id(store_ids);
|
*/
|
||||||
}
|
@Override
|
||||||
|
public UserDto loadUserByUsername(String user_account, Integer user_is_admin) {
|
||||||
userDTO.setId(admin.getUser_id());
|
if (StrUtil.isBlank(user_account)) {
|
||||||
userDTO.setUser_account(admin.getUser_account());
|
return null;
|
||||||
userDTO.setUser_password(admin.getUser_password());
|
|
||||||
userDTO.setUser_state(admin.getUser_state());
|
|
||||||
userDTO.setUser_salt(admin.getUser_salt());
|
|
||||||
|
|
||||||
setIdentityByUser(userDTO, admin);
|
|
||||||
userDTO.setUser_nickname(admin.getUser_nickname());
|
|
||||||
List<AdminRightsGroup> roles = null;
|
|
||||||
|
|
||||||
String rights_group_id = admin.getRights_group_id();
|
|
||||||
|
|
||||||
if (StrUtil.isBlank(rights_group_id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//读取分站编号
|
|
||||||
try {
|
|
||||||
Map params = new HashMap();
|
|
||||||
params.put("user_id:eq", admin.getUser_id());
|
|
||||||
CommonResult findResult = shopService.findOnePlantSubUser(params);
|
|
||||||
ShopPlantformSubsiteUser subsiteUser = findResult.getFenResult(ShopPlantformSubsiteUser.class);
|
|
||||||
|
|
||||||
if (subsiteUser != null) {
|
|
||||||
Integer subsite_id = subsiteUser.getSubsite_id();
|
|
||||||
userDTO.setSite_id(subsite_id);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("远程调用分站数据异常!" + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
roles = adminService.getRoleListById(rights_group_id);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("远程调用异常!" + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
List<String> roleNames = roles.stream().map(item -> item.getRights_group_id() + "_" + item.getRights_group_name()).collect(Collectors.toList());
|
|
||||||
userDTO.setRoles(roleNames);
|
|
||||||
return userDTO;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
if (ObjectUtil.isEmpty(user_is_admin)) {
|
||||||
|
user_is_admin = CommonConstant.USER_TYPE_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取用户信息
|
||||||
|
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("user_account", user_account).eq("user_is_admin", user_is_admin).orderByDesc("user_id");
|
||||||
|
List<AccountUserBase> list = accountUserBaseService.find(queryWrapper);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountUserBase accountUserBase = list.get(0);
|
||||||
|
|
||||||
|
UserDto userDTO = new UserDto();
|
||||||
|
String store_ids = accountUserBase.getStore_ids();
|
||||||
|
if (StrUtil.isNotBlank(store_ids)) {
|
||||||
|
userDTO.setStore_id(store_ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
userDTO.setId(accountUserBase.getUser_id());
|
||||||
|
userDTO.setUser_account(accountUserBase.getUser_account());
|
||||||
|
userDTO.setUser_password(accountUserBase.getUser_password());
|
||||||
|
userDTO.setUser_state(accountUserBase.getUser_state());
|
||||||
|
userDTO.setUser_salt(accountUserBase.getUser_salt());
|
||||||
|
|
||||||
|
setIdentityByUser(userDTO, accountUserBase);
|
||||||
|
userDTO.setUser_nickname(accountUserBase.getUser_nickname());
|
||||||
|
List<AdminRightsGroup> roles = null;
|
||||||
|
List<String> roleNames = new ArrayList<>();
|
||||||
|
//读取分站编号
|
||||||
|
try {
|
||||||
|
Map params = new HashMap();
|
||||||
|
params.put("user_id:eq", accountUserBase.getUser_id());
|
||||||
|
CommonResult findResult = shopService.findOnePlantSubUser(params);
|
||||||
|
ShopPlantformSubsiteUser subsiteUser = findResult.getFenResult(ShopPlantformSubsiteUser.class);
|
||||||
|
|
||||||
|
if (subsiteUser != null) {
|
||||||
|
Integer subsite_id = subsiteUser.getSubsite_id();
|
||||||
|
userDTO.setSite_id(subsite_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
String rights_group_id = accountUserBase.getRights_group_id();
|
||||||
|
if (StrUtil.isNotBlank(rights_group_id)) {
|
||||||
|
roles = adminService.getRoleListById(rights_group_id);
|
||||||
|
if (CollUtil.isNotEmpty(roles)) {
|
||||||
|
roleNames = roles.stream().map(item -> item.getRights_group_id() + "_" + item.getRights_group_name()).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("远程调用分站数据异常!" + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
userDTO.setRoles(roleNames);
|
||||||
|
return userDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1613,11 +1634,11 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
String verify_token = (String) userInfo.get("verify_token");
|
String verify_token = (String) userInfo.get("verify_token");
|
||||||
Integer userIsAdmin = Convert.toInt(userInfo.getOrDefault("user_is_admin", CommonConstant.USER_TYPE_NORMAL)); // 用户类型:0-普通买家; 1-管理员;2-入驻商家;
|
Integer userIsAdmin = Convert.toInt(userInfo.getOrDefault("user_is_admin", CommonConstant.USER_TYPE_NORMAL)); // 用户类型:0-普通买家; 1-管理员;2-入驻商家;
|
||||||
Integer userType = userIsAdmin; // 用户身份:0-普通买家; 1-管理员;2-入驻商家;(有歧义废弃)
|
Integer userType = userIsAdmin; // 用户身份:0-普通买家; 1-管理员;2-入驻商家;(有歧义废弃)
|
||||||
String user_intl = "";
|
|
||||||
|
|
||||||
logger.debug("### 注册参数:{}###", JSONUtil.toJsonStr(userInfo));
|
logger.debug("### 注册参数:{}###", JSONUtil.toJsonStr(userInfo));
|
||||||
|
|
||||||
// todo 支持国外手机号 isMobile() 方法
|
// todo 支持国外手机号 isMobile() 方法
|
||||||
|
String user_intl = "";
|
||||||
String currency_id = getParameter("currency_id", "");
|
String currency_id = getParameter("currency_id", "");
|
||||||
if (StrUtil.isNotBlank(currency_id)) {
|
if (StrUtil.isNotBlank(currency_id)) {
|
||||||
user_intl = "+" + currency_id;
|
user_intl = "+" + currency_id;
|
||||||
@ -1709,7 +1730,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
|
|
||||||
verifyPwd(user_password); // 忽略密码校验
|
verifyPwd(user_password); // 忽略密码校验
|
||||||
|
|
||||||
AccountUserBase user_base_row = getByAccount(user_account);
|
AccountUserBase user_base_row = getByAccount(user_account, userIsAdmin);
|
||||||
if (user_base_row != null) {
|
if (user_base_row != null) {
|
||||||
throw new ApiException(_("用户已经存在,请更换用户名"));
|
throw new ApiException(_("用户已经存在,请更换用户名"));
|
||||||
} else {
|
} else {
|
||||||
@ -1745,9 +1766,9 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
throw new ApiException(ResultCode.FAILED);
|
throw new ApiException(ResultCode.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountUserLogin user_login_reg_row = new AccountUserLogin();
|
|
||||||
|
|
||||||
Integer user_id = user_base_reg_row.getUser_id();
|
Integer user_id = user_base_reg_row.getUser_id();
|
||||||
|
|
||||||
|
AccountUserLogin user_login_reg_row = new AccountUserLogin();
|
||||||
String ip = HttpServletUtils.getClientIpAddr();
|
String ip = HttpServletUtils.getClientIpAddr();
|
||||||
user_login_reg_row.setUser_id(user_id);
|
user_login_reg_row.setUser_id(user_id);
|
||||||
user_login_reg_row.setUser_reg_datetime(cur_date);
|
user_login_reg_row.setUser_reg_datetime(cur_date);
|
||||||
@ -1756,7 +1777,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
user_login_reg_row.setUser_reg_ip(ip);
|
user_login_reg_row.setUser_reg_ip(ip);
|
||||||
user_login_reg_row.setUser_lastlogin_time(cur_date);
|
user_login_reg_row.setUser_lastlogin_time(cur_date);
|
||||||
user_login_reg_row.setUser_lastlogin_ip(ip);
|
user_login_reg_row.setUser_lastlogin_ip(ip);
|
||||||
|
|
||||||
if (!accountUserLoginService.saveOrUpdate(user_login_reg_row)) {
|
if (!accountUserLoginService.saveOrUpdate(user_login_reg_row)) {
|
||||||
throw new ApiException(ResultCode.FAILED);
|
throw new ApiException(ResultCode.FAILED);
|
||||||
}
|
}
|
||||||
@ -2191,7 +2211,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
public Integer doBindMobile(String user_intl, String mobile, UserDto currentUser) {
|
public Integer doBindMobile(String user_intl, String mobile, UserDto currentUser) {
|
||||||
// 国家码+ 手机号
|
// 国家码+ 手机号
|
||||||
String bind_id = user_intl + mobile;
|
String bind_id = user_intl + mobile;
|
||||||
Integer user_id = null;
|
Integer user_id;
|
||||||
|
|
||||||
// 判断是否已经绑定
|
// 判断是否已经绑定
|
||||||
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
||||||
@ -2266,15 +2286,31 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
return user_id;
|
return user_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountUserBase getByAccount(String user_account) {
|
/**
|
||||||
|
* 根据账号和账号类型获取一条记录
|
||||||
|
*
|
||||||
|
* @param user_account
|
||||||
|
* @param user_is_admin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AccountUserBase getByAccount(String user_account, Integer user_is_admin) {
|
||||||
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("user_account", user_account).orderByAsc("user_id");
|
if (user_is_admin == null) {
|
||||||
|
user_is_admin = CommonConstant.USER_TYPE_NORMAL;
|
||||||
|
}
|
||||||
|
queryWrapper.eq("user_account", user_account)
|
||||||
|
.eq("user_is_admin", user_is_admin)
|
||||||
|
.orderByAsc("user_id");
|
||||||
AccountUserBase data = findOne(queryWrapper);
|
AccountUserBase data = findOne(queryWrapper);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AccountUserBase getByAccount(String user_account) {
|
||||||
|
return getByAccount(user_account, CommonConstant.USER_TYPE_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送 手机/邮件 验证码
|
* 发送 手机/邮件 验证码
|
||||||
*
|
*
|
||||||
@ -2737,7 +2773,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
// 找出手机对应的用户
|
// 找出手机对应的用户
|
||||||
// 是否为手机号注册
|
// 是否为手机号注册
|
||||||
if (StrUtil.isNotBlank(user_mobile)) {
|
if (StrUtil.isNotBlank(user_mobile)) {
|
||||||
return doMobileBindLogin(user_mobile, null);
|
return doMobileBindLogin(user_mobile, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
@ -2785,9 +2821,182 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
|
|
||||||
// 找出手机对应的绑定用户
|
// 找出手机对应的绑定用户
|
||||||
// 是否为手机号注册,密码6位随机数
|
// 是否为手机号注册,密码6位随机数
|
||||||
return doMobileBindLogin(verifyMobile, true);
|
return doMobileBindLogin(verifyMobile, CommonConstant.USER_TYPE_MCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信小程序一键登录注册接口
|
||||||
|
*
|
||||||
|
* @param wxUserInfoReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CommonResult doWxUserRegisterAndLogin(WxUserInfoReq wxUserInfoReq) {
|
||||||
|
if (wxUserInfoReq == null) {
|
||||||
|
return CommonResult.failed(_("缺少必要参数!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(wxUserInfoReq.getPhoneNumber())) {
|
||||||
|
return CommonResult.failed(_("缺少手机号码!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(wxUserInfoReq.getOpenId())) {
|
||||||
|
return CommonResult.failed(_("缺少 OpenId!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
String iddCode = wxUserInfoReq.getCountryCode();
|
||||||
|
if (StrUtil.isNotBlank(iddCode)) {
|
||||||
|
iddCode = iddCode.startsWith("+") ? iddCode : ("+" + iddCode);
|
||||||
|
} else {
|
||||||
|
iddCode = CommonConstant.IDD_ZH_CN;
|
||||||
|
}
|
||||||
|
// 带国家编码的手机号
|
||||||
|
String mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(wxUserInfoReq.getPhoneNumber(), iddCode);
|
||||||
|
|
||||||
|
AccountUserBase accountUserBase = getByAccount(mobile);
|
||||||
|
if (accountUserBase == null) {
|
||||||
|
// 检测到用户尚未注册,立即新增用户基本信息和用户附加信息
|
||||||
|
Date today = new Date();
|
||||||
|
String user_nickname = wxUserInfoReq.getNickName();
|
||||||
|
Integer user_state = 2;
|
||||||
|
String user_key = IdUtil.simpleUUID();
|
||||||
|
String user_salt = IdUtil.simpleUUID();
|
||||||
|
String user_token = IdUtil.simpleUUID();
|
||||||
|
String rights_group_id = "0";
|
||||||
|
String store_ids = "";
|
||||||
|
|
||||||
|
accountUserBase = new AccountUserBase();
|
||||||
|
accountUserBase.setUser_account(mobile);
|
||||||
|
// 密码加盐加密
|
||||||
|
String user_password = com.suisung.mall.common.utils.StringUtils.random(6, com.suisung.mall.common.utils.StringUtils.RandomType.STRING);
|
||||||
|
user_password = SecureUtil.md5(user_salt + SecureUtil.md5(user_password));
|
||||||
|
accountUserBase.setUser_password(user_password);
|
||||||
|
accountUserBase.setUser_nickname(user_nickname);
|
||||||
|
accountUserBase.setUser_state(user_state);
|
||||||
|
accountUserBase.setUser_key(user_key);
|
||||||
|
accountUserBase.setUser_salt(user_salt);
|
||||||
|
accountUserBase.setRights_group_id(rights_group_id);
|
||||||
|
accountUserBase.setStore_ids(store_ids);
|
||||||
|
accountUserBase.setUser_token(user_token);
|
||||||
|
accountUserBase.setUser_is_admin(CommonConstant.USER_TYPE_NORMAL);// 用户类型:0-普通用户;1-管理员;2-入驻商户;默认是普通用户
|
||||||
|
accountUserBase.setUser_type(CommonConstant.USER_TYPE_NORMAL); // 用户类型:0-普通用户;1-管理员;2-入驻商户;默认是普通用户
|
||||||
|
accountUserBase.setRights_group_id("0");// 店铺管理员,店铺 权限
|
||||||
|
|
||||||
|
if (!saveOrUpdate(accountUserBase)) {
|
||||||
|
return CommonResult.failed(_("用户注册失败!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer userId = accountUserBase.getUser_id();
|
||||||
|
|
||||||
|
AccountUserLogin user_login_reg_row = new AccountUserLogin();
|
||||||
|
user_login_reg_row.setUser_id(userId);
|
||||||
|
user_login_reg_row.setUser_reg_time(today.getTime());
|
||||||
|
String ipAddr = HttpServletUtils.getClientIpAddr();
|
||||||
|
user_login_reg_row.setUser_reg_ip(ipAddr);
|
||||||
|
user_login_reg_row.setUser_lastlogin_ip(ipAddr);
|
||||||
|
user_login_reg_row.setUser_reg_datetime(today);
|
||||||
|
user_login_reg_row.setUser_reg_date(today);
|
||||||
|
user_login_reg_row.setUser_lastlogin_time(today);
|
||||||
|
|
||||||
|
if (!accountUserLoginService.saveOrUpdate(user_login_reg_row)) {
|
||||||
|
logger.error("写入登录信息失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountUserInfo user_info_reg_row = new AccountUserInfo();
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(mobile)) {
|
||||||
|
user_info_reg_row.setUser_mobile(mobile);
|
||||||
|
} else {
|
||||||
|
user_info_reg_row.setUser_mobile("");
|
||||||
|
}
|
||||||
|
|
||||||
|
user_info_reg_row.setUser_id(userId);
|
||||||
|
// 0-未知;1-男;2-女;
|
||||||
|
Integer user_gender = wxUserInfoReq.getGender() == null ? 1 : wxUserInfoReq.getGender() + 1;
|
||||||
|
user_info_reg_row.setUser_gender(user_gender);
|
||||||
|
user_info_reg_row.setUser_intl(iddCode);
|
||||||
|
user_info_reg_row.setUser_email("");
|
||||||
|
user_info_reg_row.setUser_avatar(wxUserInfoReq.getAvatarUrl());
|
||||||
|
user_info_reg_row.setUser_birthday(DateUtil.parse("2000-01-01"));
|
||||||
|
user_info_reg_row.setUser_notename(wxUserInfoReq.getNickName());
|
||||||
|
|
||||||
|
// todo 会员卡号
|
||||||
|
user_info_reg_row.setUser_level_card("");
|
||||||
|
if (!accountUserInfoService.saveOrUpdate(user_info_reg_row)) {
|
||||||
|
return CommonResult.failed(_("用户初始化失败!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 远程调用异常忽略掉
|
||||||
|
try {
|
||||||
|
// todo trigger
|
||||||
|
// User_Resource初始化 用户积分
|
||||||
|
payService.initUserPoints(userId);
|
||||||
|
|
||||||
|
// 初始化用户经验表
|
||||||
|
accountUserInfoService.initUserExperience(userId);
|
||||||
|
|
||||||
|
// 分销用户来源 - 平台推广员功能,佣金平台出
|
||||||
|
// 修改用户上级关系
|
||||||
|
Integer user_parent_id = getSourceUserId();
|
||||||
|
if (CheckUtil.isNotEmpty(user_parent_id)) {
|
||||||
|
if (get(user_parent_id) != null) {
|
||||||
|
addSourceUserId(userId, user_parent_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo 分享券
|
||||||
|
// 分享券活动id
|
||||||
|
Integer activityId = Convert.toInt(getParameter("activity_id"), 0);
|
||||||
|
if (CheckUtil.isNotEmpty(activityId)) {
|
||||||
|
// 公钥钥加密处理
|
||||||
|
String userParentId = RSAUtil.encrypt(user_parent_id.toString(), AuthConstant.publicKey);
|
||||||
|
// 远程调用更新并计算发放分享卷
|
||||||
|
shopService.updateCoupons(userParentId, activityId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("用户注册,远程初始化用户周边资料(积分,经验值等)时,发生异常", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
//记录渠道来源
|
||||||
|
String source_ucc_code = getSourceChannelCode();
|
||||||
|
if (CheckUtil.isNotEmpty(source_ucc_code)) {
|
||||||
|
addChannelSourceUserId(userId, source_ucc_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
//初次注册发送消息
|
||||||
|
String message_id = "registration-of-welcome-information";
|
||||||
|
HashMap<String, Object> args = new HashMap<>();
|
||||||
|
args.put("user_account", user_nickname);
|
||||||
|
args.put("register_time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(today));
|
||||||
|
|
||||||
|
messageService.sendNoticeMsg(userId, 0, message_id, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// accountUserBase == null 的情况
|
||||||
|
// 是否绑定手机号了?
|
||||||
|
AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.getBindByBindId(mobile, BindCode.MOBILE, CommonConstant.USER_TYPE_NORMAL);
|
||||||
|
if (accountUserBindConnect == null || !accountUserBase.getUser_id().equals(accountUserBindConnect.getUser_id())) {
|
||||||
|
// 先绑定手机号
|
||||||
|
if (accountUserBindConnectService.bindMobileAndOpenId(wxUserInfoReq, accountUserBase.getUser_id(), accountUserBase.getUser_is_admin()) == null) {
|
||||||
|
return CommonResult.failed(_("账号绑定失败!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已经绑定了,直接登录
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("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", mobile);
|
||||||
|
params.put("password", "");
|
||||||
|
params.put("user_mobile", mobile);
|
||||||
|
params.put("user_is_admin", CommonConstant.USER_TYPE_NORMAL.toString());
|
||||||
|
|
||||||
|
return login(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号登陆操作
|
* 手机号登陆操作
|
||||||
* 使用到的:后台管理员或商家登录,客户c端
|
* 使用到的:后台管理员或商家登录,客户c端
|
||||||
@ -2799,6 +3008,8 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
AccountUserBindConnect bind_row = bindConnectService.get(user_mobile);
|
AccountUserBindConnect bind_row = bindConnectService.get(user_mobile);
|
||||||
|
|
||||||
if (bind_row != null && ObjectUtil.equal(BindCode.MOBILE, bind_row.getBind_type())) {
|
if (bind_row != null && ObjectUtil.equal(BindCode.MOBILE, bind_row.getBind_type())) {
|
||||||
|
// AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.getBindByBindId(user_mobile, BindCode.MOBILE, CommonConstant.USER_TYPE_NORMAL);
|
||||||
|
// if (accountUserBindConnect != null) {
|
||||||
// 绑定了手机的情况,
|
// 绑定了手机的情况,
|
||||||
Integer user_id = bind_row.getUser_id();
|
Integer user_id = bind_row.getUser_id();
|
||||||
AccountUserBase user_base_row = get(user_id);
|
AccountUserBase user_base_row = get(user_id);
|
||||||
@ -2824,12 +3035,16 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
* (商家版app)入驻商家手机号绑定登录
|
* (商家版app)入驻商家手机号绑定登录
|
||||||
*
|
*
|
||||||
* @param user_mobile 带+86的中国号码
|
* @param user_mobile 带+86的中国号码
|
||||||
* @param isMerch 是否是商家入驻的
|
* @param userType 用户类型:0-普通用户;1-管理员;2-入驻商户
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public CommonResult doMobileBindLogin(String user_mobile, boolean isMerch) {
|
public CommonResult doMobileBindLogin(String user_mobile, Integer userType) {
|
||||||
|
if (StrUtil.isBlank(user_mobile) || userType == null) {
|
||||||
|
return CommonResult.failed("缺少必要参数!");
|
||||||
|
}
|
||||||
|
|
||||||
// 查询绑定手机的商家账号
|
// 查询绑定手机的商家账号
|
||||||
AccountUserBindConnect bind_row = accountUserBindConnectService.getBindByBindId(user_mobile, BindCode.MOBILE, CommonConstant.USER_TYPE_MCH);
|
AccountUserBindConnect bind_row = accountUserBindConnectService.getBindByBindId(user_mobile, BindCode.MOBILE, userType);
|
||||||
AccountUserBase accountUserBase;
|
AccountUserBase accountUserBase;
|
||||||
if (bind_row != null) {
|
if (bind_row != null) {
|
||||||
// 已经注册账号的,绑定了手机的情况,
|
// 已经注册账号的,绑定了手机的情况,
|
||||||
@ -2839,20 +3054,20 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
return CommonResult.failed("获取不到用户信息!");
|
return CommonResult.failed("获取不到用户信息!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjectUtil.notEqual(CommonConstant.USER_TYPE_MCH, accountUserBase.getUser_is_admin())) {
|
if (ObjectUtil.notEqual(userType, accountUserBase.getUser_is_admin())) {
|
||||||
// 不是入驻商家的情况,已经有普通用户使用了手机号了,提示已经被注册。
|
// 不是入驻商家的情况,已经有普通用户使用了手机号了,提示已经被注册。
|
||||||
return CommonResult.failed("已被注册,请换一个手机号码!");
|
return CommonResult.failed("已被注册,请换一个手机号码!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 手机号码未绑定的情况,直接去注册一个账号
|
// 手机号码未绑定的情况,直接去注册一个账号
|
||||||
Map<String, Object> userInfo = new HashMap<>();
|
Map<String, Object> userInfo = new HashMap<>();
|
||||||
userInfo.put("user_account", user_mobile);// 时间 yyyyMMddHHmmss + 4位随机数 com.suisung.mall.common.utils.StringUtils.genLklOrderNo(4)
|
userInfo.put("user_account", user_mobile);
|
||||||
userInfo.put("user_mobile", user_mobile);
|
userInfo.put("user_mobile", user_mobile);
|
||||||
userInfo.put("user_is_admin", CommonConstant.USER_TYPE_MCH); // 商家入驻注册
|
userInfo.put("user_is_admin", userType); // 商家入驻注册
|
||||||
// 随机数明文密码
|
// 随机数明文密码
|
||||||
String user_password = com.suisung.mall.common.utils.StringUtils.random(6, com.suisung.mall.common.utils.StringUtils.RandomType.STRING);
|
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("user_password", user_password);
|
||||||
userInfo.put("is_admin", CommonConstant.USER_TYPE_MCH); // 商家入驻注册
|
userInfo.put("is_admin", userType); // 商家入驻注册
|
||||||
|
|
||||||
// 注:注册商家账号,都是需要手机号绑定的。
|
// 注:注册商家账号,都是需要手机号绑定的。
|
||||||
accountUserBase = register(userInfo);
|
accountUserBase = register(userInfo);
|
||||||
@ -2862,7 +3077,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("client_id", isMerch ? AuthConstant.MCH_CLIENT_ID : AuthConstant.MOBILE_CLIENT_ID);
|
params.put("client_id", CommonConstant.USER_TYPE_MCH.equals(userType) ? AuthConstant.MCH_CLIENT_ID : AuthConstant.MOBILE_CLIENT_ID);
|
||||||
params.put("client_secret", AuthConstant.AUTHORITY_MOBILE_SECRET);
|
params.put("client_secret", AuthConstant.AUTHORITY_MOBILE_SECRET);
|
||||||
params.put("grant_type", "password");
|
params.put("grant_type", "password");
|
||||||
params.put("verify_pwd", "1001"); // 是否验证密码 1001:不验证;1002:验证(内部登录没有用户明文密码,只能不验证)
|
params.put("verify_pwd", "1001"); // 是否验证密码 1001:不验证;1002:验证(内部登录没有用户明文密码,只能不验证)
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import com.suisung.mall.common.exception.ApiException;
|
|||||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||||
|
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||||
import com.suisung.mall.common.utils.CheckUtil;
|
import com.suisung.mall.common.utils.CheckUtil;
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
import com.suisung.mall.common.utils.I18nUtil;
|
||||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||||
@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
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.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -308,4 +310,68 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
|
|||||||
return accountUserBindConnect != null ? accountUserBindConnect.getUser_id() : null;
|
return accountUserBindConnect != null ? accountUserBindConnect.getUser_id() : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定手机号和openid
|
||||||
|
*
|
||||||
|
* @param wxUserInfoReq
|
||||||
|
* @param userId 用户Id
|
||||||
|
* @param userType 0-普通用户;1-管理员;3-入驻商家
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AccountUserBindConnect bindMobileAndOpenId(WxUserInfoReq wxUserInfoReq, Integer userId, Integer userType) {
|
||||||
|
if (wxUserInfoReq == null || userType == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String iddCode = wxUserInfoReq.getCountryCode();
|
||||||
|
if (StrUtil.isNotBlank(iddCode)) {
|
||||||
|
iddCode = iddCode.startsWith("+") ? iddCode : ("+" + iddCode);
|
||||||
|
} else {
|
||||||
|
iddCode = CommonConstant.IDD_ZH_CN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 带国家编码的手机号
|
||||||
|
String mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(wxUserInfoReq.getPhoneNumber(), iddCode);
|
||||||
|
|
||||||
|
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("bind_id", mobile)
|
||||||
|
.eq("bind_type", BindCode.MOBILE)
|
||||||
|
.eq("user_type", userType)
|
||||||
|
.eq("user_id", userId)
|
||||||
|
.eq("bind_active", CommonConstant.Enable);
|
||||||
|
|
||||||
|
AccountUserBindConnect accountUserBindConnect = findOne(queryWrapper);
|
||||||
|
if (accountUserBindConnect != null) {
|
||||||
|
return accountUserBindConnect;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增一条绑定数据
|
||||||
|
AccountUserBindConnect record = new AccountUserBindConnect();
|
||||||
|
record.setBind_id(mobile);
|
||||||
|
record.setBind_type(BindCode.MOBILE);
|
||||||
|
record.setUser_id(userId);
|
||||||
|
record.setUser_type(userType);
|
||||||
|
record.setBind_openid(wxUserInfoReq.getOpenId());
|
||||||
|
record.setBind_unionid(wxUserInfoReq.getUnionId());
|
||||||
|
record.setBind_gender(wxUserInfoReq.getGender());
|
||||||
|
record.setBind_nickname(wxUserInfoReq.getNickName());
|
||||||
|
record.setBind_icon(wxUserInfoReq.getAvatarUrl());
|
||||||
|
record.setBind_country(wxUserInfoReq.getCountry());
|
||||||
|
record.setBind_province(wxUserInfoReq.getProvince());
|
||||||
|
record.setBind_city(wxUserInfoReq.getCity());
|
||||||
|
record.setBind_active(CommonConstant.Enable);
|
||||||
|
record.setBind_time(new Date());
|
||||||
|
record.setBind_expires_in(0);
|
||||||
|
record.setBind_token_ttl(0);
|
||||||
|
record.setBind_level(0);
|
||||||
|
record.setBind_vip(0);
|
||||||
|
|
||||||
|
if (save(record)) {
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,5 +9,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
public interface AccountService {
|
public interface AccountService {
|
||||||
|
|
||||||
@GetMapping("/admin/account/account-user-base/loadByUsername")
|
@GetMapping("/admin/account/account-user-base/loadByUsername")
|
||||||
UserDto loadUserByUsername(@RequestParam("user_account") String user_account);
|
UserDto loadUserByUsername(@RequestParam("user_account") String user_account, @RequestParam(name = "user_is_admin", required = false) Integer user_is_admin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
package com.suisung.mall.auth.service.impl;
|
package com.suisung.mall.auth.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.suisung.mall.auth.constant.MessageConstant;
|
import com.suisung.mall.auth.constant.MessageConstant;
|
||||||
import com.suisung.mall.auth.domain.SecurityUser;
|
import com.suisung.mall.auth.domain.SecurityUser;
|
||||||
import com.suisung.mall.auth.service.AccountService;
|
import com.suisung.mall.auth.service.AccountService;
|
||||||
import com.suisung.mall.common.constant.AuthConstant;
|
import com.suisung.mall.common.constant.AuthConstant;
|
||||||
|
import com.suisung.mall.common.constant.CommonConstant;
|
||||||
import com.suisung.mall.common.domain.UserDto;
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.AccountExpiredException;
|
import org.springframework.security.authentication.AccountExpiredException;
|
||||||
@ -33,11 +35,13 @@ public class UserServiceImpl implements UserDetailsService {
|
|||||||
String client_id = request.getParameter("client_id");
|
String client_id = request.getParameter("client_id");
|
||||||
UserDto userDto;
|
UserDto userDto;
|
||||||
if (AuthConstant.ADMIN_CLIENT_ID.equals(client_id)) {
|
if (AuthConstant.ADMIN_CLIENT_ID.equals(client_id)) {
|
||||||
userDto = accountService.loadUserByUsername(username);
|
userDto = accountService.loadUserByUsername(username, CommonConstant.USER_TYPE_ADMIN);
|
||||||
|
} else if (AuthConstant.MCH_CLIENT_ID.equals(client_id)) {
|
||||||
|
userDto = accountService.loadUserByUsername(username, CommonConstant.USER_TYPE_MCH);
|
||||||
} else {
|
} else {
|
||||||
userDto = accountService.loadUserByUsername(username);
|
userDto = accountService.loadUserByUsername(username, CommonConstant.USER_TYPE_NORMAL);
|
||||||
}
|
}
|
||||||
if (userDto == null) {
|
if (ObjectUtil.isEmpty(userDto)) {
|
||||||
throw new UsernameNotFoundException(MessageConstant.USERNAME_PASSWORD_ERROR);
|
throw new UsernameNotFoundException(MessageConstant.USERNAME_PASSWORD_ERROR);
|
||||||
}
|
}
|
||||||
userDto.setClient_id(client_id);
|
userDto.setClient_id(client_id);
|
||||||
|
|||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
|
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||||
|
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||||
|
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||||
|
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.suisung.mall.common.pojo.req;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@ApiModel(description = "微信小程序用户信息请求参数")
|
||||||
|
public class WxUserInfoReq implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证手机号")
|
||||||
|
private String phoneNumber;
|
||||||
|
@ApiModelProperty("国家通信编号")
|
||||||
|
private String CountryCode;
|
||||||
|
@ApiModelProperty("openId")
|
||||||
|
private String openId;
|
||||||
|
@ApiModelProperty("unionId")
|
||||||
|
private String unionId;
|
||||||
|
@ApiModelProperty("会员真实姓名")
|
||||||
|
private String nickName;
|
||||||
|
@ApiModelProperty("会员性别:1-男;2-女;")
|
||||||
|
private Integer gender;
|
||||||
|
@ApiModelProperty("省份")
|
||||||
|
private String province;
|
||||||
|
@ApiModelProperty("城市")
|
||||||
|
private String city;
|
||||||
|
@ApiModelProperty("县")
|
||||||
|
private String country;
|
||||||
|
@ApiModelProperty("头像")
|
||||||
|
private String avatarUrl;
|
||||||
|
}
|
||||||
@ -59,10 +59,6 @@ public class ShopMerchEntryController extends BaseControllerImpl {
|
|||||||
@ApiOperation(value = "获取商家入驻资料详情", notes = "获取商家入驻资料详情")
|
@ApiOperation(value = "获取商家入驻资料详情", notes = "获取商家入驻资料详情")
|
||||||
@RequestMapping(value = "/detail", method = RequestMethod.POST)
|
@RequestMapping(value = "/detail", method = RequestMethod.POST)
|
||||||
public CommonResult shopMerchEntryDetail(@RequestBody JSONObject jsonParam) {
|
public CommonResult shopMerchEntryDetail(@RequestBody JSONObject jsonParam) {
|
||||||
// approvalStatus 入驻商家的审批状态:1-已通过;2-未通过;3-待审核;
|
|
||||||
// List<Integer> approvalStatusList = new ArrayList<Integer>();
|
|
||||||
// approvalStatusList.add(2);
|
|
||||||
// approvalStatusList.add(3);
|
|
||||||
return shopMerchEntryService.shopMerchEntryDetail(null, jsonParam.getStr("mobile"), null);
|
return shopMerchEntryService.shopMerchEntryDetail(null, jsonParam.getStr("mobile"), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -391,14 +391,32 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShopMerchEntry record = recordList.get(0);
|
ShopMerchEntry record = recordList.get(0);
|
||||||
|
|
||||||
|
// 试试更新入驻表的合同下载地址和合同签署状态
|
||||||
|
updateMerchEntrySignedStatusAndContractDownloadUrl(record);
|
||||||
|
|
||||||
|
return CommonResult.success(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 试试更新入驻表的合同下载地址和合同签署状态
|
||||||
|
*
|
||||||
|
* @param record
|
||||||
|
*/
|
||||||
|
private void updateMerchEntrySignedStatusAndContractDownloadUrl(ShopMerchEntry record) {
|
||||||
|
if (record == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (CommonConstant.MCH_APPR_STA_PASS.equals(record.getApproval_status())
|
if (CommonConstant.MCH_APPR_STA_PASS.equals(record.getApproval_status())
|
||||||
&& StrUtil.isBlank(record.getContract_download_url())) {
|
&& (StrUtil.isBlank(record.getContract_download_url()) || !CommonConstant.CONTRACT_SIGN_STA_FINISH.equals(record.getSigned_status()))) {
|
||||||
|
// 审核通过的,但是没有合同文件的情况,要进一步同步状态和合同文件
|
||||||
Pair<Integer, String> contractInfo = esignContractService.checkSignFlowStatus(record.getLogin_mobile());
|
Pair<Integer, String> contractInfo = esignContractService.checkSignFlowStatus(record.getLogin_mobile());
|
||||||
if (contractInfo != null) {
|
if (contractInfo != null) {
|
||||||
record.setSigned_status(contractInfo.getFirst());
|
record.setSigned_status(contractInfo.getFirst());
|
||||||
record.setContract_download_url(contractInfo.getSecond());
|
record.setContract_download_url(contractInfo.getSecond());
|
||||||
|
|
||||||
// 更改同步合同审核状态和下载地址失败
|
// 更改同步合同审核状态和合同下载地址
|
||||||
taskService.executeTask(() -> {
|
taskService.executeTask(() -> {
|
||||||
log.debug("###更改同步合同审核状态和下载地址###");
|
log.debug("###更改同步合同审核状态和下载地址###");
|
||||||
if (!updateMerchEntrySignedStatusAndContractDownloadUrl(record.getLogin_mobile(), record.getSigned_status(), record.getContract_download_url())) {
|
if (!updateMerchEntrySignedStatusAndContractDownloadUrl(record.getLogin_mobile(), record.getSigned_status(), record.getContract_download_url())) {
|
||||||
@ -407,8 +425,6 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommonResult.success(record);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -564,7 +580,7 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
|
|||||||
|
|
||||||
QueryWrapper<ShopMerchEntry> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopMerchEntry> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("login_mobile", loginMobile)
|
queryWrapper.eq("login_mobile", loginMobile)
|
||||||
.select("id", "approval_status", "approval_remark", "approval_invalid_col")
|
.select("id", "approval_status", "approval_remark", "login_mobile", "approval_invalid_col", "signed_status", "contract_download_url")
|
||||||
.orderByAsc("id");
|
.orderByAsc("id");
|
||||||
|
|
||||||
List<ShopMerchEntry> recordList = list(queryWrapper);
|
List<ShopMerchEntry> recordList = list(queryWrapper);
|
||||||
@ -572,7 +588,12 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return recordList.get(0);
|
ShopMerchEntry record = recordList.get(0);
|
||||||
|
|
||||||
|
// 试试更新入驻表的合同下载地址和合同签署状态
|
||||||
|
updateMerchEntrySignedStatusAndContractDownloadUrl(record);
|
||||||
|
|
||||||
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -181,6 +181,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private WxQrCodeService wxQrCodeService;
|
private WxQrCodeService wxQrCodeService;
|
||||||
|
@Autowired
|
||||||
|
private I18nUtil i18nUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1698,10 +1700,12 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
}
|
}
|
||||||
store_id = store_row.getStore_id();
|
store_id = store_row.getStore_id();
|
||||||
|
|
||||||
// 生成店铺的太阳码 2025-03-31
|
if (StrUtil.isBlank(store_row.getWx_qrcode())) {
|
||||||
Pair<String, String> resp = wxQrCodeService.genUnlimitedWxQrCode("pagesub/index/store", "store_id=" + store_id);
|
// 生成店铺的太阳码 2025-03-31
|
||||||
if (StrUtil.isNotBlank(resp.getFirst())) {
|
Pair<String, String> resp = wxQrCodeService.genUnlimitedWxQrCode("pagesub/index/store", "store_id=" + store_id);
|
||||||
updateStoreBaseQrCode(store_id, resp.getFirst());
|
if (StrUtil.isNotBlank(resp.getFirst())) {
|
||||||
|
updateStoreBaseQrCode(store_id, resp.getFirst());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2486,6 +2490,10 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean saveInfo(ShopStoreBase base, ShopStoreInfo info, AccountUserBase userInfo, ShopStoreCompany company) {
|
public boolean saveInfo(ShopStoreBase base, ShopStoreInfo info, AccountUserBase userInfo, ShopStoreCompany company) {
|
||||||
|
if (base == null) {
|
||||||
|
throw new ApiException(I18nUtil._("缺少店铺相关信息"));
|
||||||
|
}
|
||||||
|
|
||||||
/*start根据需求新增编辑店铺介绍*/
|
/*start根据需求新增编辑店铺介绍*/
|
||||||
if (company != null && StrUtil.isNotBlank(company.getCompany_description())) {
|
if (company != null && StrUtil.isNotBlank(company.getCompany_description())) {
|
||||||
QueryWrapper<ShopStoreCompany> companyQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopStoreCompany> companyQueryWrapper = new QueryWrapper<>();
|
||||||
@ -3448,17 +3456,17 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
*/
|
*/
|
||||||
public ShopStoreBase bd09ToGcj02Gps(ShopStoreBase shopStoreBase) {
|
public ShopStoreBase bd09ToGcj02Gps(ShopStoreBase shopStoreBase) {
|
||||||
// 百度坐标系BD09经纬度 转出 火星坐标系GCJ02经纬度 (因为数据库保存的经纬度统一是GCJ02经纬度,所以需要转换 )
|
// 百度坐标系BD09经纬度 转出 火星坐标系GCJ02经纬度 (因为数据库保存的经纬度统一是GCJ02经纬度,所以需要转换 )
|
||||||
if (shopStoreBase == null || StrUtil.isBlank(shopStoreBase.getStore_longitude()) || StrUtil.isBlank(shopStoreBase.getStore_latitude())) {
|
if (shopStoreBase == null
|
||||||
return null;
|
|| StrUtil.isBlank(shopStoreBase.getStore_longitude())
|
||||||
|
|| StrUtil.isBlank(shopStoreBase.getStore_latitude())) {
|
||||||
|
return shopStoreBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpsDTO gps = bd09ToGcj02Gps(shopStoreBase.getStore_longitude(), shopStoreBase.getStore_latitude());
|
GpsDTO gps = bd09ToGcj02Gps(shopStoreBase.getStore_longitude(), shopStoreBase.getStore_latitude());
|
||||||
if (gps == null || gps.getWgLon() == 0 || gps.getWgLat() == 0) {
|
if (gps != null && gps.getWgLon() != 0 && gps.getWgLat() != 0) {
|
||||||
return null;
|
shopStoreBase.setStore_longitude(String.valueOf(gps.getWgLon()));
|
||||||
|
shopStoreBase.setStore_latitude(String.valueOf(gps.getWgLat()));
|
||||||
}
|
}
|
||||||
shopStoreBase.setStore_longitude(String.valueOf(gps.getWgLon()));
|
|
||||||
shopStoreBase.setStore_latitude(String.valueOf(gps.getWgLat()));
|
|
||||||
|
|
||||||
return shopStoreBase;
|
return shopStoreBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user