Authored by caoyan

退款

1 package com.yoho.ufo.order.controller; 1 package com.yoho.ufo.order.controller;
2 2
  3 +import java.io.File;
3 import java.text.ParseException; 4 import java.text.ParseException;
4 5
  6 +import javax.servlet.http.HttpServletResponse;
  7 +
5 import org.apache.commons.lang3.StringUtils; 8 import org.apache.commons.lang3.StringUtils;
6 import org.slf4j.Logger; 9 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory; 10 import org.slf4j.LoggerFactory;
@@ -12,9 +15,13 @@ import org.springframework.web.bind.annotation.RestController; @@ -12,9 +15,13 @@ import org.springframework.web.bind.annotation.RestController;
12 import com.yoho.order.model.AppraiseOrderReq; 15 import com.yoho.order.model.AppraiseOrderReq;
13 import com.yoho.order.model.RefundRecordBo; 16 import com.yoho.order.model.RefundRecordBo;
14 import com.yoho.order.model.RefundRecordReq; 17 import com.yoho.order.model.RefundRecordReq;
  18 +import com.yoho.ufo.exception.PlatformException;
15 import com.yoho.ufo.order.service.IRefundRecordService; 19 import com.yoho.ufo.order.service.IRefundRecordService;
  20 +import com.yoho.ufo.service.impl.BatchService;
16 import com.yoho.ufo.service.model.ApiResponse; 21 import com.yoho.ufo.service.model.ApiResponse;
  22 +import com.yoho.ufo.service.model.ExportParam;
17 import com.yoho.ufo.service.model.PageResponseBO; 23 import com.yoho.ufo.service.model.PageResponseBO;
  24 +import com.yoho.ufo.util.HttpUtil;
18 25
19 @RestController 26 @RestController
20 @RequestMapping(value = "/refundRecord") 27 @RequestMapping(value = "/refundRecord")
@@ -24,6 +31,9 @@ public class RefundRecordController { @@ -24,6 +31,9 @@ public class RefundRecordController {
24 31
25 @Autowired 32 @Autowired
26 private IRefundRecordService refundRecordService; 33 private IRefundRecordService refundRecordService;
  34 +
  35 + @Autowired
  36 + private BatchService batchService;
27 37
28 @RequestMapping(value = "/list") 38 @RequestMapping(value = "/list")
29 public ApiResponse list(RefundRecordReq req) { 39 public ApiResponse list(RefundRecordReq req) {
@@ -109,5 +119,23 @@ public class RefundRecordController { @@ -109,5 +119,23 @@ public class RefundRecordController {
109 return new ApiResponse.ApiResponseBuilder().code(400).message("更新失败").build(); 119 return new ApiResponse.ApiResponseBuilder().code(400).message("更新失败").build();
110 } 120 }
111 } 121 }
  122 +
  123 + @RequestMapping(value = "/export")
  124 + public String export(HttpServletResponse response, String param) {
  125 + File file;
  126 + try {
  127 + ExportParam exportParam = new ExportParam();
  128 + exportParam.setType("refundRecordServiceImpl");
  129 + exportParam.setQueryConf(param);
  130 + file = batchService.batchExport(exportParam);
  131 + return HttpUtil.writeFile(response, file, "application/vnd.ms-excel");
  132 + } catch (PlatformException e) {
  133 + LOGGER.warn("exportForGet find wrong.", e);
  134 + return HttpUtil.writeErrorInfo(response, e.getMessage());
  135 + } catch (Exception e) {
  136 + LOGGER.warn("exportForGet find wrong.", e);
  137 + return HttpUtil.writeErrorInfo(response, "<p>导出失败</p>");
  138 + }
  139 + }
112 140
113 } 141 }