New file |
| | |
| | | package com.yeshi.fanli.dao.user.vip;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.stereotype.Repository;
|
| | |
|
| | | import com.yeshi.fanli.dao.MongodbBaseDao;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
|
| | |
|
| | | @Repository
|
| | | public class TearcherInfoDao extends MongodbBaseDao<TearcherInfo> {
|
| | |
|
| | | public List<TearcherInfo> listByType(int type, int start, int count) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("type").is(type));
|
| | | query.skip(start);
|
| | | query.limit(count);
|
| | | return findList(query);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dao.user.vip;
|
| | |
|
| | | import org.springframework.stereotype.Repository;
|
| | |
|
| | | import com.yeshi.fanli.dao.MongodbBaseDao;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserTearcherMap;
|
| | |
|
| | | @Repository
|
| | | public class UserTearcherMapDao extends MongodbBaseDao<UserTearcherMap> {
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.user.vip;
|
| | |
|
| | | import org.springframework.data.annotation.Id;
|
| | | import org.springframework.data.mongodb.core.mapping.Document;
|
| | | import org.springframework.data.mongodb.core.mapping.Field;
|
| | |
|
| | | /**
|
| | | * 导师信息
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Document(collection = "tearcherInfo")
|
| | | public class TearcherInfo {
|
| | |
|
| | | public final static int TYPE_OFFICIAL = 1;// 官方导师
|
| | |
|
| | | @Id
|
| | | private String id;
|
| | | @Field
|
| | | private Integer type;
|
| | | @Field
|
| | | private String wxID;// 微信号
|
| | |
|
| | | public TearcherInfo(String id) {
|
| | | super();
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public TearcherInfo() {
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public Integer getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(Integer type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public String getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(String id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getWxID() {
|
| | | return wxID;
|
| | | }
|
| | |
|
| | | public void setWxID(String wxID) {
|
| | | this.wxID = wxID;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.user.vip;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.springframework.data.annotation.Id;
|
| | | import org.springframework.data.mongodb.core.mapping.DBRef;
|
| | | import org.springframework.data.mongodb.core.mapping.Document;
|
| | | import org.springframework.data.mongodb.core.mapping.Field;
|
| | |
|
| | | /**
|
| | | * 用户与导师的对应关系
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Document(collection = "userTearcherMap")
|
| | | public class UserTearcherMap {
|
| | | @DBRef
|
| | | @Field("tearcher")
|
| | | private TearcherInfo tearcherInfo;
|
| | | @Id
|
| | | private Long uid;
|
| | | private Date createTime;
|
| | | private Date updateTime;
|
| | |
|
| | | public TearcherInfo getTearcherInfo() {
|
| | | return tearcherInfo;
|
| | | }
|
| | |
|
| | | public void setTearcherInfo(TearcherInfo tearcherInfo) {
|
| | | this.tearcherInfo = tearcherInfo;
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | hongBaoV2Service.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
|
| | | |
| | | if (hongBao.getType() == HongBaoV2.TYPE_ZIGOU || hongBao.getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | userOrderMsgNotificationService.orderInvalidToBusinessRunning(uid, orderId, sourceType, hongBao.getType());
|
| | | }
|
| | |
| | |
|
| | | userActivedRecordService.add(new UserActivedRecord(uid));
|
| | |
|
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | // if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | new InviteCodeActiveMQMsg(uid, new Date()));
|
| | | producer.send(message);
|
| | | }
|
| | | // }
|
| | |
|
| | | return inviteCode;
|
| | | }
|
| | |
| | |
|
| | | if (!Constant.IS_TEST) { // 发送邀请码更改成功的消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userInfoUpdate,
|
| | | new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip,
|
| | | new Date())));
|
| | | new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip,
|
| | | new Date()));
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | |
| | | } else {// 修改
|
| | | if (type == ModifyTypeEnum.portrait) {
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER,
|
| | | UserTopicTagEnum.userInfoUpdate, new Gson().toJson(new UserInfoUpdateMQMsg(uid,
|
| | | UserInfoUpdateTypeEnum.portrait, value, new Date())));
|
| | | UserTopicTagEnum.userInfoUpdate,new UserInfoUpdateMQMsg(uid,
|
| | | UserInfoUpdateTypeEnum.portrait, value, new Date()));
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime,
|
| | | String endTime, Integer validState) {
|
| | |
| | | return threeSaleMapper.getSuccessRelationshipNum(uid);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void bindInviteRelationship(Long workerId, Long bossId) throws ThreeSaleException {
|
| | |
| | | @Transactional
|
| | | private void inviteSuccess(Long workerId, Long bossId) {
|
| | | if (!Constant.IS_TEST) {
|
| | | UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(), UserInviteMQMsg.STATE_SUCCESS);
|
| | | UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(),
|
| | | UserInviteMQMsg.STATE_SUCCESS);
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg);
|
| | | producer.send(message);
|
| | | }
|
| | |
| | | return threeSaleMapper.getByWorkerId(workerId);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public ThreeSale selectByWorkerId(Long workerId) {
|
| | | return threeSaleMapper.selectSuccessByWorkerId(workerId);
|
| | |
| | | public long countSecondTeam(Long uid) {
|
| | | return threeSaleMapper.countSecondTeam(uid);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public ThreeSale selectLatestByWorkerIdAndState(Long workerId, int state) {
|
| | |
| | | return getMyBossDeepList(uid, 100);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Long getTopBoss(Long uid) {
|
| | | Long bossUid = null;
|
| | | UserInfo boss = getBoss(uid);
|
| | | while (boss != null) {
|
| | | bossUid = boss.getId();
|
| | | boss = getBoss(boss.getId());
|
| | | }
|
| | | return bossUid;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user.vip;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.vip.TearcherInfoDao;
|
| | | import com.yeshi.fanli.dao.user.vip.UserTearcherMapDao;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserTearcherMap;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TearcherService;
|
| | |
|
| | | @Service
|
| | | public class TearcherServiceImpl implements TearcherService {
|
| | |
|
| | | @Resource
|
| | | private TearcherInfoDao tearcherInfoDao;
|
| | |
|
| | | @Resource
|
| | | private UserTearcherMapDao userTearcherMapDao;
|
| | |
|
| | | @Override
|
| | | public TearcherInfo addTearcherInfo(TearcherInfo info) {
|
| | |
|
| | | if (info.getId() == null)
|
| | | info.setId(UUID.randomUUID().toString());
|
| | |
|
| | | TearcherInfo old = tearcherInfoDao.get(info.getId());
|
| | | if (old != null)
|
| | | return old;
|
| | | tearcherInfoDao.save(info);
|
| | | return info;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addUserTearcherMap(String tearcherId, Long uid) {
|
| | | UserTearcherMap map = userTearcherMapDao.get(uid);
|
| | | if (map != null)
|
| | | return;
|
| | | map = new UserTearcherMap();
|
| | | map.setCreateTime(new Date());
|
| | | map.setUid(uid);
|
| | | map.setTearcherInfo(new TearcherInfo(tearcherId));
|
| | | userTearcherMapDao.save(map);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TearcherInfo> listByType(int type, int page, int count) {
|
| | | return tearcherInfoDao.listByType(type, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | void effective(UserInfo worker);
|
| | |
|
| | |
|
| | | /**
|
| | | * 一级查询
|
| | | *
|
| | |
| | | public List<ThreeSale> listSuperiorQuery(long start, int count, Integer state, Long uid);
|
| | |
|
| | | public long countSuperiorQuery(Integer state, Long uid);
|
| | |
|
| | |
|
| | |
|
| | | /**
|
| | | * 前端查询一级队员
|
| | |
| | | */
|
| | | public int getSuccessRelationshipNum(Long uid);
|
| | |
|
| | |
|
| | | /**
|
| | | * 根据邀请者查询关系
|
| | | *
|
| | |
| | | * @return
|
| | | */
|
| | | public ThreeSale selectByWorkerId(Long workerId);
|
| | | |
| | |
|
| | | /**
|
| | | * 查询最近一条数据(根据下级用户ID与状态)
|
| | |
| | | */
|
| | | public List<ThreeSale> listSecondTeam(long start, int count, Long uid);
|
| | |
|
| | | |
| | | /**
|
| | | * 统计直接粉丝数量
|
| | | *
|
| | |
| | | */
|
| | | public void inviteSeparate(Long workerId, Long bossId);
|
| | |
|
| | | |
| | | /*
|
| | | * 该队员 在队中排第几
|
| | | */
|
| | |
| | | */
|
| | | public List<ThreeSale> getValidWorkerIdsByTime(Long bossId, long limitTime);
|
| | |
|
| | | |
| | | /**
|
| | | * 获取上几级邀请人
|
| | | * @Title: getMyBossDeepList
|
| | |
| | | */
|
| | | public List<ThreeSale> getMyBossDeepList(Long uid,int deep);
|
| | |
|
| | | |
| | | /**
|
| | | * 获取上级列表
|
| | | * @Title: getMyBossDeepList
|
| | |
| | | */
|
| | | public List<ThreeSale> getMyBossDeepList(Long uid);
|
| | |
|
| | | /**
|
| | | * 获取用户的顶级boss
|
| | | * @Title: getTopBoss
|
| | | * @Description: |
| | | * @param uid
|
| | | * @return |
| | | * Long 返回类型
|
| | | * @throws
|
| | | */
|
| | | public Long getTopBoss(Long uid);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user.vip;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
|
| | |
|
| | | /**
|
| | | * 导师服务
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface TearcherService {
|
| | |
|
| | | /**
|
| | | * 添加导师信息
|
| | | * @Title: addTearcherInfo
|
| | | * @Description: |
| | | * @param info
|
| | | * @return |
| | | * TearcherInfo 返回类型
|
| | | * @throws
|
| | | */
|
| | | public TearcherInfo addTearcherInfo(TearcherInfo info);
|
| | |
|
| | | /**
|
| | | * 为用户分配导师
|
| | | * @Title: addUserTearcherMap
|
| | | * @Description: |
| | | * @param tearcherId
|
| | | * @param uid |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void addUserTearcherMap(String tearcherId, Long uid);
|
| | |
|
| | | /**
|
| | | * 根据type查询
|
| | | * @Title: listByType
|
| | | * @Description: |
| | | * @param type
|
| | | * @param page
|
| | | * @param count
|
| | | * @return |
| | | * List<TearcherInfo> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public List<TearcherInfo> listByType(int type, int page,int count);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.user;
|
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | 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.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TearcherService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 用户超级会员
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class TearcherMessageListener implements MessageListener {
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private TearcherService tearcherService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | private static Set<Long> officialUids = null;
|
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | | LogHelper.mqInfo("consumer-TearcherMessageListener", message.getMsgID(), message.getTopic(), message.getTag(),
|
| | | new String(message.getBody()));
|
| | | String tag = message.getTag();
|
| | | if (tag == null)
|
| | | tag = "";
|
| | | String topic = message.getTopic();
|
| | |
|
| | | if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(topic)) {
|
| | |
|
| | | // 邀请激活
|
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteCodeActive.name())) {
|
| | |
|
| | | JSONObject json = JSONObject.fromObject(new String(message.getBody()));
|
| | |
|
| | | InviteCodeActiveMQMsg inviteCodeActiveMQMsg = new Gson().fromJson(json.toString(),
|
| | | InviteCodeActiveMQMsg.class);
|
| | | if (inviteCodeActiveMQMsg != null) {
|
| | | // 顶级为测试用户的全部分配官方导师微信
|
| | |
|
| | | // 获取顶级boss
|
| | | Long bossId = threeSaleSerivce.getTopBoss(inviteCodeActiveMQMsg.getUid());
|
| | | if (bossId != null) {
|
| | |
|
| | | if (officialUids == null) {
|
| | | officialUids = new HashSet<>();
|
| | | List<UserInfo> userList = userInfoService.listByType(1, 1, 10000);
|
| | |
|
| | | for (UserInfo user : userList)
|
| | | officialUids.add(user.getId());
|
| | | }
|
| | |
|
| | | if (officialUids.contains(bossId)) {
|
| | | List<TearcherInfo> tearcherList = tearcherService.listByType(TearcherInfo.TYPE_OFFICIAL, 1,
|
| | | 1);
|
| | | if (tearcherList != null && tearcherList.size() > 0) {
|
| | | tearcherService.addUserTearcherMap(tearcherList.get(0).getId(),
|
| | | inviteCodeActiveMQMsg.getUid());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | |
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | | |
| | | |
| | | <!-- 导师分配 -->
|
| | | <bean id="tearcherMessageListener"
|
| | | class="com.yeshi.fanli.util.rocketmq.consumer.user.TearcherMessageListener"></bean>
|
| | | <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean -->
|
| | | <bean id="tearcherConsumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | | <property name="properties"> <!--消费者配置信息 -->
|
| | | <props>
|
| | | <prop key="AccessKey">${rocketmq.AccessKey}</prop>
|
| | | <prop key="SecretKey">${rocketmq.SecretKey}</prop>
|
| | | <prop key="GROUP_ID">GID_TEARCHER</prop>
|
| | | <prop key="NAMESRV_ADDR">${rocketmq.NAMESRV_ADDR}</prop>
|
| | | <prop key="ConsumeThreadNums">50</prop>
|
| | | </props>
|
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <!--用户活跃 -->
|
| | | <entry value-ref="tearcherMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_USER" />
|
| | | <property name="expression" value="inviteCodeActive" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | | |
| | | |
| | | |
| | | |
| | |
|
| | |
|
| | |
|