| | |
| | | import com.yeshi.fanli.service.inter.user.UserInviteRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.notify.UserActivedRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | |
| | | @Resource
|
| | | @Lazy
|
| | | private UserActivedRecordService userActivedRecordService;
|
| | | |
| | | @Resource
|
| | | private UserAccountMsgNotificationService userAccountMsgNotificationService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
| | | throw new UserInfoExtraException(1, "已经激活, 无需再次激活");
|
| | |
|
| | | inviteCode = inviteCode.toUpperCase();
|
| | | |
| | | // 邀请码对应用户信息
|
| | | UserInfo inviter = userInfoService.getUserInfoByInviteCode(inviteCode);
|
| | | if (inviter == null)
|
| | | UserInfo boss = userInfoService.getUserInfoByInviteCode(inviteCode);
|
| | | if (boss == null || boss.getState() != UserInfo.STATE_NORMAL)
|
| | | throw new UserInfoExtraException(1, "上级邀请码不存在");
|
| | |
|
| | | // 绑定关系
|
| | | try {
|
| | | threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter);
|
| | | } catch (ThreeSaleException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | throw new UserInfoExtraException(1, "激活失败");
|
| | | }
|
| | |
|
| | | // 生成邀请码
|
| | | String mycode = createInviteCode(uid);
|
| | | if (StringUtil.isNullOrEmpty(mycode))
|
| | | throw new UserInfoExtraException(1, "激活码生成失败");
|
| | |
|
| | | UserInfoExtra userInfoExtra = new UserInfoExtra();
|
| | | userInfoExtra.setUserInfo(invitee);
|
| | | userInfoExtra.setInviteCode(mycode);
|
| | | userInfoExtra.setUpdateTime(new Date());
|
| | | if (extra != null) {
|
| | | userInfoExtra.setId(extra.getId());
|
| | | userInfoExtraMapper.updateByPrimaryKeySelective(userInfoExtra);
|
| | | } else {
|
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | | userActivedRecordService.add(new UserActivedRecord(uid));
|
| | |
|
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | return mycode;
|
| | | // 生成邀请关系
|
| | | return inviteCodeActive(uid, boss.getId());
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | Long inviterId = userInviteRecordService.getNewestInviterId(wxUnionId);
|
| | | if (inviterId == null)
|
| | | throw new UserInfoExtraException(1, "没有对应的邀请关系");
|
| | |
|
| | | // 绑定关系
|
| | | try {
|
| | | threeSaleSerivce.bindRelationshipByWX(invitee, inviterId);
|
| | | } catch (ThreeSaleException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | throw new UserInfoExtraException(1, "关系绑定时失败");
|
| | | }
|
| | |
|
| | | // 生成邀请码
|
| | | String inviteCode = createInviteCode(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode))
|
| | | throw new UserInfoExtraException(1, "激活码生成失败");
|
| | |
|
| | | UserInfoExtra userInfoExtra = new UserInfoExtra();
|
| | | userInfoExtra.setUserInfo(invitee);
|
| | | userInfoExtra.setInviteCode(inviteCode);
|
| | | userInfoExtra.setUpdateTime(new Date());
|
| | | if (extra != null) {
|
| | | userInfoExtra.setId(extra.getId());
|
| | | userInfoExtraMapper.updateByPrimaryKeySelective(userInfoExtra);
|
| | | } else {
|
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | | userActivedRecordService.add(new UserActivedRecord(uid));
|
| | |
|
| | |
|
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | producer.send(message);
|
| | | UserInfo boss = userInfoService.selectByPKey(inviterId);
|
| | | if (boss == null || boss.getState() != UserInfo.STATE_NORMAL) {
|
| | | throw new UserInfoExtraException(1, "没有对应的邀请关系");
|
| | | }
|
| | |
|
| | | // 邀请码激活
|
| | | inviteCodeActive(uid, boss.getId());
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | UserInfo invitee = userInfoService.selectByPKey(uid);
|
| | | if (invitee == null) {
|
| | | throw new UserInfoExtraException(1, "用户不存在");
|
| | | }
|
| | |
|
| | | // 用户额外信息
|
| | | UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (extra != null) {
|
| | | String inviteCodeHas = extra.getInviteCode();
|
| | | if (inviteCodeHas != null && inviteCodeHas.trim().length() > 0) {
|
| | | throw new UserInfoExtraException(1, "已经激活, 无需再次激活");
|
| | | }
|
| | | }
|
| | |
|
| | | String wxUnionId = weiXinUser.getUnionid();
|
| | |
| | | if (inviterId == null) {
|
| | | throw new UserInfoExtraException(1, "没有对应的邀请关系");
|
| | | }
|
| | |
|
| | | |
| | | UserInfo boss = userInfoService.selectByPKey(inviterId);
|
| | | if (boss == null || boss.getState() != UserInfo.STATE_NORMAL) {
|
| | | throw new UserInfoExtraException(1, "没有对应的邀请关系");
|
| | | }
|
| | | |
| | | // 邀请码激活
|
| | | inviteCodeActive(uid, boss.getId());
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 邀请关系生成激活码
|
| | | * @param uid
|
| | | * @param bossId
|
| | | * @return
|
| | | * @throws UserInfoExtraException
|
| | | */
|
| | | private String inviteCodeActive(Long uid, Long bossId) throws UserInfoExtraException{
|
| | | UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (extra != null && !StringUtil.isNullOrEmpty(extra.getInviteCode())) {
|
| | | throw new UserInfoExtraException(1, "已经激活, 无需再次激活");
|
| | | }
|
| | | |
| | | // 绑定关系
|
| | | try {
|
| | | threeSaleSerivce.bindRelationshipByWX(invitee, inviterId);
|
| | | threeSaleSerivce.bindInviteRelationship(uid, bossId);
|
| | | } catch (ThreeSaleException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | |
|
| | | // 生成邀请码
|
| | | String inviteCode = createInviteCode(uid);
|
| | | ;
|
| | | if (StringUtil.isNullOrEmpty(inviteCode))
|
| | | throw new UserInfoExtraException(1, "激活码生成失败");
|
| | |
|
| | | UserInfoExtra userInfoExtra = new UserInfoExtra();
|
| | | userInfoExtra.setUserInfo(invitee);
|
| | | userInfoExtra.setUserInfo(new UserInfo(uid));
|
| | | userInfoExtra.setInviteCode(inviteCode);
|
| | | userInfoExtra.setUpdateTime(new Date());
|
| | | if (extra != null) {
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void updateActiveTime(Long uid, Date date) {
|
| | |
| | | UserInfo inviter = userInfoService.getUserInfoByInviteCode(inviteCode);
|
| | | if (inviter == null)
|
| | | throw new UserInfoExtraException(1, "上级邀请码不存在");
|
| | | |
| | | if (inviter.getState() != UserInfo.STATE_NORMAL) {
|
| | | throw new UserInfoExtraException(1, "上级邀请码不存在");
|
| | | }
|
| | |
|
| | | return inviter;
|
| | | }
|
| | |
| | | if (inviter == null) {
|
| | | throw new UserInfoExtraException(1, "对应的邀请关系不存在");
|
| | | }
|
| | | |
| | | if (inviter.getState() != UserInfo.STATE_NORMAL) {
|
| | | throw new UserInfoExtraException(1, "对应的邀请关系不存在");
|
| | | }
|
| | | |
| | | return inviter;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | 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);
|
| | | }
|
| | | |
| | | // 消息
|
| | | userAccountMsgNotificationService.createChangeInviteCode(uid, extra.getInviteCode(), inviteCodeVip);
|
| | | }
|
| | |
|
| | | @Override
|