v1.1 首次登录发小秘书 提醒设置密码
This commit is contained in:
@@ -95,6 +95,7 @@ public class ShardingJdbcConfig {
|
||||
private Map<String, DataSource> createDataSourceMap() {
|
||||
Map<String, DataSource> result = new HashMap<>(4);
|
||||
result.put("ds", dataSource);
|
||||
result.put("ds-1", dataSource);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -68,7 +68,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";
|
||||
|
||||
@@ -121,7 +121,7 @@ public class JmsConfig {
|
||||
public Queue activityUserLoginQueue() { return new ActiveMQQueue(ACTIVITY_USER_LOGIN_QUEUE); }
|
||||
|
||||
@Bean
|
||||
public Queue passwordLoginVersionMsgQueue() { return new ActiveMQQueue(PASSWORD_LOGIN_VERSION_MSG_QUEUE); }
|
||||
public Queue firstLoginVersionMsgQueue() { return new ActiveMQQueue(FIRST_LOGIN_VERSION_MSG_QUEUE); }
|
||||
|
||||
@Bean
|
||||
public Queue userFirstLoginMsgQueue() { return new ActiveMQQueue(USER_FIRST_LOGIN_MSG_QUEUE); }
|
||||
@@ -242,10 +242,10 @@ public class JmsConfig {
|
||||
return template;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -373,7 +373,6 @@ public class JmsConfig {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@Bean("newyearJmsContainer")
|
||||
public DefaultJmsListenerContainerFactory newyearJmsContainer() {
|
||||
DefaultJmsListenerContainerFactory factory
|
||||
@@ -387,11 +386,6 @@ public class JmsConfig {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Bean("cleanMusicContainer")
|
||||
public DefaultJmsListenerContainerFactory cleanMusicContainer() {
|
||||
DefaultJmsListenerContainerFactory factory
|
||||
@@ -469,8 +463,8 @@ public class JmsConfig {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Bean("passwordLoginVersionMsgContainer")
|
||||
public DefaultJmsListenerContainerFactory passwordLoginVersionMsgContainer() {
|
||||
@Bean("firstLoginVersionMsgContainer")
|
||||
public DefaultJmsListenerContainerFactory firstLoginVersionMsgContainer() {
|
||||
DefaultJmsListenerContainerFactory factory
|
||||
= new DefaultJmsListenerContainerFactory();
|
||||
factory.setConnectionFactory(connectionFactory());
|
||||
|
@@ -0,0 +1,59 @@
|
||||
package com.accompany.business.mq;
|
||||
|
||||
|
||||
import com.accompany.business.param.neteasepush.NeteaseSendMsgParam;
|
||||
import com.accompany.business.service.SendSysMsgService;
|
||||
import com.accompany.common.config.SystemConfig;
|
||||
import com.accompany.common.constant.Attach;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.core.vo.UserLoginMessageVo;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.annotation.JmsListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FirstLoginVersionUpdateMsgUserLoginListener {
|
||||
|
||||
@Autowired
|
||||
private SendSysMsgService sendSysMsgService;
|
||||
|
||||
@JmsListener(destination = "first_login_version_msg_queue",containerFactory = "firstLoginVersionMsgContainer")
|
||||
public void onMessage(UserLoginMessageVo userLogin) {
|
||||
log.info("首次登录版本小秘书登录消息, msg: {} ", JSON.toJSONString(userLogin));
|
||||
try {
|
||||
sendFirstLoginVersionUpdateMsgToUser(userLogin.getUid(), userLogin.getAppVersion());
|
||||
} catch (Exception e) {
|
||||
log.error("首次登录版本小秘书登录消息失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送小秘书通知给用户
|
||||
*/
|
||||
private void sendFirstLoginVersionUpdateMsgToUser(Long uid, String currLoginVersion) {
|
||||
Attach attach = new Attach();
|
||||
attach.setFirst(Constant.DefineProtocol.CUSTOM_MESS_HEAD_SECRETARY);
|
||||
attach.setSecond(Constant.DefineProtocol.CUSTOM_MESS_SUB_SECRETARY_INTRACTION);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("title", "歡迎來到Peko邂逅你的專屬聲音!為了方便您的使用,可前往【我的】-【設置】去設置登錄密碼喔>>");
|
||||
jsonObject.put("msg", "歡迎來到Peko邂逅你的專屬聲音!為了方便您的使用,可前往【我的】-【設置】去設置登錄密碼喔>>");
|
||||
jsonObject.put("routerType", Constant.SecretarySkipType.SET_PASSWORD);
|
||||
attach.setData(jsonObject);
|
||||
|
||||
NeteaseSendMsgParam neteaseSendMsgParam = new NeteaseSendMsgParam();
|
||||
neteaseSendMsgParam.setType(Constant.DefineProtocol.CUSTOM_MESS_DEFINE);
|
||||
neteaseSendMsgParam.setFrom(SystemConfig.secretaryUid);
|
||||
|
||||
neteaseSendMsgParam.setOpe(0);
|
||||
neteaseSendMsgParam.setTo(uid.toString());
|
||||
neteaseSendMsgParam.setAttach(attach);
|
||||
sendSysMsgService.sendMsg(neteaseSendMsgParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,100 +0,0 @@
|
||||
package com.accompany.business.mq;
|
||||
|
||||
|
||||
import com.accompany.business.param.neteasepush.NeteaseSendMsgParam;
|
||||
import com.accompany.business.service.SendSysMsgService;
|
||||
import com.accompany.common.config.SystemConfig;
|
||||
import com.accompany.common.constant.Attach;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.AppVersionUtil;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.vo.UserLoginMessageVo;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.annotation.JmsListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PasswordLoginVersionUpdateMsgUserLoginListener {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private SendSysMsgService sendSysMsgService;
|
||||
|
||||
private final static String PASSWORD_LOGIN_VERSION = "1.0.0";
|
||||
|
||||
@JmsListener(destination = "password_login_version_msg_queue",containerFactory = "passwordLoginVersionMsgContainer")
|
||||
public void onMessage(UserLoginMessageVo userLogin) {
|
||||
log.info("密码登录版本小秘书登录消息, msg: {} ", JSON.toJSONString(userLogin));
|
||||
try {
|
||||
sendPasswordLoginVersionUpdateMsgToUser(userLogin.getUid(), userLogin.getLastLoginVersion(), userLogin.getAppVersion());
|
||||
} catch (Exception e) {
|
||||
log.error("密码登录版本小秘书登录消息失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送小秘书通知给用户
|
||||
*/
|
||||
private void sendPasswordLoginVersionUpdateMsgToUser(Long uid, String lastAppVersion, String currLoginVersion) {
|
||||
// 判断用户是否已经发送了消息
|
||||
String flag = jedisService.hget(RedisKey.password_login_version_update_msg.getKey(), uid.toString());
|
||||
log.info("密码登录版本小秘书登录消息, uid {} flag {}", uid, flag);
|
||||
if (StringUtils.isNotBlank(flag)) {
|
||||
return;
|
||||
}
|
||||
boolean userNeedSendMsgFlag = getUserNeedSendMsgFlag(uid, lastAppVersion, currLoginVersion);
|
||||
log.info("密码登录版本小秘书登录消息, uid {} userNeedSendMsgFlag {}", uid, userNeedSendMsgFlag);
|
||||
if (!userNeedSendMsgFlag) {
|
||||
return;
|
||||
}
|
||||
// 发送小秘书
|
||||
sendSysMsg(uid);
|
||||
// 将标识存入缓存
|
||||
jedisService.hset(RedisKey.password_login_version_update_msg.getKey(), uid.toString(), Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
private boolean getUserNeedSendMsgFlag(Long uid, String lastAppVersion, String currLoginVersion) {
|
||||
log.info("密码登录版本小秘书登录消息, uid {} lastAppVersion {} currLoginVersion {}", uid, lastAppVersion, currLoginVersion);
|
||||
if (null == currLoginVersion || AppVersionUtil.compareVersion(currLoginVersion, PASSWORD_LOGIN_VERSION) < 0) {
|
||||
return false;
|
||||
} else {
|
||||
if (null == lastAppVersion) {
|
||||
return true;
|
||||
}
|
||||
// 仅当最后一次登入的版本小与特定版本时需要发送
|
||||
if (AppVersionUtil.compareVersion(lastAppVersion, PASSWORD_LOGIN_VERSION) < 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendSysMsg(Long uid) {
|
||||
Attach attach = new Attach();
|
||||
attach.setFirst(Constant.DefineProtocol.CUSTOM_MESS_HEAD_SECRETARY);
|
||||
attach.setSecond(Constant.DefineProtocol.CUSTOM_MESS_SUB_SECRETARY_INTRACTION);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("title", "支持密碼登錄啦~現在可以立即前往設置密碼啦 立即前往>>");
|
||||
jsonObject.put("msg", "支持密碼登錄啦~現在可以立即前往設置密碼啦 立即前往>>");
|
||||
jsonObject.put("routerType", Constant.SecretarySkipType.SET_PASSWORD);
|
||||
attach.setData(jsonObject);
|
||||
|
||||
NeteaseSendMsgParam neteaseSendMsgParam = new NeteaseSendMsgParam();
|
||||
neteaseSendMsgParam.setType(Constant.DefineProtocol.CUSTOM_MESS_DEFINE);
|
||||
neteaseSendMsgParam.setFrom(SystemConfig.secretaryUid);
|
||||
|
||||
neteaseSendMsgParam.setOpe(0);
|
||||
neteaseSendMsgParam.setTo(uid.toString());
|
||||
neteaseSendMsgParam.setAttach(attach);
|
||||
sendSysMsgService.sendMsg(neteaseSendMsgParam);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user