123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- 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<String, Object> 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<JSONObject> 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<String, Object> 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<JSONObject> 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<String, Object> 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<Long> 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<Long> promoterIds = jiaoYangReportService.getPromoterIdsByUserIds(userIds);
- if (Check.isNull(promoterIds)) {
- return getDataTable(new ArrayList<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(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<JSONObject> 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<String, Object> 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<Long> 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<Long> 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<JSONObject> 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<String, Object> 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<Long> 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<Long> 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<JSONObject> 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<JSONObject> 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<String, Object> 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<Long> 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<Long> 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<String, Object> 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<String, Object> 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<Long> 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<Long> 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<String, Object> 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<Long> 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<Long> 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<String, Object> 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<String, Object> 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<Long> 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<Long> 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<JSONObject> 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<JSONObject> 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<String, Object> 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<JSONObject> 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<JSONObject> orderRankRatioList = jiaoYangReportService.getOrderRankList(requestMap);
- return getDataTable(orderRankRatioList);
- }
- }
- /**
- * 首页-统计图
- *
- * @param orderStartDate
- * @param orderEndDate
- * @param type
- * @return
- */
- @GetMapping("/indexStatistics")
- @ApiOperation(value = "首页-统计图")
- public List<JSONObject> 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<String, Object> 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<Long> 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<Long> 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<JSONObject> 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<String, Object> 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<Long> 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<Long> 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;
- }
- }
|