| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | 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.DateUtils; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.AuditCourseOrderRefundDTO; |
| | | import com.ruoyi.system.export.TCourseOrderExport; |
| | | import com.ruoyi.system.export.TRefundOrderExport; |
| | | import com.ruoyi.system.model.TCourse; |
| | | import com.ruoyi.system.model.TCourseOrder; |
| | | import com.ruoyi.system.query.TCourseOrderQuery; |
| | |
| | | import com.ruoyi.system.vo.TCourseVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | courseOrderVO.setCourseCover(course.getCourseCover()); |
| | | courseOrderVO.setCourseType(course.getCourseType()); |
| | | courseOrderVO.setReleaseTime(course.getCreateTime()); |
| | | courseOrderVO.setPeopleLimit(course.getPeopleLimit()); |
| | | return R.ok(courseOrderVO); |
| | | } |
| | | |
| | | |
| | | @Log(title = "课程订单管理信息-批量通过支付审核", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "批量通过支付审核") |
| | | @PostMapping(value = "/agreePay") |
| | | public R<Boolean> agreePay(@RequestBody List<String> ids) { |
| | | List<TCourseOrder> tCourseOrders = courseOrderService.listByIds(ids); |
| | | long count = tCourseOrders.stream().filter(e -> e.getPayStatus() != 0).count(); |
| | | if(count > 0){ |
| | | return R.fail("存在无需审核的订单"); |
| | | } |
| | | tCourseOrders.forEach(e -> { |
| | | e.setPayStatus(1); |
| | | }); |
| | | courseOrderService.updateBatchById(tCourseOrders); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(dto.getRefundStatus() == 3){ |
| | | // 驳回 |
| | | courseOrder.setRejectReason(dto.getRejectReason()); |
| | | courseOrder.setPayStatus(2); |
| | | } |
| | | courseOrderService.updateById(courseOrder); |
| | | return R.ok(); |
| | |
| | | return R.ok(courseService.removeByIds(ids)); |
| | | } |
| | | |
| | | @Log(title = "课程订单管理信息-课程报名记录导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "课程报名记录导出") |
| | | @PostMapping("/exportCourseOrder") |
| | | public void exportCourseOrder(@RequestBody TCourseOrderQuery query){ |
| | | List<TCourseOrderExport> courseOrderExports = courseOrderService.exportCourseOrder(query); |
| | | for (TCourseOrderExport courseOrderExport : courseOrderExports) { |
| | | if(Objects.nonNull(courseOrderExport.getPayTime())){ |
| | | courseOrderExport.setPayTimeStr(DateUtils.localDateTimeToString(courseOrderExport.getPayTime())); |
| | | } |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TCourseOrderExport.class, courseOrderExports); |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | @Log(title = "课程订单管理信息-退款记录导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "退款记录导出") |
| | | @PostMapping("/exportRefundOrder") |
| | | public void exportRefundOrder(@RequestBody TCourseOrderQuery query){ |
| | | List<TRefundOrderExport> refundOrderExports = courseOrderService.exportRefundOrder(query); |
| | | for (TRefundOrderExport courseOrderExport : refundOrderExports) { |
| | | if(Objects.nonNull(courseOrderExport.getPayTime())){ |
| | | courseOrderExport.setPayTimeStr(DateUtils.localDateTimeToString(courseOrderExport.getPayTime())); |
| | | } |
| | | if(Objects.nonNull(courseOrderExport.getRequestRefundTime())){ |
| | | courseOrderExport.setRequestRefundTimeStr(DateUtils.localDateTimeToString(courseOrderExport.getRequestRefundTime())); |
| | | } |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TRefundOrderExport.class, refundOrderExports); |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |