|
@@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.util.ThirdSessionHolder;
|
|
import com.util.ThirdSessionHolder;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
-import org.jeecg.common.api.vo.Result;
|
|
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.util.JwtUtil;
|
|
import org.jeecg.common.system.util.JwtUtil;
|
|
@@ -21,7 +20,7 @@ import org.jeecg.common.util.TenantContextHolder;
|
|
|
import org.jeecg.modules.wxuser.dto.LoginDto;
|
|
import org.jeecg.modules.wxuser.dto.LoginDto;
|
|
|
import org.jeecg.modules.wxuser.dto.WxOpenDataDto;
|
|
import org.jeecg.modules.wxuser.dto.WxOpenDataDto;
|
|
|
import org.jeecg.modules.wxuser.entity.ThirdSession;
|
|
import org.jeecg.modules.wxuser.entity.ThirdSession;
|
|
|
-import org.jeecg.modules.wxuser.entity.UserInfo;
|
|
|
|
|
|
|
+import org.jeecg.modules.wxuser.entity.MallUserInfo;
|
|
|
import org.jeecg.modules.wxuser.entity.WxAppConfig;
|
|
import org.jeecg.modules.wxuser.entity.WxAppConfig;
|
|
|
import org.jeecg.modules.wxuser.entity.WxUser;
|
|
import org.jeecg.modules.wxuser.entity.WxUser;
|
|
|
import org.jeecg.modules.wxuser.mapper.UserInfoMapper;
|
|
import org.jeecg.modules.wxuser.mapper.UserInfoMapper;
|
|
@@ -37,10 +36,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @Description: user_info
|
|
* @Description: user_info
|
|
@@ -49,7 +45,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
* @Version: V1.0
|
|
* @Version: V1.0
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
-public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements IUserInfoService {
|
|
|
|
|
|
|
+public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, MallUserInfo> implements IUserInfoService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private IWxAppConfigService wxAppConfigService;
|
|
private IWxAppConfigService wxAppConfigService;
|
|
|
@Resource
|
|
@Resource
|
|
@@ -65,7 +61,7 @@ private IWxAppConfigService wxAppConfigService;
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public UserInfo loginMa(LoginDto dto) {
|
|
|
|
|
|
|
+ public MallUserInfo loginMa(LoginDto dto) {
|
|
|
LambdaQueryWrapper<WxAppConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<WxAppConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(WxAppConfig::getAppId, dto.getAppId());
|
|
lambdaQueryWrapper.eq(WxAppConfig::getAppId, dto.getAppId());
|
|
|
WxAppConfig wxApp = wxAppConfigService.getOne(lambdaQueryWrapper);
|
|
WxAppConfig wxApp = wxAppConfigService.getOne(lambdaQueryWrapper);
|
|
@@ -99,7 +95,7 @@ private IWxAppConfigService wxAppConfigService;
|
|
|
throw new JeecgBootException("小程序获取登录后的微信用户失败:" + e.getMessage());
|
|
throw new JeecgBootException("小程序获取登录后的微信用户失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
System.out.println("【授权登录前】" + wxUser.toString());
|
|
System.out.println("【授权登录前】" + wxUser.toString());
|
|
|
- UserInfo userInfo;
|
|
|
|
|
|
|
+ MallUserInfo userInfo;
|
|
|
if (wxUser == null || StrUtil.isBlank(wxUser.getId())) {
|
|
if (wxUser == null || StrUtil.isBlank(wxUser.getId())) {
|
|
|
//新增微信用户
|
|
//新增微信用户
|
|
|
wxUser.setAppId(wxApp.getId());
|
|
wxUser.setAppId(wxApp.getId());
|
|
@@ -110,7 +106,7 @@ private IWxAppConfigService wxAppConfigService;
|
|
|
if (StrUtil.isNotBlank(wxUser.getUserId())) {
|
|
if (StrUtil.isNotBlank(wxUser.getUserId())) {
|
|
|
userInfo = baseMapper.selectById(wxUser.getUserId());
|
|
userInfo = baseMapper.selectById(wxUser.getUserId());
|
|
|
} else {
|
|
} else {
|
|
|
- userInfo = new UserInfo();
|
|
|
|
|
|
|
+ userInfo = new MallUserInfo();
|
|
|
}
|
|
}
|
|
|
System.out.println("【用户信息】" + userInfo.toString());
|
|
System.out.println("【用户信息】" + userInfo.toString());
|
|
|
|
|
|
|
@@ -137,7 +133,7 @@ private IWxAppConfigService wxAppConfigService;
|
|
|
* @param dto
|
|
* @param dto
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public UserInfo loginByPhoneMa(WxOpenDataDto dto,String token) {
|
|
|
|
|
|
|
+ public MallUserInfo loginByPhoneMa(WxOpenDataDto dto, String token) {
|
|
|
ThirdSession thirdSession = ThirdSessionHolder.getThirdSession();
|
|
ThirdSession thirdSession = ThirdSessionHolder.getThirdSession();
|
|
|
String key = CommonConstant.PREFIX_WX_APP_USER_TOKEN + token;
|
|
String key = CommonConstant.PREFIX_WX_APP_USER_TOKEN + token;
|
|
|
dto.setSessionKey(thirdSession.getSessionKey());
|
|
dto.setSessionKey(thirdSession.getSessionKey());
|
|
@@ -164,18 +160,18 @@ private IWxAppConfigService wxAppConfigService;
|
|
|
throw new JeecgBootException("微信小程序授权拉取手机号码:" + e.getMessage());
|
|
throw new JeecgBootException("微信小程序授权拉取手机号码:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
//通过手机号登录
|
|
//通过手机号登录
|
|
|
- UserInfo userInfo = loginByMobileWx(thirdSession, phone, key);
|
|
|
|
|
|
|
+ MallUserInfo userInfo = loginByMobileWx(thirdSession, phone, key);
|
|
|
return userInfo;
|
|
return userInfo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public UserInfo loginByMobileWx(ThirdSession thirdSession, String mobile, String key) {
|
|
|
|
|
|
|
+ public MallUserInfo loginByMobileWx(ThirdSession thirdSession, String mobile, String key) {
|
|
|
//先查询该手机号是不是商城用户
|
|
//先查询该手机号是不是商城用户
|
|
|
- UserInfo userInfo = baseMapper.selectOne(Wrappers.<UserInfo>lambdaQuery()
|
|
|
|
|
- .eq(UserInfo::getMobile, mobile));
|
|
|
|
|
|
|
+ MallUserInfo userInfo = baseMapper.selectOne(Wrappers.<MallUserInfo>lambdaQuery()
|
|
|
|
|
+ .eq(MallUserInfo::getMobile, mobile));
|
|
|
if (userInfo == null) {//不是商城用户,则新增
|
|
if (userInfo == null) {//不是商城用户,则新增
|
|
|
- userInfo = new UserInfo();
|
|
|
|
|
|
|
+ userInfo = new MallUserInfo();
|
|
|
userInfo.setCreateTime(DateTime.now());
|
|
userInfo.setCreateTime(DateTime.now());
|
|
|
userInfo.setUpdateTime(DateTime.now());
|
|
userInfo.setUpdateTime(DateTime.now());
|
|
|
}
|
|
}
|