| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | 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.query.TCourseQuery; |
| | | import com.ruoyi.system.service.TCourseOrderService; |
| | | import com.ruoyi.system.service.TCourseService; |
| | | import com.ruoyi.system.vo.TCourseOrderVO; |
| | | 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 org.springframework.web.bind.annotation.RestController; |
| | | 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> |
| | |
| | | * @author xiaochen |
| | | * @since 2025-11-06 |
| | | */ |
| | | @Api(tags = "课程订单管理") |
| | | @RestController |
| | | @RequestMapping("/t-course-order") |
| | | public class TCourseOrderController { |
| | | |
| | | private final TCourseService courseService; |
| | | private final TCourseOrderService courseOrderService; |
| | | private final TokenService tokenService; |
| | | @Autowired |
| | | public TCourseOrderController(TCourseService courseService, TCourseOrderService courseOrderService, TokenService tokenService) { |
| | | this.courseService = courseService; |
| | | this.courseOrderService = courseOrderService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | | /** |
| | | * 获取课程订单管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取课程报名记录分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TCourseOrderVO>> pageList(@RequestBody TCourseOrderQuery query) { |
| | | return R.ok(courseOrderService.pageList(query)); |
| | | } |
| | | /** |
| | | * 获取课程申请退款记录分页列表 |
| | | */ |
| | | @ApiOperation(value = "获取课程申请退款记录分页列表") |
| | | @PostMapping(value = "/refundPageList") |
| | | public R<PageInfo<TCourseOrderVO>> refundPageList(@RequestBody TCourseOrderQuery query) { |
| | | return R.ok(courseOrderService.refundPageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取课程订单管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取课程订单管理列表") |
| | | @PostMapping(value = "/list") |
| | | public R<List<TCourseOrder>> list() { |
| | | return R.ok(courseOrderService.list(Wrappers.lambdaQuery(TCourseOrder.class).orderByDesc(TCourseOrder::getCreateTime))); |
| | | } |
| | | |
| | | /** |
| | | * 查看课程订单管理详情 |
| | | */ |
| | | @ApiOperation(value = "查看课程订单管理详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TCourseOrderVO> getDetailById(@RequestParam String id) { |
| | | TCourseOrder courseOrder = courseOrderService.getById(id); |
| | | TCourseOrderVO courseOrderVO = new TCourseOrderVO(); |
| | | BeanUtils.copyProperties(courseOrder, courseOrderVO); |
| | | // 查询课程信息 |
| | | TCourse course = courseService.getById(courseOrder.getCourseId()); |
| | | courseOrderVO.setCourseTitle(course.getCourseTitle()); |
| | | courseOrderVO.setCourseCost(course.getCourseCost()); |
| | | courseOrderVO.setCourseLecturer(course.getCourseLecturer()); |
| | | 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 = "/auditCourseOrderRefund") |
| | | public R<String> auditCourseOrderRefund(@Validated @RequestBody AuditCourseOrderRefundDTO dto) { |
| | | TCourseOrder courseOrder = courseOrderService.getById(dto.getId()); |
| | | courseOrder.setRefundStatus(dto.getRefundStatus()); |
| | | if(dto.getRefundStatus() == 2){ |
| | | // 通过 |
| | | courseOrder.setRefundVoucher(dto.getRefundVoucher()); |
| | | // 修改支付状态为已退款 |
| | | courseOrder.setPayStatus(3); |
| | | } |
| | | if(dto.getRefundStatus() == 3){ |
| | | // 驳回 |
| | | courseOrder.setRejectReason(dto.getRejectReason()); |
| | | courseOrder.setPayStatus(2); |
| | | } |
| | | courseOrderService.updateById(courseOrder); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除课程订单管理 |
| | | */ |
| | | @Log(title = "课程订单管理信息-删除课程订单管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除课程订单管理") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | return R.ok(courseOrderService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除课程订单管理 |
| | | */ |
| | | @Log(title = "课程订单管理信息-删除课程订单管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除课程订单管理") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |