From b22a1695fd1398692747ffe2976b978fd37a2f59 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 30 四月 2020 10:19:38 +0800
Subject: [PATCH] 队员
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/TeamUserLevelStatisticServiceImpl.java | 70 ++++++++++++++++++++++++++--------
1 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/TeamUserLevelStatisticServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/TeamUserLevelStatisticServiceImpl.java
index 5e6be64..58d0e01 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/TeamUserLevelStatisticServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/TeamUserLevelStatisticServiceImpl.java
@@ -1,7 +1,10 @@
package com.yeshi.fanli.service.impl.user.vip;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.annotation.Resource;
@@ -23,10 +26,9 @@
@Resource
private TeamUserLevelStatisticMapper teamUserLevelStatisticMapper;
-
+
@Resource
private UserInviteValidRecordService userInviteValidRecordService;
-
@Override
public TeamUserLevelStatistic selectByUid(Long uid) {
@@ -34,27 +36,50 @@
}
@Override
+ public List<TeamUserLevelStatistic> listByUids(List<Long> uids) {
+
+ List<TeamUserLevelStatistic> resultList = new ArrayList<>();
+
+ List<TeamUserLevelStatistic> list = teamUserLevelStatisticMapper.listByUids(uids);
+ // 鏀惧叆Map涓�
+ Map<Long, TeamUserLevelStatistic> map = new HashMap<>();
+ if (list != null)
+ for (TeamUserLevelStatistic s : list) {
+ map.put(s.getId(), s);
+ }
+
+ for (Long uid : uids) {
+ if (map.get(uid) == null) {
+ initData(uid);
+ TeamUserLevelStatistic statistic = selectByUid(uid);
+ resultList.add(statistic);
+ } else {
+ resultList.add(map.get(uid));
+ }
+ }
+
+ return resultList;
+ }
+
+ @Override
public void initData(Long uid) {
int pageSize = 1000;
-
+
// 鐩存帴绮変笣缁熻
int daRenFirstCount = 0;
- int normalFirstCount = 0;
int highFirstCount = 0;
int superFirstCount = 0;
int tearcherFirstCount = 0;
- for (int i = 0; i < 100; i ++) {
+ for (int i = 0; i < 100; i++) {
List<UserInviteValidRecord> list = userInviteValidRecordService.listFirstTeam(i * pageSize, pageSize, uid);
if (list == null || list.size() == 0) {
break;
}
-
+
for (UserInviteValidRecord ts : list) {
UserLevelEnum level = userLevelManager.getUserLevel(ts.getWorkerId());
if (level == UserLevelEnum.daRen) {
daRenFirstCount++;
- } else if (level == UserLevelEnum.normalVIP) {
- normalFirstCount++;
} else if (level == UserLevelEnum.highVIP) {
highFirstCount++;
} else if (level == UserLevelEnum.superVIP) {
@@ -64,26 +89,22 @@
}
}
}
-
-
+
// 闂存帴绮変笣缁熻
int daRenSecondCount = 0;
- int normalSecondCount = 0;
int highSecondCount = 0;
int superSecondCount = 0;
int tearcherSecondCount = 0;
- for (int i = 0; i < 100; i ++) {
+ for (int i = 0; i < 100; i++) {
List<UserInviteValidRecord> list = userInviteValidRecordService.listSecondTeam(i * pageSize, pageSize, uid);
if (list == null || list.size() == 0) {
break;
}
-
+
for (UserInviteValidRecord ts : list) {
UserLevelEnum level = userLevelManager.getUserLevel(ts.getWorkerId());
if (level == UserLevelEnum.daRen) {
daRenSecondCount++;
- } else if (level == UserLevelEnum.normalVIP) {
- normalSecondCount++;
} else if (level == UserLevelEnum.highVIP) {
highSecondCount++;
} else if (level == UserLevelEnum.superVIP) {
@@ -98,8 +119,6 @@
TeamUserLevelStatistic statistic = new TeamUserLevelStatistic();
statistic.setDaRenFirstCount(daRenFirstCount);
statistic.setDaRenSecondCount(daRenSecondCount);
- statistic.setNormalFirstCount(normalFirstCount);
- statistic.setNormalSecondCount(normalSecondCount);
statistic.setHighFirstCount(highFirstCount);
statistic.setHighSecondCount(highSecondCount);
statistic.setSuperFirstCount(superFirstCount);
@@ -112,6 +131,23 @@
}
@Override
+ public void setUserLevel(Long uid, UserLevelEnum level) {
+
+ TeamUserLevelStatistic old = selectByUid(uid);
+ if (old == null) {
+ initData(uid);
+ old = selectByUid(uid);
+ }
+
+ TeamUserLevelStatistic update = new TeamUserLevelStatistic();
+ update.setId(old.getId());
+ update.setLevel(level);
+ update.setUpdateTime(new Date());
+ teamUserLevelStatisticMapper.updateByPrimaryKeySelective(update);
+
+ }
+
+ @Override
public void add(TeamUserLevelStatistic statistic) {
TeamUserLevelStatistic old = selectByUid(statistic.getId());
if (old == null) {
--
Gitblit v1.8.0