|
@@ -131,11 +131,23 @@ public class ExchangeCodeController extends AbstractController {
|
|
|
|
|
|
@RequestMapping("/download")
|
|
|
public void download(@RequestParam("eid") Integer eid, HttpServletResponse response) throws IOException{
|
|
|
+ ExchangeCode exchangeCode = exchangeCodeService.queryOneExchangeCode(eid);
|
|
|
+ if (exchangeCode == null){
|
|
|
+ throw new ZSKKException(ErrorConstant.PARAM_ERROR);
|
|
|
+ }
|
|
|
+ GoodBase good = goodService.queryOneGoodBase(exchangeCode.getGid());
|
|
|
+ exchangeCodeService.addDownloadRecord(this.getUser(), eid);
|
|
|
List<ExchangeCodeItem> list = exchangeCodeService.getItems(eid, null);
|
|
|
- this.exportItems(this.getUser(), list, response);
|
|
|
+ this.exportItems(this.getUser(), list, good, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/downloadrecords")
|
|
|
+ @ResponseBody
|
|
|
+ public ControllerResult downloadRecords(@RequestParam("eid") Integer eid){
|
|
|
+ return new ControllerResult(exchangeCodeService.queryDownloadRecords(eid));
|
|
|
}
|
|
|
|
|
|
- private void exportItems(UserBean user, List<ExchangeCodeItem> items, HttpServletResponse response) throws IOException{
|
|
|
+ private void exportItems(UserBean user, List<ExchangeCodeItem> items, GoodBase good, HttpServletResponse response) throws IOException{
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
HSSFSheet sheet = workbook.createSheet("sheet1");
|
|
|
|
|
@@ -146,9 +158,11 @@ public class ExchangeCodeController extends AbstractController {
|
|
|
for (int i = 0; i < items.size(); ++i){
|
|
|
ExchangeCodeItem item = items.get(i);
|
|
|
HSSFRow row = sheet.createRow(i + 1);
|
|
|
- row.createCell(0).setCellValue(item.getEicode());
|
|
|
- row.createCell(1).setCellValue(item.getEipwd());
|
|
|
- row.createCell(2).setCellValue(item.getStatus().equals(ExchangeCodeService.ITEM_USE_STATUS_WAIT)? "未使用":"已使用");
|
|
|
+ row.createCell(0).setCellValue(good.getGid());
|
|
|
+ row.createCell(1).setCellValue(good.getName());
|
|
|
+ row.createCell(2).setCellValue(item.getEicode());
|
|
|
+ row.createCell(3).setCellValue(item.getEipwd());
|
|
|
+ row.createCell(4).setCellValue(item.getStatus().equals(ExchangeCodeService.ITEM_USE_STATUS_WAIT)? "未使用":"已使用");
|
|
|
}
|
|
|
|
|
|
String fileName = "兑换码-" + user.getName() + "-" + user.getPhone() + "-" + ToolsUtil.formatTime(new Date(), ToolsUtil.getYYYYMMDDHHMMSS()) + ".xls";
|
|
@@ -160,8 +174,10 @@ public class ExchangeCodeController extends AbstractController {
|
|
|
|
|
|
private void writeHead(HSSFSheet sheet){
|
|
|
HSSFRow row = sheet.createRow(0);
|
|
|
- row.createCell(0).setCellValue("兑换码");
|
|
|
- row.createCell(1).setCellValue("密码");
|
|
|
- row.createCell(2).setCellValue("使用状态");
|
|
|
+ row.createCell(0).setCellValue("商品ID");
|
|
|
+ row.createCell(1).setCellValue("商品名称");
|
|
|
+ row.createCell(2).setCellValue("兑换码");
|
|
|
+ row.createCell(3).setCellValue("密码");
|
|
|
+ row.createCell(4).setCellValue("使用状态");
|
|
|
}
|
|
|
}
|