diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardDeptTotalDto.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardDeptTotalDto.java new file mode 100644 index 000000000..e414333d2 --- /dev/null +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardDeptTotalDto.java @@ -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; + +} diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderSumAndCountDto.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderSumAndCountDto.java index 225ea7a4a..e29580abb 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderSumAndCountDto.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderSumAndCountDto.java @@ -14,4 +14,6 @@ public class HardOrderSumAndCountDto { private LocalDateTime[] createTimeList; + private Long walletTypeId; + } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java index e56565163..b3eac7a16 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java @@ -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> pageListDept(@ParameterObject Page page, @ParameterObject HardOrderDto dto) { - dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes()); - return R.ok(HardOrderTotalService.pageListDept(page, dto)); + public R> 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 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 map = new HashMap(); + 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); + } + } } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java index cdd9f6d03..6a605938c 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderTotalService.java @@ -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 listCs(HardOrderDto dto); - Page pageListDept(Page page, HardOrderDto dto); + List pageListDept(HardDeptTotalDto dto); } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java index 72a3a21f3..78adec755 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardOrderTotalServiceImpl.java @@ -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 pageListDept(Page page, HardOrderDto dto) { + public List pageListDept(HardDeptTotalDto dto) { // 查询部门 CompletableFuture> deptFuture = CompletableFuture.supplyAsync(() -> remoteDeptService.getInnerAllDept().getData() @@ -151,6 +152,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { CompletableFuture> 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 allFutures = CompletableFuture.allOf(walletFuture, payFuture, refundFuture); @@ -195,7 +214,6 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService { } return resultList; }); - List resultList = resultListFuture.join(); - return null; + return resultListFuture.join(); } } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx new file mode 100644 index 000000000..f0d9426b8 Binary files /dev/null and b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/部门交易金额汇总.xlsx differ diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml index f583469ba..33001b027 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/mapper/order/HardOrderMapper.xml @@ -146,6 +146,8 @@ from hard_order a a.del_flag = 0 and a.dept_id is not null + + and a.order_status in diff --git a/pjcloud-upms/pjcloud-upms-api/src/main/java/com/bsd/pjcloud/admin/api/feign/RemoteDeptService.java b/pjcloud-upms/pjcloud-upms-api/src/main/java/com/bsd/pjcloud/admin/api/feign/RemoteDeptService.java index 3c9ceb845..c1a44e43d 100644 --- a/pjcloud-upms/pjcloud-upms-api/src/main/java/com/bsd/pjcloud/admin/api/feign/RemoteDeptService.java +++ b/pjcloud-upms/pjcloud-upms-api/src/main/java/com/bsd/pjcloud/admin/api/feign/RemoteDeptService.java @@ -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; diff --git a/pjcloud-upms/pjcloud-upms-biz/src/main/java/com/bsd/pjcloud/admin/controller/SysDeptController.java b/pjcloud-upms/pjcloud-upms-biz/src/main/java/com/bsd/pjcloud/admin/controller/SysDeptController.java index 5732c87a6..bf123e0d9 100644 --- a/pjcloud-upms/pjcloud-upms-biz/src/main/java/com/bsd/pjcloud/admin/controller/SysDeptController.java +++ b/pjcloud-upms/pjcloud-upms-biz/src/main/java/com/bsd/pjcloud/admin/controller/SysDeptController.java @@ -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.*; diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionSumAndCountDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionSumAndCountDto.java index 7aef47cf0..e4b837ea3 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionSumAndCountDto.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionSumAndCountDto.java @@ -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; + } diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletTransactionMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletTransactionMapper.xml index 1c571c899..8e0718ab8 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletTransactionMapper.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/WalletTransactionMapper.xml @@ -58,6 +58,8 @@ from wallet_transaction a a.del_flag = 0 and a.dept_id is not null + + and a.price > 0