|
@@ -1,10 +1,8 @@
|
|
|
package com.book.server.controller;
|
|
|
|
|
|
import com.book.dao.VO.SunVO;
|
|
|
-import com.book.dao.polardb.entity.SunChannel;
|
|
|
-import com.book.dao.polardb.entity.SunOrder;
|
|
|
-import com.book.dao.polardb.entity.SunOrderCollect;
|
|
|
-import com.book.dao.polardb.entity.SunUserCollect;
|
|
|
+import com.book.dao.polardb.entity.*;
|
|
|
+import com.book.dao.utils.TimeUtil;
|
|
|
import com.book.server.common.entity.PageResult;
|
|
|
import com.book.server.common.entity.Result;
|
|
|
import com.book.server.config.SunTypeEnum;
|
|
@@ -13,10 +11,16 @@ import com.book.server.vo.SunNotifyRequest;
|
|
|
import com.book.server.vo.SunRequest;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.websocket.server.PathParam;
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
@@ -36,6 +40,7 @@ public class SunDataController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* getData
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @param request
|
|
|
* @return
|
|
@@ -49,6 +54,7 @@ public class SunDataController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* pullData
|
|
|
+ *
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
@@ -106,6 +112,7 @@ public class SunDataController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 统计某天的订单
|
|
|
+ *
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
@@ -117,6 +124,7 @@ public class SunDataController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 获取今天订单统计
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getTodayOrderStatic")
|
|
@@ -126,6 +134,7 @@ public class SunDataController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 获取今天订单统计按渠道
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getTodayOrderStaticByChannel")
|
|
@@ -133,8 +142,98 @@ public class SunDataController extends BaseController {
|
|
|
return Result.success(sunDataService.getTodayOrderStaticByChannel());
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/exportTodayOrderStaticByChannel")
|
|
|
+ public void exportTodayOrderStaticByChannel(HttpServletResponse response) throws UnsupportedEncodingException {
|
|
|
+ List<SunStaticOrderDayChannel> list = sunDataService.getTodayOrderStaticByChannel();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出
|
|
|
+ */
|
|
|
+ response.setContentType("text/plain");
|
|
|
+ String fileName = TimeUtil.getTodayStr() + UUID.randomUUID() + ".csv";
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
|
|
|
+
|
|
|
+ BufferedOutputStream buff = null;
|
|
|
+ StringBuffer write = new StringBuffer();
|
|
|
+ String enter = "\r\n";
|
|
|
+ ServletOutputStream outSTr = null;
|
|
|
+ try {
|
|
|
+ outSTr = response.getOutputStream();
|
|
|
+ buff = new BufferedOutputStream(outSTr);
|
|
|
+ // 把内容写入文件
|
|
|
+ if (list.size() > 0) {
|
|
|
+ // 添加表头
|
|
|
+ write.append("日期,渠道 Id,渠道名称,活跃用户数,充值用户数,充值金额,充值笔数,充值人均");
|
|
|
+ write.append(enter);
|
|
|
+
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ SunStaticOrderDayChannel text = list.get(i);
|
|
|
+ write.append(text.getStaticDate() + "," + text.getChannelId() + ","+ text.getChannelName() + ","+ text.getActiveCount() + "," + text.getRechargeUserCount() + "," + text.getRechargeSum() + "," + text.getRechargeCount() + "," + text.getRechargeAvg());
|
|
|
+ write.append(enter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ buff.write(write.toString().getBytes("UTF-8"));
|
|
|
+ buff.flush();
|
|
|
+ buff.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ buff.close();
|
|
|
+ outSTr.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/exportOrderStaticAll")
|
|
|
+ public void exportTodayOrderStatic(HttpServletResponse response) throws UnsupportedEncodingException {
|
|
|
+ List<SunStaticOrderDay> list = sunDataService.getOrderStaticsAll();
|
|
|
+ /**
|
|
|
+ * 导出
|
|
|
+ */
|
|
|
+ response.setContentType("text/plain");
|
|
|
+ String fileName = TimeUtil.getTodayStr() + UUID.randomUUID() + ".csv";
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
|
|
|
+
|
|
|
+ BufferedOutputStream buff = null;
|
|
|
+ StringBuffer write = new StringBuffer();
|
|
|
+ String enter = "\r\n";
|
|
|
+ ServletOutputStream outSTr = null;
|
|
|
+ try {
|
|
|
+ outSTr = response.getOutputStream();
|
|
|
+ buff = new BufferedOutputStream(outSTr);
|
|
|
+ // 把内容写入文件
|
|
|
+ if (list.size() > 0) {
|
|
|
+ // 添加表头
|
|
|
+ write.append("日期,活跃用户数,充值用户数,充值金额,充值笔数,充值人均");
|
|
|
+ write.append(enter);
|
|
|
+
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ SunStaticOrderDay text = list.get(i);
|
|
|
+ write.append(text.getStaticDate() + "," + text.getActiveCount() + "," + text.getRechargeUserCount() + "," + text.getRechargeSum() + "," + text.getRechargeCount() + "," + text.getRechargeAvg());
|
|
|
+ write.append(enter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ buff.write(write.toString().getBytes("UTF-8"));
|
|
|
+ buff.flush();
|
|
|
+ buff.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ buff.close();
|
|
|
+ outSTr.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取昨天订单统计
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getYesterdayOrderStatic")
|
|
@@ -144,6 +243,7 @@ public class SunDataController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 获取历史订单统计
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getHistoryOrderStatic")
|
|
@@ -153,19 +253,22 @@ public class SunDataController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 订单统计-按天排序
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getOrderStatics")
|
|
|
- public Result getOrderStatics(int page,int size) {
|
|
|
- return Result.success(sunDataService.getOrderStatics(page,size));
|
|
|
+ public Result getOrderStatics(int page, int size) {
|
|
|
+ return Result.success(sunDataService.getOrderStatics(page, size));
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 订单统计-渠道-按天查询
|
|
|
+ * 订单统计-按天查询
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getOrderStaticByDateAndChannel")
|
|
|
- public Result getOrderStaticByDateAndChannel(String date,String channelId) {
|
|
|
- return Result.success(sunDataService.getOrderStaticByDateAndChannel(date,channelId));
|
|
|
+ public Result getOrderStaticByDateAndChannel(String date) {
|
|
|
+ return Result.success(sunDataService.getOrderStaticByDateAndChannel(date));
|
|
|
}
|
|
|
|
|
|
|