package com.ruoyi.web.controller.api;
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.basic.PageInfo;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.WebUtils;
|
import com.ruoyi.system.dto.AuditInsuranceOrderOfflineDTO;
|
import com.ruoyi.system.dto.AuditInsuranceOrderRefundDTO;
|
import com.ruoyi.system.export.TInsuranceOrderExport;
|
import com.ruoyi.system.export.TInsuranceOrderRefundExport;
|
import com.ruoyi.system.export.TRefundOrderExport;
|
import com.ruoyi.system.model.TCourse;
|
import com.ruoyi.system.model.TInsurance;
|
import com.ruoyi.system.model.TInsuranceOrder;
|
import com.ruoyi.system.query.TInsuranceOrderQuery;
|
import com.ruoyi.system.service.TInsuranceOrderService;
|
import com.ruoyi.system.service.TInsuranceService;
|
import com.ruoyi.system.vo.TInsuranceOrderVO;
|
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.time.LocalDateTime;
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* <p>
|
* 用户保险费 前端控制器
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2025-12-29
|
*/
|
@Api(tags = "保险订单")
|
@RestController
|
@RequestMapping("/t-insurance-order")
|
public class TInsuranceOrderController {
|
|
private final TInsuranceOrderService insuranceOrderService;
|
private final TInsuranceService insuranceService;
|
|
@Autowired
|
public TInsuranceOrderController(TInsuranceOrderService insuranceOrderService, TInsuranceService insuranceService) {
|
this.insuranceOrderService = insuranceOrderService;
|
this.insuranceService = insuranceService;
|
}
|
|
/**
|
* 获取保险订单管理管理列表
|
*/
|
@ApiOperation(value = "获取保险订单记录分页列表")
|
@PostMapping(value = "/pageList")
|
public R<PageInfo<TInsuranceOrderVO>> pageList(@RequestBody TInsuranceOrderQuery query) {
|
return R.ok(insuranceOrderService.pageList(query));
|
}
|
/**
|
* 获取保险申请退款记录分页列表
|
*/
|
@ApiOperation(value = "获取保险申请退款记录分页列表")
|
@PostMapping(value = "/refundPageList")
|
public R<PageInfo<TInsuranceOrderVO>> refundPageList(@RequestBody TInsuranceOrderQuery query) {
|
return R.ok(insuranceOrderService.refundPageList(query));
|
}
|
|
/**
|
* 查看保险订单管理详情
|
*/
|
@ApiOperation(value = "查看保险订单管理详情")
|
@GetMapping(value = "/getDetailById")
|
public R<TInsuranceOrderVO> getDetailById(@RequestParam String id) {
|
TInsuranceOrder insuranceOrder = insuranceOrderService.getById(id);
|
TInsuranceOrderVO insuranceOrderVO = new TInsuranceOrderVO();
|
BeanUtils.copyProperties(insuranceOrder, insuranceOrderVO);
|
// 查询保险信息
|
TInsurance insurance = insuranceService.getById(insuranceOrder.getInsuranceId());
|
insuranceOrderVO.setInsurance(insurance);
|
return R.ok(insuranceOrderVO);
|
}
|
|
/**
|
* 审核保险订单管理退款申请
|
*/
|
@Log(title = "保险订单管理信息-审核保险订单管理线下支付", businessType = BusinessType.UPDATE)
|
@ApiOperation(value = "审核保险订单管理线下支付")
|
@PostMapping(value = "/auditInsuranceOrderOffline")
|
public R<String> auditInsuranceOrderOffline(@Validated @RequestBody AuditInsuranceOrderOfflineDTO dto) {
|
TInsuranceOrder insuranceOrder = insuranceOrderService.getById(dto.getId());
|
if(dto.getOfflineStatus() == 1){
|
// 通过
|
insuranceOrder.setOfflineVoucher(dto.getOfflineVoucher());
|
insuranceOrder.setPayTime(LocalDateTime.now());
|
// 修改支付状态为已退款
|
insuranceOrder.setStatus(2);
|
}
|
if(dto.getOfflineStatus() == 2){
|
// 驳回
|
insuranceOrder.setOfflineReason(dto.getOfflineReason());
|
insuranceOrder.setStatus(4);
|
}
|
insuranceOrderService.updateById(insuranceOrder);
|
return R.ok();
|
}
|
|
/**
|
* 审核保险订单管理退款申请
|
*/
|
@Log(title = "保险订单管理信息-审核保险订单管理退款申请", businessType = BusinessType.UPDATE)
|
@ApiOperation(value = "审核保险订单管理退款申请")
|
@PostMapping(value = "/auditInsuranceOrderRefund")
|
public R<String> auditInsuranceOrderRefund(@Validated @RequestBody AuditInsuranceOrderRefundDTO dto) {
|
TInsuranceOrder insuranceOrder = insuranceOrderService.getById(dto.getId());
|
insuranceOrder.setRefundStatus(dto.getRefundStatus());
|
if(dto.getRefundStatus() == 2){
|
// 通过
|
insuranceOrder.setRefundVoucher(dto.getRefundVoucher());
|
// 修改支付状态为已退款
|
insuranceOrder.setStatus(1);
|
}
|
if(dto.getRefundStatus() == 3){
|
// 驳回
|
insuranceOrder.setRejectReason(dto.getRejectReason());
|
insuranceOrder.setStatus(2);
|
}
|
insuranceOrderService.updateById(insuranceOrder);
|
return R.ok();
|
}
|
|
/**
|
* 删除保险订单管理
|
*/
|
@Log(title = "保险订单管理信息-删除保险订单管理", businessType = BusinessType.DELETE)
|
@ApiOperation(value = "删除保险订单管理")
|
@DeleteMapping(value = "/deleteById")
|
public R<Boolean> deleteById(@RequestParam String id) {
|
return R.ok(insuranceOrderService.removeById(id));
|
}
|
|
/**
|
* 批量删除保险订单管理
|
*/
|
@Log(title = "保险订单管理信息-删除保险订单管理", businessType = BusinessType.DELETE)
|
@ApiOperation(value = "批量删除保险订单管理")
|
@DeleteMapping(value = "/deleteByIds")
|
public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
|
return R.ok(insuranceOrderService.removeByIds(ids));
|
}
|
|
@Log(title = "保险订单管理信息-保险订单记录导出", businessType = BusinessType.EXPORT)
|
@ApiOperation(value = "保险订单记录导出")
|
@PostMapping("/exportInsuranceOrder")
|
public void exportInsuranceOrder(@RequestBody TInsuranceOrderQuery query){
|
List<TInsuranceOrderExport> insuranceOrderExports = insuranceOrderService.exportInsuranceOrder(query);
|
for (TInsuranceOrderExport insuranceOrderExport : insuranceOrderExports) {
|
if(Objects.nonNull(insuranceOrderExport.getPayTime())){
|
insuranceOrderExport.setPayTimeStr(DateUtils.localDateTimeToString(insuranceOrderExport.getPayTime()));
|
}
|
if(Objects.nonNull(insuranceOrderExport.getEndTime())){
|
insuranceOrderExport.setEndTimeStr(DateUtils.localDateToString(insuranceOrderExport.getEndTime()));
|
}
|
}
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TInsuranceOrderExport.class, insuranceOrderExports);
|
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 TInsuranceOrderQuery query){
|
List<TInsuranceOrderRefundExport> insuranceOrderRefundExports = insuranceOrderService.exportRefundOrder(query);
|
for (TInsuranceOrderRefundExport insuranceOrderRefundExport : insuranceOrderRefundExports) {
|
if(Objects.nonNull(insuranceOrderRefundExport.getPayTime())){
|
insuranceOrderRefundExport.setPayTimeStr(DateUtils.localDateTimeToString(insuranceOrderRefundExport.getPayTime()));
|
}
|
if(Objects.nonNull(insuranceOrderRefundExport.getEndTime())){
|
insuranceOrderRefundExport.setEndTimeStr(DateUtils.localDateToString(insuranceOrderRefundExport.getEndTime()));
|
}
|
if(Objects.nonNull(insuranceOrderRefundExport.getRequestRefundTime())){
|
insuranceOrderRefundExport.setRequestRefundTimeStr(DateUtils.localDateTimeToString(insuranceOrderRefundExport.getRequestRefundTime()));
|
}
|
}
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TInsuranceOrderRefundExport.class, insuranceOrderRefundExports);
|
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();
|
}
|
}
|
}
|
|
}
|