From a13a93a493e7e94e28b2225c26e7e13b52d3288c Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 12 Apr 2021 19:48:45 +0800
Subject: [PATCH] 20210412 tqq环境
---
zq-erp/src/main/java/com/matrix/system/hive/statistics/OrderFlowAction.java | 103 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 79 insertions(+), 24 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/statistics/OrderFlowAction.java b/zq-erp/src/main/java/com/matrix/system/hive/statistics/OrderFlowAction.java
index 70ac932..a3ad197 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/statistics/OrderFlowAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/statistics/OrderFlowAction.java
@@ -1,44 +1,30 @@
package com.matrix.system.hive.statistics;
-import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
-import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.DateUtil;
-import com.matrix.core.tools.WebUtil;
+import com.matrix.core.tools.LogUtil;
+import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.excl.ExcelSheetPO;
+import com.matrix.core.tools.excl.ExcelUtil;
import com.matrix.core.tools.excl.ExcelVersion;
-import com.matrix.system.app.vo.UserInfoVo;
-import com.matrix.system.common.bean.SysUsers;
-import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.tools.DataAuthUtil;
-import com.matrix.system.common.tools.ResponseHeadUtil;
import com.matrix.system.hive.action.util.QueryUtil;
-import com.matrix.system.hive.bean.AchieveNew;
-import com.matrix.system.hive.bean.SysOrder;
-import com.matrix.system.hive.bean.SysOrderFlow;
-import com.matrix.system.hive.bean.SysOrderItem;
import com.matrix.system.hive.dao.SysOrderFlowDao;
import com.matrix.system.hive.dto.OrderFlowListDto;
-import com.matrix.system.hive.service.AchieveNewService;
-import com.matrix.system.hive.service.SysOrderItemService;
-import com.matrix.system.hive.service.SysOrderService;
import com.matrix.system.hive.vo.OrderFlowVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import io.swagger.models.auth.In;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
/**
@@ -50,11 +36,8 @@
@RequestMapping(value = "/admin/orderFlow")
public class OrderFlowAction {
-
@Resource
private SysOrderFlowDao orderFlowDao;
-
-
/**
* 交易流水查询
*/
@@ -63,9 +46,13 @@
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = OrderFlowListDto.class)
})
- @PostMapping(value = "/findSumDailyInfoNew")
+ @PostMapping(value = "/findOrderFlow")
public @ResponseBody
- AjaxResult findSumDailyInfoNew(@RequestBody OrderFlowListDto orderFlowListDto) {
+ AjaxResult findOrderFlow(@RequestBody OrderFlowListDto orderFlowListDto) {
+ if(StringUtils.isBlank(orderFlowListDto.getSort())){
+ orderFlowListDto.setSort("createTime");
+ orderFlowListDto.setOrder("desc");
+ }
if (!DataAuthUtil.hasAllShopAuth()) {
QueryUtil.setQueryLimit(orderFlowListDto);
} else {
@@ -77,6 +64,74 @@
return result;
}
+ /**
+ * 导出Excel
+ */
+ @GetMapping(value = "/exportOrderFlowExcel")
+ public void exportOrderFlowExcel(OrderFlowListDto orderFlowListDto, HttpServletResponse res) {
+ OutputStream os = null;
+ try {
+ if (!DataAuthUtil.hasAllShopAuth()) {
+ QueryUtil.setQueryLimit(orderFlowListDto);
+ } else {
+ QueryUtil.setQueryLimitCom(orderFlowListDto);
+ }
+ orderFlowListDto.setLimit(null);
+ List<OrderFlowVo> rows = orderFlowDao.selectInPage(orderFlowListDto);
+ res.setCharacterEncoding("UTF-8");
+ res.setHeader("content-type", "application/octet-stream;charset=UTF-8");
+ res.setContentType("application/octet-stream;charset=UTF-8");
+
+ Date date = new Date();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss");
+ res.setHeader("Content-Disposition", "attachment;filename=" +
+ java.net.URLEncoder.encode("交易流水" + dateFormat.format(date) + ".xlsx".trim(), "UTF-8"));
+ os = res.getOutputStream();
+ ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, disPoseExcelData(rows), os, true);
+ } catch (Exception e) {
+ LogUtil.error("交易流水导出异常", e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ LogUtil.error("关闭资源异常", e);
+ }
+ }
+ }
+ }
+
+ private List<ExcelSheetPO> disPoseExcelData(List<OrderFlowVo> orderFlowVos) {
+ List<ExcelSheetPO> res = new ArrayList<>();
+ ExcelSheetPO orderSheet = new ExcelSheetPO();
+ orderSheet.setSheetName("交易流水");
+ orderSheet.setTitle("交易流水");
+ String[] header = new String[]{"订单编号", "交易内容", "交易时间", "交易类型", "交易金额", "会员姓名",
+ "支付方式", "支付流水号", "操作人", "门店名称"};
+ orderSheet.setHeaders(header);
+ List<List<Object>> body = new ArrayList<>();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
+ for (OrderFlowVo flowVo : orderFlowVos) {
+ List<Object> bodyItem = new ArrayList<>();
+ bodyItem.add(flowVo.getOrderNo());
+ bodyItem.add(flowVo.getFlowContent());
+ bodyItem.add(DateUtil.dateFormatStr(flowVo.getCreateTime(),DateUtil.DATE_FORMAT_MM));
+ bodyItem.add(flowVo.getFlowType());
+ bodyItem.add(flowVo.getAmount());
+ bodyItem.add(flowVo.getVipName());
+ bodyItem.add(flowVo.getPayMethod());
+ bodyItem.add(flowVo.getFlowNo());
+ bodyItem.add(flowVo.getStaffName());
+ bodyItem.add(flowVo.getShopName());
+ body.add(bodyItem);
+ }
+ orderSheet.setDataList(body);
+ res.add(orderSheet);
+ return res;
+ }
+
+
+
}
--
Gitblit v1.9.1