From 818937959bb19d3669585fa87a526bffe9ce77a4 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 24 四月 2025 09:28:41 +0800
Subject: [PATCH] 修改默认验证码

---
 ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TWithdrawalController.java |  120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 115 insertions(+), 5 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 5625fcb..20d7d6c 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
@@ -1,24 +1,42 @@
 package com.stylefeng.guns.modular.system.controller.general;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.stylefeng.guns.core.base.controller.BaseController;
 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.controller.util.HttpUtils;
+import com.stylefeng.guns.modular.system.model.TDriver;
 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;
 
 /**
  * 提现相关控制器
  */
-@RestController
-@RequestMapping("/api/withdrawal")
+@Controller
+@RequestMapping("/withdrawal")
 public class TWithdrawalController extends BaseController {
 
     @Autowired
@@ -51,9 +69,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";
+        }
+
     }
 
     /**
@@ -62,7 +87,7 @@
     @RequestMapping(value = "/list")
     @ResponseBody
     public Object list(String insertTime,
-                       String receivePaymentName,
+                       String driverName,
                        Integer status) {
         String beginTime = null;
         String endTime = null;
@@ -72,7 +97,7 @@
             endTime = timeArray[1];
         }
         Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
-        page.setRecords(withdrawalService.getWithdrawalList(page,beginTime,endTime,receivePaymentName,status));
+        page.setRecords(withdrawalService.getWithdrawalList(page,beginTime,endTime,driverName,status));
         return super.packForBT(page);
     }
 
@@ -111,11 +136,96 @@
 
         if(withdrawal.getStatus() == 3){
             withdrawal.setRemark(withdrawal.getRemark());
+            TWithdrawal tWithdrawal = withdrawalService.selectById(withdrawal.getId());
+            TDriver driver = driverService.selectById(tWithdrawal.getDriverId());
+            BigDecimal balance = driver.getBalance();
+            BigDecimal withdrawalMoney = tWithdrawal.getWithdrawalMoney();
+            driver.setBalance(balance.add(withdrawalMoney));
+            driverService.updateById(driver);
         }
 
         withdrawalService.updateById(withdrawal);
         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.excel1(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] = "银行卡";
+                values[i][3] = "开户行:"+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