| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.user;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | 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.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | | * 用户邀请图改变
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class InvitePictureChangeMessageListener implements MessageListener {
|
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | | LogHelper.mqInfo("consumer-InvitePictureChangeMessageListener", 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.inviteCodeActive.name())) {// 邀请码激活
|
| | | InviteCodeActiveMQMsg inviteCodeActiveMQMsg = new Gson().fromJson(new String(message.getBody()),
|
| | | InviteCodeActiveMQMsg.class);
|
| | | if (inviteCodeActiveMQMsg != null && inviteCodeActiveMQMsg.getUid() != null)
|
| | | spreadUserImgService.deleteImgUrl(inviteCodeActiveMQMsg.getUid());
|
| | |
|
| | | return Action.CommitMessage;
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userInfoUpdate.name())) {// 订单统计
|
| | |
|
| | | try {
|
| | | UserInfoUpdateMQMsg userInfoUpdateMQMsg = new Gson().fromJson(new String(message.getBody()),
|
| | | UserInfoUpdateMQMsg.class);
|
| | | if (userInfoUpdateMQMsg != null && (userInfoUpdateMQMsg.getType() == UserInfoUpdateTypeEnum.portrait
|
| | | || userInfoUpdateMQMsg.getType() == UserInfoUpdateTypeEnum.inviteCode)) {
|
| | | if (userInfoUpdateMQMsg.getUid() != null)
|
| | | spreadUserImgService.deleteImgUrl(userInfoUpdateMQMsg.getUid());
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e, "msgId:" + message.getMsgID(), "");
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.util.rocketmq.consumer.user; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.util.SystemInfoUtil; |
| | | 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.google.gson.Gson; |
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; |
| | | import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg; |
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg; |
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService; |
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName; |
| | | |
| | | /** |
| | | * 用户邀请图改变 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | @Component |
| | | public class InvitePictureChangeMessageListener implements MessageListener { |
| | | |
| | | @Resource |
| | | private SpreadUserImgService spreadUserImgService; |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Override |
| | | public Action consume(Message message, ConsumeContext context) { |
| | | LogHelper.mqInfo("consumer-InvitePictureChangeMessageListener", 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.inviteCodeActive.name())) {// 邀请码激活 |
| | | InviteCodeActiveMQMsg inviteCodeActiveMQMsg = new Gson().fromJson(new String(message.getBody()), |
| | | InviteCodeActiveMQMsg.class); |
| | | |
| | | //是否有三级分销权限 |
| | | SystemEnum system = userInfoService.getUserSystem(inviteCodeActiveMQMsg.getUid()); |
| | | if (!SystemInfoUtil.hasFunctions(system, SystemFunction.threeSale)) |
| | | return Action.CommitMessage; |
| | | |
| | | if (inviteCodeActiveMQMsg != null && inviteCodeActiveMQMsg.getUid() != null) |
| | | spreadUserImgService.deleteImgUrl(inviteCodeActiveMQMsg.getUid()); |
| | | |
| | | return Action.CommitMessage; |
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userInfoUpdate.name())) {// 用户信息更新 |
| | | |
| | | try { |
| | | UserInfoUpdateMQMsg userInfoUpdateMQMsg = new Gson().fromJson(new String(message.getBody()), |
| | | UserInfoUpdateMQMsg.class); |
| | | |
| | | //是否有三级分销权限 |
| | | SystemEnum system = userInfoService.getUserSystem(userInfoUpdateMQMsg.getUid()); |
| | | if (!SystemInfoUtil.hasFunctions(system, SystemFunction.threeSale)) |
| | | return Action.CommitMessage; |
| | | |
| | | if (userInfoUpdateMQMsg != null && (userInfoUpdateMQMsg.getType() == UserInfoUpdateTypeEnum.portrait |
| | | || userInfoUpdateMQMsg.getType() == UserInfoUpdateTypeEnum.inviteCode)) { |
| | | if (userInfoUpdateMQMsg.getUid() != null) |
| | | spreadUserImgService.deleteImgUrl(userInfoUpdateMQMsg.getUid()); |
| | | } |
| | | return Action.CommitMessage; |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e, "msgId:" + message.getMsgID(), ""); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return Action.CommitMessage; |
| | | } |
| | | } |