| | |
| | | package com.yeshi.fanli.service.manger.user;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleDetail;
|
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.exception.user.TeamDailyRecordException;
|
| | | import com.yeshi.fanli.service.inter.user.invite.TeamDailyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import org.yeshi.utils.TimeUtil;
|
| | |
|
| | | /**
|
| | | * 团队成员统计
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class UserTeamStatisticManager {
|
| | |
|
| | | @Resource
|
| | | private UserVIPPreInfoService userVIPPreInfoService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleDetailService threeSaleDetailService;
|
| | |
|
| | | @Resource
|
| | | private TeamDailyRecordService teamDailyRecordService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | |
|
| | | /**
|
| | | * 同步会员信息(一级/二级/二级外)
|
| | | * @Title: statisticVIPData
|
| | | * @Description: |
| | | * @param minTime
|
| | | * @param maxTime
|
| | | * @return |
| | | * int 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void syncVIPData(Date minTime, Date maxTime) {
|
| | |
|
| | | List<UserVIPPreInfo> totalList = new ArrayList<>();
|
| | |
|
| | | long count = userVIPPreInfoService.countByProcess(UserLevelEnum.highVIP.getLevel(), minTime, maxTime);
|
| | | int pageSize = 1000;
|
| | | int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<UserVIPPreInfo> list = userVIPPreInfoService.listByProcess(UserLevelEnum.highVIP.getLevel(), minTime,
|
| | | maxTime, i + 1, pageSize);
|
| | | if (list != null)
|
| | | totalList.addAll(list);
|
| | | }
|
| | |
|
| | | count = userVIPPreInfoService.countByProcess(UserLevelEnum.superVIP.getLevel(), minTime, maxTime);
|
| | | page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<UserVIPPreInfo> list = userVIPPreInfoService.listByProcess(UserLevelEnum.superVIP.getLevel(), minTime,
|
| | | maxTime, i + 1, pageSize);
|
| | | if (list != null)
|
| | | totalList.addAll(list);
|
| | | }
|
| | |
|
| | | Map<String, Integer> map = new HashMap<>();
|
| | |
|
| | | for (UserVIPPreInfo vipPre : totalList) {
|
| | | String day = TimeUtil.getGernalTime(vipPre.getCreateTime().getTime(), "yyyy-MM-dd");
|
| | | List<ThreeSaleDetail> list = threeSaleDetailService.listByWorkerUid(vipPre.getUid());
|
| | | for (ThreeSaleDetail ts : list) {
|
| | | String key = ts.getBossUid() + "#" + day + "#" + vipPre.getProcess() + "#";
|
| | | if (ts.getLevel() == 1) {
|
| | | key += "1";
|
| | | } else if (ts.getLevel() == 2) {
|
| | | key += "2";
|
| | | } else {
|
| | | key += "3";
|
| | | }
|
| | |
|
| | | if (map.get(key) == null) {
|
| | | map.put(key, 0);
|
| | | }
|
| | |
|
| | | map.put(key, map.get(key) + 1);
|
| | | }
|
| | | }
|
| | |
|
| | | for (java.util.Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | Long uid = Long.parseLong(key.split("#")[0]);
|
| | | String day = key.split("#")[1];
|
| | | int process = Integer.parseInt(key.split("#")[2]);
|
| | | int level = Integer.parseInt(key.split("#")[3]);
|
| | |
|
| | | TeamDailyRecord record = new TeamDailyRecord();
|
| | | record.setUid(uid);
|
| | | record.setCountDay(new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd")));
|
| | | if (level == 1) {
|
| | | String tempKey = uid + "#" + day + "#" + UserLevelEnum.highVIP.getLevel() + "#" + level;
|
| | | record.setFirstHighVIP(map.get(tempKey));
|
| | |
|
| | | tempKey = uid + "#" + day + "#" + UserLevelEnum.superVIP.getLevel() + "#" + level;
|
| | | record.setFirstSuperVIP(map.get(tempKey));
|
| | |
|
| | | } else if (level == 2) {
|
| | |
|
| | | String tempKey = uid + "#" + day + "#" + UserLevelEnum.highVIP.getLevel() + "#" + level;
|
| | | record.setSecondHighVIP(map.get(tempKey));
|
| | |
|
| | | tempKey = uid + "#" + day + "#" + UserLevelEnum.superVIP.getLevel() + "#" + level;
|
| | | record.setSecondSuperVIP(map.get(tempKey));
|
| | |
|
| | | } else {
|
| | | String tempKey = uid + "#" + day + "#" + UserLevelEnum.highVIP.getLevel() + "#" + level;
|
| | | record.setBeyondHighVIP(map.get(tempKey));
|
| | |
|
| | | tempKey = uid + "#" + day + "#" + UserLevelEnum.superVIP.getLevel() + "#" + level;
|
| | | record.setBeyondSuperVIP(map.get(tempKey));
|
| | | }
|
| | | // 保存
|
| | | try {
|
| | | teamDailyRecordService.save(record);
|
| | | } catch (TeamDailyRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 同步注册信息
|
| | | * @Title: syncRegisterData
|
| | | * @Description: |
| | | * @param minTime
|
| | | * @param maxTime |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void syncInviteAndTotalData(Date minTime, Date maxTime) {
|
| | | List<ThreeSale> totalList = new ArrayList<>();
|
| | | long count = threeSaleSerivce.countAll(minTime, maxTime);
|
| | | int pageSize = 1000;
|
| | | int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<ThreeSale> list = threeSaleSerivce.listAll(minTime, maxTime, i + 1, pageSize);
|
| | | if (list != null)
|
| | | totalList.addAll(list);
|
| | | }
|
| | |
|
| | | Map<String, Integer> map = new HashMap<>();
|
| | |
|
| | | for (ThreeSale threeSale : totalList) {
|
| | | String day = TimeUtil.getGernalTime(threeSale.getSucceedTime(), "yyyy-MM-dd");
|
| | | List<ThreeSaleDetail> list = threeSaleDetailService.listByWorkerUid(threeSale.getWorker().getId());
|
| | | for (ThreeSaleDetail ts : list) {
|
| | | String key = ts.getBossUid() + "#" + day + "#";
|
| | | if (ts.getLevel() == 1) {
|
| | | key += "1";
|
| | | } else if (ts.getLevel() == 2) {
|
| | | key += "2";
|
| | | } else {
|
| | | key += "3";
|
| | | }
|
| | |
|
| | | if (map.get(key) == null) {
|
| | | map.put(key, 0);
|
| | | }
|
| | |
|
| | | map.put(key, map.get(key) + 1);
|
| | | }
|
| | | }
|
| | |
|
| | | for (java.util.Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | Long uid = Long.parseLong(key.split("#")[0]);
|
| | | String day = key.split("#")[1];
|
| | | int level = Integer.parseInt(key.split("#")[2]);
|
| | |
|
| | | TeamDailyRecord record = new TeamDailyRecord();
|
| | | record.setUid(uid);
|
| | | record.setCountDay(new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd")));
|
| | | if (level == 1) {
|
| | | record.setFirstDaRen(map.get(key));
|
| | | record.setFirstNum(map.get(key));
|
| | | } else if (level == 2) {
|
| | | record.setSecondDaRen(map.get(key));
|
| | | record.setSecondNum(map.get(key));
|
| | | } else {
|
| | | record.setBeyondDaRen(map.get(key));
|
| | | record.setBeyondNum(map.get(key));
|
| | | }
|
| | | // 保存
|
| | | try {
|
| | | teamDailyRecordService.save(record);
|
| | | } catch (TeamDailyRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.manger.user; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale; |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleDetail; |
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo; |
| | | import com.yeshi.fanli.exception.user.TeamDailyRecordException; |
| | | import com.yeshi.fanli.service.inter.user.invite.TeamDailyRecordService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | /** |
| | | * 团队成员统计 |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | @Component |
| | | public class UserTeamStatisticManager { |
| | | |
| | | @Resource |
| | | private UserVIPPreInfoService userVIPPreInfoService; |
| | | |
| | | @Resource |
| | | private ThreeSaleDetailService threeSaleDetailService; |
| | | |
| | | @Resource |
| | | private TeamDailyRecordService teamDailyRecordService; |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | |
| | | |
| | | /** |
| | | * 同步会员信息(一级/二级/二级外) |
| | | * @Title: statisticVIPData |
| | | * @Description: |
| | | * @param minTime |
| | | * @param maxTime |
| | | * @return |
| | | * int 返回类型 |
| | | * @throws |
| | | */ |
| | | public void syncVIPData(Date minTime, Date maxTime) { |
| | | |
| | | List<UserVIPPreInfo> totalList = new ArrayList<>(); |
| | | |
| | | long count = userVIPPreInfoService.countByProcess(UserLevelEnum.highVIP.getLevel(), minTime, maxTime); |
| | | int pageSize = 1000; |
| | | int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | for (int i = 0; i < page; i++) { |
| | | List<UserVIPPreInfo> list = userVIPPreInfoService.listByProcess(UserLevelEnum.highVIP.getLevel(), minTime, |
| | | maxTime, i + 1, pageSize); |
| | | if (list != null) |
| | | totalList.addAll(list); |
| | | } |
| | | |
| | | count = userVIPPreInfoService.countByProcess(UserLevelEnum.superVIP.getLevel(), minTime, maxTime); |
| | | page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | for (int i = 0; i < page; i++) { |
| | | List<UserVIPPreInfo> list = userVIPPreInfoService.listByProcess(UserLevelEnum.superVIP.getLevel(), minTime, |
| | | maxTime, i + 1, pageSize); |
| | | if (list != null) |
| | | totalList.addAll(list); |
| | | } |
| | | |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | |
| | | for (UserVIPPreInfo vipPre : totalList) { |
| | | String day = TimeUtil.getGernalTime(vipPre.getCreateTime().getTime(), "yyyy-MM-dd"); |
| | | List<ThreeSaleDetail> list = threeSaleDetailService.listByWorkerUid(vipPre.getUid()); |
| | | for (ThreeSaleDetail ts : list) { |
| | | String key = ts.getBossUid() + "#" + day + "#" + vipPre.getProcess() + "#"; |
| | | if (ts.getLevel() == 1) { |
| | | key += "1"; |
| | | } else if (ts.getLevel() == 2) { |
| | | key += "2"; |
| | | } else { |
| | | key += "3"; |
| | | } |
| | | |
| | | if (map.get(key) == null) { |
| | | map.put(key, 0); |
| | | } |
| | | |
| | | map.put(key, map.get(key) + 1); |
| | | } |
| | | } |
| | | |
| | | for (java.util.Iterator<String> its = map.keySet().iterator(); its.hasNext();) { |
| | | String key = its.next(); |
| | | Long uid = Long.parseLong(key.split("#")[0]); |
| | | String day = key.split("#")[1]; |
| | | int process = Integer.parseInt(key.split("#")[2]); |
| | | int level = Integer.parseInt(key.split("#")[3]); |
| | | |
| | | TeamDailyRecord record = new TeamDailyRecord(); |
| | | record.setUid(uid); |
| | | record.setCountDay(new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd"))); |
| | | if (level == 1) { |
| | | String tempKey = uid + "#" + day + "#" + UserLevelEnum.highVIP.getLevel() + "#" + level; |
| | | record.setFirstHighVIP(map.get(tempKey)); |
| | | |
| | | tempKey = uid + "#" + day + "#" + UserLevelEnum.superVIP.getLevel() + "#" + level; |
| | | record.setFirstSuperVIP(map.get(tempKey)); |
| | | |
| | | } else if (level == 2) { |
| | | |
| | | String tempKey = uid + "#" + day + "#" + UserLevelEnum.highVIP.getLevel() + "#" + level; |
| | | record.setSecondHighVIP(map.get(tempKey)); |
| | | |
| | | tempKey = uid + "#" + day + "#" + UserLevelEnum.superVIP.getLevel() + "#" + level; |
| | | record.setSecondSuperVIP(map.get(tempKey)); |
| | | |
| | | } else { |
| | | String tempKey = uid + "#" + day + "#" + UserLevelEnum.highVIP.getLevel() + "#" + level; |
| | | record.setBeyondHighVIP(map.get(tempKey)); |
| | | |
| | | tempKey = uid + "#" + day + "#" + UserLevelEnum.superVIP.getLevel() + "#" + level; |
| | | record.setBeyondSuperVIP(map.get(tempKey)); |
| | | } |
| | | // 保存 |
| | | try { |
| | | teamDailyRecordService.save(record); |
| | | } catch (TeamDailyRecordException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 同步注册信息 |
| | | * @Title: syncRegisterData |
| | | * @Description: |
| | | * @param minTime |
| | | * @param maxTime |
| | | * void 返回类型 |
| | | * @throws |
| | | */ |
| | | public void syncInviteAndTotalData(Date minTime, Date maxTime) { |
| | | List<ThreeSale> totalList = new ArrayList<>(); |
| | | long count = threeSaleSerivce.countAll(minTime, maxTime); |
| | | int pageSize = 1000; |
| | | int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | for (int i = 0; i < page; i++) { |
| | | List<ThreeSale> list = threeSaleSerivce.listAll(minTime, maxTime, i + 1, pageSize); |
| | | if (list != null) |
| | | totalList.addAll(list); |
| | | } |
| | | |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | |
| | | for (ThreeSale threeSale : totalList) { |
| | | String day = TimeUtil.getGernalTime(threeSale.getSucceedTime(), "yyyy-MM-dd"); |
| | | List<ThreeSaleDetail> list = threeSaleDetailService.listByWorkerUid(threeSale.getWorker().getId()); |
| | | for (ThreeSaleDetail ts : list) { |
| | | String key = ts.getBossUid() + "#" + day + "#"; |
| | | if (ts.getLevel() == 1) { |
| | | key += "1"; |
| | | } else if (ts.getLevel() == 2) { |
| | | key += "2"; |
| | | } else { |
| | | key += "3"; |
| | | } |
| | | |
| | | if (map.get(key) == null) { |
| | | map.put(key, 0); |
| | | } |
| | | |
| | | map.put(key, map.get(key) + 1); |
| | | } |
| | | } |
| | | |
| | | for (java.util.Iterator<String> its = map.keySet().iterator(); its.hasNext();) { |
| | | String key = its.next(); |
| | | Long uid = Long.parseLong(key.split("#")[0]); |
| | | String day = key.split("#")[1]; |
| | | int level = Integer.parseInt(key.split("#")[2]); |
| | | |
| | | TeamDailyRecord record = new TeamDailyRecord(); |
| | | record.setUid(uid); |
| | | record.setCountDay(new Date(TimeUtil.convertToTimeTemp(day, "yyyy-MM-dd"))); |
| | | if (level == 1) { |
| | | record.setFirstDaRen(map.get(key)); |
| | | record.setFirstNum(map.get(key)); |
| | | } else if (level == 2) { |
| | | record.setSecondDaRen(map.get(key)); |
| | | record.setSecondNum(map.get(key)); |
| | | } else { |
| | | record.setBeyondDaRen(map.get(key)); |
| | | record.setBeyondNum(map.get(key)); |
| | | } |
| | | // 保存 |
| | | try { |
| | | teamDailyRecordService.save(record); |
| | | } catch (TeamDailyRecordException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |