|
|
|
|
@ -9,19 +9,18 @@ import com.flossom.common.core.domain.entity.WxUserMember;
|
|
|
|
|
import com.flossom.common.core.exception.ServiceException;
|
|
|
|
|
import com.flossom.common.core.mapper.WxUserMemberMapper;
|
|
|
|
|
import com.flossom.common.core.utils.DateUtils;
|
|
|
|
|
import com.flossom.common.core.utils.StringUtils;
|
|
|
|
|
import com.flossom.common.redis.service.RedisService;
|
|
|
|
|
import com.flossom.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.flossom.miniProgram.domain.vo.*;
|
|
|
|
|
import com.flossom.miniProgram.service.IWxUserMemberService;
|
|
|
|
|
import com.flossom.miniProgram.utils.MiniProgramUtils;
|
|
|
|
|
import com.flossom.system.api.RemoteAuthService;
|
|
|
|
|
import com.flossom.system.api.model.LoginUser;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@ -114,19 +113,52 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateUser(UserMemberUpdateVo userMemberUpdateVo) {
|
|
|
|
|
public LoginUserVo updateUser(UserMemberUpdateVo userMemberUpdateVo) {
|
|
|
|
|
// 完善用户信息, 判断是否标记完善信息
|
|
|
|
|
WxUserMember wxUserMember = SecurityUtils.getLoginUser().getWxUserMember();
|
|
|
|
|
if (wxUserMember.getIsCompleteInformation() == null ||
|
|
|
|
|
wxUserMember.getIsCompleteInformation() == 0) {
|
|
|
|
|
// 修改完善
|
|
|
|
|
WxUserMember wxUserMember = wxUserMemberMapper.selectWxUserMemberByOpenId(SecurityUtils.getLoginUser().getWxUserMember().getOpenid());
|
|
|
|
|
if (wxUserMember.getIsCompleteInformation() == null || wxUserMember.getIsCompleteInformation() == 0) {
|
|
|
|
|
// 修改完善状态
|
|
|
|
|
wxUserMember.setIsCompleteInformation(1);
|
|
|
|
|
// TODO: 首次完善,增加加分
|
|
|
|
|
// TODO: 首次完善,增加加分 (未完成)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
BeanUtils.copyProperties(userMemberUpdateVo, wxUserMember);
|
|
|
|
|
wxUserMember.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
wxUserMemberMapper.updateWxUserMember(wxUserMember);
|
|
|
|
|
|
|
|
|
|
// 刷新用户信息
|
|
|
|
|
return refreshWxUserInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重构用户缓存信息
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public LoginUserVo refreshWxUserInfo() {
|
|
|
|
|
// 1、获取用户最新信息
|
|
|
|
|
String openid = SecurityUtils.getLoginUser().getWxUserMember().getOpenid();
|
|
|
|
|
WxUserMember wxUserMember = wxUserMemberMapper.selectWxUserMemberByOpenId(openid);
|
|
|
|
|
if (wxUserMember == null) {
|
|
|
|
|
logger.error("刷新用户信息失败");
|
|
|
|
|
throw new ServiceException("刷新用户信息失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2、刷新redis缓存信息
|
|
|
|
|
String userKey = SecurityUtils.getUserKey();
|
|
|
|
|
LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + userKey);
|
|
|
|
|
loginUser.setWxUserMember(wxUserMember);
|
|
|
|
|
loginUser.setWxUserid(wxUserMember.getId());
|
|
|
|
|
loginUser.setUsername(wxUserMember.getNickname());
|
|
|
|
|
loginUser.setExpireTime(loginUser.getLoginTime() + CacheConstants.EXPIRATION * 60 * 1000);
|
|
|
|
|
redisService.setCacheObject(userKey, loginUser, CacheConstants.EXPIRATION, TimeUnit.MINUTES);
|
|
|
|
|
|
|
|
|
|
// 3、构建前端缓存对象
|
|
|
|
|
LoginUserVo loginUserVo = new LoginUserVo();
|
|
|
|
|
BeanUtils.copyProperties(wxUserMember, loginUserVo);
|
|
|
|
|
loginUserVo.setToken(loginUser.getToken());
|
|
|
|
|
return loginUserVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|