|
@@ -1,7 +1,10 @@
|
|
|
package com.qs.mp.framework.web.service;
|
|
|
|
|
|
+import com.qs.mp.channel.domain.Channel;
|
|
|
+import com.qs.mp.channel.service.IChannelService;
|
|
|
import com.qs.mp.common.constant.Constants;
|
|
|
import com.qs.mp.common.core.redis.RedisCache;
|
|
|
+import com.qs.mp.common.enums.UserIdentityEnum;
|
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
|
import com.qs.mp.common.exception.user.CaptchaException;
|
|
|
import com.qs.mp.common.exception.user.CaptchaExpireException;
|
|
@@ -18,6 +21,7 @@ import com.qs.mp.sms.domain.SmsCode;
|
|
|
import com.qs.mp.system.domain.SysUser;
|
|
|
import com.qs.mp.system.service.ISysConfigService;
|
|
|
import com.qs.mp.system.service.ISysUserService;
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -53,6 +57,9 @@ public class SysLoginService
|
|
|
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IChannelService channelService;
|
|
|
|
|
|
/**
|
|
|
* 登录验证
|
|
@@ -91,6 +98,9 @@ public class SysLoginService
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
recordLoginInfo(loginUser.getUser());
|
|
|
+
|
|
|
+ // loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
|
+ fillChannelInfo(loginUser);
|
|
|
/*
|
|
|
// 根据用户身份,设置对应的属性
|
|
|
loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
@@ -143,6 +153,9 @@ public class SysLoginService
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
recordLoginInfo(loginUser.getUser());
|
|
|
+
|
|
|
+ // loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
|
+ fillChannelInfo(loginUser);
|
|
|
/*
|
|
|
// 根据用户身份,设置对应的属性
|
|
|
loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
@@ -185,6 +198,8 @@ public class SysLoginService
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(smsCode.getMobile(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
recordLoginInfo(loginUser.getUser());
|
|
|
+
|
|
|
+ fillChannelInfo(loginUser);
|
|
|
/*
|
|
|
// 根据用户身份,设置对应的属性
|
|
|
loginUser.setIdentity(UserIdentityEnum.valueOf(smsCode.getIdentity()));
|
|
@@ -263,5 +278,24 @@ public class SysLoginService
|
|
|
user.setLoginDate(DateUtils.getNowDate());
|
|
|
userService.updateUserProfile(user);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 填充注入Channel 渠道/经销商 信息
|
|
|
+ * @param loginUser
|
|
|
+ */
|
|
|
+ public void fillChannelInfo(LoginUser loginUser){
|
|
|
+ Channel channel = channelService.getChannelByUserId(loginUser.getUserId());
|
|
|
+ if (null != channel && null != channel.getId()){
|
|
|
+ loginUser.setChannelId(channel.getId());
|
|
|
+ loginUser.setChannelNo(channel.getChannelNo());
|
|
|
+ if(null != channel.getLevel()) {
|
|
|
+ loginUser.setIdentity(channel.getLevel().intValue() == 0?UserIdentityEnum.SALESITE:UserIdentityEnum.CHANNEL);
|
|
|
+ }
|
|
|
+ } else if (loginUser.getUserId() != 1L){
|
|
|
+ throw new ServiceException("登录账号不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|