| | |
| | | package com.yeshi.fanli.aspect;
|
| | |
|
| | | import java.lang.reflect.Method;
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserActiveMQMsg;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.annotation.UserActive;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | | import redis.clients.jedis.params.SetParams;
|
| | |
|
| | | /**
|
| | | * 活跃用户处理
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | | |
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | | |
| | |
|
| | | private ExpressionParser parser = new SpelExpressionParser();
|
| | |
|
| | |
| | | String key = "useractive-" + uidStr;
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | if (jedis.setnx(key, "1") > 0) {
|
| | | jedis.expire(key, 60*5);// 5分钟内不处理
|
| | | if (!StringUtil.isNullOrEmpty(jedis.set(key, "1", new SetParams().nx().ex(Constant.IS_TEST?10:300)))) {
|
| | | try {
|
| | | // TODO 用户活跃处理
|
| | | userInfoModifyRecordService.syncBeforeInfo(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);
|
| | | // message.setStartDeliverTime(System.currentTimeMillis()+1000*10L);//10s后发送活跃消息
|
| | | // producer.send(message);
|
| | | // }
|
| | | } catch (Exception e) {
|
| | | |
| | | }
|
| | | }
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | | });
|