| | |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.order.api.model.ExportUidDto; |
| | | import com.ruoyi.order.api.model.TChargingBill; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.query.TOrderInvoiceQuery; |
| | |
| | | @ApiOperation(value = "列表查询", tags = {"管理后台-账户结算账单"}) |
| | | public R<AccountListVO> accountBillList(@RequestBody ChargingListQuery dto) { |
| | | AccountListVO accountListVO = new AccountListVO(); |
| | | ChargingBillVO res = chargingBillService.chargingBillList(dto); |
| | | ChargingBillVO res = chargingBillService.chargingBillList1(dto); |
| | | |
| | | ChargingBillVO res1 = chargingBillService.chargingBillList1(dto); |
| | | List<ChargingBillListVO> records = res1.getList().getRecords(); |
| | | accountListVO.setBillCount(records.size()); |
| | | accountListVO.setTotalAmount( |
| | | res1.getPaymentAmount().subtract(res1.getRefundAmount()==null?BigDecimal.ZERO:res1.getRefundAmount()) |
| | | .subtract(res1.getCommissionAmount()==null?BigDecimal.ZERO:res1.getCommissionAmount()) |
| | | .subtract(res1.getSharingAmount()==null?BigDecimal.ZERO:res1.getSharingAmount())); |
| | | accountListVO.setPaymentAmount(res1.getPaymentAmount()); |
| | | accountListVO.setRefundAmount(res1.getRefundAmount()); |
| | | accountListVO.setCommissionAmount(res1.getCommissionAmount()); |
| | | accountListVO.setSharingAmount(res1.getSharingAmount()); |
| | | accountListVO.setList(res.getList()); |
| | | return R.ok(accountListVO); |
| | | } |
| | | @PostMapping(value = "/chargingBillList") |
| | |
| | | return R.ok(null); |
| | | } |
| | | @ApiOperation(value = "导出", tags = {"管理后台-充电算账单"}) |
| | | @PostMapping("/export") |
| | | @PutMapping("/export") |
| | | public void export(@RequestBody ChargingListQuery dto) |
| | | { |
| | | ChargingBillVO res = chargingBillService.chargingBillList(dto); |
| | |
| | | } |
| | | } |
| | | } |
| | | @ApiOperation(value = "导出", tags = {"管理后台-账户结算账单"}) |
| | | @PutMapping("/exportAccount") |
| | | public void exportAccount(@RequestBody ChargingListQuery dto) |
| | | { |
| | | ChargingBillVO res = chargingBillService.chargingBillList1(dto); |
| | | List<ChargingBillListVO> list = res.getList().getRecords(); |
| | | List<TChargingBillExport> tChargingBillExports = new ArrayList<>(); |
| | | for (ChargingBillListVO orderInvoiceVO : list) { |
| | | TChargingBillExport tChargingBillExport = new TChargingBillExport(); |
| | | tChargingBillExport.setCode(orderInvoiceVO.getCode()); |
| | | switch (orderInvoiceVO.getOrderState()){ |
| | | case 1: |
| | | tChargingBillExport.setBillType("日账单"); |
| | | break; |
| | | case 2: |
| | | tChargingBillExport.setBillType("月账单"); |
| | | break; |
| | | } |
| | | tChargingBillExport.setType(orderInvoiceVO.getType().toString()); |
| | | tChargingBillExport.setBillWeek(orderInvoiceVO.getBillWeek()); |
| | | tChargingBillExport.setSiteName(orderInvoiceVO.getSiteName()); |
| | | tChargingBillExport.setPaymentAmount(orderInvoiceVO.getPaymentAmount()); |
| | | tChargingBillExport.setElectrovalence(orderInvoiceVO.getElectrovalence()); |
| | | tChargingBillExport.setServiceCharge(orderInvoiceVO.getServiceCharge()); |
| | | tChargingBillExport.setChargingCapacity(orderInvoiceVO.getChargingCapacity()); |
| | | Integer chargingSecond = orderInvoiceVO.getChargingSecond(); |
| | | // 根据秒数 转换为xx小时xx分钟xx秒 如果小时为0不展示 如果分钟为0则不展示 |
| | | // 计算小时、分钟和秒 |
| | | int hours = chargingSecond / 60 / 60; |
| | | int minutes = chargingSecond /60 % 60; |
| | | int seconds = 0; // 如果没有秒数,则默认是0 |
| | | // 构造结果字符串 |
| | | StringBuilder result = new StringBuilder(); |
| | | if (hours > 0) { |
| | | result.append(hours).append("小时"); |
| | | } |
| | | if (minutes > 0) { |
| | | result.append(minutes).append("分钟"); |
| | | } |
| | | if (seconds > 0 || result.length() == 0) { // 如果秒数大于0,或者小时和分钟都为0,则显示秒数 |
| | | result.append(seconds).append("秒"); |
| | | } |
| | | tChargingBillExport.setChargingTime(result.toString()); |
| | | tChargingBillExport.setOrderCount(orderInvoiceVO.getOrderCount()); |
| | | tChargingBillExport.setBillTime(orderInvoiceVO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | tChargingBillExports.add(tChargingBillExport); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TChargingBillExport.class, tChargingBillExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("月账单-"+res.getCategory()+"-"+res.getBillWeek()+"-"+res.getSiteName()+".xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @ApiOperation(value = "下载-未出账", tags = {"管理后台-充电算账单"}) |
| | | @GetMapping("/download") |
| | | public void download(String uid) |
| | | @PutMapping("/download") |
| | | public void download(@RequestBody ExportUidDto uid) |
| | | { |
| | | List<ChargingBillExport> chargingBillExports = new ArrayList<>(); |
| | | List<ChargingBillRefundExport> chargingBillRefundExports = new ArrayList<>(); |
| | | List<ChargingBillPayExport> chargingBillPayExports = new ArrayList<>(); |
| | | TChargingBill byId = chargingBillService.getById(uid); |
| | | TChargingBill byId = chargingBillService.getById(uid.getUid()); |
| | | ChargingBillExport chargingBillExport = new ChargingBillExport(); |
| | | chargingBillExport.setCode(byId.getCode()); |
| | | // todo 确认商户类型 |