feat:设备交易记录、商户交易记录导出
This commit is contained in:
1 parent
55af27dde1
commit
bafd38976e
6 files changed
+111
-36
No files matched your search
-8
@@ -13,13 +13,8 @@ import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@HeadRowHeight(40)
|
||||
@ColumnWidth(50)
|
||||
@ContentRowHeight(20)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
|
||||
|
||||
@ExcelProperty("设备名称")
|
||||
@Schema(description = "设备id")
|
||||
private Long hardId;
|
||||
|
||||
@@ -29,7 +24,6 @@ public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
|
||||
@Schema(description = "设备类型")
|
||||
private String hardType;
|
||||
|
||||
@ExcelProperty("所属商户")
|
||||
@Schema(description = "商户名")
|
||||
private String merchantName;
|
||||
|
||||
@@ -39,11 +33,9 @@ public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
|
||||
@Schema(description = "商户id")
|
||||
private Long merchantId;
|
||||
|
||||
@ExcelProperty("总消费金额")
|
||||
@Schema(description = "总消费金额")
|
||||
private BigDecimal totalPayPrice;
|
||||
|
||||
@ExcelProperty("总消费次数")
|
||||
@Schema(description = "总消费次数")
|
||||
private BigDecimal totalPayCount;
|
||||
|
||||
|
||||
+14
-19
@@ -1,6 +1,7 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.order;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
@@ -12,36 +13,30 @@ import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@HeadRowHeight(40)
|
||||
@ColumnWidth(50)
|
||||
@ContentRowHeight(20)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class HardOrderSbVo implements BaseMchInterface, BaseHardInterface {
|
||||
|
||||
@Schema(description = "设备id")
|
||||
private Long hardId;
|
||||
|
||||
@Schema(description = "设备名称")
|
||||
private String hardName;
|
||||
|
||||
@Schema(description = "设备类型")
|
||||
private String hardType;
|
||||
|
||||
@Schema(description = "商户id")
|
||||
private Long merchantId;
|
||||
|
||||
@Schema(description = "总消费金额")
|
||||
@Schema(description = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@Schema(description = "商户logo")
|
||||
private String logoPic;
|
||||
|
||||
@Schema(description = "总消费金额(元)")
|
||||
private BigDecimal totalPayPrice;
|
||||
|
||||
@Schema(description = "总消费次数")
|
||||
private BigDecimal totalPayCount;
|
||||
|
||||
/**
|
||||
* 商户相关
|
||||
*/
|
||||
private String merchantName;
|
||||
|
||||
private String logoPic;
|
||||
|
||||
/**
|
||||
* 设备相关
|
||||
*/
|
||||
private String hardName;
|
||||
|
||||
private String hardType;
|
||||
|
||||
}
|
||||
@@ -175,4 +175,24 @@
|
||||
<id>boot</id>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/*.xlsx</exclude>
|
||||
<exclude>**/*.xls</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>**/*.xlsx</include>
|
||||
<include>**/*.xls</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
+77
-9
@@ -1,25 +1,37 @@
|
||||
package com.bsd.pjcloud.hard.controller.order;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionTkExcelVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -44,24 +56,80 @@ public class HardOrderTotalController {
|
||||
return R.ok(HardOrderTotalService.pageListCs(page, dto));
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@Operation(summary = "设备交易记录导出", description = "退款导出")
|
||||
@GetMapping("/export-sb")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_sb')")
|
||||
public List<WalletTransactionTkExcelVo> exportSb(HardOrderDto dto) {
|
||||
public void exportSb(HttpServletResponse response, HardOrderDto dto) throws IOException {
|
||||
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
|
||||
List<HardOrderSbVo> list = HardOrderTotalService.listSb(dto);
|
||||
return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class);
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/设备交易金额汇总.xlsx")).build()) {
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getPayTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal priceTotal = BigDecimal.ZERO;
|
||||
BigDecimal countTotal = BigDecimal.ZERO;
|
||||
for (HardOrderSbVo v : list) {
|
||||
if (ObjectUtil.isNotEmpty(v.getHardType())) {
|
||||
v.setHardType(HardTypeEnum.valueOfByType(v.getHardType()).getDescription());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalPayPrice())) {
|
||||
priceTotal = priceTotal.add(v.getTotalPayPrice());
|
||||
v.setTotalPayPrice(v.getTotalPayPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalPayCount())) {
|
||||
countTotal = countTotal.add(v.getTotalPayCount());
|
||||
}
|
||||
}
|
||||
map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("computeTotalPayCount", countTotal.toString());
|
||||
}
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ResponseExcel
|
||||
@Operation(summary = "商户交易记录导出", description = "退款导出")
|
||||
@GetMapping("/export-cs")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_cs')")
|
||||
public List<WalletTransactionTkExcelVo> exportTk(HardOrderDto dto) {
|
||||
public void exportTk(HttpServletResponse response, HardOrderDto dto) throws IOException {
|
||||
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
|
||||
List<HardOrderCsVo> list = HardOrderTotalService.listCs(dto);
|
||||
return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class);
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/商户交易金额汇总.xlsx")).build()) {
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getPayTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal priceTotal = BigDecimal.ZERO;
|
||||
BigDecimal countTotal = BigDecimal.ZERO;
|
||||
for (HardOrderCsVo v : list) {
|
||||
if (ObjectUtil.isNotEmpty(v.getHardType())) {
|
||||
v.setHardType(HardTypeEnum.valueOfByType(v.getHardType()).getDescription());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalPayPrice())) {
|
||||
priceTotal = priceTotal.add(v.getTotalPayPrice());
|
||||
v.setTotalPayPrice(v.getTotalPayPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getTotalPayCount())) {
|
||||
countTotal = countTotal.add(v.getTotalPayCount());
|
||||
}
|
||||
}
|
||||
map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
map.put("computeTotalPayCount", countTotal.toString());
|
||||
}
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user