1
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.jarvis.domain.GroupRebateExcelUpload;
|
||||
import com.ruoyi.jarvis.domain.OrderRows;
|
||||
import com.ruoyi.jarvis.service.IGroupRebateExcelUploadService;
|
||||
import com.ruoyi.jarvis.service.impl.GroupRebateExcelImportService;
|
||||
import com.ruoyi.jarvis.service.IOrderRowsService;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
@@ -37,14 +43,17 @@ public class JDOrderListController extends BaseController
|
||||
private final IOrderRowsService orderRowsService;
|
||||
private final IInstructionService instructionService;
|
||||
private final GroupRebateExcelImportService groupRebateExcelImportService;
|
||||
private final IGroupRebateExcelUploadService groupRebateExcelUploadService;
|
||||
|
||||
public JDOrderListController(IJDOrderService jdOrderService, IOrderRowsService orderRowsService,
|
||||
IInstructionService instructionService,
|
||||
GroupRebateExcelImportService groupRebateExcelImportService) {
|
||||
GroupRebateExcelImportService groupRebateExcelImportService,
|
||||
IGroupRebateExcelUploadService groupRebateExcelUploadService) {
|
||||
this.jdOrderService = jdOrderService;
|
||||
this.orderRowsService = orderRowsService;
|
||||
this.instructionService = instructionService;
|
||||
this.groupRebateExcelImportService = groupRebateExcelImportService;
|
||||
this.groupRebateExcelUploadService = groupRebateExcelUploadService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,10 +149,7 @@ public class JDOrderListController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出JD订单列表
|
||||
*/
|
||||
/**
|
||||
* 导入跟团返现类 Excel:按「单号/订单号」匹配系统订单,将「是否返现」「总共返现」等写入后返备注(可多次导入累加)
|
||||
* 导入跟团返现类 Excel:按「单号/订单号」匹配系统订单,将「是否返现」「总共返现」等写入后返备注(可多次导入累加);文件落盘并记上传记录。
|
||||
*/
|
||||
@Log(title = "JD订单后返表导入", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importGroupRebateExcel")
|
||||
@@ -151,15 +157,55 @@ public class JDOrderListController extends BaseController
|
||||
@RequestParam(value = "documentTitle", required = false) String documentTitle) {
|
||||
try {
|
||||
Map<String, Object> data = groupRebateExcelImportService.importExcel(file, documentTitle);
|
||||
if (Boolean.FALSE.equals(data.get("success"))) {
|
||||
return AjaxResult.error(String.valueOf(data.get("message")));
|
||||
}
|
||||
return AjaxResult.success(data);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("导入失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后返表上传记录(分页)
|
||||
*/
|
||||
@GetMapping("/groupRebateUpload/list")
|
||||
public TableDataInfo groupRebateUploadList(GroupRebateExcelUpload query, HttpServletRequest request) {
|
||||
startPage();
|
||||
String beginTimeStr = request.getParameter("beginTime");
|
||||
String endTimeStr = request.getParameter("endTime");
|
||||
if (beginTimeStr != null && !beginTimeStr.isEmpty()) {
|
||||
query.getParams().put("beginTime", beginTimeStr);
|
||||
}
|
||||
if (endTimeStr != null && !endTimeStr.isEmpty()) {
|
||||
query.getParams().put("endTime", endTimeStr);
|
||||
}
|
||||
List<GroupRebateExcelUpload> list = groupRebateExcelUploadService.selectGroupRebateExcelUploadList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新下载已上传的后返表原件(与通用 download 一致,使用 POST + blob)
|
||||
*/
|
||||
@Log(title = "后返表上传记录下载", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/groupRebateUpload/download/{id}")
|
||||
public void downloadGroupRebateUpload(@PathVariable("id") Long id, HttpServletResponse response) throws Exception {
|
||||
GroupRebateExcelUpload rec = groupRebateExcelUploadService.selectGroupRebateExcelUploadById(id);
|
||||
if (rec == null || StringUtils.isEmpty(rec.getFilePath())) {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
File file = GroupRebateExcelImportService.resolveDiskFile(rec.getFilePath());
|
||||
if (!file.isFile()) {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
String downloadName = StringUtils.isNotEmpty(rec.getOriginalFilename()) ? rec.getOriginalFilename() : file.getName();
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
||||
FileUtils.writeBytes(file.getAbsolutePath(), response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出JD订单列表
|
||||
*/
|
||||
@Log(title = "JD订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, JDOrder jdOrder) throws IOException
|
||||
|
||||
Reference in New Issue
Block a user