|
@@ -0,0 +1,921 @@
|
|
|
+package com.hboxs.control.admin;
|
|
|
+
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
+import com.hboxs.common.Filter;
|
|
|
+import com.hboxs.common.JsonMessage;
|
|
|
+import com.hboxs.common.Pageable;
|
|
|
+import com.hboxs.common.utils.AdminUtils;
|
|
|
+import com.hboxs.dto.AdminStatisticsDTO;
|
|
|
+import com.hboxs.dto.OrderStatisticsDTO;
|
|
|
+import com.hboxs.entity.Admin;
|
|
|
+import com.hboxs.excel.AdminStatisticsTarget;
|
|
|
+import com.hboxs.excel.CoinStaticsTarget;
|
|
|
+import com.hboxs.excel.OrderStaticsTarget;
|
|
|
+import com.hboxs.excel.ProductStaticTarget;
|
|
|
+import com.hboxs.service.AdminService;
|
|
|
+import com.hboxs.service.CoinOrderService;
|
|
|
+import com.hboxs.service.OrderService;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 统计数据
|
|
|
+ */
|
|
|
+@Controller("orderStatisticsController")
|
|
|
+@RequestMapping("/asl-admin/orderStatistics")
|
|
|
+public class OrderStatisticsController extends BaseController {
|
|
|
+
|
|
|
+ @Resource(name = "orderServiceImpl")
|
|
|
+ private OrderService orderService;
|
|
|
+ @Resource(name = "adminServiceImpl")
|
|
|
+ private AdminService adminService;
|
|
|
+
|
|
|
+ @Resource(name = "coinOrderServiceImpl")
|
|
|
+ private CoinOrderService coinOrderService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单汇总统计,包括所有下级的下级
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
+ public String summaryStatistics(@RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, @RequestParam(value = "unit", defaultValue = "0") Integer unit, String productName, String name, Pageable pageable, ModelMap model, String clientId) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查找商家名称
|
|
|
+ List<Filter> filters = pageable.getFilters();
|
|
|
+ //商家的所有id
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ List<Admin> admins1 = null;
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ filters.add(Filter.like("username", "%" + name + "%"));
|
|
|
+ }
|
|
|
+ admins1 = adminService.findPage(pageable).getContent();
|
|
|
+ if (admins1.size() == 0) {
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("unit", unit);
|
|
|
+ model.addAttribute("productName", productName);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("msg", "找不到此商家");
|
|
|
+ return "/admin/orderStatistics/summaryStatistics";
|
|
|
+
|
|
|
+ }
|
|
|
+ if (admins1 != null) {
|
|
|
+ for (Admin admin1 : admins1) {
|
|
|
+ longs.add(admin1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<OrderStatisticsDTO> list = orderService.findByTime(type, begin, end, unit, productName, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("unit", unit);
|
|
|
+ model.addAttribute("productName", productName);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("list", list);
|
|
|
+ return "/admin/orderStatistics/summaryStatistics";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计商家增长记录
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param beginEndDate
|
|
|
+ * @param unit
|
|
|
+ * @param pageable
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/adminStatistics", method = RequestMethod.GET)
|
|
|
+ public String adminStatistics(@RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, @RequestParam(value = "unit", defaultValue = "0") Integer unit, Pageable pageable, ModelMap model) {
|
|
|
+ String admintype = adminService.getCurrent().getType().toValue();
|
|
|
+ model.addAttribute("adminType", admintype);
|
|
|
+ if (type == null) {
|
|
|
+ type = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<AdminStatisticsDTO> list = adminService.findByTime(begin, end, type, unit, lowerIds);
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("unit", unit);
|
|
|
+ model.addAttribute("list", list);
|
|
|
+ return "/admin/orderStatistics/adminStatistics";
|
|
|
+ }
|
|
|
+
|
|
|
+ //按花型统计
|
|
|
+ @RequestMapping(value = "/productStatistic", method = RequestMethod.GET)
|
|
|
+ public String productStatistic(@RequestParam(value = "statisticType", defaultValue = "0") Integer statisticType, @RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, Pageable pageable, ModelMap model, String clientId, String name) {
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+ String admintype = admin.getType().toValue();
|
|
|
+ model.addAttribute("adminType", admintype);
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查找商家名称
|
|
|
+ List<Filter> filters = pageable.getFilters();
|
|
|
+ //商家的所有id
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ List<Admin> admins1 = null;
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ filters.add(Filter.like("username", "%" + name + "%"));
|
|
|
+ }
|
|
|
+ admins1 = adminService.findList(null, filters, null);
|
|
|
+ if (admins1.size() == 0) {
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("msg", "找不到此商家");
|
|
|
+ model.addAttribute("statisticType", statisticType);
|
|
|
+ return "/admin/orderStatistics/productStatistics";
|
|
|
+ }
|
|
|
+ if (admins1 != null) {
|
|
|
+ for (Admin admin1 : admins1) {
|
|
|
+ longs.add(admin1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //List<OrderStatisticsDTO> list = orderService.findByTime(type, begin, end, unit, productName, lowerIds, longs.toArray(new Long[longs.size()]));
|
|
|
+ //List<OrderStatisticsDTO> list = orderService.findByProduct(type, begin, end, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+ List<OrderStatisticsDTO> list = orderService.findByProduct(statisticType, type, begin, end, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("list", list);
|
|
|
+ model.addAttribute("statisticType", statisticType);
|
|
|
+ return "/admin/orderStatistics/productStatistics";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单统计,不包括下级
|
|
|
+ *
|
|
|
+ * @param beginEndDate
|
|
|
+ * @param pageable
|
|
|
+ * @param model
|
|
|
+ * @param managerId 管理系统ID
|
|
|
+ * @param clientId
|
|
|
+ * @param unit
|
|
|
+ * @param productName 产品名称
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/orderStatistic", method = RequestMethod.GET)
|
|
|
+ public String orderStatistic(String beginEndDate, Pageable pageable, ModelMap model, String managerId, String clientId, @RequestParam(value = "unit", defaultValue = "0") Integer unit, String productName) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+ String admintype = admin.getType().toValue();
|
|
|
+ model.addAttribute("adminType", admintype);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(managerId)) {
|
|
|
+ managerId = AdminUtils.encrypt(false, admin.getId());
|
|
|
+ }
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+ Long[] lowerIds = new Long[1];
|
|
|
+ for (Admin admin1 : admins) {
|
|
|
+ if (admin1.getId() == AdminUtils.decrypt(false, managerId)) {
|
|
|
+ Long id = admin1.getId();
|
|
|
+ lowerIds[0] = admin1.getId();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<OrderStatisticsDTO> list = orderService.findByManagerId(unit, begin, end, lowerIds[0], clientId, productName);
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("managerId", managerId);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("unit", unit);
|
|
|
+ model.addAttribute("productName", productName);
|
|
|
+ model.addAttribute("list", list);
|
|
|
+ return "/admin/orderStatistics/orderStatistics";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 线下汇总统计
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param beginEndDate
|
|
|
+ * @param unit
|
|
|
+ * @param productName
|
|
|
+ * @param name
|
|
|
+ * @param pageable
|
|
|
+ * @param model
|
|
|
+ * @param clientId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/coinStatistics/{payType}", method = RequestMethod.GET)
|
|
|
+ public String coinStatistics(@PathVariable Integer payType, @RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, @RequestParam(value = "unit", defaultValue = "0") Integer unit, String productName, String name, Pageable pageable, ModelMap model, String clientId) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查找商家名称
|
|
|
+ List<Filter> filters = pageable.getFilters();
|
|
|
+ //商家的所有id
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ List<Admin> admins1 = null;
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ filters.add(Filter.like("username", "%" + name + "%"));
|
|
|
+ }
|
|
|
+ admins1 = adminService.findPage(pageable).getContent();
|
|
|
+ if (admins1.size() == 0) {
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("unit", unit);
|
|
|
+ model.addAttribute("productName", productName);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("msg", "找不到此商家");
|
|
|
+ model.addAttribute("payType", payType);
|
|
|
+
|
|
|
+ return "/admin/orderStatistics/coinStatistics";
|
|
|
+
|
|
|
+ }
|
|
|
+ if (admins1 != null) {
|
|
|
+ for (Admin admin1 : admins1) {
|
|
|
+ longs.add(admin1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<OrderStatisticsDTO> list = coinOrderService.findByTime(payType, type, begin, end, unit, productName, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("unit", unit);
|
|
|
+ model.addAttribute("productName", productName);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("list", list);
|
|
|
+ model.addAttribute("payType", payType);
|
|
|
+
|
|
|
+ return "/admin/orderStatistics/coinStatistics";
|
|
|
+ }
|
|
|
+
|
|
|
+ //线下花型统计
|
|
|
+ @RequestMapping(value = "/coinProductStatistics/{payType}", method = RequestMethod.GET)
|
|
|
+ public String coinProductStatistics(@PathVariable Integer payType, @RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, Pageable pageable, ModelMap model, String clientId, String name) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+ String admintype = admin.getType().toValue();
|
|
|
+ model.addAttribute("adminType", admintype);
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查找商家名称
|
|
|
+ List<Filter> filters = pageable.getFilters();
|
|
|
+ //商家的所有id
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ List<Admin> admins1 = null;
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ filters.add(Filter.like("username", "%" + name + "%"));
|
|
|
+ }
|
|
|
+ admins1 = adminService.findList(null, filters, null);
|
|
|
+ if (admins1.size() == 0) {
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("msg", "找不到此商家");
|
|
|
+ model.addAttribute("payType", payType);
|
|
|
+ return "/admin/orderStatistics/coinProductStatistics";
|
|
|
+ }
|
|
|
+ if (admins1 != null) {
|
|
|
+ for (Admin admin1 : admins1) {
|
|
|
+ longs.add(admin1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<OrderStatisticsDTO> list = coinOrderService.findByProduct(payType, type, begin, end, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+ model.addAttribute("beginEndDate", beginEndDate);
|
|
|
+ model.addAttribute("type", type);
|
|
|
+ model.addAttribute("name", name);
|
|
|
+ model.addAttribute("clientId", clientId);
|
|
|
+ model.addAttribute("list", list);
|
|
|
+ model.addAttribute("payType", payType);
|
|
|
+
|
|
|
+ return "/admin/orderStatistics/coinProductStatistics";
|
|
|
+ }
|
|
|
+
|
|
|
+ //花型统计导出
|
|
|
+ @RequestMapping(value = "/export", method = RequestMethod.GET)
|
|
|
+ public Object export(HttpServletResponse response, @RequestParam(value = "statisticType", defaultValue = "0") Integer statisticType, @RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, Pageable pageable, ModelMap model, String clientId, String name) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+ String admintype = admin.getType().toValue();
|
|
|
+ model.addAttribute("adminType", admintype);
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查找商家名称
|
|
|
+ List<Filter> filters = pageable.getFilters();
|
|
|
+ //商家的所有id
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ List<Admin> admins1 = null;
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ filters.add(Filter.like("username", "%" + name + "%"));
|
|
|
+ }
|
|
|
+ admins1 = adminService.findList(null, filters, null);
|
|
|
+
|
|
|
+ if (admins1 != null) {
|
|
|
+ for (Admin admin1 : admins1) {
|
|
|
+ longs.add(admin1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<OrderStatisticsDTO> list = orderService.findByProduct(statisticType, type, begin, end, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+ //判断是否是导出请求
|
|
|
+ ArrayList<ProductStaticTarget> productStaticTargets = new ArrayList<>();
|
|
|
+ for (OrderStatisticsDTO orderStatisticsDTO : list) {
|
|
|
+ ProductStaticTarget productStaticTarget = new ProductStaticTarget();
|
|
|
+ productStaticTarget.setProductName(orderStatisticsDTO.getProductName());
|
|
|
+ productStaticTarget.setTotalNumber(orderStatisticsDTO.getTotalNumber());
|
|
|
+ productStaticTarget.setStaticTime(beginEndDate);
|
|
|
+ productStaticTargets.add(productStaticTarget);
|
|
|
+ }
|
|
|
+ ExportParams params = new ExportParams("花型统计", beginEndDate);
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params, ProductStaticTarget.class, productStaticTargets);
|
|
|
+
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("花型统计记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //商家增长统计导出
|
|
|
+ @RequestMapping(value = "/exportAdminStatics", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Object exportAdminStatics(HttpServletResponse response, @RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, @RequestParam(value = "unit", defaultValue = "0") Integer unit, Pageable pageable, ModelMap model) {
|
|
|
+ String admintype = adminService.getCurrent().getType().toValue();
|
|
|
+ model.addAttribute("adminType", admintype);
|
|
|
+ if (type == null) {
|
|
|
+ type = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<AdminStatisticsDTO> list = adminService.findByTime(begin, end, type, unit, lowerIds);
|
|
|
+ ArrayList<AdminStatisticsTarget> adminStatisticsTargets = new ArrayList<>();
|
|
|
+ for (AdminStatisticsDTO adminStatisticsDTO : list) {
|
|
|
+ AdminStatisticsTarget adminStatisticsTarget = new AdminStatisticsTarget();
|
|
|
+ adminStatisticsTarget.setsTime(adminStatisticsDTO.getsTime());
|
|
|
+ adminStatisticsTarget.setTotalNumber(adminStatisticsDTO.getTotalNumber());
|
|
|
+ adminStatisticsTargets.add(adminStatisticsTarget);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ExportParams params = new ExportParams("商家增长统计", beginEndDate);
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params, AdminStatisticsTarget.class, adminStatisticsTargets);
|
|
|
+
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("商家增长统计记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ //线下汇总统计导出
|
|
|
+ @RequestMapping(value = "/exportCoinStatistics/{payType}", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Object exportCoinStatistics(HttpServletResponse response, @PathVariable Integer payType, @RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, @RequestParam(value = "unit", defaultValue = "0") Integer unit, String productName, String name, Pageable pageable, ModelMap model, String clientId) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查找商家名称
|
|
|
+ List<Filter> filters = pageable.getFilters();
|
|
|
+ //商家的所有id
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ List<Admin> admins1 = null;
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ filters.add(Filter.like("username", "%" + name + "%"));
|
|
|
+ }
|
|
|
+ admins1 = adminService.findPage(pageable).getContent();
|
|
|
+
|
|
|
+ if (admins1 != null) {
|
|
|
+ for (Admin admin1 : admins1) {
|
|
|
+ longs.add(admin1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<OrderStatisticsDTO> list = coinOrderService.findByTime(payType, type, begin, end, unit, productName, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+ ArrayList<CoinStaticsTarget> coinStaticsTargets = new ArrayList<>();
|
|
|
+ for (OrderStatisticsDTO orderStatisticsDTO : list) {
|
|
|
+ CoinStaticsTarget target = new CoinStaticsTarget();
|
|
|
+ target.setsTime(orderStatisticsDTO.getsTime());
|
|
|
+ target.setTotalNumber(orderStatisticsDTO.getTotalNumber());
|
|
|
+ target.setTotalPrice(orderStatisticsDTO.getTotalPrice());
|
|
|
+ coinStaticsTargets.add(target);
|
|
|
+
|
|
|
+ }
|
|
|
+ String title = payType == 0 ? "无需支付汇总统计" : "投币汇总统计";
|
|
|
+ ExportParams params = new ExportParams(title, beginEndDate);
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params, CoinStaticsTarget.class, coinStaticsTargets);
|
|
|
+
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(title + "记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //订单统计导出
|
|
|
+ @RequestMapping(value = "/exportOrderStatistic", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Object exportOrderStatistic(HttpServletResponse response, String beginEndDate, Pageable pageable, ModelMap model, String managerId, String clientId, @RequestParam(value = "unit", defaultValue = "0") Integer unit, String productName) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+ String admintype = admin.getType().toValue();
|
|
|
+ model.addAttribute("adminType", admintype);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(managerId)) {
|
|
|
+ managerId = AdminUtils.encrypt(false, admin.getId());
|
|
|
+ }
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+ Long[] lowerIds = new Long[1];
|
|
|
+ for (Admin admin1 : admins) {
|
|
|
+ if (admin1.getId() == AdminUtils.decrypt(false, managerId)) {
|
|
|
+ Long id = admin1.getId();
|
|
|
+ lowerIds[0] = admin1.getId();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<OrderStatisticsDTO> list = orderService.findByManagerId(unit, begin, end, lowerIds[0], clientId, productName);
|
|
|
+ ArrayList<OrderStaticsTarget> orderStaticsTargets = new ArrayList<>();
|
|
|
+ for (OrderStatisticsDTO orderStatisticsDTO : list) {
|
|
|
+ OrderStaticsTarget orderStaticsTarget = new OrderStaticsTarget();
|
|
|
+ orderStaticsTarget.setsTime(orderStatisticsDTO.getsTime());
|
|
|
+ orderStaticsTarget.setTotalNumber(orderStatisticsDTO.getTotalNumber());
|
|
|
+ orderStaticsTarget.setTotalPrice(orderStatisticsDTO.getTotalPrice());
|
|
|
+ orderStaticsTargets.add(orderStaticsTarget);
|
|
|
+ }
|
|
|
+ ExportParams params = new ExportParams("订单统计", beginEndDate);
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params, OrderStaticsTarget.class, orderStaticsTargets);
|
|
|
+
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("订单统计记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ //订单汇总统计导出
|
|
|
+ @RequestMapping(value = "/exportSummaryStatistics", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Object exportSummaryStatistics(HttpServletResponse response, @RequestParam(value = "type", defaultValue = "2") Integer type, String beginEndDate, @RequestParam(value = "unit", defaultValue = "0") Integer unit, String productName, String name, Pageable pageable, ModelMap model, String clientId) {
|
|
|
+
|
|
|
+ Admin admin = adminService.getCurrent();
|
|
|
+
|
|
|
+ List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
|
|
|
+
|
|
|
+ Long[] lowerIds = null;
|
|
|
+ if (admins == null) {
|
|
|
+ lowerIds = new Long[]{};
|
|
|
+ } else {
|
|
|
+ lowerIds = new Long[admins.size()];
|
|
|
+ for (int i = 0; i < admins.size(); i++) {
|
|
|
+ lowerIds[i] = admins.get(i).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ if (StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ Date date = new Date();
|
|
|
+ String startToday = simpleDateFormat.format(date);
|
|
|
+ SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 24:00:00");
|
|
|
+ String endToday = _format.format(date);
|
|
|
+
|
|
|
+ beginEndDate = startToday + " - " + endToday;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查找商家名称
|
|
|
+ List<Filter> filters = pageable.getFilters();
|
|
|
+ //商家的所有id
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ List<Admin> admins1 = null;
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ filters.add(Filter.like("username", "%" + name + "%"));
|
|
|
+ }
|
|
|
+ admins1 = adminService.findPage(pageable).getContent();
|
|
|
+
|
|
|
+ if (admins1 != null) {
|
|
|
+ for (Admin admin1 : admins1) {
|
|
|
+ longs.add(admin1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<OrderStatisticsDTO> list = orderService.findByTime(type, begin, end, unit, productName, lowerIds, longs.toArray(new Long[longs.size()]), clientId);
|
|
|
+ ArrayList<OrderStaticsTarget> orderStaticsTargets = new ArrayList<>();
|
|
|
+ for (OrderStatisticsDTO orderStatisticsDTO : list) {
|
|
|
+ OrderStaticsTarget orderStaticsTarget = new OrderStaticsTarget();
|
|
|
+ orderStaticsTarget.setsTime(orderStatisticsDTO.getsTime());
|
|
|
+ orderStaticsTarget.setTotalNumber(orderStatisticsDTO.getTotalNumber());
|
|
|
+ orderStaticsTarget.setTotalPrice(orderStatisticsDTO.getTotalPrice());
|
|
|
+ orderStaticsTargets.add(orderStaticsTarget);
|
|
|
+ }
|
|
|
+ ExportParams params = new ExportParams("订单汇总统计", beginEndDate);
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params, OrderStaticsTarget.class, orderStaticsTargets);
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("订单汇总统计记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|