| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TransferOrderDto; |
| | | import com.ruoyi.system.export.BigGiftPackageImport; |
| | | import com.ruoyi.system.export.TBigGiftPackageOrderExport; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.BigGiftPackageOrderQuery; |
| | | import com.ruoyi.system.query.OrderTransferQuery; |
| | |
| | | import com.ruoyi.system.vo.TOrderTransferVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | List<TBigGiftPackageOrder> list = tBigGiftPackageOrderService.pageList(tBigGiftPackageOrderPage,query); |
| | | tBigGiftPackageOrderPage.setRecords(list); |
| | | return R.ok(tBigGiftPackageOrderPage); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出大礼包订单") |
| | | @Log(title = "大礼包订单-导出", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export( @RequestBody BigGiftPackageOrderQuery query) { |
| | | List<TBigGiftPackageOrder> list = tBigGiftPackageOrderService.export(query); |
| | | ArrayList<TBigGiftPackageOrderExport> exports = new ArrayList<>(); |
| | | for (TBigGiftPackageOrder order : list) { |
| | | TBigGiftPackageOrderExport export = new TBigGiftPackageOrderExport(); |
| | | export.setCompanyName(order.getCompanyName()); |
| | | export.setOrderNo(order.getCode()); |
| | | export.setCreateTime(order.getCreateTime()); |
| | | export.setUsername(order.getUserName()); |
| | | export.setUserPhone(order.getPhone()); |
| | | export.setOrderAmount(order.getOrderPrice()); |
| | | export.setGoodsName(order.getBigGiftPackageName()); |
| | | export.setPayMethod("微信支付"); |
| | | export.setDeposit(order.getDeposit()); |
| | | export.setBalance(order.getFinalPayment()); |
| | | export.setOrderStatus(order.getStatus()); |
| | | exports.add(export); |
| | | } |
| | | |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TBigGiftPackageOrderExport.class, exports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("大礼包订单导出信息.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(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | return update ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "订单转让列表") |
| | | @PostMapping(value = "/transferList") |
| | | public R<Page<TOrderTransferVo>> transferList(@RequestBody OrderTransferQuery query) { |
| | |
| | | tOrderTransferPage.setRecords(list); |
| | | return R.ok(tOrderTransferPage); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单转让--导出") |
| | | @Log(title = "订单转让-导出", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/transferExport") |
| | | public void transferExport(@RequestBody OrderTransferQuery query) { |
| | | List<TOrderTransferVo> list = tOrderTransferService.pageListExport(query); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderTransferVo.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("订单转让导出信息.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 = "订单转让详情") |
| | | @PostMapping(value = "/transferDetail/{id}") |
| | |
| | | tOrderTransferVo.setOperateUser(sysUser.getNickName()); |
| | | return R.ok(tOrderTransferVo); |
| | | } |
| | | |
| | | } |
| | | |
| | | |