From 2e4640768bec302ed465c9c17002df842c96ee96 Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期二, 10 十月 2023 15:28:37 +0800 Subject: [PATCH] 后台代码 --- cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/DataStatisticsController.java | 910 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 867 insertions(+), 43 deletions(-) diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/DataStatisticsController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/DataStatisticsController.java index deeb3ec..ee41af0 100644 --- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/DataStatisticsController.java +++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/DataStatisticsController.java @@ -1,10 +1,9 @@ package com.dsh.guns.modular.system.controller.code; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.dsh.course.feignClient.account.*; -import com.dsh.course.feignClient.account.model.CityManager; -import com.dsh.course.feignClient.account.model.TAppUser; -import com.dsh.course.feignClient.account.model.VipPayment; +import com.dsh.course.feignClient.account.model.*; import com.dsh.course.feignClient.activity.PointMercharsClient; import com.dsh.course.feignClient.competition.CompetitionClient; import com.dsh.course.feignClient.competition.model.Competition; @@ -18,8 +17,9 @@ import com.dsh.course.model.MoneyBack; import com.dsh.guns.config.UserExt; import com.dsh.guns.core.base.controller.BaseController; +import com.dsh.guns.core.util.ToolUtil; import com.dsh.guns.modular.system.model.*; -import com.dsh.guns.modular.system.service.ICityService; +import com.dsh.guns.modular.system.service.*; import groovyjarjarpicocli.CommandLine; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -50,8 +50,17 @@ private ICityService cityService; @Autowired private CityManagerClient cityManagerClient; + + @Autowired + private IUserService sysUserService; @Autowired private AppUserClient appUserClient; + + @Autowired + private CourseClient courseClient; + + @Autowired + private IStoreService storeService; @Autowired private VipPaymentClient vipPaymentClient; @Autowired @@ -60,6 +69,9 @@ private CoursePackagePaymentClient coursePackagePaymentClient; @Autowired private CompetitionClient competitionClient; + + @Autowired + private ISiteBookingService siteBookingService; @Autowired private StoreClient storeClient; @Autowired @@ -72,11 +84,24 @@ private CourseStuddentClient courseStuddentClient; @Autowired private CoursePackageClient coursePackageClient; + @Autowired + private TOperatorService operatorService; /** * 跳转到平台统计数据页面 */ @RequestMapping("/platform") public String index(Model model) { + Object o = type1(null); + model.addAttribute("data",o); + + + + // 教学统计 + HashMap<String, Object> map = appUserClient.queryUserAge(); + model.addAttribute("stuData",map); + + + return PREFIX + "platformIncome.html"; } @@ -86,7 +111,7 @@ */ @RequestMapping(value = "/getIncomeData") @ResponseBody - public Object getIncomeData(Integer type) { + public Object getIncomeData(Integer operatorId,Integer storeId) { // 充值记录查询query RechargeRecordsQuery rechargeRecordsQuery = new RechargeRecordsQuery(); // 报名课程查询query @@ -98,6 +123,12 @@ // 场地预约记录查询query SiteBookingQuery siteBookingQuery = new SiteBookingQuery(); Integer roleType = UserExt.getUser().getObjectType(); + rechargeRecordsQuery.setInsertType(roleType); + query.setInsertType(roleType); + competitionQuery.setInsertType(roleType); + incomeQuery.setInsertType(roleType); + incomeQuery.setInsertType(roleType); + IncomeVO incomeVO = new IncomeVO(); List<IncomeVO> incomeVOS = new ArrayList<>(); // 会员支付记录 @@ -114,6 +145,7 @@ } // 充值记录 List<RechargeRecordsVO> rechargeRecordsVOS = financeClient.rechargeList(rechargeRecordsQuery); + List<RechargeRecords> rechargeRecords = financeClient.rechargeList1(rechargeRecordsQuery); for (RechargeRecordsVO rechargeRecordsVO : rechargeRecordsVOS) { IncomeVO temp = new IncomeVO(); temp.setInsertTime(rechargeRecordsVO.getInsertTime()); @@ -195,8 +227,8 @@ // 累加到总金额 totalAmount1 = totalAmount1.add(total); - Date insertTime = incomeVO1.getInsertTime(); // 假设有一个方法用于获取 insertTime - BigDecimal amount1 = incomeVO1.getAmount(); // 假设有一个方法用于获取 amount + Date insertTime = incomeVO1.getInsertTime(); + BigDecimal amount1 = incomeVO1.getAmount(); Calendar calendar = Calendar.getInstance(); calendar.setTime(insertTime); int year = calendar.get(Calendar.YEAR); // 获取年份 @@ -214,8 +246,13 @@ Collections.sort(sortedYears); // 创建一个新的 IncomeVO 列表,包含按年份累计的 amount List<Object> resultIncomeVOS = new ArrayList<>(); - // 循环遍历2023年到2028年的年份 - for (int year = 2023; year <= 2028; year++) { + // 当前年往前推十年 + List<Integer> integers1 = new ArrayList<>(); + int years = DateUtil.year(new Date()); + for (int i = 0; i < 10; i++) { + integers1.add(years-i); + } + for (int year = integers1.get(0); year >= integers1.get(integers1.size()-1); year++) { BigDecimal totalAmount = yearToTotalAmountMap.getOrDefault(year, BigDecimal.ZERO); // 创建一个新的 IncomeVO 对象,并设置年份和累计金额 IncomeVO resultIncomeVO = new IncomeVO(); @@ -248,20 +285,55 @@ int currentMonth = currentDate.getMonthValue(); // 初始化一个长度为当前月份的天数的列表,并将每一天的金额初始化为零 int daysInCurrentMonth = currentDate.lengthOfMonth(); - List<BigDecimal> weekAmount = new ArrayList<>(daysInCurrentMonth); - for (int i = 0; i < daysInCurrentMonth; i++) { - weekAmount.add(BigDecimal.ZERO); - } + List<BigDecimal> weekAmount = new ArrayList<>(); + + // 获取最近四周 + LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); + LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); + // 周度数据 + LocalDateTime week1Start = minNow.minusDays(6); + LocalDateTime week1End = maxNow; + + LocalDateTime week2Start = minNow.minusDays(13); + LocalDateTime week2End = minNow.minusDays(7); + + LocalDateTime week3Start = minNow.minusDays(20); + LocalDateTime week3End = minNow.minusDays(14); + + LocalDateTime week4Start = minNow.minusDays(27); + LocalDateTime week4End = minNow.minusDays(21); + // 用于存放四个周的数据 + List<Object> objects1 = new ArrayList<>(); + // 计算每个周的amount总和 + BigDecimal tAmount1 = BigDecimal.ZERO; + BigDecimal tAmount2 = BigDecimal.ZERO; + BigDecimal tAmount3 = BigDecimal.ZERO; + BigDecimal tAmount4 = BigDecimal.ZERO; for (IncomeVO incomeVO1 : incomeVOS) { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String string = dateFormat.format(incomeVO1.getInsertTime()); - LocalDate insertDate = LocalDate.parse(string, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - if (insertDate.getMonthValue() == currentMonth) { - int dayOfMonth = insertDate.getDayOfMonth(); - BigDecimal currentAmount = weekAmount.get(dayOfMonth - 1); // 列表索引从0开始 - weekAmount.set(dayOfMonth - 1, currentAmount.add(incomeVO1.getAmount())); + Date insertTime = incomeVO1.getInsertTime(); + // 将Date转换为LocalDateTime + Instant instant = insertTime.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); + // 判断该数据属于哪个周 + if (dateTime.isAfter(week1Start) && dateTime.isBefore(week1End)) { + BigDecimal amount1 = incomeVO1.getAmount(); + tAmount1=tAmount1.add(amount1); + } else if (dateTime.isAfter(week2Start) && dateTime.isBefore(week2End)) { + BigDecimal amount1 = incomeVO1.getAmount(); + tAmount2=tAmount2.add(amount1); + } else if (dateTime.isAfter(week3Start) && dateTime.isBefore(week3End)) { + BigDecimal amount1 = incomeVO1.getAmount(); + tAmount4=tAmount3.add(amount1); + } else if (dateTime.isAfter(week4Start) && dateTime.isBefore(week4End)) { + BigDecimal amount1 = incomeVO1.getAmount(); + tAmount4=tAmount4.add(amount1); } } + weekAmount.add(tAmount1); + weekAmount.add(tAmount2); + weekAmount.add(tAmount3); + weekAmount.add(tAmount4); monthlyData.put("weekIncome", Collections.singletonList(weekAmount)); LocalDateTime currentDateTime = LocalDateTime.now(); @@ -283,11 +355,6 @@ } monthlyData.put("dayIncome", Collections.singletonList(amountByDay)); - // 创建一个 Map 用于存储今年本周的累计 amount - Map<Integer, BigDecimal> dayToTotalAmountMap = new HashMap<>(); - BigDecimal yearAmount = BigDecimal.ZERO; // 初始化累加变量为0 - BigDecimal monthAmount = BigDecimal.ZERO; // 初始化累加变量为0 - BigDecimal todayAmount = BigDecimal.ZERO; // 初始化累加变量为0 // 获取当前日期和时间 LocalDateTime now = LocalDateTime.now(); // 今年的起始日期和结束日期 @@ -387,6 +454,13 @@ // 最后put monthlyData.put("yearMount",objects); + ArrayList<Object> integers = new ArrayList<>(); + int year = DateUtil.year(new Date()); + for (int i = 0; i < 10; i++) { + integers.add(year-i); + } + List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); + monthlyData.put("year",collect); return monthlyData; } @@ -468,44 +542,794 @@ return null; } + + + @Autowired + private TBackRecordService backRecordService; + + @RequestMapping(value = "/backPt") + @ResponseBody + public Object backPt(Integer type) { + HashMap<String, Object> map = new HashMap<>(); + List<Integer> userPt = appUserClient.getUserPt(Arrays.asList(1)); + if(userPt.size()==0){ + userPt.add(-1); + } + ArrayList<Object> integers = new ArrayList<>(); + int year = DateUtil.year(new Date()); + List<TBackRecord> thisYear = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, year).in(TBackRecord::getUserId,userPt)); + double sum5 = thisYear.stream().mapToDouble(TBackRecord::getMoney).sum(); + map.put("thisYear",sum5); + + List<TBackRecord> thisMonth = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, new SimpleDateFormat("yyyy-MM").format(new Date())).in(TBackRecord::getUserId,userPt)); + double sum6= thisMonth.stream().mapToDouble(TBackRecord::getMoney).sum(); + map.put("thisMonth",sum6); + + + + for (int i = 0; i < 10; i++) { + integers.add(year-i); + } + List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); + // 年 + ArrayList<Double> years = new ArrayList<>(); + for (Object o : collect) { + double sum=0.0; + String s = o.toString(); + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, s).in(TBackRecord::getUserId,userPt)); + sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + years.add(sum); + } + ArrayList<Double> months = new ArrayList<>(); + // 月 + for (int i = 1; i <= 12; i++) { + double sum=0.0; + String m=i+""; + if(i<10){ + m="0"+i; + } + String s = year + "-" + m; + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, s).in(TBackRecord::getUserId,userPt)); + sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + months.add(sum); + } + + // 获取最近四周 + LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); + LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); + // 周度数据 + String s1 = minNow.minusDays(6).toString(); + String s2 = maxNow.toString(); + + String s3 = minNow.minusDays(13).toString(); + String s4 = maxNow.minusDays(6).toString(); + + + String s5 = minNow.minusDays(20).toString(); + String s6 = maxNow.minusDays(13).toString(); + + String s7 = minNow.minusDays(27).toString(); + String s8 = maxNow.minusDays(20).toString(); + + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s7,s8).in(TBackRecord::getUserId,userPt)); + double sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + + List<TBackRecord> list1 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s5,s6).in(TBackRecord::getUserId,userPt)); + double sum1 = list1.stream().mapToDouble(TBackRecord::getMoney).sum(); + List<TBackRecord> list2 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s3,s4).in(TBackRecord::getUserId,userPt)); + double sum2 = list2.stream().mapToDouble(TBackRecord::getMoney).sum(); + List<TBackRecord> list3 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s1,s2).in(TBackRecord::getUserId,userPt)); + double sum3 = list3.stream().mapToDouble(TBackRecord::getMoney).sum(); + + map.put("thisWeek",sum3); + + ArrayList<Double> week = new ArrayList<>(); + week.add(sum); + week.add(sum1); + week.add(sum2); + week.add(sum3); + + // 日 + ArrayList<Double> days = new ArrayList<>(); + Double thisDay=0.0; + for (int i = 6; i >= 0; i--) { + String s = minNow.minusDays(i).toString(); + String s9 = maxNow.minusDays(i).toString(); + List<TBackRecord> day = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s,s9).in(TBackRecord::getUserId,userPt)); + double sum4 = day.stream().mapToDouble(TBackRecord::getMoney).sum(); + days.add(sum4); + if(i==0){ + thisDay=sum4; + } + } + + map.put("thisDay",thisDay); + map.put("yearData",years); + map.put("monthData",months); + map.put("weekData",week); + map.put("dayData",days); + + return map; + } + + @RequestMapping(value = "/backYys") + @ResponseBody + public Object backYys(Integer id) { + HashMap<String, Object> map = new HashMap<>(); + List<Integer> userPt = appUserClient.getUserYYs(id); + if(userPt.size()==0){ + userPt.add(-1); + } + ArrayList<Object> integers = new ArrayList<>(); + int year = DateUtil.year(new Date()); + List<TBackRecord> thisYear = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, year).in(TBackRecord::getUserId,userPt)); + double sum5 = thisYear.stream().mapToDouble(TBackRecord::getMoney).sum(); + map.put("thisYear",sum5); + + List<TBackRecord> thisMonth = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, new SimpleDateFormat("yyyy-MM").format(new Date())).in(TBackRecord::getUserId,userPt)); + double sum6= thisMonth.stream().mapToDouble(TBackRecord::getMoney).sum(); + map.put("thisMonth",sum6); + + + + for (int i = 0; i < 10; i++) { + integers.add(year-i); + } + List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); + // 年 + ArrayList<Double> years = new ArrayList<>(); + for (Object o : collect) { + double sum=0.0; + String s = o.toString(); + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, s).in(TBackRecord::getUserId,userPt)); + sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + years.add(sum); + } + ArrayList<Double> months = new ArrayList<>(); + // 月 + for (int i = 1; i <= 12; i++) { + double sum=0.0; + String m=i+""; + if(i<10){ + m="0"+i; + } + String s = year + "-" + m; + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, s).in(TBackRecord::getUserId,userPt)); + sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + months.add(sum); + } + + // 获取最近四周 + LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); + LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); + // 周度数据 + String s1 = minNow.minusDays(6).toString(); + String s2 = maxNow.toString(); + + String s3 = minNow.minusDays(13).toString(); + String s4 = maxNow.minusDays(6).toString(); + + + String s5 = minNow.minusDays(20).toString(); + String s6 = maxNow.minusDays(13).toString(); + + String s7 = minNow.minusDays(27).toString(); + String s8 = maxNow.minusDays(20).toString(); + + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s7,s8).in(TBackRecord::getUserId,userPt)); + double sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + + List<TBackRecord> list1 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s5,s6).in(TBackRecord::getUserId,userPt)); + double sum1 = list1.stream().mapToDouble(TBackRecord::getMoney).sum(); + List<TBackRecord> list2 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s3,s4).in(TBackRecord::getUserId,userPt)); + double sum2 = list2.stream().mapToDouble(TBackRecord::getMoney).sum(); + List<TBackRecord> list3 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s1,s2).in(TBackRecord::getUserId,userPt)); + double sum3 = list3.stream().mapToDouble(TBackRecord::getMoney).sum(); + + map.put("thisWeek",sum3); + + ArrayList<Double> week = new ArrayList<>(); + week.add(sum); + week.add(sum1); + week.add(sum2); + week.add(sum3); + + // 日 + ArrayList<Double> days = new ArrayList<>(); + Double thisDay=0.0; + for (int i = 6; i >= 0; i--) { + String s = minNow.minusDays(i).toString(); + String s9 = maxNow.minusDays(i).toString(); + List<TBackRecord> day = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s,s9).in(TBackRecord::getUserId,userPt)); + double sum4 = day.stream().mapToDouble(TBackRecord::getMoney).sum(); + days.add(sum4); + if(i==0){ + thisDay=sum4; + } + } + + map.put("thisDay",thisDay); + map.put("yearData",years); + map.put("monthData",months); + map.put("weekData",week); + map.put("dayData",days); + + return map; + } + @RequestMapping(value = "/backStore") + @ResponseBody + public Object backStore(Integer id) { + HashMap<String, Object> map = new HashMap<>(); + List<Integer> userPt = appUserClient.getUserStore(id); + if(userPt.size()==0){ + userPt.add(-1); + } + ArrayList<Object> integers = new ArrayList<>(); + int year = DateUtil.year(new Date()); + List<TBackRecord> thisYear = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, year).in(TBackRecord::getUserId,userPt)); + double sum5 = thisYear.stream().mapToDouble(TBackRecord::getMoney).sum(); + map.put("thisYear",sum5); + + List<TBackRecord> thisMonth = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, new SimpleDateFormat("yyyy-MM").format(new Date())).in(TBackRecord::getUserId,userPt)); + double sum6= thisMonth.stream().mapToDouble(TBackRecord::getMoney).sum(); + map.put("thisMonth",sum6); + + + + for (int i = 0; i < 10; i++) { + integers.add(year-i); + } + List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); + // 年 + ArrayList<Double> years = new ArrayList<>(); + for (Object o : collect) { + double sum=0.0; + String s = o.toString(); + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, s).in(TBackRecord::getUserId,userPt)); + sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + years.add(sum); + } + ArrayList<Double> months = new ArrayList<>(); + // 月 + for (int i = 1; i <= 12; i++) { + double sum=0.0; + String m=i+""; + if(i<10){ + m="0"+i; + } + String s = year + "-" + m; + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().like(TBackRecord::getTime, s).in(TBackRecord::getUserId,userPt)); + sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + months.add(sum); + } + + // 获取最近四周 + LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); + LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); + // 周度数据 + String s1 = minNow.minusDays(6).toString(); + String s2 = maxNow.toString(); + + String s3 = minNow.minusDays(13).toString(); + String s4 = maxNow.minusDays(6).toString(); + + + String s5 = minNow.minusDays(20).toString(); + String s6 = maxNow.minusDays(13).toString(); + + String s7 = minNow.minusDays(27).toString(); + String s8 = maxNow.minusDays(20).toString(); + + List<TBackRecord> list = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s7,s8).in(TBackRecord::getUserId,userPt)); + double sum = list.stream().mapToDouble(TBackRecord::getMoney).sum(); + + List<TBackRecord> list1 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s5,s6).in(TBackRecord::getUserId,userPt)); + double sum1 = list1.stream().mapToDouble(TBackRecord::getMoney).sum(); + List<TBackRecord> list2 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s3,s4).in(TBackRecord::getUserId,userPt)); + double sum2 = list2.stream().mapToDouble(TBackRecord::getMoney).sum(); + List<TBackRecord> list3 = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s1,s2).in(TBackRecord::getUserId,userPt)); + double sum3 = list3.stream().mapToDouble(TBackRecord::getMoney).sum(); + + map.put("thisWeek",sum3); + + ArrayList<Double> week = new ArrayList<>(); + week.add(sum); + week.add(sum1); + week.add(sum2); + week.add(sum3); + + // 日 + ArrayList<Double> days = new ArrayList<>(); + Double thisDay=0.0; + for (int i = 6; i >= 0; i--) { + String s = minNow.minusDays(i).toString(); + String s9 = maxNow.minusDays(i).toString(); + List<TBackRecord> day = backRecordService.list(new LambdaQueryWrapper<TBackRecord>().between(TBackRecord::getTime, s,s9).in(TBackRecord::getUserId,userPt)); + double sum4 = day.stream().mapToDouble(TBackRecord::getMoney).sum(); + days.add(sum4); + if(i==0){ + thisDay=sum4; + } + } + + map.put("thisDay",thisDay); + map.put("yearData",years); + map.put("monthData",months); + map.put("weekData",week); + map.put("dayData",days); + + return map; + } + + + @RequestMapping(value = "/userAndVipPt") + @ResponseBody + public Object userAndVipPt(Integer type) { + HashMap<String, Object> map = appUserClient.userAndVipPt(type); + return map; + } + @RequestMapping(value = "/actPt") + @ResponseBody + public Object actPt(Integer type) { + List<Integer> userPt = appUserClient.getUserPt(Arrays.asList(1)); + HashMap<String, Object> map = competitionClient.actPt(userPt); + + List<TStore> list = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getOperatorId, 0)); + for (TStore tStore : list) { + long l = DateUtil.betweenDay(tStore.getCreateTime(), new Date(), true); + tStore.getStartTime(); + } + return map; + } + + + /** * 跳转到运营商统计数据页面 */ @RequestMapping("/operator") public String operator(Model model) { Integer objectType = UserExt.getUser().getObjectType(); - List<CityManager> cityManagers = cityManagerClient.listAll(); - HashSet<String> city = new HashSet<>(); - List<CityManager> list = new ArrayList<>(); - for (CityManager cityManager : cityManagers) { - if (!city.contains(cityManager.getCity())){ - city.add(cityManager.getCity()); - list.add(cityManager); - } - } + List<TOperator> list = operatorService.list(new LambdaQueryWrapper<TOperator>().ne(TOperator::getState, 3)); model.addAttribute("list",list); model.addAttribute("objectType",objectType); return PREFIX + "operatorIncome.html"; } + + /** + * 运营商 + * @param + * @return + */ + @ResponseBody + @RequestMapping("/selectYys") + public Object selectYys(Integer id,String time) { + HashMap<String, Object> map = new HashMap<>(); + // 找出平台的用户 + List<User> list = sysUserService.list(new LambdaQueryWrapper<User>().eq(User::getObjectType, 2)); + List<Integer> ids = list.stream().map(User::getId).collect(Collectors.toList()); + List<Integer> userIds = appUserClient.getUserYYs(id); + QueryDataFee queryDataFee = new QueryDataFee(time, userIds); + // 会员费 + HashMap<String, Object> map1 = appUserClient.queryFee(queryDataFee); + Object fee1 = map1.get("fee1"); + + map.put("fee1",fee1); + //玩湃比 + Object fee2 = map1.get("fee2"); + map.put("fee2",fee2); + // 课程收入 + HashMap<String, Object> map3 = courseClient.queryFee(queryDataFee); + map.put("fee3",map3.get("fee")); + Object data = map3.get("data"); + map.put("courseData",data); + + + // 赛事收入 + Double aDouble1 = competitionClient.queryFee(queryDataFee); + map.put("fee4",aDouble1); + + // 订场 + if(ids.size()==0){ + ids.add(-1); + } + LambdaQueryWrapper<SiteBooking> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>(); + if(ToolUtil.isNotEmpty(time)){ + String stime = time.split(" - ")[0]+" 00:00:00"; + String etime = time.split(" - ")[1]+" 23:59:59"; + vipPaymentLambdaQueryWrapper.between(SiteBooking::getInsertTime,stime,etime); + } + if(userIds.size()==0){ + userIds.add(-1); + } + vipPaymentLambdaQueryWrapper.in(SiteBooking::getAppUserId,userIds); + vipPaymentLambdaQueryWrapper.ne(SiteBooking::getStatus,0); + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + objects.add(2); + vipPaymentLambdaQueryWrapper.in(SiteBooking::getPayType,objects); + List<SiteBooking> list1 = siteBookingService.list(vipPaymentLambdaQueryWrapper); + double sum = list1.stream().mapToDouble(SiteBooking::getPayMoney).sum(); + map.put("fee5",sum); + + + List<Integer> collect = list1.stream().map(SiteBooking::getSiteId).collect(Collectors.toList()); + if(collect.size()==0){ + collect.add(-1); + } + List<TSite> list3 = siteService.list(new LambdaQueryWrapper<TSite>().in(TSite::getId, collect)); + for (SiteBooking siteBooking : list1) { + for (TSite tSite : list3) { + if(siteBooking.getSiteId().equals(tSite.getId())){ + siteBooking.setType(tSite.getSiteTypeId()); + } + } + } + + + List<TSiteType> list2 = siteTypeService.list(); + + List<Map<String,Object>> mapList = new ArrayList<>(); + + for (TSiteType tSiteType : list2) { + HashMap<String, Object> map2 = new HashMap<>(); + map2.put("name",tSiteType.getName()); + double a =0; + for (SiteBooking siteBooking : list1) { + if(tSiteType.getId().equals(siteBooking.getType())){ + a += siteBooking.getPayMoney(); + } + } + map2.put("value",a); + mapList.add(map2); + } + map.put("siteData",mapList); + + + // 商品 门票 + HashMap<String, Object> map2 = pointMercharsClient.queryFee(queryDataFee); + Object all = map2.get("all"); + Object day = map2.get("day"); + Object month = map2.get("month"); + Object quarter = map2.get("quarter"); + Object year = map2.get("year"); + map.put("fee7",all); + map.put("dayone",day); + map.put("monthone",month); + map.put("quarterone",quarter); + map.put("yearone",year); + + return map; + } + + + + /** + * 运营商 + * @param + * @return + */ + @ResponseBody + @RequestMapping("/selectStore") + public Object selectStore(Integer id,String time) { + HashMap<String, Object> map = new HashMap<>(); + // 找出平台的用户 + List<User> list = sysUserService.list(new LambdaQueryWrapper<User>().eq(User::getObjectType, 2)); + List<Integer> ids = list.stream().map(User::getId).collect(Collectors.toList()); + List<Integer> userIds = appUserClient.getUserStore(id); + QueryDataFee queryDataFee = new QueryDataFee(time, userIds); + // 会员费 + HashMap<String, Object> map1 = appUserClient.queryFee(queryDataFee); + Object fee1 = map1.get("fee1"); + + map.put("fee1",fee1); + //玩湃比 + Object fee2 = map1.get("fee2"); + map.put("fee2",fee2); + // 课程收入 + HashMap<String, Object> map3 = courseClient.queryFee(queryDataFee); + map.put("fee3",map3.get("fee")); + Object data = map3.get("data"); + map.put("courseData",data); + + + // 赛事收入 + Double aDouble1 = competitionClient.queryFee(queryDataFee); + map.put("fee4",aDouble1); + + // 订场 + if(ids.size()==0){ + ids.add(-1); + } + LambdaQueryWrapper<SiteBooking> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>(); + if(ToolUtil.isNotEmpty(time)){ + String stime = time.split(" - ")[0]+" 00:00:00"; + String etime = time.split(" - ")[1]+" 23:59:59"; + vipPaymentLambdaQueryWrapper.between(SiteBooking::getInsertTime,stime,etime); + } + if(userIds.size()==0){ + userIds.add(-1); + } + vipPaymentLambdaQueryWrapper.in(SiteBooking::getAppUserId,userIds); + vipPaymentLambdaQueryWrapper.ne(SiteBooking::getStatus,0); + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + objects.add(2); + vipPaymentLambdaQueryWrapper.in(SiteBooking::getPayType,objects); + List<SiteBooking> list1 = siteBookingService.list(vipPaymentLambdaQueryWrapper); + double sum = list1.stream().mapToDouble(SiteBooking::getPayMoney).sum(); + map.put("fee5",sum); + + + List<Integer> collect = list1.stream().map(SiteBooking::getSiteId).collect(Collectors.toList()); + if(collect.size()==0){ + collect.add(-1); + } + List<TSite> list3 = siteService.list(new LambdaQueryWrapper<TSite>().in(TSite::getId, collect)); + for (SiteBooking siteBooking : list1) { + for (TSite tSite : list3) { + if(siteBooking.getSiteId().equals(tSite.getId())){ + siteBooking.setType(tSite.getSiteTypeId()); + } + } + } + + + List<TSiteType> list2 = siteTypeService.list(); + + List<Map<String,Object>> mapList = new ArrayList<>(); + + for (TSiteType tSiteType : list2) { + HashMap<String, Object> map2 = new HashMap<>(); + map2.put("name",tSiteType.getName()); + double a =0; + for (SiteBooking siteBooking : list1) { + if(tSiteType.getId().equals(siteBooking.getType())){ + a += siteBooking.getPayMoney(); + } + } + map2.put("value",a); + mapList.add(map2); + } + map.put("siteData",mapList); + + + // 商品 门票 + HashMap<String, Object> map2 = pointMercharsClient.queryFee(queryDataFee); + Object all = map2.get("all"); + Object day = map2.get("day"); + Object month = map2.get("month"); + Object quarter = map2.get("quarter"); + Object year = map2.get("year"); + map.put("fee7",all); + map.put("dayone",day); + map.put("monthone",month); + map.put("quarterone",quarter); + map.put("yearone",year); + + return map; + } + + /** * 跳转到门店统计数据页面 */ @RequestMapping("/store") public String store(Model model) { Integer objectType = UserExt.getUser().getObjectType(); - List<CityManager> cityManagers = cityManagerClient.listAll(); - HashSet<String> city = new HashSet<>(); - List<CityManager> list = new ArrayList<>(); - for (CityManager cityManager : cityManagers) { - if (!city.contains(cityManager.getCity())){ - city.add(cityManager.getCity()); - list.add(cityManager); - } - } + List<TStore> list = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getState, 1)); model.addAttribute("list",list); model.addAttribute("objectType",objectType); return PREFIX + "storeIncome.html"; } + + + @Autowired + private ITSiteTypeService siteTypeService; + + + @Autowired + private ITSiteService siteService; + + @RequestMapping("/type1") + @ResponseBody + public Object type1(String time) { + HashMap<String, Object> map = new HashMap<>(); + // 找出平台的用户 + List<User> list = sysUserService.list(new LambdaQueryWrapper<User>().eq(User::getObjectType, 1)); + List<Integer> ids = list.stream().map(User::getId).collect(Collectors.toList()); + List<Integer> userIds = appUserClient.getUserPt(ids); + QueryDataFee queryDataFee = new QueryDataFee(time, userIds); + // 会员费 + HashMap<String, Object> map1 = appUserClient.queryFee(queryDataFee); + Object fee1 = map1.get("fee1"); + + map.put("fee1",fee1); + //玩湃比 + Object fee2 = map1.get("fee2"); + map.put("fee2",fee2); + // 课程收入 + HashMap<String, Object> map3 = courseClient.queryFee(queryDataFee); + map.put("fee3",map3.get("fee")); + Object data = map3.get("data"); + map.put("courseData",data); + + + // 赛事收入 + Double aDouble1 = competitionClient.queryFee(queryDataFee); + map.put("fee4",aDouble1); + + // 订场 + if(ids.size()==0){ + ids.add(-1); + } + LambdaQueryWrapper<SiteBooking> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>(); + if(ToolUtil.isNotEmpty(time)){ + String stime = time.split(" - ")[0]+" 00:00:00"; + String etime = time.split(" - ")[1]+" 23:59:59"; + vipPaymentLambdaQueryWrapper.between(SiteBooking::getInsertTime,stime,etime); + } + if(userIds.size()==0){ + userIds.add(-1); + } + vipPaymentLambdaQueryWrapper.in(SiteBooking::getAppUserId,userIds); + vipPaymentLambdaQueryWrapper.ne(SiteBooking::getStatus,0); + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + objects.add(2); + vipPaymentLambdaQueryWrapper.in(SiteBooking::getPayType,objects); + List<SiteBooking> list1 = siteBookingService.list(vipPaymentLambdaQueryWrapper); + double sum = list1.stream().mapToDouble(SiteBooking::getPayMoney).sum(); + map.put("fee5",sum); + + + List<Integer> collect = list1.stream().map(SiteBooking::getSiteId).collect(Collectors.toList()); + if(collect.size()==0){ + collect.add(-1); + } + List<TSite> list3 = siteService.list(new LambdaQueryWrapper<TSite>().in(TSite::getId, collect)); + for (SiteBooking siteBooking : list1) { + for (TSite tSite : list3) { + if(siteBooking.getSiteId().equals(tSite.getId())){ + siteBooking.setType(tSite.getSiteTypeId()); + } + } + } + + + List<TSiteType> list2 = siteTypeService.list(); + + List<Map<String,Object>> mapList = new ArrayList<>(); + + for (TSiteType tSiteType : list2) { + HashMap<String, Object> map2 = new HashMap<>(); + map2.put("name",tSiteType.getName()); + double a =0; + for (SiteBooking siteBooking : list1) { + if(tSiteType.getId().equals(siteBooking.getType())){ + a += siteBooking.getPayMoney(); + } + } + map2.put("value",a); + mapList.add(map2); + } + map.put("siteData",mapList); + + + // 商品 门票 + HashMap<String, Object> map2 = pointMercharsClient.queryFee(queryDataFee); + Object all = map2.get("all"); + Object day = map2.get("day"); + Object month = map2.get("month"); + Object quarter = map2.get("quarter"); + Object year = map2.get("year"); + map.put("fee7",all); + map.put("dayone",day); + map.put("monthone",month); + map.put("quarterone",quarter); + map.put("yearone",year); + + return map; + } + @RequestMapping("/stuCourseData") + @ResponseBody + public Object stuCourseData() { + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + List<Integer> userIds = appUserClient.getUserPt(objects); + List<Map<String,Object>> list = coursePackagePaymentClient.queryCourseData(userIds); + ArrayList<Object> objects2 = new ArrayList<>(); + ArrayList<Object> objects3 = new ArrayList<>(); + for (Map<String, Object> map : list) { + Object name = map.get("name"); + Object value = map.get("value"); + objects2.add(name); + objects3.add(value); + } + HashMap<String, Object> map = new HashMap<>(); + map.put("data1",objects2); + map.put("data2",objects3); + return map; + } + @RequestMapping("/stuUserData") + @ResponseBody + public Object stuUserData() { + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + HashMap<String, Object> map = appUserClient.queryUserAge1(); + + return map; + } + @RequestMapping("/stuUserDataYys") + @ResponseBody + public Object stuUserDataYys(Integer id) { + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + HashMap<String, Object> map = appUserClient.queryUserAgeYys(id); + + return map; + } + @RequestMapping("/stuUserDataStore") + @ResponseBody + public Object stuUserDataStore(Integer id) { + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + HashMap<String, Object> map = appUserClient.queryUserAgeStore(id); + + return map; + } + @RequestMapping("/selectYysJx") + @ResponseBody + public Object selectYysJx(Integer id) { + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + HashMap<String, Object> map1 = appUserClient.queryUserAgeYys1(id); + // 找出运营商的用户 + List<Integer> userYYs = appUserClient.getUserYYs(id); + + + List<Map<String, Object>> mapList = coursePackagePaymentClient.queryCourseData(userYYs); + ArrayList<Object> objects2 = new ArrayList<>(); + ArrayList<Object> objects3 = new ArrayList<>(); + for (Map<String, Object> map : mapList) { + Object name = map.get("name"); + Object value = map.get("value"); + objects2.add(name); + objects3.add(value); + } + HashMap<String, Object> map = new HashMap<>(); + map1.put("data1",objects2); + map1.put("data2",objects3); + + + return map1; + } + @RequestMapping("/selectStoreJx") + @ResponseBody + public Object selectStoreJx(Integer id) { + ArrayList<Integer> objects = new ArrayList<>(); + objects.add(1); + HashMap<String, Object> map1 = appUserClient.queryUserAgeStore1(id); + // 找出运营商的用户 + List<Integer> userYYs = appUserClient.getUserYYs(id); + + + List<Map<String, Object>> mapList = coursePackagePaymentClient.queryCourseData(userYYs); + ArrayList<Object> objects2 = new ArrayList<>(); + ArrayList<Object> objects3 = new ArrayList<>(); + for (Map<String, Object> map : mapList) { + Object name = map.get("name"); + Object value = map.get("value"); + objects2.add(name); + objects3.add(value); + } + HashMap<String, Object> map = new HashMap<>(); + map1.put("data1",objects2); + map1.put("data2",objects3); + + + return map1; + } } -- Gitblit v1.7.1