feat:部门交易金额导出

This commit is contained in:
dzc committed 2025-01-23 14:22:03 +08:00
1 parent 7e1be7ef2f
commit b5666485de
11 files changed
+122 -9

No files matched your search

@@ -0,0 +1,17 @@
package com.bsd.pjcloud.hard.api.dto.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class HardDeptTotalDto {
@Schema(description = "饭卡类型id")
private Long walletTypeId;
@Schema(description = "饭卡类型id")
private LocalDateTime[] createTimeList;
}
@@ -14,4 +14,6 @@ public class HardOrderSumAndCountDto {
private LocalDateTime[] createTimeList;
private Long walletTypeId;
}
@@ -10,8 +10,10 @@ 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.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
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.HardDeptTotalDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardDeptTotalVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
@@ -59,13 +61,13 @@ public class HardOrderTotalController {
@GetMapping("/page-list-dept")
@Operation(summary = "部门交易记录")
public R<Page<HardDeptTotalVo>> pageListDept(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
return R.ok(HardOrderTotalService.pageListDept(page, dto));
public R<List<HardDeptTotalVo>> pageListDept(@ParameterObject HardDeptTotalDto dto) {
return R.ok(HardOrderTotalService.pageListDept(dto));
}
@Operation(summary = "设备交易记录导出", description = "退款导出")
@Operation(summary = "设备交易记录导出", description = "设备交易记录导出")
@GetMapping("/export-sb")
@SysLog("设备交易记录导出")
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_sb')")
public void exportSb(HttpServletResponse response, HardOrderDto dto) throws IOException {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
@@ -103,8 +105,9 @@ public class HardOrderTotalController {
}
@Operation(summary = "商户交易记录导出", description = "退款导出")
@Operation(summary = "商户交易记录导出", description = "商户交易记录导出")
@GetMapping("/export-cs")
@SysLog("商户交易记录导出")
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_cs')")
public void exportTk(HttpServletResponse response, HardOrderDto dto) throws IOException {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
@@ -140,4 +143,64 @@ public class HardOrderTotalController {
excelWriter.fill(list, fillConfig, writeSheet);
}
}
@Operation(summary = "部门交易记录导出", description = "部门交易记录导出")
@GetMapping("/export-dept")
@SysLog("部门交易记录导出")
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_dept')")
public void exportDept(HttpServletResponse response, HardDeptTotalDto dto) throws IOException {
List<HardDeptTotalVo> list = HardOrderTotalService.pageListDept(dto);
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.getCreateTimeList())) {
map.put("timeSpan", " 到 ");
map.put("startTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
map.put("endTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
}
if (ObjectUtil.isNotEmpty(list)) {
BigDecimal walletPriceSum = BigDecimal.ZERO;
BigDecimal walletCountSum = BigDecimal.ZERO;
BigDecimal totalPayPriceSum = BigDecimal.ZERO;
BigDecimal totalPayCountSum = BigDecimal.ZERO;
BigDecimal orderRefundPriceSum = BigDecimal.ZERO;
BigDecimal orderRefundContSum = BigDecimal.ZERO;
for (HardDeptTotalVo v : list) {
if (ObjectUtil.isNotEmpty(v.getWalletPrice())) {
walletPriceSum = walletPriceSum.add(BigDecimal.valueOf(v.getWalletPrice()));
v.setWalletPrice(BigDecimal.valueOf(v.getWalletPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
if (ObjectUtil.isNotEmpty(v.getWalletCount())) {
walletCountSum = walletCountSum.add(BigDecimal.valueOf(v.getWalletCount()));
v.setWalletCount(BigDecimal.valueOf(v.getWalletCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
if (ObjectUtil.isNotEmpty(v.getOrderPayPrice())) {
totalPayPriceSum = totalPayPriceSum.add(BigDecimal.valueOf(v.getOrderPayPrice()));
v.setOrderPayPrice(BigDecimal.valueOf(v.getOrderPayPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
if (ObjectUtil.isNotEmpty(v.getOrderPayCount())) {
totalPayCountSum = totalPayCountSum.add(BigDecimal.valueOf(v.getOrderPayCount()));
v.setOrderPayCount(BigDecimal.valueOf(v.getOrderPayCount()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
if (ObjectUtil.isNotEmpty(v.getOrderRefundPrice())) {
orderRefundPriceSum = orderRefundPriceSum.add(BigDecimal.valueOf(v.getOrderRefundPrice()));
v.setOrderRefundPrice(BigDecimal.valueOf(v.getOrderRefundPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
if (ObjectUtil.isNotEmpty(v.getOrderRefundCont())) {
orderRefundContSum = orderRefundContSum.add(BigDecimal.valueOf(v.getOrderRefundCont()));
v.setOrderRefundCont(BigDecimal.valueOf(v.getOrderRefundCont()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).longValue());
}
map.put("walletPriceSum", walletPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
map.put("walletCountSum", walletCountSum.toString());
map.put("totalPayPriceSum", totalPayPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
map.put("totalPayCountSum", totalPayCountSum.toString());
map.put("orderRefundPriceSum", orderRefundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
map.put("orderRefundContSum", orderRefundContSum.toString());
}
}
excelWriter.fill(map, writeSheet);
excelWriter.fill(list, fillConfig, writeSheet);
}
}
}
@@ -1,6 +1,7 @@
package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardDeptTotalVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
@@ -18,5 +19,5 @@ public interface HardOrderTotalService {
List<HardOrderCsVo> listCs(HardOrderDto dto);
Page<HardDeptTotalVo> pageListDept(Page page, HardOrderDto dto);
List<HardDeptTotalVo> pageListDept(HardDeptTotalDto dto);
}
@@ -9,6 +9,7 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderSumAndCountDto;
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
@@ -133,7 +134,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
}
@Override
public Page<HardDeptTotalVo> pageListDept(Page page, HardOrderDto dto) {
public List<HardDeptTotalVo> pageListDept(HardDeptTotalDto dto) {
// 查询部门
CompletableFuture<List<SysDept>> deptFuture = CompletableFuture.supplyAsync(() ->
remoteDeptService.getInnerAllDept().getData()
@@ -151,6 +152,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
CompletableFuture<List<WalletTransactionSumAndCountVo>> walletFuture = CompletableFuture.supplyAsync(() -> {
WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto();
walletDto.setDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
walletDto.setCreateTimeList(dto.getCreateTimeList());
}
if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) {
walletDto.setWalletTypeId(dto.getWalletTypeId());
}
return remoteWalletTransactionService.sumAndCount(walletDto).getData();
});
// 查询订单支付流水
@@ -158,6 +165,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
HardOrderSumAndCountDto payDto = new HardOrderSumAndCountDto();
payDto.setDeptIds(deptIds);
payDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
payDto.setCreateTimeList(dto.getCreateTimeList());
}
if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) {
payDto.setWalletTypeId(dto.getWalletTypeId());
}
return hardOrderMapper.sumAndCount(payDto);
});
// 查询订单退款流水
@@ -165,6 +178,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
HardOrderSumAndCountDto refundDto = new HardOrderSumAndCountDto();
refundDto.setDeptIds(deptIds);
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes());
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
refundDto.setCreateTimeList(dto.getCreateTimeList());
}
if (ObjectUtil.isNotEmpty(dto.getWalletTypeId())) {
refundDto.setWalletTypeId(dto.getWalletTypeId());
}
return hardOrderMapper.sumAndCount(refundDto);
});
CompletableFuture<Void> allFutures = CompletableFuture.allOf(walletFuture, payFuture, refundFuture);
@@ -195,7 +214,6 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
}
return resultList;
});
List<HardDeptTotalVo> resultList = resultListFuture.join();
return null;
return resultListFuture.join();
}
}
@@ -146,6 +146,8 @@
from hard_order a
<where>
a.del_flag = 0 and a.dept_id is not null
<if test="dto.walletTypeId != null">
</if>
<if test="dto.orderStatusCodes != null and dto.orderStatusCodes.size() != 0">
and a.order_status in
<foreach collection="dto.orderStatusCodes" item="v" open="(" close=")" separator=",">
@@ -19,6 +19,7 @@
package com.bsd.pjcloud.admin.api.feign;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
@@ -19,6 +19,9 @@
package com.bsd.pjcloud.admin.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.vo.DeptExcelVO;
import com.bsd.pjcloud.admin.service.SysDeptService;
@@ -32,6 +35,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@@ -1,5 +1,6 @@
package com.bsd.pjcloud.wallet.api.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@@ -24,4 +25,6 @@ public class WalletTransactionSumAndCountDto {
private LocalDateTime[] createTimeList;
private Long walletTypeId;
}
@@ -58,6 +58,8 @@
from wallet_transaction a
<where>
a.del_flag = 0 and a.dept_id is not null
<if test="dto.walletTypeId != null">
</if>
<if test="dto.type != null">
<if test="dto.type == 1">
and a.price &gt; 0