package com.ruixuan.jiaoyang.controller; import com.alibaba.fastjson.JSONObject; import com.ruixuan.common.core.controller.BaseController; import com.ruixuan.common.core.page.TableDataInfo; import com.ruixuan.common.utils.Check; import com.ruixuan.common.utils.DateUtils; import com.ruixuan.jiaoyang.service.IJiaoYangReportService; import com.ruixuan.system.service.ISysDeptService; import com.ruixuan.system.service.ISysRoleService; import com.ruixuan.system.service.ISysUserService; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.text.SimpleDateFormat; import java.util.*; @RestController @RequestMapping("/jy/report") public class JiaoYangReportController extends BaseController { @Autowired private IJiaoYangReportService jiaoYangReportService; @Autowired private ISysRoleService sysRoleService; @Autowired private ISysDeptService sysDeptService; @Autowired private ISysUserService sysUserService; /** * 商品数据 * * @param itemId * @param itemTitle * @param orderStartDate * @param orderEndDate * @param fieId * @param sort * @return */ @GetMapping("/item") @ApiOperation(value = "商品列表") public TableDataInfo item( @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId, @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId, @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort) { Map requestMap = new HashMap<>(); if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } if (!Check.isNull(itemId)) { requestMap.put("itemId", itemId); } if (!Check.isNull(itemTitle)) { requestMap.put("itemTitle", itemTitle); } requestMap.put("fieId", fieId); requestMap.put("sort", sort); TableDataInfo dataInfo = new TableDataInfo(); if (Check.isNullMap(requestMap)) { dataInfo.setCode(-1); dataInfo.setMsg("入参不能为空"); return dataInfo; } startPage(); List list = jiaoYangReportService.item(requestMap); return getDataTable(list); } /** * 商品详情 * * @param itemId * @param orderStartDate * @param orderEndDate * @param promoterId * @param promoterNickName * @return */ @GetMapping("/itemDetail") @ApiOperation(value = "商品详情") public TableDataInfo itemDetail( @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId, @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId, @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName) { Map requestMap = new HashMap<>(); if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } if (!Check.isNull(promoterId)) { requestMap.put("promoterId", promoterId); } if (!Check.isNull(itemId)) { requestMap.put("itemId", itemId); } if (!Check.isNull(promoterNickName)) { requestMap.put("itemTitle", promoterNickName); } TableDataInfo dataInfo = new TableDataInfo(); if (Check.isNullMap(requestMap)) { dataInfo.setCode(-1); dataInfo.setMsg("入参不能为空"); return dataInfo; } startPage(); List list = jiaoYangReportService.itemDetail(requestMap); return getDataTable(list); } /** * 达人数据 * * @param orderStartDate * @param orderEndDate * @param promoterNickName * @param promoterId * @return */ @GetMapping("/promoter") @ApiOperation(value = "达人订单") public TableDataInfo promoter(@ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName, @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId, @ApiParam("类型") @RequestParam(value = "type", required = false) Long type, Long userId) { Map requestMap = new HashMap<>(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return getDataTable(new ArrayList()); } requestMap.put("promoterIds", promoterIds); } if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } if (!Check.isNull(promoterNickName)) { requestMap.put("promoterNickName", promoterNickName); } if (!Check.isNull(promoterId)) { requestMap.put("promoterId", promoterId); } if (!Check.isNull(type)) { requestMap.put("type", type); } TableDataInfo dataInfo = new TableDataInfo(); if (Check.isNullMap(requestMap)) { dataInfo.setCode(-1); dataInfo.setMsg("入参不能为空"); return dataInfo; } startPage(); List list = jiaoYangReportService.promoter(requestMap); return getDataTable(list); } /** * 达人带货详情 * * @param promoterId * @param orderStartDate * @param orderEndDate * @param itemTitle * @param itemId * @return */ @GetMapping("/promoterDetail") @ApiOperation(value = "达人带货详情") public TableDataInfo promoterDetail( @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId, @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle, @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId, Long userId) { Map requestMap = new HashMap<>(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return getDataTable(new ArrayList<>()); } requestMap.put("promoterIds", promoterIds); } if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } if (!Check.isNull(promoterId)) { requestMap.put("promoterId", promoterId); } if (!Check.isNull(itemId)) { requestMap.put("itemId", itemId); } if (!Check.isNull(itemTitle)) { requestMap.put("itemTitle", itemTitle); } TableDataInfo dataInfo = new TableDataInfo(); if (Check.isNullMap(requestMap)) { dataInfo.setCode(-1); dataInfo.setMsg("入参不能为空"); return dataInfo; } startPage(); List list = jiaoYangReportService.anchorOrderDetail(requestMap); return getDataTable(list); } @GetMapping("/promoterStatistics") @ApiOperation(value = "订单统计") public JSONObject promoterStatistics( @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId, @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,Long userId) { Map requestMap = new HashMap<>(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return new JSONObject(); } requestMap.put("promoterIds", promoterIds); } if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } if (!Check.isNull(promoterId)) { requestMap.put("promoterId", promoterId); } JSONObject returnJson = new JSONObject(); if (Check.isNullMap(requestMap)) { returnJson.put("code", -1); returnJson.put("message", "入参不能为空"); return returnJson; } List list = jiaoYangReportService.promoterStatistics(requestMap); returnJson.put("code", 0); returnJson.put("data", list); return returnJson; } @GetMapping("/getClipCooperation") public TableDataInfo list(String statDate, Long promoterId, String promoterName) { Long date = Long.valueOf(statDate.replace("-", "")); startPage(); List list = jiaoYangReportService.getClipCooperation(date, promoterId, promoterName); return getDataTable(list); } @GetMapping("/indexOrderInfo") @ApiOperation(value = "首页-订单数据") public JSONObject orderTotal( @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, @ApiParam("结束时间") @RequestParam(value = "userId", required = false) Long userId ) { Map requestMap = new HashMap<>(); JSONObject returnJson = new JSONObject(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return returnJson; } requestMap.put("promoterIds", promoterIds); } if (dateType == 0) { if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); //当天开始时间 requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); // 当天结束时间 requestMap.put("end", end); } JSONObject orderTotal = jiaoYangReportService.getOrderTotal(requestMap); returnJson.put("orderTotal", orderTotal); Integer hour = DateUtils.getNowHour() - 1; // 当前小时 if (hour >= 0) { JSONObject ratioJson = new JSONObject(); Long nowDate = DateUtils.strDateToInt(orderStartDate); Long yesDate = DateUtils.strDateToInt(DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1)); // 昨日日期 Map ratioMap = new HashMap<>(); ratioMap.put("nowDate", nowDate); ratioMap.put("yesDate", yesDate); ratioMap.put("hour", hour); Double ringRatio = jiaoYangReportService.getOrderTotalRatio(ratioMap); //环比 ratioJson.put("ringRatio", ringRatio); yesDate = DateUtils.strDateToInt(DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6)); // 昨日日期 ratioMap.put("yesDate", yesDate); Double yearRatio = jiaoYangReportService.getOrderTotalRatio(ratioMap); //同比 ratioJson.put("yearRatio", yearRatio); returnJson.put("ratio", ratioJson); } } else { if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); //昨日开始时间 requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); // 前日开始时间 requestMap.put("end", end); } JSONObject orderTotal = jiaoYangReportService.getOrderTotal(requestMap); returnJson.put("orderTotal", orderTotal); } return returnJson; } /** * 首页-服务费数据 * * @param dateType * @param orderStartDate * @param orderEndDate * @return */ @GetMapping("/indexServiceAmountInfo") @ApiOperation(value = "首页-服务费数据") public JSONObject indexServiceAmountInfo( @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, Long userId ) { Map requestMap = new HashMap<>(); JSONObject returnJson = new JSONObject(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return returnJson; } requestMap.put("promoterIds", promoterIds); } if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } JSONObject serviceAmountTotal = jiaoYangReportService.getServiceAmountTotal(requestMap); returnJson.put("serviceAmountTotal", serviceAmountTotal); return returnJson; } /** * 首页-金额数据 * * @param dateType * @param orderStartDate * @param orderEndDate * @return */ @GetMapping("/indexAmountInfo") @ApiOperation(value = "首页-金额数据") public JSONObject indexAmountInfo( @ApiParam("时间类型") @RequestParam(value = "dateType", required = false) Integer dateType, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, Long userId) { Map requestMap = new HashMap<>(); JSONObject returnJson = new JSONObject(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return returnJson; } requestMap.put("promoterIds", promoterIds); } if (dateType == 0) { if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); //当天开始时间 requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); // 当天结束时间 requestMap.put("end", end); } JSONObject amountTotal = jiaoYangReportService.getAmountTotal(requestMap); returnJson.put("amountTotal", amountTotal); Integer hour = DateUtils.getNowHour() - 1; // 当前小时 if (hour >= 0) { JSONObject amountRatioJson = new JSONObject(); Long nowDate = DateUtils.strDateToInt(orderStartDate); Long yesDate = DateUtils.strDateToInt(DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1)); // 昨日日期 Map ratioMap = new HashMap<>(); ratioMap.put("nowDate", nowDate); ratioMap.put("yesDate", yesDate); ratioMap.put("hour", hour); Double amountRingRatio = jiaoYangReportService.getAmountTotalRatio(ratioMap); //环比 amountRatioJson.put("amountRingRatio", amountRingRatio); yesDate = DateUtils.strDateToInt(DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -6)); // 昨日日期 ratioMap.put("yesDate", yesDate); Double amountYearRatio = jiaoYangReportService.getAmountTotalRatio(ratioMap); //同比 amountRatioJson.put("amountYearRatio", amountYearRatio); returnJson.put("amountRatio", amountRatioJson); } } else { if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); //昨日开始时间 requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); // 前日开始时间 requestMap.put("end", end); } JSONObject amountTotal = jiaoYangReportService.getAmountTotal(requestMap); returnJson.put("amountTotal", amountTotal); } return returnJson; } @GetMapping("/indexPromoterRank") @ApiOperation(value = "首页-达人排行") public TableDataInfo indexPromoterRank( @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate, @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId ) { Map requestMap = new HashMap<>(); /*String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return getDataTable( new ArrayList<>() ); } requestMap.put("promoterIds", promoterIds); }*/ if (dateType == 0) { if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); //当天开始时间 requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); // 当天结束时间 requestMap.put("end", end); } Integer hour = DateUtils.getNowHour(); // 当前小时 Long nowDate = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳 Long yesDate = DateUtils.strDateToInt(DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1)); // 昨日日期 requestMap.put("nowDate", nowDate); requestMap.put("hour", hour); requestMap.put("yesDate", yesDate); startPage(); List promoterRankRatioList = jiaoYangReportService.getPromoterRankRatioList(requestMap); return getDataTable(promoterRankRatioList); } else { if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } startPage(); List orderRatioList = jiaoYangReportService.getPromoterRatioList(requestMap); return getDataTable(orderRatioList); } } /** * 首页-商品排行 * * @param dateType * @param orderStartDate * @param orderEndDate * @return */ @GetMapping("/indexOrderRank") @ApiOperation(value = "首页-商品排行") public TableDataInfo indexOrderRank( @ApiParam("时间类型") @RequestParam(value = "dateType", required = true) Integer dateType, @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = true) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = true) String orderEndDate) { Map requestMap = new HashMap<>(); if (dateType == 0) { Integer hour = DateUtils.getNowHour(); // 当前小时 Long nowDate = DateUtils.strDateToInt(orderStartDate); // 当天开始时间戳 Long yesDate = DateUtils.strDateToInt(DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1)); // 昨日日期 requestMap.put("nowDate", nowDate); requestMap.put("yesDate", yesDate); requestMap.put("hour", hour); startPage(); List orderRankRatioList = jiaoYangReportService.getOrderRankRatioList(requestMap); return getDataTable(orderRankRatioList); } else { if (!Check.isNull(orderStartDate)) { Long start = DateUtils.strDateToInt(orderStartDate); requestMap.put("start", start); } if (!Check.isNull(orderEndDate)) { Long end = DateUtils.strDateToInt(orderEndDate); requestMap.put("end", end); } startPage(); List orderRankRatioList = jiaoYangReportService.getOrderRankList(requestMap); return getDataTable(orderRankRatioList); } } /** * 首页-统计图 * * @param orderStartDate * @param orderEndDate * @param type * @return */ @GetMapping("/indexStatistics") @ApiOperation(value = "首页-统计图") public List indexStatistics( @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, @ApiParam("类型") @RequestParam(value = "type", required = false) String type, Long userId) { Map requestMap = new HashMap<>(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return new ArrayList<>(); } requestMap.put("promoterIds", promoterIds); } String nowDate = DateUtils.getNowDateStr(); Long start = null; Long end = null; if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) { String endStr = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); end = DateUtils.strDateToInt(endStr); start = DateUtils.strDateToInt(DateUtils.getAnotherDay("yyyy-MM-dd", endStr, -6)); } else { start = DateUtils.strDateToInt(orderStartDate); end = DateUtils.strDateToInt(orderEndDate); } if (!Check.isNull(start)) { requestMap.put("start", start); } if (!Check.isNull(end)) { requestMap.put("end", end); } if (!Check.isNull(type)) { requestMap.put("type", type); } List list = jiaoYangReportService.indexStatistics(requestMap); return list; } /** * 首页-时段对比 * * @param orderStartDate * @param orderEndDate * @return */ @SneakyThrows @GetMapping("/indexTimeIntervalRatio") @ApiOperation(value = "首页-时段对比") public JSONObject indexTimeIntervalRatio( @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate, @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, Long userId ) { Map requestMap = new HashMap<>(); String roleId = sysRoleService.getRoleBYUserId(userId); if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) { List userIds = new ArrayList<>(); if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId)) { Long deptId = sysDeptService.getDeptIdByUserId(userId); userIds = sysDeptService.getDeptUserListByDeptId(deptId); } else { userIds.add(userId); } List promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds); if (Check.isNull(promoterIds)) { return new JSONObject(); } requestMap.put("promoterIds", promoterIds); } String nowDate = DateUtils.getNowDateStr(); String thisCycleEnd = null; // 当前时段结束日期 String thisCycleStart = null; // 当前时段开始日期 String lastCycleEnd = null; // 上一时段结束日期 String lastCycleStart = null; // 上一时段开始日期 if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) { thisCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); thisCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleEnd, -6); lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleStart, -1); lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -6); } else { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(orderStartDate), simpleDateFormat.parse(orderEndDate)); thisCycleEnd = orderEndDate; thisCycleStart = orderStartDate; lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1); lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -differDay); } if (!Check.isNull(thisCycleStart)) { Long thisCycleStartTemp = DateUtils.strDateToInt(thisCycleStart); requestMap.put("thisCycleStartTemp", thisCycleStartTemp); } if (!Check.isNull(thisCycleEnd)) { Long thisCycleEndTemp = DateUtils.strDateToInt(thisCycleEnd); requestMap.put("thisCycleEndTemp", thisCycleEndTemp); } if (!Check.isNull(lastCycleStart)) { Long lastCycleStartTemp = DateUtils.strDateToInt(lastCycleStart); requestMap.put("lastCycleStartTemp", lastCycleStartTemp); } if (!Check.isNull(lastCycleEnd)) { Long lastCycleEndTemp = DateUtils.strDateToInt(lastCycleEnd); requestMap.put("lastCycleEndTemp", lastCycleEndTemp); } JSONObject timeIntervalRatioJson = jiaoYangReportService.getTimeIntervalRatio(requestMap); return timeIntervalRatioJson; } }