| | |
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(jedis.set(key, "1", new SetParams().nx().ex(Constant.IS_TEST?10:300)))) {
|
| | | try {
|
| | | Long uid = Long.parseLong(uidStr);
|
| | | // Long uid = Long.parseLong(uidStr);
|
| | | // if (!Constant.IS_TEST) { // 活跃通知
|
| | | UserActiveMQMsg msg = new UserActiveMQMsg(uid, new Date());
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userActve, msg);
|
| | | producer.send(message);
|
| | | // UserActiveMQMsg msg = new UserActiveMQMsg(uid, new Date());
|
| | | // Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userActve, msg);
|
| | | // message.setStartDeliverTime(System.currentTimeMillis()+1000*10L);//10s后发送活跃消息
|
| | | // producer.send(message);
|
| | | // }
|
| | | } catch (Exception e) {
|
| | |
|
| | |
| | | userActiveLog.setDeviceType("wxmp");
|
| | | userActiveLog.setDevice(acceptData.getDevice());
|
| | | userActiveLogService.addUserActiveLog(userActiveLog);
|
| | | |
| | |
|
| | | // 处理用户信息
|
| | | outUserInfoHandle(userInfo);
|
| | |
| | | package com.yeshi.fanli.dto.mq.user;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.user.body.BeComeValidUserMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.InterTokenMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.TaoBaoBindSuccessMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.ThreeSaleSeparateMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserActiveMQMsg;
|
| | |
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserMoneyChangeMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserRedPackGiftMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserRegisterMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserSystemCouponUseMQMsg;
|
| | |
| | | forbiddenUser(UserForbiddenMQMsg.class), // 封禁用户
|
| | | userInfoUpdate(UserInfoUpdateMQMsg.class), // 用户信息修改
|
| | | userLevelChanged(UserLevelChangedMQMsg.class), // 用户等级变化
|
| | | userMoneyAdd(UserMoneyChangeMQMsg.class), // 用户资金增加
|
| | | taobaoBindSuccess(TaoBaoBindSuccessMQMsg.class),
|
| | | becomeValidUser(BeComeValidUserMQMsg.class), // 成为有效用户
|
| | | threeSaleSeparate(ThreeSaleSeparateMQMsg.class);// 邀请关系脱离
|
| | |
|
| | | private final Class<?> clazz;
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 成为有效用户
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class BeComeValidUserMQMsg extends BaseMQMsgBody {
|
| | | private Long uid;
|
| | | private Date createTime;
|
| | |
|
| | | public BeComeValidUserMQMsg(Long uid, Date createTime) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.setCreateTime(createTime);
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 淘宝绑定成功
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class TaoBaoBindSuccessMQMsg extends BaseMQMsgBody {
|
| | | private Long uid;// 用户ID
|
| | | private Long fromUid;// 淘宝绑定的原用户ID
|
| | | private Long taoBaoUid;// 淘宝ID
|
| | | private Date createTime;// 发生时间
|
| | |
|
| | | public TaoBaoBindSuccessMQMsg(Long uid, Long fromUid, Long taoBaoUid, Date createTime) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.fromUid = fromUid;
|
| | | this.taoBaoUid = taoBaoUid;
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public Long getFromUid() {
|
| | | return fromUid;
|
| | | }
|
| | |
|
| | | public void setFromUid(Long fromUid) {
|
| | | this.fromUid = fromUid;
|
| | | }
|
| | |
|
| | | public Long getTaoBaoUid() {
|
| | | return taoBaoUid;
|
| | | }
|
| | |
|
| | | public void setTaoBaoUid(Long taoBaoUid) {
|
| | | this.taoBaoUid = taoBaoUid;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 邀请信息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class UserMoneyChangeMQMsg extends BaseMQMsgBody {
|
| | | private Long uid;
|
| | | private BigDecimal changeMoney;// 改变的金额
|
| | | private Date createTime;// 发生时间
|
| | |
|
| | | public UserMoneyChangeMQMsg(Long uid, BigDecimal changeMoney, Date createTime) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.changeMoney = changeMoney;
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public BigDecimal getChangeMoney() {
|
| | | return changeMoney;
|
| | | }
|
| | |
|
| | | public void setChangeMoney(BigDecimal changeMoney) {
|
| | | this.changeMoney = changeMoney;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserActiveLogMapper;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserActiveMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoRegister;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoRegisterService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | | public class UserActiveLogServiceImpl implements UserActiveLogService {
|
| | |
| | | @Resource
|
| | | private UserInfoRegisterService userInfoRegisterService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Override
|
| | | public void addUserActiveLog(UserActiveLog userActiveLog) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | // 间隔5分钟以上再记录
|
| | | if (latestLog == null || System.currentTimeMillis() - latestLog.getCreateTime().getTime() > 1000 * 60 * 5L) {
|
| | | userActiveLog.setCreateTime(new Date());
|
| | |
| | | userActiveLogMapper.insertSelective(userActiveLog);
|
| | | // 更新最新活跃时间
|
| | | userInfoExtraService.updateActiveTime(userActiveLog.getUid() , new Date());
|
| | | addMQMsg(userActiveLog.getUid());
|
| | | } else if (latestLog != null) {
|
| | | // 如果设备 ,版本,渠道有变化则需要更改
|
| | | String oldIdentify = latestLog.getDevice() + "#" + latestLog.getVersionCode() + "#"
|
| | |
| | | userActiveLogMapper.insertSelective(userActiveLog);
|
| | | // 更新最新活跃时间
|
| | | userInfoExtraService.updateActiveTime(userActiveLog.getUid() , new Date());
|
| | | addMQMsg(userActiveLog.getUid());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | //添加活跃消息
|
| | | private void addMQMsg(Long uid) {
|
| | | UserActiveMQMsg msg = new UserActiveMQMsg(uid, new Date());
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userActve, msg);
|
| | | message.setStartDeliverTime(System.currentTimeMillis() + 1000 * 5L);// 5s后发送活跃消息
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | public UserActiveLog getFirstActiveInfo(Long uid) {
|
| | | return userActiveLogMapper.selectFirstActiveInfo(uid);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public long count90DaysLaterActiveNum(String preDay){
|
| | |
| | | update.setLevel(level);
|
| | | update.setUpdateTime(new Date());
|
| | | teamUserLevelStatisticMapper.updateByPrimaryKeySelective(update);
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserLevelUpgradedNotifyService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | |
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | |
|
| | | @Service
|
| | | public class UserVIPPreInfoServiceImpl implements UserVIPPreInfoService {
|
| | |
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private TeamUserLevelStatisticService teamUserLevelStatisticService;
|
| | |
|
| | | @Override
|
| | | public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
|
| | | if (info == null || info.getUid() == null || info.getProcess() == null)
|
| | |
| | | if (info.getCreateTime() == null)
|
| | | info.setCreateTime(new Date());
|
| | | userVIPPreInfoMapper.insertSelective(info);
|
| | | // 设置统计数据
|
| | | teamUserLevelStatisticService.setUserLevel(info.getUid(), UserLevelUtil.getByLevel(info.getProcess()));
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | Message message = null; // 做循环传来的key
|
| | | Builder builder = new Message.Builder().restrictedPackageName(PackageName).title(title).payload(payload)
|
| | | .notifyId((int) (Math.random() * Integer.MAX_VALUE))
|
| | | .description(description).passThrough(0) // 设置消息是否通过透传方式至App,
|
| | | // 1表示透传,0表示通知栏消息(默认)
|
| | | .notifyType(1); // 设置通知类型, type类型(1-默认提示音, 2-使用默认震动提示,
|
| | |
| | |
|
| | | Message message = null; // 做循环传来的key
|
| | | Builder builder = new Message.Builder().restrictedPackageName(PackageName).title(title).payload(payload)
|
| | | .notifyId((int) (Math.random() * Integer.MAX_VALUE))
|
| | | .description(description).passThrough(0) // 设置消息是否通过透传方式至App,
|
| | | // 1表示透传,0表示通知栏消息(默认)
|
| | | .notifyType(1); // 设置通知类型, type类型(1-默认提示音, 2-使用默认震动提示,
|
| | |
| | | Message message = null; // 做循环传来的key
|
| | | Builder builder = new Message.Builder().restrictedPackageName(PackageName).title(title).description(content)
|
| | | .passThrough(0) // 设置消息是否通过透传方式至App, 1表示透传,0表示通知栏消息(默认)
|
| | | .notifyType(1); // 设置通知类型, type类型(1-默认提示音, 2-使用默认震动提示,
|
| | | .notifyId((int) (Math.random() * Integer.MAX_VALUE)).notifyType(1); // 设置通知类型,
|
| | | // type类型(1-默认提示音,
|
| | | // 2-使用默认震动提示,
|
| | | // 3-使用默认led灯光提示)
|
| | | // 将extra放入MessageInfo对象中, 循环遍历extra中的key 和 value
|
| | | if (map != null) {
|
| | |
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.userActve.name())) {
|
| | | UserActiveMQMsg msg = new Gson().fromJson(new String(message.getBody()), UserActiveMQMsg.class);
|
| | | Long uid = msg.getUid();
|
| | |
|
| | | // 老用户同步绑定信息
|
| | | userInfoModifyRecordService.syncBeforeInfo(uid);
|
| | |
|
| | | userInfoModifyRecordService.syncBeforeInfo(uid);
|
| | | // 低版本全部升级普通会员
|
| | |
|
| | | List<ThreeSale> threeSaleList = threeSaleSerivce.getMyBossDeepList(uid, 2);
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.user;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Action;
|
| | | import com.aliyun.openservices.ons.api.ConsumeContext;
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.MessageListener;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | | * 用户粉丝消息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class UserTeamMessageListener implements MessageListener {
|
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | |
|
| | | LogHelper.mqInfo("consumer-UserTeamMessageListener", message.getMsgID(), message.getTopic(), message.getTag(),
|
| | | new String(message.getBody()));
|
| | | String tag = message.getTag();
|
| | | if (tag == null)
|
| | | tag = "";
|
| | |
|
| | | // 订阅粉丝增加/粉丝成为有效用户 消息,淘宝授权,微信号绑定,最近登录,用户资金增加
|
| | |
|
| | | if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.userActve.name())) {// 用户活跃
|
| | | // TODO 更改用户活跃时间
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userInfoUpdate.name())) {// 用户信息更新
|
| | |
|
| | | // TODO 更改微信号绑定
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.taobaoBindSuccess.name())) {// 淘宝绑定成功
|
| | |
|
| | | // TODO 更改淘宝绑定状态与原用户淘宝绑定状态
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {// 邀请成功
|
| | |
|
| | | // TODO 更新粉丝数量
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userMoneyAdd.name())) {// 资金到账
|
| | |
|
| | | // TODO 更新近60天到账
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.becomeValidUser.name())) {// 成为有效用户
|
| | |
|
| | | // TODO 有效用户标识
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.producer;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.bean.ProducerBean;
|
| | |
|
| | | @Component
|
| | | public class UserRocketMsgProducer extends ProducerBean {
|
| | |
|
| | | }
|