package cn.iocoder.yudao.module.crm.controller.admin.refund;
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundAuditReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundRespVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.refund.vo.CrmRefundSaveReqVO;
|
import cn.iocoder.yudao.module.crm.service.refund.CrmRefundService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.annotation.Resource;
|
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.validation.Valid;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.io.IOException;
|
import java.util.List;
|
import java.util.Map;
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
@Tag(name = "管理后台 - CRM 退费单")
|
@RestController
|
@RequestMapping("/crm/refund")
|
@Validated
|
public class CrmRefundController {
|
|
@Resource
|
private CrmRefundService refundService;
|
|
@PostMapping("/create")
|
@Operation(summary = "创建退费单")
|
@PreAuthorize("@ss.hasPermission('crm:refund:create')")
|
public CommonResult<Long> createRefund(@Valid @RequestBody CrmRefundSaveReqVO createReqVO) {
|
return success(refundService.createRefund(createReqVO));
|
}
|
|
@PutMapping("/update")
|
@Operation(summary = "更新退费单")
|
@PreAuthorize("@ss.hasPermission('crm:refund:update')")
|
public CommonResult<Boolean> updateRefund(@Valid @RequestBody CrmRefundSaveReqVO updateReqVO) {
|
refundService.updateRefund(updateReqVO);
|
return success(true);
|
}
|
|
@PutMapping("/audit")
|
@Operation(summary = "审批退费单(通过/驳回)")
|
@PreAuthorize("@ss.hasPermission('crm:refund:update')")
|
public CommonResult<Boolean> auditRefund(@Valid @RequestBody CrmRefundAuditReqVO auditReqVO) {
|
refundService.auditRefund(auditReqVO);
|
return success(true);
|
}
|
|
@PutMapping("/submit")
|
@Operation(summary = "提交退费单审批")
|
@PreAuthorize("@ss.hasPermission('crm:refund:update')")
|
public CommonResult<Boolean> submitRefund(@RequestParam("id") Long id,
|
@RequestParam("processDefinitionKey") String processDefinitionKey) {
|
refundService.submitRefund(id, processDefinitionKey, getLoginUserId());
|
return success(true);
|
}
|
|
@GetMapping("/approve-process-list")
|
@Operation(summary = "获得退费单审批流程定义列表")
|
@PreAuthorize("@ss.hasPermission('crm:refund:query')")
|
public CommonResult<List<Map<String, Object>>> getRefundApproveProcessDefinitionList() {
|
return success(refundService.getRefundApproveProcessDefinitionList());
|
}
|
|
@DeleteMapping("/delete")
|
@Operation(summary = "删除退费单")
|
@Parameter(name = "id", description = "编号", required = true)
|
@PreAuthorize("@ss.hasPermission('crm:refund:delete')")
|
public CommonResult<Boolean> deleteRefund(@RequestParam("id") Long id) {
|
refundService.deleteRefund(id);
|
return success(true);
|
}
|
|
@GetMapping("/get")
|
@Operation(summary = "获得退费单")
|
@Parameter(name = "id", description = "编号", required = true)
|
@PreAuthorize("@ss.hasPermission('crm:refund:query')")
|
public CommonResult<CrmRefundRespVO> getRefund(@RequestParam("id") Long id) {
|
return success(refundService.getRefund(id));
|
}
|
|
@GetMapping("/page")
|
@Operation(summary = "获得退费单分页")
|
@PreAuthorize("@ss.hasPermission('crm:refund:query')")
|
public CommonResult<PageResult<CrmRefundRespVO>> getRefundPage(@Valid CrmRefundPageReqVO pageReqVO) {
|
return success(refundService.getRefundPage(pageReqVO));
|
}
|
|
@GetMapping("/export-excel")
|
@Operation(summary = "导出退费单 Excel")
|
@PreAuthorize("@ss.hasPermission('crm:refund:export')")
|
@ApiAccessLog(operateType = EXPORT)
|
public void exportRefundExcel(@Valid CrmRefundPageReqVO exportReqVO,
|
HttpServletResponse response) throws IOException {
|
exportReqVO.setPageSize(PAGE_SIZE_NONE);
|
List<CrmRefundRespVO> list = refundService.getRefundList(exportReqVO);
|
ExcelUtils.write(response, "退费单.xls", "数据", CrmRefundRespVO.class, list);
|
}
|
|
}
|