新增抽奖明细导出
This commit is contained in:
@@ -16,18 +16,18 @@ import java.util.List;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Pagination {
|
||||
public class Pagination<T> {
|
||||
|
||||
private long total;
|
||||
|
||||
private List rows;
|
||||
private List<T> rows;
|
||||
|
||||
public Pagination(IPage pageInfo){
|
||||
public Pagination(IPage<T> pageInfo) {
|
||||
this.total = pageInfo.getTotal();
|
||||
this.rows = pageInfo.getRecords();
|
||||
}
|
||||
|
||||
public Pagination(PageInfo pageInfo){
|
||||
public Pagination(PageInfo<T> pageInfo) {
|
||||
this.total = pageInfo.getTotal();
|
||||
this.rows = pageInfo.getList();
|
||||
}
|
||||
|
@@ -0,0 +1,81 @@
|
||||
package com.accompany.admin.dto.treasure;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2023/10/25 16:57
|
||||
* @description:
|
||||
*/
|
||||
@Data
|
||||
public class SeizeTreasureRecordDto {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 平台号
|
||||
*/
|
||||
@ExcelProperty("平台号")
|
||||
private Long erbanNo;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@ExcelProperty("昵称")
|
||||
private String userNick;
|
||||
|
||||
/**
|
||||
* 奖励ID
|
||||
*/
|
||||
@ExcelProperty("奖励ID")
|
||||
private Long rewardId;
|
||||
|
||||
/**
|
||||
* 奖励关联ID
|
||||
*/
|
||||
@ExcelProperty("奖励关联ID")
|
||||
private Long rewardRefId;
|
||||
|
||||
/**
|
||||
* 奖励类型
|
||||
*/
|
||||
@ExcelProperty("奖励类型")
|
||||
private String rewardType;
|
||||
|
||||
/**
|
||||
* 奖励名称
|
||||
*/
|
||||
@ExcelProperty("奖励名称")
|
||||
private String rewardName;
|
||||
|
||||
/**
|
||||
* 奖励数量
|
||||
*/
|
||||
@ExcelProperty("奖励数量")
|
||||
private Integer rewardNum;
|
||||
|
||||
/**
|
||||
* 奖励等级
|
||||
*/
|
||||
@ExcelProperty("奖励等级")
|
||||
private Integer rewardLevel;
|
||||
|
||||
/**
|
||||
* 奖励价值
|
||||
*/
|
||||
@ExcelProperty("奖励价值")
|
||||
private Integer rewardShowValue;
|
||||
|
||||
/**
|
||||
* 抽奖时间
|
||||
*/
|
||||
@ExcelProperty("抽奖时间")
|
||||
private String createTimeStr;
|
||||
}
|
@@ -1,22 +1,31 @@
|
||||
package com.accompany.admin.service.treasure;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.accompany.admin.base.Pagination;
|
||||
import com.accompany.admin.dto.treasure.SeizeTreasureRecordDto;
|
||||
import com.accompany.admin.mapper.treasure.SeizeTreasureAdminMapper;
|
||||
import com.accompany.admin.params.treasure.TreasureRecordReq;
|
||||
import com.accompany.admin.vo.GiftSendRecordAdminVo;
|
||||
import com.accompany.admin.vo.treasure.SeizeTreasureDailyRecordVo;
|
||||
import com.accompany.admin.vo.treasure.SeizeTreasureRecordVo;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.treasure.record.SeizeTreasureStaticVo;
|
||||
import com.accompany.common.model.PageReq;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SeizeTreasureAdminService {
|
||||
@Autowired
|
||||
@@ -65,7 +74,39 @@ public class SeizeTreasureAdminService {
|
||||
List<SeizeTreasureRecordVo> recordDaily = seizeTreasureAdminMapper.getRecord(
|
||||
recordReq.getPoolTypeList(), recordReq.getPoolGroupList(), recordReq.getPoolLevelList(), userByErbanNo == null ? null : userByErbanNo.getUid(),
|
||||
recordReq.getStartTime(), recordReq.getEndTime());
|
||||
PageInfo<GiftSendRecordAdminVo> pageInfo = new PageInfo(recordDaily);
|
||||
PageInfo<SeizeTreasureRecordVo> pageInfo = new PageInfo<>(recordDaily);
|
||||
return new Pagination(pageInfo);
|
||||
}
|
||||
|
||||
public void export(TreasureRecordReq params, ServletWebRequest servletWebRequest) {
|
||||
PageReq pageReq = new PageReq();
|
||||
pageReq.setPage(1);
|
||||
pageReq.setPageSize(10000000);
|
||||
Pagination<SeizeTreasureRecordVo> pagination = getRecord(params, pageReq);
|
||||
List<SeizeTreasureRecordDto> datas = new ArrayList<>();
|
||||
List<SeizeTreasureRecordVo> records = pagination.getRows();
|
||||
if (CollectionUtil.isNotEmpty(records)) {
|
||||
for (SeizeTreasureRecordVo record : records) {
|
||||
SeizeTreasureRecordDto admin = new SeizeTreasureRecordDto();
|
||||
BeanUtils.copyProperties(record, admin);
|
||||
if (record.getCreateTime() != null) {
|
||||
admin.setCreateTimeStr(DateTimeUtil.convertDate(record.getCreateTime()));
|
||||
}
|
||||
datas.add(admin);
|
||||
}
|
||||
}
|
||||
if (servletWebRequest.getResponse() != null) {
|
||||
try {
|
||||
//这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
||||
servletWebRequest.getResponse().setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
servletWebRequest.getResponse().setCharacterEncoding("utf-8");
|
||||
//这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||
String fileName = URLEncoder.encode("抽奖明细", "UTF-8").replaceAll("\\+", "%20");
|
||||
servletWebRequest.getResponse().setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
EasyExcel.write(servletWebRequest.getResponse().getOutputStream(), SeizeTreasureRecordDto.class).sheet("抽奖明细").doWrite(datas);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,12 +8,16 @@ import com.accompany.business.vo.treasure.record.SeizeTreasureStaticVo;
|
||||
import com.accompany.common.constant.SeizeTreasureConstant;
|
||||
import com.accompany.common.model.PageReq;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,4 +53,17 @@ public class SeizeTreasureAdminController extends BaseController {
|
||||
}
|
||||
return seizeTreasureAdminService.getRecord(params, pageReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param params
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation("导出")
|
||||
@GetMapping("/treasure/record/export")
|
||||
public void export(TreasureRecordReq params, HttpServletRequest request, HttpServletResponse response) {
|
||||
seizeTreasureAdminService.export(params, new ServletWebRequest(request, response));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user