| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverCommissionResp; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TRechargeRecordAgentResp; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TRechargeRecordUserResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.stylefeng.guns.modular.system.model.TRechargeRecord; |
| | | import com.stylefeng.guns.modular.system.service.ITRechargeRecordService; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | model.addAttribute("item",tRechargeRecord); |
| | | LogObjectHolder.me().set(tRechargeRecord); |
| | | return PREFIX + "tRechargeRecord_edit.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到用户充值列表 |
| | | */ |
| | | @RequestMapping("/userRecharge") |
| | | public String userRecharge() { |
| | | return PREFIX + "tRechargeRecordUser.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到代理商充值列表 |
| | | */ |
| | | @RequestMapping("/agentRecharge") |
| | | public String agentRecharge() { |
| | | return PREFIX + "tRechargeRecordAgent.html"; |
| | | } |
| | | |
| | | /** |
| | | * 获取用户充值列表 |
| | | */ |
| | | @RequestMapping(value = "/userRechargeList") |
| | | @ResponseBody |
| | | public Object userRechargeList(String userName,String userPhone,String code,String createTime) { |
| | | return tRechargeRecordService.userRecharge(userName,userPhone,code,createTime); |
| | | } |
| | | |
| | | /** |
| | | * 获取代理商充值列表 |
| | | */ |
| | | @RequestMapping(value = "/agentRechargeList") |
| | | @ResponseBody |
| | | public Object agentRechargeList(String driverName,String driverPhone,String createTime) { |
| | | return tRechargeRecordService.agentRechargeList(driverName,driverPhone,createTime); |
| | | } |
| | | |
| | | /** |
| | |
| | | public Object detail(@PathVariable("tRechargeRecordId") Integer tRechargeRecordId) { |
| | | return tRechargeRecordService.selectById(tRechargeRecordId); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出用户充值列表",notes="导出用户充值列表") |
| | | @RequestMapping(value = "/exportUserRecharge") |
| | | @ResponseBody |
| | | public void exportUserRecharge(String userName,String userPhone,String code,String createTime, HttpServletResponse response) { |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName = "UserRechargeRecord"+time1+".xls"; |
| | | String[] title = new String[] {"充值时间","流水ID","用户姓名","用户手机号","充值金额", |
| | | "充值方式","状态"}; |
| | | List<TRechargeRecordUserResp> userRechargeList = tRechargeRecordService.userRecharge(userName,userPhone,code,createTime); |
| | | |
| | | String[][] values = new String[userRechargeList.size()][]; |
| | | for (int i = 0; i < userRechargeList.size(); i++) { |
| | | TRechargeRecordUserResp d = userRechargeList.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0] = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d.getCreateTime()); |
| | | values[i][1] = d.getCode(); |
| | | values[i][2] = d.getUserName(); |
| | | values[i][3] = d.getUserPhone(); |
| | | values[i][4] = String.valueOf(Objects.nonNull(d.getAmount())?d.getAmount(): BigDecimal.ZERO); |
| | | Integer payType = d.getPayType(); |
| | | if(1 == payType){ |
| | | values[i][5] = "微信"; |
| | | }else if(2 == payType){ |
| | | values[i][5] = "系统充值"; |
| | | }else{ |
| | | values[i][5] = "其他"; |
| | | } |
| | | Integer status1 = d.getPayStatus(); |
| | | if(1 == status1){ |
| | | values[i][6] = "失败"; |
| | | }else if(2 == status1){ |
| | | values[i][6] = "成功"; |
| | | } |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "导出代理商充值列表",notes="导出代理商充值列表") |
| | | @RequestMapping(value = "/exportAgentRecharge") |
| | | @ResponseBody |
| | | public void exportAgentRecharge(String driverName,String driverPhone,String createTime, HttpServletResponse response) { |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName = "AgentRechargeRecord"+time1+".xls"; |
| | | String[] title = new String[] {"充值时间","代理商姓名","联系电话","代理区域","司机姓名","司机手机号","充值金额", |
| | | "充值方式","状态"}; |
| | | List<TRechargeRecordAgentResp> agentRechargeList = tRechargeRecordService.agentRechargeList(driverName,driverPhone,createTime); |
| | | |
| | | String[][] values = new String[agentRechargeList.size()][]; |
| | | for (int i = 0; i < agentRechargeList.size(); i++) { |
| | | TRechargeRecordAgentResp d = agentRechargeList.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0] = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d.getCreateTime()); |
| | | values[i][1] = d.getPrincipal(); |
| | | values[i][2] = d.getPrincipalPhone(); |
| | | values[i][3] = d.getProvinceName()+d.getCityName(); |
| | | values[i][4] = d.getDriverName(); |
| | | values[i][5] = d.getDriverPhone(); |
| | | values[i][6] = String.valueOf(Objects.nonNull(d.getAmount())?d.getAmount(): BigDecimal.ZERO); |
| | | Integer payType = d.getPayType(); |
| | | if(1 == payType){ |
| | | values[i][7] = "微信"; |
| | | }else if(2 == payType){ |
| | | values[i][7] = "系统充值"; |
| | | }else{ |
| | | values[i][7] = "其他"; |
| | | } |
| | | Integer status1 = d.getPayStatus(); |
| | | if(1 == status1){ |
| | | values[i][8] = "失败"; |
| | | }else if(2 == status1){ |
| | | values[i][8] = "成功"; |
| | | } |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |