| | |
| | | threeSaleMapper.deleteExpireRecord(inviter.getId(), inviteeUser.getId());
|
| | | }
|
| | |
|
| | | // 创建通知
|
| | | userInviteMsgNotificationService.inviteScan(inviter.getId(), threeSale);
|
| | |
|
| | | } else {// 是已经存在的用户
|
| | | if (worker.getId().longValue() == inviter.getId())
|
| | | throw new ThreeSaleException(4, "不能绑定自己");
|
| | |
| | | threeSaleMapper.deleteExpireRecord(inviter.getId(), worker.getId());
|
| | | }
|
| | |
|
| | | userInviteMsgNotificationService.inviteScan(inviter.getId(), threeSale);
|
| | | // threeSaleSerivce.bind(invitee, inviter);
|
| | |
|
| | | } else {
|
| | | // 还存在有效的邀请,则不做处理
|
| | | }
|
| | |
| | | ts.setSucceedTime(System.currentTimeMillis());
|
| | | ts.setWorker(worker);
|
| | | threeSaleMapper.insertSelective(ts);
|
| | | inviteSuccess(inviter.getId(), worker.getId(), ts);
|
| | | } else {
|
| | | if (!list.get(0).getState() && list.get(0).getExpire() == ThreeSale.EXPIRE_NORMAL
|
| | | && list.get(0).getBoss().getId() == inviter.getId().longValue()) {// 未生效的上级和现在上级一样就生效
|
| | |
| | | update.setState(true);
|
| | | update.setSucceedTime(System.currentTimeMillis());
|
| | | threeSaleMapper.updateByPrimaryKeySelective(update);
|
| | | inviteSuccess(list.get(0).getBoss().getId(), list.get(0).getWorker().getId(), list.get(0));
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // if (inviter != null)
|
| | | // reComputeUserRank(inviter.getId());
|
| | | // 添加到队列
|
| | | inviteSuccess(oldSale.getBoss().getId(), oldSale.getWorker().getId(), oldSale);
|
| | | inviteSuccess(oldSale.getBoss().getId(), worker);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleMapper.insertSelective(threeSale);
|
| | |
|
| | | inviteSuccess(inviter.getId(), invitee.getId(), threeSale);
|
| | | inviteSuccess(inviter.getId(), invitee);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleMapper.insertSelective(threeSale);
|
| | |
|
| | | UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId());
|
| | | threeSale.setBoss(boss);
|
| | | threeSale.setWorker(invitee);
|
| | |
|
| | | // 邀请成功:消息、相关处理
|
| | | inviteSuccess(boss.getId(), invitee.getId(), threeSale);
|
| | | inviteSuccess(inviterId, invitee);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请成功
|
| | | */
|
| | | @Transactional
|
| | | private void inviteSuccess(Long bossId, Long workerId, ThreeSale threeSale) {
|
| | | // 邀请消息
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
|
| | | if (activeLog != null && VersionUtil.greaterThan_2_0_5(
|
| | | "appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android", activeLog.getVersionCode())) { // 2.1版本以上
|
| | | userInviteMsgNotificationService.inviteSuccess2_1(bossId, threeSale);
|
| | | } else { // 最初消息
|
| | | userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale);
|
| | | private void inviteSuccess(Long bossId, UserInfo invitee) {
|
| | | if (!Constant.IS_TEST) {
|
| | | UserInviteMQMsg msg = new UserInviteMQMsg(bossId, invitee.getId(), null, new Date(), UserInviteMQMsg.STATE_SUCCESS);
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg);
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 邀请金币
|
| | | integralGetService.addInviteLevelOne(bossId, workerId);
|
| | | try {
|
| | | // 邀请金币
|
| | | integralGetService.addInviteLevelOne(bossId, invitee.getId());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | try {
|
| | | // 直接粉丝邀请成功
|
| | | userInviteMsgNotificationService.directInviteSuccess(bossId, invitee.getNickName(),
|
| | | invitee.getPortrait(), new Date());
|
| | | |
| | | // 间接粉丝邀请成功
|
| | | ThreeSale myBoss = threeSaleMapper.getMyBoss(bossId);
|
| | | if (myBoss != null) {
|
| | | UserInfo boss = userInfoService.selectByPKey(bossId);
|
| | | userInviteMsgNotificationService.indirectInviteSuccess(bossId, boss.getNickName(),
|
| | | invitee.getNickName(), invitee.getPortrait(), new Date());
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(), UserInviteMQMsg.STATE_SUCCESS);
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg);
|
| | | if (!Constant.IS_TEST)
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | import com.yeshi.fanli.dto.msg.MsgInviteContentDTO;
|
| | | import com.yeshi.fanli.dto.push.PushContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgExtra;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.config.push.PushMsgFactory;
|
| | | import com.yeshi.fanli.exception.msg.MsgInviteDetailException;
|
| | | import com.yeshi.fanli.exception.push.PushException;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgExtraService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.MsgInviteDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
|
| | |
| | |
|
| | | @Resource
|
| | | private MsgInviteDetailService msgInviteDetailService;
|
| | | |
| | | @Resource
|
| | | private MsgExtraService msgExtraService;
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
| | | @Override
|
| | | public void inviteScan(Long uid, ThreeSale sale) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.createInviteScanSuccess(sale, uid, null);
|
| | | public void directInviteSuccess(Long uid, String nickName, String portrait, Date time) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.directInviteSuccess(uid, nickName, portrait, time);
|
| | | try {
|
| | | msgInviteDetailService.addMsgInviteDetail(detail);
|
| | | // 消息内容
|
| | | msgExtraService.addMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_INVITE);
|
| | | } catch (MsgInviteDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void inviteSuccess(Long uid, ThreeSale sale) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.createInviteSuccess(sale, uid, null);
|
| | | public void indirectInviteSuccess(Long uid, String inviteName, String nickName, String portrait, Date time) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.indirectInviteSuccess(uid, inviteName, nickName, portrait, time);
|
| | | try {
|
| | | msgInviteDetailService.addMsgInviteDetail(detail);
|
| | | } catch (MsgInviteDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | PushContentDTO dto = PushMsgFactory.createInviteTeamSuccess(new Date(), sale.getWorker().getNickName());
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void inviteSuccess2_1(Long uid, ThreeSale sale) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.createInviteSuccess2_1(uid, sale);
|
| | | msgInviteDetailService.insertSelective(detail);
|
| | | PushContentDTO dto = PushMsgFactory.createInviteTeamSuccess(new Date(), sale.getWorker().getNickName());
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void inviteFail(Long uid, ThreeSale sale) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.createInviteFail(sale, uid, null);
|
| | | try {
|
| | | msgInviteDetailService.addMsgInviteDetail(detail);
|
| | | // 消息内容
|
| | | msgExtraService.addMsgExtra(detail.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_INVITE);
|
| | | } catch (MsgInviteDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void receiveGift(Long uid, String beizu, MsgInviteContentDTO content) {
|
| | |
| | | package com.yeshi.fanli.service.inter.user.invite;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.msg.MsgInviteContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | |
|
| | |
| | | public interface UserInviteMsgNotificationService {
|
| | |
|
| | | /**
|
| | | * 二维码扫描
|
| | | * |
| | | * @param uid
|
| | | * @param sale
|
| | | */
|
| | | public void inviteScan(Long uid, ThreeSale sale);
|
| | |
|
| | | /**
|
| | | * 邀请成功
|
| | | * |
| | | * @param uid
|
| | | * @param sale
|
| | | */
|
| | | public void inviteSuccess(Long uid, ThreeSale sale);
|
| | |
|
| | | /**
|
| | | * 邀请失败
|
| | | * |
| | | * @param uid
|
| | | * @param sale
|
| | | */
|
| | | public void inviteFail(Long uid, ThreeSale sale);
|
| | |
|
| | | /**
|
| | | * 领取券、红包激活邀请
|
| | | * @param uid
|
| | | * @param beizu
|
| | |
| | | */
|
| | | public void receiveGift(Long uid, String beizu, MsgInviteContentDTO content);
|
| | |
|
| | |
|
| | | /**
|
| | | * 2.0.2 版本新邀请消息
|
| | | * 直接粉丝邀请成功
|
| | | * @param uid
|
| | | * @param sale
|
| | | * @param nickName
|
| | | * @param portrait
|
| | | * @param time
|
| | | */
|
| | | public void inviteSuccess2_1(Long uid, ThreeSale sale);
|
| | | public void directInviteSuccess(Long uid, String nickName, String portrait, Date time);
|
| | |
|
| | | /**
|
| | | * 间接粉丝
|
| | | * @param uid
|
| | | * @param inviteName
|
| | | * @param nickName
|
| | | * @param portrait
|
| | | * @param time
|
| | | */
|
| | | public void indirectInviteSuccess(Long uid, String inviteName, String nickName, String portrait, Date time);
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | | import com.yeshi.fanli.vo.msg.CommonMsgItemVO;
|
| | | import com.yeshi.fanli.vo.msg.CommonMsgItemVOFactory;
|
| | |
| | | public class MsgInviteDetailFactory {
|
| | |
|
| | | /**
|
| | | * 邀请成功
|
| | | * |
| | | * @param threeSale
|
| | | * 直接粉丝邀请提醒
|
| | | * @param uid
|
| | | * @param nickName
|
| | | * @param portrait
|
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public static MsgInviteDetail createInviteSuccess(ThreeSale threeSale, Long uid, String beiZhu) {
|
| | | if (threeSale == null || uid == null)
|
| | | public static MsgInviteDetail directInviteSuccess(Long uid, String nickName, String portrait, Date time) {
|
| | | if (nickName == null || uid == null || portrait == null || time == null)
|
| | | return null;
|
| | |
|
| | | |
| | | |
| | | |
| | | List<CommonMsgItemVO> listMsg = new ArrayList<>();
|
| | | List<ClientTextStyleVO> contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO("恭喜你!团队增加直接粉丝:", ClientTextStyleVO.COLOR_CONTENT));
|
| | | contentList.add(new ClientTextStyleVO("",ClientTextStyleVO.COLOR_CONTENT, portrait));
|
| | | contentList.add(new ClientTextStyleVO("、" + nickName, ClientTextStyleVO.COLOR_CONTENT));
|
| | | listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("直接粉丝", ClientTextStyleVO.COLOR_TITLE),contentList));
|
| | | listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("加入时间", ClientTextStyleVO.COLOR_TITLE),
|
| | | new ClientTextStyleVO(TimeUtil.formatDate(time), ClientTextStyleVO.COLOR_CONTENT)));
|
| | | listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("备注", ClientTextStyleVO.COLOR_TITLE),
|
| | | new ClientTextStyleVO("无", ClientTextStyleVO.COLOR_CONTENT)));
|
| | |
|
| | | MsgInviteDetail detail = new MsgInviteDetail();
|
| | | if (StringUtil.isNullOrEmpty(beiZhu))
|
| | | detail.setBeiZhu("无");
|
| | | else
|
| | | detail.setBeiZhu(beiZhu);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setDesc("恭喜你,成功邀请一个粉丝");
|
| | | detail.setInviteUser(threeSale);
|
| | | detail.setMsgType(MsgTypeInviteTypeEnum.invite);
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | |
|
| | | return detail;
|
| | | }
|
| | | /**
|
| | | * 邀请成功
|
| | | * |
| | | * @param threeSale
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public static MsgInviteDetail createInviteSuccess2_1(Long uid, ThreeSale threeSale) {
|
| | | if (threeSale == null || uid == null)
|
| | | return null;
|
| | | MsgInviteDetail detail = new MsgInviteDetail();
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | | detail.setInviteUser(threeSale);
|
| | | detail.setMsgType(MsgTypeInviteTypeEnum.inviteSucceed);
|
| | | detail.setDesc("粉丝(好友)熟练使用App可获得红包");
|
| | | detail.setBeiZhu("满足获得红包条件后系统将自动下发到“我的-红包”中");
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | | detail.setExtraInfo(new Gson().toJson(listMsg));
|
| | | return detail;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 扫描邀请二维码成功,但是未登录
|
| | | * |
| | | * @param threeSale
|
| | | * 间接邀请
|
| | | * @param uid
|
| | | * @param inviteName
|
| | | * @param nickName
|
| | | * @param portrait
|
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public static MsgInviteDetail createInviteScanSuccess(ThreeSale threeSale, Long uid, String beiZhu) {
|
| | | if (threeSale == null || uid == null)
|
| | | public static MsgInviteDetail indirectInviteSuccess(Long uid, String inviteName, String nickName, String portrait, Date time) {
|
| | | if (nickName == null || uid == null || portrait == null || time == null)
|
| | | return null;
|
| | |
|
| | | List<CommonMsgItemVO> listMsg = new ArrayList<>();
|
| | | List<ClientTextStyleVO> contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO("恭喜你!团队增加直接粉丝:", ClientTextStyleVO.COLOR_CONTENT));
|
| | | contentList.add(new ClientTextStyleVO("",ClientTextStyleVO.COLOR_CONTENT, portrait));
|
| | | contentList.add(new ClientTextStyleVO("、" + nickName, ClientTextStyleVO.COLOR_CONTENT));
|
| | | listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("间接粉丝", ClientTextStyleVO.COLOR_TITLE),contentList));
|
| | | |
| | | List<ClientTextStyleVO> contentList2 = new ArrayList<>();
|
| | | contentList2.add(new ClientTextStyleVO("由直接粉丝", ClientTextStyleVO.COLOR_CONTENT));
|
| | | contentList2.add(new ClientTextStyleVO(inviteName,ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));
|
| | | contentList2.add(new ClientTextStyleVO("邀请", ClientTextStyleVO.COLOR_CONTENT));
|
| | | listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("邀请人", ClientTextStyleVO.COLOR_TITLE),contentList2));
|
| | | listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("加入时间", ClientTextStyleVO.COLOR_TITLE),
|
| | | new ClientTextStyleVO(TimeUtil.formatDate(time), ClientTextStyleVO.COLOR_CONTENT)));
|
| | | listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("备注", ClientTextStyleVO.COLOR_TITLE),
|
| | | new ClientTextStyleVO("无", ClientTextStyleVO.COLOR_CONTENT)));
|
| | | |
| | | MsgInviteDetail detail = new MsgInviteDetail();
|
| | | if (StringUtil.isNullOrEmpty(beiZhu))
|
| | | detail.setBeiZhu("无");
|
| | | else
|
| | | detail.setBeiZhu(beiZhu);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setDesc("恭喜你,有新粉丝加入你的队列,若对方60天内未激活将会与你脱离邀请关系");
|
| | | detail.setInviteUser(threeSale);
|
| | | detail.setMsgType(MsgTypeInviteTypeEnum.invite);
|
| | | detail.setMsgType(MsgTypeInviteTypeEnum.inviteSucceed);
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | | detail.setExtraInfo(new Gson().toJson(listMsg));
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 邀请失败
|
| | | * |
| | | * @param threeSale
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public static MsgInviteDetail createInviteFail(ThreeSale threeSale, Long uid, String beiZhu) {
|
| | | if (threeSale == null || uid == null)
|
| | | return null;
|
| | |
|
| | | MsgInviteDetail detail = new MsgInviteDetail();
|
| | | if (StringUtil.isNullOrEmpty(beiZhu))
|
| | | detail.setBeiZhu("无");
|
| | | else
|
| | | detail.setBeiZhu(beiZhu);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setDesc("抱歉,该粉丝因60天内未激活,已脱离了你的队列,可以试着重新邀请");
|
| | | detail.setInviteUser(threeSale);
|
| | | detail.setMsgType(MsgTypeInviteTypeEnum.invite);
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | | return detail;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 领取信息激活邀请关系
|