|
|
@@ -1,4 +1,5 @@
|
|
|
package com.kxs.stat.biz.service.impl;
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
@@ -54,10 +55,10 @@ public class KxsUserActTradeServiceImpl extends ServiceImpl<KxsUserActTradeMappe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R getActivateMerchantList(Page<KxsUserActTrade> page, Integer totalType,Long userId,String month) {
|
|
|
+ public R getActivateMerchantList(Integer totalType,Long userId,String month) {
|
|
|
LocalDate now = LocalDate.now();
|
|
|
List<String> times = new ArrayList<>();
|
|
|
- int type = 0;
|
|
|
+ int type;
|
|
|
if (month.equals("0")){
|
|
|
type = 2;
|
|
|
//查询近半年
|
|
|
@@ -69,40 +70,9 @@ public class KxsUserActTradeServiceImpl extends ServiceImpl<KxsUserActTradeMappe
|
|
|
String currentDateString = LocalDateTimeUtil.format(currentDay, DatePattern.SIMPLE_MONTH_PATTERN);
|
|
|
times.add(currentDateString);
|
|
|
}
|
|
|
-
|
|
|
- //查询全部激活
|
|
|
- List<TrendTimesVO> trendTimesVOS = baseMapper.getUserActListByDayOrMonth(times, userId,null, type);
|
|
|
- //查询激活, 根据品牌分组
|
|
|
- List<TrendTimesVO> trendTimesVOListBrand = baseMapper.getUserActListByDayOrMonth(times, userId, 1, type);
|
|
|
-
|
|
|
- // todo 暂停
|
|
|
- //构造数据
|
|
|
- //将全部交易额以及品牌交易额构造进入map key为品牌id 或 all
|
|
|
-// ArrayList<ActivityAddVO> activityAddVOS = new ArrayList<>();
|
|
|
-// Map<String,List<ActivityAddVO>> treadTrend = new HashMap<>();
|
|
|
-// for (TrendTimesVO trendTimesVO : trendTimesVOS) {
|
|
|
-// Integer total = trendTimesVO.getTotal();
|
|
|
-// Integer brandId = trendTimesVO.getBrandId();
|
|
|
-// ActivityAddVO activityAddVO = new ActivityAddVO();
|
|
|
-// activityAddVO.setName(String.valueOf(brandId));
|
|
|
-// activityAddVO.setTotal(total);
|
|
|
-// activityAddVOS.add(activityAddVO);
|
|
|
-// }
|
|
|
-// treadTrend.put("all",activityAddVOS);
|
|
|
-// treadTrend.put("all", allTimeVOS);
|
|
|
-//
|
|
|
-// for (TrendTimesVO trendTimesVO : trendTimesVOListBrand) {
|
|
|
-// List<TrendTimesVO> trendTimesVOSBrand = treadTrend.get(trendTimesVO.getBrandId().toString());
|
|
|
-//
|
|
|
-// }
|
|
|
-// //将map转换为返回实体类
|
|
|
-// ArrayList<TrendVO> trendVOS = new ArrayList<>();
|
|
|
-// for (Map.Entry<String, List<TrendTimesVO>> entry : treadTrend.entrySet()) {
|
|
|
-// TrendVO trendVO = new TrendVO();
|
|
|
-// trendVO.setName(entry.getKey());
|
|
|
-// trendVO.setTimes(entry.getValue());
|
|
|
-// trendVOS.add(trendVO);
|
|
|
-// }
|
|
|
+ //获取全部激活并构造为TimeVo格式
|
|
|
+ ArrayList<TimeVO> timeVOS = getTimeVOArrayList(totalType,userId, times, type);
|
|
|
+ return R.ok(timeVOS);
|
|
|
}else {
|
|
|
type = 1;
|
|
|
//校验时间格式是yyyyMM
|
|
|
@@ -128,13 +98,102 @@ public class KxsUserActTradeServiceImpl extends ServiceImpl<KxsUserActTradeMappe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //获取全部激活并构造为TimeVo格式
|
|
|
+ ArrayList<TimeVO> timeVOArrayList = getTimeVOArrayList(totalType,userId, times, type);
|
|
|
+
|
|
|
+ return R.ok(timeVOArrayList);
|
|
|
+ }
|
|
|
|
|
|
- //查询广电激活
|
|
|
- Integer gdNumber = baseMapper.getActivityStatByGdOrPos(userId,times,2);
|
|
|
- //查询来客吧激活
|
|
|
- Integer lkbNumber = baseMapper.getActivityStatByLkb(userId,times);
|
|
|
- TimesVO timesVO = new TimesVO();
|
|
|
- return null;
|
|
|
+ private ArrayList<TimeVO> getTimeVOArrayList(Integer totalType,Long userId, List<String> times, int type) {
|
|
|
+ //查询全部激活
|
|
|
+ List<TrendTimesVO> trendTimesVOS = baseMapper.getUserActListByDayOrMonth(times, userId,null, type,totalType);
|
|
|
+ //查询激活, 根据品牌分组
|
|
|
+ List<TrendTimesVO> trendTimesVOListBrand = baseMapper.getUserActListByDayOrMonth(times, userId, 1, type,totalType);
|
|
|
+ //构造数据
|
|
|
+ //将全部交易额以及品牌交易额构造进入map key为品牌id 或 all 或来客吧码牌
|
|
|
+ Map<String,List<ActivityAddVO>> timeActivityMap = new HashMap<>();
|
|
|
+ //查询来客吧码牌激活
|
|
|
+ List<TrendTimesVO> trendTimesVOLkbList = baseMapper.getActivityStatByLkbList(userId, times,totalType);
|
|
|
+ //来客吧码牌不再品牌列表中 同all 需要做特殊处理
|
|
|
+ for (TrendTimesVO trendTimesVO : trendTimesVOLkbList) {
|
|
|
+ ArrayList<ActivityAddVO> activityAddVOS = new ArrayList<>();
|
|
|
+ String time = trendTimesVO.getTime();
|
|
|
+ Integer total = trendTimesVO.getTotal();
|
|
|
+ ActivityAddVO activityAddVO = new ActivityAddVO();
|
|
|
+ activityAddVO.setName("来客吧码牌");
|
|
|
+ activityAddVO.setTotal(total);
|
|
|
+ activityAddVOS.add(activityAddVO);
|
|
|
+ //将该来客吧码牌构造成时间为key的map
|
|
|
+ timeActivityMap.put(time,activityAddVOS);
|
|
|
+ }
|
|
|
+ //遍历全部激活集合 注 该集合全部不包含来客吧码牌
|
|
|
+ for (TrendTimesVO trendTimesVO : trendTimesVOS) {
|
|
|
+ //先查询map中是否包含有改时间日期的来客吧码牌激活数据
|
|
|
+ Integer total = trendTimesVO.getTotal();
|
|
|
+ String time = trendTimesVO.getTime();
|
|
|
+ List<ActivityAddVO> activityAddVOList = timeActivityMap.get(time);
|
|
|
+ if (activityAddVOList == null){
|
|
|
+ //当前全部的时间点不存在码牌激活数据时,走正常逻辑构造map
|
|
|
+ //将全部激活集合全部构造成ActivityAddVO放入hashMap中,
|
|
|
+ ArrayList<ActivityAddVO> activityAddVOS = new ArrayList<>();
|
|
|
+ ActivityAddVO activityAddVO = new ActivityAddVO();
|
|
|
+ activityAddVO.setName("all");
|
|
|
+ activityAddVO.setTotal(total);
|
|
|
+ activityAddVOS.add(activityAddVO);
|
|
|
+ //key为时间,值为其ActivityAddVO本身
|
|
|
+ timeActivityMap.put(time,activityAddVOS);
|
|
|
+ }else {
|
|
|
+ //存在数据时,我们需要将码牌数量添加到总激活中
|
|
|
+ for (ActivityAddVO activityAddVO : activityAddVOList) {
|
|
|
+ //激活总量加上码牌激活量
|
|
|
+ total += activityAddVO.getTotal();
|
|
|
+ }
|
|
|
+ //再将全部激活集合全部构造成ActivityAddVO放入hashMap中,
|
|
|
+ ActivityAddVO activityAddVO = new ActivityAddVO();
|
|
|
+ activityAddVO.setName("all");
|
|
|
+ activityAddVO.setTotal(total);
|
|
|
+ //将构造的数据添加到我们从map中拿出的List中
|
|
|
+ activityAddVOList.add(activityAddVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历品牌激活
|
|
|
+ for (TrendTimesVO trendTimesVO : trendTimesVOListBrand) {
|
|
|
+ //查找map获取当前品牌激活统计的时间点
|
|
|
+ List<ActivityAddVO> activityAddVOList = timeActivityMap.get(trendTimesVO.getTime());
|
|
|
+ //在逻辑上,该activityAddVOList不可能为null,但添加校验防止脏数据导致报错
|
|
|
+ if (activityAddVOList != null){
|
|
|
+ //将当前品牌的激活数量构造成activityAddVO 添加入map中去
|
|
|
+ ActivityAddVO activityAddVO = new ActivityAddVO();
|
|
|
+ activityAddVO.setName(trendTimesVO.getBrandId().toString());
|
|
|
+ activityAddVO.setTotal(trendTimesVO.getTotal());
|
|
|
+ activityAddVOList.add(activityAddVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //此时我们的hashmap格式已为TimeVO类格式
|
|
|
+ //将map转换为返回实体类
|
|
|
+ ArrayList<TimeVO> timeVOS = new ArrayList<>();
|
|
|
+ //直接遍历map无法根据时间返回 弃用
|
|
|
+// for (Map.Entry<String, List<ActivityAddVO>> entry : timeActivityMap.entrySet()) {
|
|
|
+// TimeVO timeVO = new TimeVO();
|
|
|
+// String key = entry.getKey();
|
|
|
+// List<ActivityAddVO> value = entry.getValue();
|
|
|
+// timeVO.setDate(key);
|
|
|
+// timeVO.setActivityAdd(value);
|
|
|
+// timeVOS.add(timeVO);
|
|
|
+// }
|
|
|
+ //改用foresch 根据我们传入的时间进行写入
|
|
|
+ for (String time : times) {
|
|
|
+ List<ActivityAddVO> activityAddVOList = timeActivityMap.get(time);
|
|
|
+ //存在数据则开始构造TimeVO
|
|
|
+ if (activityAddVOList != null){
|
|
|
+ TimeVO timeVO = new TimeVO();
|
|
|
+ timeVO.setDate(time);
|
|
|
+ timeVO.setActivityAdd(activityAddVOList);
|
|
|
+ timeVOS.add(timeVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return timeVOS;
|
|
|
}
|
|
|
}
|
|
|
|