From 5d47b1c7a70ebd532e39906c6c238531258405e3 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Thu, 28 Jan 2021 14:32:50 +0800
Subject: [PATCH] Merge branch 'api' into hive2.0

---
 zq-erp/src/main/java/com/matrix/system/hive/statistics/OrderFlowAction.java |  137 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 0 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
new file mode 100644
index 0000000..a3ad197
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/hive/statistics/OrderFlowAction.java
@@ -0,0 +1,137 @@
+package com.matrix.system.hive.statistics;
+
+import com.matrix.core.pojo.AjaxResult;
+import com.matrix.core.tools.DateUtil;
+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.common.tools.DataAuthUtil;
+import com.matrix.system.hive.action.util.QueryUtil;
+import com.matrix.system.hive.dao.SysOrderFlowDao;
+import com.matrix.system.hive.dto.OrderFlowListDto;
+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 org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+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;
+
+/**
+ * 交易流水统计
+ */
+@CrossOrigin(origins = "*")
+@Api(value = "OrderFlowAction", tags = "交易流水")
+@RestController
+@RequestMapping(value = "/admin/orderFlow")
+public class OrderFlowAction {
+
+    @Resource
+    private SysOrderFlowDao orderFlowDao;
+    /**
+     * 交易流水查询
+     */
+
+    @ApiOperation(value = "查询交易流水")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "OK",  response = OrderFlowListDto.class)
+    })
+    @PostMapping(value = "/findOrderFlow")
+    public @ResponseBody
+    AjaxResult findOrderFlow(@RequestBody OrderFlowListDto orderFlowListDto) {
+        if(StringUtils.isBlank(orderFlowListDto.getSort())){
+            orderFlowListDto.setSort("createTime");
+            orderFlowListDto.setOrder("desc");
+        }
+        if (!DataAuthUtil.hasAllShopAuth()) {
+            QueryUtil.setQueryLimit(orderFlowListDto);
+        } else {
+            QueryUtil.setQueryLimitCom(orderFlowListDto);
+        }
+        List<OrderFlowVo> rows = orderFlowDao.selectInPage(orderFlowListDto);
+        Integer total = orderFlowDao.selectTotal(orderFlowListDto);
+        AjaxResult result = AjaxResult.buildSuccessInstance(rows, total);
+        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