From 652de4214ebe5efcf3abd30e68c83cb38beb2a23 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期一, 22 六月 2020 16:44:09 +0800
Subject: [PATCH] 云发单-发圈调整
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java | 74 ++++++++++++++++++++++++++++++-------
1 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
index b6bd027..b07b699 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
@@ -34,6 +34,7 @@
import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
+import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
import com.yeshi.fanli.service.inter.user.vip.UserLevelUpgradedNotifyService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
@@ -43,6 +44,7 @@
import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
+import com.yeshi.fanli.util.user.UserLevelUtil;
@Service
public class UserVIPPreInfoServiceImpl implements UserVIPPreInfoService {
@@ -89,17 +91,51 @@
@Resource(name = "producer")
private Producer producer;
+ @Resource
+ private TeamUserLevelStatisticService teamUserLevelStatisticService;
+
+ @Transactional
@Override
public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
- if (info == null || info.getUid() == null || info.getProcess() == null)
+ if (info == null || info.getUid() == null || info.getProcess() == null || info.getSourceType() == null)
throw new UserVIPPreInfoException(1, "淇℃伅涓嶅畬鏁�");
+ for (Long fuid : Constant.NO_UPGRADE_UIDS) {// 绂佹涓嶈兘鍗囩骇鐨勭敤鎴峰崌绾�
+ if (info.getUid().longValue() == fuid)
+ throw new UserVIPPreInfoException(100, "绂佹鍗囩骇");
+ }
UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(info.getUid(), info.getProcess());
if (oldInfo != null)
throw new UserVIPPreInfoException(2, "杩涘害宸插瓨鍦�");
if (info.getCreateTime() == null)
info.setCreateTime(new Date());
+
+ UserVIPPreInfo old = getLatestProcessInfo(info.getUid());
+
userVIPPreInfoMapper.insertSelective(info);
+ // 璁剧疆缁熻鏁版嵁
+ teamUserLevelStatisticService.setUserLevel(info.getUid(), UserLevelUtil.getByLevel(info.getProcess()));
+
+ // 鍙戦�佺瓑绾у彉鍖栨秷鎭�
+ if (!Constant.IS_TEST) {
+ UserLevelEnum oldLevel = null;
+ if (old == null)
+ oldLevel = UserLevelEnum.daRen;
+ else {
+ oldLevel = UserLevelUtil.getByLevel(old.getProcess());
+ }
+
+ if (oldLevel == UserLevelEnum.normalVIP)
+ oldLevel = UserLevelEnum.daRen;
+
+ UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(info.getUid(), oldLevel,
+ UserLevelUtil.getByLevel(info.getProcess()), new Date());
+ Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
+ //寤舵椂10s鍙戦��
+ message.setStartDeliverTime(System.currentTimeMillis()+1000*10L);
+ producer.send(message);
+ }
+
}
@Override
@@ -177,14 +213,13 @@
}
}
}
-
+
@Override
@RequestSerializableByKeyService(key = "#uid")
@Transactional(rollbackFor = Exception.class)
public void upgradeVipByTeamNum(Long uid) {
vipTeamVerify(uid);
}
-
@Override
@RequestSerializableByKeyService(key = "#tid")
@@ -197,8 +232,6 @@
vipTeamVerify(boss.getId());
}
-
-
/**
* 楠岃瘉鐢ㄦ埛鏄惁婊¤冻鍗囩骇闃熷憳鏉′欢
* @param uid
@@ -220,11 +253,17 @@
long limitFirst7 = 0;
String first7 = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
+ if (Constant.IS_TEST)
+ first7 = "30";
+
if (!StringUtil.isNullOrEmpty(first7)) {
limitFirst7 = Long.parseLong(first7);
}
+
long limitSecond7 = 0;
String second7 = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
+ if (Constant.IS_TEST)
+ second7 = "30";
if (!StringUtil.isNullOrEmpty(second7)) {
limitSecond7 = Long.parseLong(second7);
}
@@ -238,9 +277,7 @@
}
}
}
-
-
-
+
/**
* 浜岄樁娈�
*
@@ -265,6 +302,11 @@
info.setProcess(UserVIPPreInfo.PROCESS_2);
info.setCreateTime(upgradeTime);
info.setUpdateTime(upgradeTime);
+ if (teamPass)
+ info.setSourceType(UserVIPPreInfo.SOURCE_TYPE_TEAM);
+ else
+ info.setSourceType(UserVIPPreInfo.SOURCE_TYPE_ORDER);
+
addUserVIPPreInfo(info);
// 鍗囩骇寮规鎻愮ず
@@ -298,12 +340,6 @@
LogHelper.error(e);
}
- if (!Constant.IS_TEST) {
- UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, UserLevelEnum.daRen, UserLevelEnum.highVIP,
- new Date());
- Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
- producer.send(message);
- }
}
@Override
@@ -316,4 +352,14 @@
userVIPPreInfoMapper.deleteByPrimaryKey(id);
}
+ @Override
+ public List<UserVIPPreInfo> listByProcess(int process, Date minTime, Date maxTime, int page, int pageSize) {
+ return userVIPPreInfoMapper.listByProcess(process, minTime, maxTime, (page - 1) * pageSize, pageSize);
+ }
+
+ @Override
+ public long countByProcess(int process, Date minTime, Date maxTime) {
+ return userVIPPreInfoMapper.countByProcess(process, minTime, maxTime);
+ }
+
}
--
Gitblit v1.8.0