fix:商户流水导出修改
This commit is contained in:
1 parent
71acd46cb7
commit
780279b936
1 file changed
+27
-14
+27
-14
@@ -249,9 +249,7 @@ public class HardOrderTotalController {
|
||||
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("商户不存在");
|
||||
|
||||
Long count = hardOrderMapper.count(dto, DataScope.of());
|
||||
if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围");
|
||||
List<HardOrderVo> list = hardOrderService.scopeList(dto, DataScope.of());
|
||||
List<HardMchOrderExcelVo> excelList = BeanUtils.toBean(list, HardMchOrderExcelVo.class);
|
||||
if (count > 10 * 10000) throw new RuntimeException("导出数据超出100000条,请缩小查询范围");
|
||||
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/商户交易流水导出.xlsx")).build()) {
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||
@@ -263,12 +261,23 @@ public class HardOrderTotalController {
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[1], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
map.put("merchantName", mch.getName());
|
||||
if (ObjectUtil.isNotEmpty(excelList)) {
|
||||
BigDecimal totalPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal extraPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal payPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal refundPriceSum = BigDecimal.ZERO;
|
||||
Long lineNumber = 1L;
|
||||
// 统计
|
||||
BigDecimal totalPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal extraPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal payPriceSum = BigDecimal.ZERO;
|
||||
BigDecimal refundPriceSum = BigDecimal.ZERO;
|
||||
// 列号
|
||||
Long lineNumber = 1L;
|
||||
// 分页相关
|
||||
long currentPage = 1;
|
||||
long pageSize = 1000;
|
||||
|
||||
while (true) {
|
||||
Page<HardOrderVo> page = hardOrderService.scopePageList(new Page(currentPage, pageSize), dto, DataScope.of());
|
||||
List<HardOrderVo> records = page.getRecords();
|
||||
if (ObjectUtil.isEmpty(records)) break;
|
||||
List<HardMchOrderExcelVo> excelList = BeanUtils.toBean(records, HardMchOrderExcelVo.class);
|
||||
// 处理excel start
|
||||
for (HardMchOrderExcelVo v : excelList) {
|
||||
v.setLineNumber(lineNumber);
|
||||
lineNumber++;
|
||||
@@ -295,13 +304,17 @@ public class HardOrderTotalController {
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("totalPriceSum", totalPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("extraPriceSum", extraPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("payPriceSum", payPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("refundPriceSum", refundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
excelWriter.fill(excelList, fillConfig, writeSheet);
|
||||
// 处理excel end
|
||||
if (page.getTotal() < pageSize) break;
|
||||
currentPage++;
|
||||
}
|
||||
map.put("totalPriceSum", totalPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("extraPriceSum", extraPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("payPriceSum", payPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("refundPriceSum", refundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(excelList, fillConfig, writeSheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user