From 6906168ccb03e4865d3e9385a9ae4a6e87008ca1 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 13 一月 2025 15:56:52 +0800
Subject: [PATCH] 管理后台提现管理

---
 ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TWithdrawalController.java |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 101 insertions(+), 1 deletions(-)

diff --git a/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TWithdrawalController.java b/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TWithdrawalController.java
index 1c24bf8..02c717e 100644
--- a/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TWithdrawalController.java
+++ b/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TWithdrawalController.java
@@ -5,14 +5,26 @@
 import com.stylefeng.guns.core.common.constant.factory.PageFactory;
 import com.stylefeng.guns.core.log.LogObjectHolder;
 import com.stylefeng.guns.core.util.SinataUtil;
+import com.stylefeng.guns.modular.system.controller.util.ExcelUtil;
 import com.stylefeng.guns.modular.system.model.TWithdrawal;
 import com.stylefeng.guns.modular.system.service.ITDriverService;
 import com.stylefeng.guns.modular.system.service.ITWithdrawalService;
+import com.stylefeng.guns.modular.system.util.DateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -52,9 +64,16 @@
     @RequestMapping("/tWithdrawal_update/{tWithdrawalId}")
     public String tWithdrawalUpdate(@PathVariable Integer tWithdrawalId, Model model) {
         TWithdrawal tWithdrawal = withdrawalService.selectById(tWithdrawalId);
+        tWithdrawal.setWithdrawalTimeStr(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(tWithdrawal.getWithdrawalTime()));
+        tWithdrawal.setWithdrawalTypeStr(tWithdrawal.getWithdrawalType()==1?"支付宝":"银行卡");
         model.addAttribute("item",tWithdrawal);
         LogObjectHolder.me().set(tWithdrawal);
-        return PREFIX + "tWithdrawal_edit.html";
+        if(tWithdrawal.getStatus() == 1){
+            return PREFIX + "tWithdrawal_edit.html";
+        }else {
+            return PREFIX + "tWithdrawal_detail.html";
+        }
+
     }
 
     /**
@@ -118,5 +137,86 @@
         return SUCCESS_TIP;
     }
 
+    @RequestMapping(value = "/excel")
+    @ResponseBody
+    public Object excel(String insertTime,
+                        String driverName,
+                        Integer status,
+                        HttpServletResponse response) {
+            String beginTime = null;
+            String endTime = null;
+            if (SinataUtil.isNotEmpty(insertTime)){
+                String[] timeArray = insertTime.split(" - ");
+                beginTime = timeArray[0];
+                endTime = timeArray[1];
+            }
+        List<Map<String, Object>> list = withdrawalService.excel(beginTime, endTime, driverName, status);
+        try {
+            String fileName = "提现管理" + System.currentTimeMillis() + ".xls"; // 文件名
+            String sheetName = "提现管理";// sheet名
+            Map<String,Object> object = null;
+            String[] title = new String[] {
+                    "下单时间",
+                    "提现人",
+                    "提现方式",
+                    "收款人信息",
+                    "账户余额",
+                    "提现金额",
+                    "联系电话",
+                    "备注",
+                    "状态"
+            };// 标题
+            String[][] values = new String[list.size()][];
+            for (int i = 0; i < list.size(); i++) {
+                values[i] = new String[title.length];
+                // 将对象内容转换成string
+                object = list.get(i);
+                values[i][0] = new SimpleDateFormat("yyyy-MM-dd HH:mm").format((Date) object.get("withdrawalTime"));
+                values[i][1] = object.get("driverName").toString();
+                values[i][2] = (Integer)object.get("withdrawalType")==1?"支付宝": "银行卡";
+                values[i][3] = (Integer)object.get("withdrawalType")==1?
+                        "收款人:"+object.get("receivePaymentName").toString()+"/n"+"支付宝号:"+object.get("receivePaymentAccount").toString()
+                : "开户行:"+object.get("openBank").toString()+"/n"+"收款人:"+object.get("receivePaymentName").toString()+"/n"+"银行卡号:"+object.get("receivePaymentAccount").toString();
+                values[i][4] = new BigDecimal(object.get("driverBalance").toString()).setScale(2, RoundingMode.HALF_UP).toString();
+                values[i][5] = object.get("withdrawalMoney").toString();
+                values[i][6] = object.get("driverPhone").toString();
+                values[i][7] = object.get("remark")!=null?object.get("remark").toString():"-";
+                values[i][8] = (Integer)object.get("status")==1?"待处理":(Integer)object.get("status")==2?"成功":"失败";
+            }
+            HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName, title, values, null);
+
+            this.setResponseHeader(response, fileName);
+            OutputStream os = response.getOutputStream();
+            wb.write(os);
+            os.flush();
+            os.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return SUCCESS_TIP;
+    }
+
+    /**
+     * 设置相应头部信息
+     * @param response
+     * @param fileName
+     * @return
+     */
+    public void setResponseHeader(HttpServletResponse response, String fileName) {
+        try {
+            try {
+                fileName = new String(fileName.getBytes(), "ISO8859-1");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            response.setContentType("application/octet-stream;charset=ISO8859-1");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.addHeader("Pargam", "no-cache");
+            response.addHeader("Cache-Control", "no-cache");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
 
 }

--
Gitblit v1.7.1