| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | @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"; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | 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.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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |