v1.1 首次登录发小秘书 提醒设置密码

This commit is contained in:
2022-10-17 11:23:43 +08:00
parent e6d7f715b0
commit 97c416cd7e
6 changed files with 95 additions and 141 deletions

View File

@@ -5,7 +5,6 @@ import com.accompany.common.constant.Constant;
import com.accompany.common.device.DeviceInfo;
import com.accompany.common.redis.RedisKey;
import com.accompany.common.status.BusiStatus;
import com.accompany.common.utils.AppVersionUtil;
import com.accompany.common.utils.CommonUtil;
import com.accompany.core.dto.ShuMeiDto;
import com.accompany.core.dto.YiDunDto;
@@ -79,10 +78,8 @@ public class MyUserDetailsServiceImpl implements MyUserDetailsService {
@Autowired
private PhoneBlackService phoneBlackService;
@Autowired
@Qualifier( value = "passwordLoginVersionMsgJmsTemplate")
private JmsTemplate passwordLoginVersionMsgJmsTemplate;
private final static String PASSWORD_LOGIN_VERSION = "1.0.0";
@Qualifier( value = "firstLoginVersionMsgJmsTemplate")
private JmsTemplate firstLoginVersionMsgJmsTemplate;
/**
* 不允许登录的用户账号类型
@@ -131,7 +128,6 @@ public class MyUserDetailsServiceImpl implements MyUserDetailsService {
if(account == null) {
throw new CustomOAuth2Exception(CustomOAuth2Exception.USER_NOT_EXISTED,
OAuthStatus.USER_NOT_EXISTED.getReasonPhrase());
}
return new AccountDetails(account);
}
@@ -175,8 +171,10 @@ public class MyUserDetailsServiceImpl implements MyUserDetailsService {
accountManageService.checkAccountCancel(uid);
//AccountLoginRecord latestLoginRecord = loginRecordService.getLatestLoginRecord(uid);
//sendPasswordVersionMsgToUser(uid, latestLoginRecord == null ? null : latestLoginRecord.getAppVersion(), deviceInfo.getAppVersion());
AccountLoginRecord latestLoginRecord = loginRecordService.getLatestLoginRecord(uid);
if (latestLoginRecord == null){
sendFirstLoginEvent(uid, deviceInfo.getAppVersion());
}
//更新account信息
String newToken = accountService.refreshAndGetNetEaseToken(account);
@@ -196,11 +194,11 @@ public class MyUserDetailsServiceImpl implements MyUserDetailsService {
account.setLastLoginTime(date);
accountService.updateById(account);
//更新用户正在使用的app字段
this.userAppService.updateCurrentApp(uid, deviceInfo.getApp());
userAppService.updateCurrentApp(uid, deviceInfo.getApp());
//将用户信息登记
AccountLoginRecord accountLoginRecord = this.buildAccountLoginRecord(ip, account, loginType.getValue(), deviceInfo, openId);
this.loginRecordService.addAccountLoginRecordAsync(accountLoginRecord);
AccountLoginRecord accountLoginRecord = buildAccountLoginRecord(ip, account, loginType.getValue(), deviceInfo, openId);
loginRecordService.addAccountLoginRecordAsync(accountLoginRecord);
jedisService.hset(RedisKey.acc_latest_login.getKey(), uid.toString(), gson.toJson(accountLoginRecord));
}
@@ -269,8 +267,12 @@ public class MyUserDetailsServiceImpl implements MyUserDetailsService {
//YiDunDto yiDunDto = accountManageService.buildYiDunDto(oAuthConfig, ipAddress, yiDunToken, null,null, deviceInfo);
//ShuMeiDto shuMeiDto = accountManageService.buildShuMeiDto(oAuthConfig, deviceInfo, phone, ipAddress, phone, shuMeiDeviceId,"register");
account = accountManageService.register(ipAddress, deviceInfo, Constant.AccountType.phone_account, null, null, phone);
//AccountLoginRecord latestLoginRecord = loginRecordService.getLatestLoginRecord(account.getUid());
//sendPasswordVersionMsgToUser(account.getUid(), latestLoginRecord == null ? null : latestLoginRecord.getAppVersion(), deviceInfo.getAppVersion());
AccountLoginRecord latestLoginRecord = loginRecordService.getLatestLoginRecord(account.getUid());
if (latestLoginRecord == null){
sendFirstLoginEvent(account.getUid(), deviceInfo.getAppVersion());
}
return new AccountDetails(account);
}
}
@@ -307,15 +309,13 @@ public class MyUserDetailsServiceImpl implements MyUserDetailsService {
}
@Async
public void sendPasswordVersionMsgToUser(Long uid, String lastLoginVersion, String currLoginVersion) {
if (lastLoginVersion == null || AppVersionUtil.compareVersion(lastLoginVersion, PASSWORD_LOGIN_VERSION) < 0) {
UserLoginMessageVo userLogin = new UserLoginMessageVo();
userLogin.setUid(uid);
userLogin.setLastLoginVersion(lastLoginVersion);
userLogin.setAppVersion(currLoginVersion);
log.info("登录时发送用户队列 userLogin {}", JSON.toJSONString(userLogin));
passwordLoginVersionMsgJmsTemplate.convertAndSend("password_login_version_msg_queue", userLogin);
}
public void sendFirstLoginEvent(Long uid, String currLoginVersion) {
UserLoginMessageVo userLogin = new UserLoginMessageVo();
userLogin.setUid(uid);
userLogin.setLastLoginVersion(null);
userLogin.setAppVersion(currLoginVersion);
log.info("首次登录时发送用户队列 userLogin {}", JSON.toJSONString(userLogin));
firstLoginVersionMsgJmsTemplate.convertAndSend("first_login_version_msg_queue", userLogin);
}
}

View File

@@ -49,7 +49,7 @@ public class JmsConfig {
// 活动用户登录队列
public final static String ACTIVITY_USER_LOGIN_QUEUE = "activity_user_login_queue";
// 密码登入新版本小秘书消息队列
public final static String PASSWORD_LOGIN_VERSION_MSG_QUEUE = "password_login_version_msg_queue";
public final static String FIRST_LOGIN_VERSION_MSG_QUEUE = "first_login_version_msg_queue";
// 用户首登消息队列
public final static String USER_FIRST_LOGIN_MSG_QUEUE = "user_first_login_msg_queue";
public final static String AD_PLATFORM_USER_LOGIN_MSG_QUEUE = "ad_platform_user_login_msg_queue";
@@ -138,15 +138,15 @@ public class JmsConfig {
/**
* 密码登入版本小秘书通知队列
* 首次登录版本小秘书通知队列
*/
@Bean
public Queue passwordLoginVersionMsgQueue() { return new ActiveMQQueue(PASSWORD_LOGIN_VERSION_MSG_QUEUE); }
public Queue firstLoginVersionMsgQueue() { return new ActiveMQQueue(FIRST_LOGIN_VERSION_MSG_QUEUE); }
@Bean("passwordLoginVersionMsgJmsTemplate")
public JmsTemplate passwordLoginVersionMsgJmsTemplate(@Qualifier("myConnectionFactory")ConnectionFactory activeMQConnectionFactory) {
@Bean("firstLoginVersionMsgJmsTemplate")
public JmsTemplate firstLoginVersionMsgJmsTemplate(@Qualifier("myConnectionFactory")ConnectionFactory activeMQConnectionFactory) {
JmsTemplate template = new JmsTemplate(activeMQConnectionFactory);
template.setDefaultDestination(passwordLoginVersionMsgQueue());
template.setDefaultDestination(firstLoginVersionMsgQueue());
return template;
}