|
@@ -8,12 +8,15 @@ import com.ruixuan.common.utils.DateUtils;
|
|
|
import com.ruixuan.jiaoyang.service.IJiaoYangReportService;
|
|
|
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.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -262,4 +265,332 @@ public class JiaoYangReportController extends BaseController {
|
|
|
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) {
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
+ 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) {
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
+
|
|
|
+ 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) {
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
+ 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,
|
|
|
+ @ApiParam("媒体,1-抖音;2-快手") @RequestParam(value = "mediaId", required = false) String mediaId
|
|
|
+ ) {
|
|
|
+
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ 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) {
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ 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) {
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|