|
@@ -3493,6 +3493,216 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
return trendVos;
|
|
return trendVos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public TopOrderStatisticsViewVo getStatisticsTenantView(TopOrderStatisticsViewBo bo) {
|
|
|
|
+ //筛选时间处理
|
|
|
|
+ if (ObjectUtils.isNull(bo.getTimeSign()) && ObjectUtils.isNull(bo.getStartTime()) && ObjectUtils.isNull(bo.getEndTime())){
|
|
|
|
+ //没有选择时间范围,默认为当前时间向前推30天
|
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
|
+ Long dayBefore = DateUtils.getDayBefore(nowTime, 30);
|
|
|
|
+ bo.setStartTime(dayBefore);
|
|
|
|
+ bo.setEndTime(nowTime);
|
|
|
|
+ }else if (ObjectUtils.isNotNull(bo.getTimeSign())){
|
|
|
|
+ switch (bo.getTimeSign()){
|
|
|
|
+ case 1://本周
|
|
|
|
+ Map<String, Long> timeInterval = DateUtils.getTimeInterval(new Date());
|
|
|
|
+ bo.setStartTime(timeInterval.get("start"));
|
|
|
|
+ bo.setEndTime(timeInterval.get("end"));
|
|
|
|
+ break;
|
|
|
|
+ case 2://本月
|
|
|
|
+ Long toMonthZeroTime = DateUtils.getToMonthZeroTime();
|
|
|
|
+ bo.setStartTime(toMonthZeroTime);
|
|
|
|
+ bo.setEndTime(DateUtils.getNowTime());
|
|
|
|
+ break;
|
|
|
|
+ case 3://本年
|
|
|
|
+ Long toYearZeroTime = DateUtils.getToYearZeroTime();
|
|
|
|
+ bo.setStartTime(toYearZeroTime);
|
|
|
|
+ bo.setEndTime(DateUtils.getNowTime());
|
|
|
|
+ break;
|
|
|
|
+ default :
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ TopOrderStatisticsViewVo viewVo = new TopOrderStatisticsViewVo();
|
|
|
|
+ //天
|
|
|
|
+ bo.setViewSign(1);
|
|
|
|
+ List<TopOrderStatisticsTwoVo> voList = baseMapper.getStatisticsTenantView(bo);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(voList)){
|
|
|
|
+ List<Long> dayTime = getDayTime(bo.getStartTime(), bo.getEndTime());
|
|
|
|
+ List<TopOrderStatisticsTwoVo> vos = new ArrayList<>();
|
|
|
|
+ for (Long day : dayTime) {
|
|
|
|
+ TopOrderStatisticsTwoVo twoVo = new TopOrderStatisticsTwoVo();
|
|
|
|
+ twoVo.setTime(day);
|
|
|
|
+ twoVo.setTimeStr(DateUtils.timestampToDateFormat(day,"yyyy-MM-dd"));
|
|
|
|
+ if (voList.stream().anyMatch(x -> DateUtils.getScheduleTimeStrZeroTime(x.getTimeStr(), "yyyy-MM-dd").equals(day))){
|
|
|
|
+ TopOrderStatisticsTwoVo statisticsTwoVo = voList.stream()
|
|
|
|
+ .filter(x -> DateUtils.getScheduleTimeStrZeroTime(x.getTimeStr(), "yyyy-MM-dd").equals(day)).findFirst().get();
|
|
|
|
+ twoVo.setMoney(statisticsTwoVo.getMoney());
|
|
|
|
+ twoVo.setOrderNum(statisticsTwoVo.getOrderNum());
|
|
|
|
+ }
|
|
|
|
+ vos.add(twoVo);
|
|
|
|
+ }
|
|
|
|
+ viewVo.setDayView(vos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //周
|
|
|
|
+ bo.setViewSign(2);
|
|
|
|
+ List<TopOrderStatisticsTwoVo> voList2 = baseMapper.getStatisticsTenantView(bo);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(voList2)){
|
|
|
|
+ Map<Long, Long> weekTime = getWeekTime(bo.getStartTime(), bo.getEndTime());
|
|
|
|
+ List<TopOrderStatisticsTwoVo> vos = new ArrayList<>();
|
|
|
|
+ for (Long time : weekTime.keySet()) {
|
|
|
|
+ TopOrderStatisticsTwoVo twoVo = new TopOrderStatisticsTwoVo();
|
|
|
|
+ twoVo.setTime(time);
|
|
|
|
+ twoVo.setTimeStr(DateUtils.timestampToDateFormat(time,"yyyy-MM-dd"));
|
|
|
|
+ if (voList2.stream().anyMatch(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= weekTime.get(time))){
|
|
|
|
+ TopOrderStatisticsTwoVo statisticsTwoVo = voList2.stream()
|
|
|
|
+ .filter(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= weekTime.get(time)).findFirst().get();
|
|
|
|
+ twoVo.setMoney(statisticsTwoVo.getMoney());
|
|
|
|
+ twoVo.setOrderNum(statisticsTwoVo.getOrderNum());
|
|
|
|
+ }
|
|
|
|
+ vos.add(twoVo);
|
|
|
|
+ }
|
|
|
|
+ viewVo.setWeekView(vos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //月
|
|
|
|
+ bo.setViewSign(3);
|
|
|
|
+ List<TopOrderStatisticsTwoVo> voList3 = baseMapper.getStatisticsTenantView(bo);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(voList3)){
|
|
|
|
+ Map<Long, Long> monthTime = DateUtils.getMonthTime(bo.getStartTime(), bo.getEndTime());
|
|
|
|
+ List<TopOrderStatisticsTwoVo> vos = new ArrayList<>();
|
|
|
|
+ for (Long time : monthTime.keySet()) {
|
|
|
|
+ TopOrderStatisticsTwoVo twoVo = new TopOrderStatisticsTwoVo();
|
|
|
|
+ twoVo.setTime(time);
|
|
|
|
+ twoVo.setTimeStr(DateUtils.timestampToDateFormat(time,"yyyy-MM"));
|
|
|
|
+ if (voList2.stream().anyMatch(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= monthTime.get(time))){
|
|
|
|
+ TopOrderStatisticsTwoVo statisticsTwoVo = voList2.stream()
|
|
|
|
+ .filter(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= monthTime.get(time)).findFirst().get();
|
|
|
|
+ twoVo.setMoney(statisticsTwoVo.getMoney());
|
|
|
|
+ twoVo.setOrderNum(statisticsTwoVo.getOrderNum());
|
|
|
|
+ }
|
|
|
|
+ vos.add(twoVo);
|
|
|
|
+ }
|
|
|
|
+ viewVo.setMonthView(vos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return viewVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public TopOrderStatisticsViewVo getStatisticsBusinessView(TopOrderStatisticsViewBo bo) {
|
|
|
|
+ //筛选时间处理
|
|
|
|
+ if (ObjectUtils.isNull(bo.getTimeSign()) && ObjectUtils.isNull(bo.getStartTime()) && ObjectUtils.isNull(bo.getEndTime())){
|
|
|
|
+ //没有选择时间范围,默认为当前时间向前推30天
|
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
|
+ Long dayBefore = DateUtils.getDayBefore(nowTime, 30);
|
|
|
|
+ bo.setStartTime(dayBefore);
|
|
|
|
+ bo.setEndTime(nowTime);
|
|
|
|
+ }else if (ObjectUtils.isNotNull(bo.getTimeSign())){
|
|
|
|
+ switch (bo.getTimeSign()){
|
|
|
|
+ case 1://本周
|
|
|
|
+ Map<String, Long> timeInterval = DateUtils.getTimeInterval(new Date());
|
|
|
|
+ bo.setStartTime(timeInterval.get("start"));
|
|
|
|
+ bo.setEndTime(timeInterval.get("end"));
|
|
|
|
+ break;
|
|
|
|
+ case 2://本月
|
|
|
|
+ Long toMonthZeroTime = DateUtils.getToMonthZeroTime();
|
|
|
|
+ bo.setStartTime(toMonthZeroTime);
|
|
|
|
+ bo.setEndTime(DateUtils.getNowTime());
|
|
|
|
+ break;
|
|
|
|
+ case 3://本年
|
|
|
|
+ Long toYearZeroTime = DateUtils.getToYearZeroTime();
|
|
|
|
+ bo.setStartTime(toYearZeroTime);
|
|
|
|
+ bo.setEndTime(DateUtils.getNowTime());
|
|
|
|
+ break;
|
|
|
|
+ default :
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ TopOrderStatisticsViewVo viewVo = new TopOrderStatisticsViewVo();
|
|
|
|
+ //天
|
|
|
|
+ bo.setViewSign(1);
|
|
|
|
+ List<TopOrderStatisticsTwoVo> voList = baseMapper.getStatisticsBusinessView(bo);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(voList)){
|
|
|
|
+ List<Long> dayTime = getDayTime(bo.getStartTime(), bo.getEndTime());
|
|
|
|
+ List<TopOrderStatisticsTwoVo> vos = new ArrayList<>();
|
|
|
|
+ for (Long day : dayTime) {
|
|
|
|
+ TopOrderStatisticsTwoVo twoVo = new TopOrderStatisticsTwoVo();
|
|
|
|
+ twoVo.setTime(day);
|
|
|
|
+ twoVo.setTimeStr(DateUtils.timestampToDateFormat(day,"yyyy-MM-dd"));
|
|
|
|
+ if (voList.stream().anyMatch(x -> DateUtils.getScheduleTimeStrZeroTime(x.getTimeStr(), "yyyy-MM-dd").equals(day))){
|
|
|
|
+ TopOrderStatisticsTwoVo statisticsTwoVo = voList.stream()
|
|
|
|
+ .filter(x -> DateUtils.getScheduleTimeStrZeroTime(x.getTimeStr(), "yyyy-MM-dd").equals(day)).findFirst().get();
|
|
|
|
+ twoVo.setMoney(statisticsTwoVo.getMoney());
|
|
|
|
+ twoVo.setOrderNum(statisticsTwoVo.getOrderNum());
|
|
|
|
+ }
|
|
|
|
+ vos.add(twoVo);
|
|
|
|
+ }
|
|
|
|
+ viewVo.setDayView(vos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //周
|
|
|
|
+ bo.setViewSign(2);
|
|
|
|
+ List<TopOrderStatisticsTwoVo> voList2 = baseMapper.getStatisticsBusinessView(bo);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(voList2)){
|
|
|
|
+ Map<Long, Long> weekTime = getWeekTime(bo.getStartTime(), bo.getEndTime());
|
|
|
|
+ List<TopOrderStatisticsTwoVo> vos = new ArrayList<>();
|
|
|
|
+ for (Long time : weekTime.keySet()) {
|
|
|
|
+ TopOrderStatisticsTwoVo twoVo = new TopOrderStatisticsTwoVo();
|
|
|
|
+ twoVo.setTime(time);
|
|
|
|
+ twoVo.setTimeStr(DateUtils.timestampToDateFormat(time,"yyyy-MM-dd"));
|
|
|
|
+ if (voList2.stream().anyMatch(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= weekTime.get(time))){
|
|
|
|
+ TopOrderStatisticsTwoVo statisticsTwoVo = voList2.stream()
|
|
|
|
+ .filter(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= weekTime.get(time)).findFirst().get();
|
|
|
|
+ twoVo.setMoney(statisticsTwoVo.getMoney());
|
|
|
|
+ twoVo.setOrderNum(statisticsTwoVo.getOrderNum());
|
|
|
|
+ }
|
|
|
|
+ vos.add(twoVo);
|
|
|
|
+ }
|
|
|
|
+ viewVo.setWeekView(vos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //月
|
|
|
|
+ bo.setViewSign(3);
|
|
|
|
+ List<TopOrderStatisticsTwoVo> voList3 = baseMapper.getStatisticsBusinessView(bo);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(voList3)){
|
|
|
|
+ Map<Long, Long> monthTime = DateUtils.getMonthTime(bo.getStartTime(), bo.getEndTime());
|
|
|
|
+ List<TopOrderStatisticsTwoVo> vos = new ArrayList<>();
|
|
|
|
+ for (Long time : monthTime.keySet()) {
|
|
|
|
+ TopOrderStatisticsTwoVo twoVo = new TopOrderStatisticsTwoVo();
|
|
|
|
+ twoVo.setTime(time);
|
|
|
|
+ twoVo.setTimeStr(DateUtils.timestampToDateFormat(time,"yyyy-MM"));
|
|
|
|
+ if (voList2.stream().anyMatch(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= monthTime.get(time))){
|
|
|
|
+ TopOrderStatisticsTwoVo statisticsTwoVo = voList2.stream()
|
|
|
|
+ .filter(x ->
|
|
|
|
+ DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) >= time
|
|
|
|
+ && DateUtils.getScheduleTimeZeroTime(x.getOrderTime()) <= monthTime.get(time)).findFirst().get();
|
|
|
|
+ twoVo.setMoney(statisticsTwoVo.getMoney());
|
|
|
|
+ twoVo.setOrderNum(statisticsTwoVo.getOrderNum());
|
|
|
|
+ }
|
|
|
|
+ vos.add(twoVo);
|
|
|
|
+ }
|
|
|
|
+ viewVo.setMonthView(vos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return viewVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
private List<Long> getDayTime(Long startTime,Long endTime){
|
|
private List<Long> getDayTime(Long startTime,Long endTime){
|
|
List<Long> tiemList = new ArrayList<>();
|
|
List<Long> tiemList = new ArrayList<>();
|
|
Long zeroTime = DateUtils.getScheduleTimeZeroTime(startTime);
|
|
Long zeroTime = DateUtils.getScheduleTimeZeroTime(startTime);
|