liujie
2023-10-08 35d72e26dc2b3159021636dc1e540da0a8735b4e
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/DataStatisticsController.java
@@ -3,6 +3,7 @@
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.QueryDataFee;
import com.dsh.course.feignClient.account.model.TAppUser;
import com.dsh.course.feignClient.account.model.VipPayment;
import com.dsh.course.feignClient.activity.PointMercharsClient;
@@ -18,8 +19,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 +52,14 @@
    private ICityService cityService;
    @Autowired
    private CityManagerClient cityManagerClient;
    @Autowired
    private IUserService sysUserService;
    @Autowired
    private AppUserClient appUserClient;
    @Autowired
    private CourseClient courseClient;
    @Autowired
    private VipPaymentClient vipPaymentClient;
    @Autowired
@@ -60,6 +68,9 @@
    private CoursePackagePaymentClient coursePackagePaymentClient;
    @Autowired
    private CompetitionClient competitionClient;
    @Autowired
    private ISiteBookingService siteBookingService;
    @Autowired
    private StoreClient storeClient;
    @Autowired
@@ -77,6 +88,17 @@
     */
    @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";
    }
@@ -506,6 +528,135 @@
        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;
    }
}