Commit 0e7ce637192e5ca96c4ff8abbe0e3feb13dc6672

Authored by YunaiV
1 parent 288d8e31

feat:【PAY 支付】转账单,支持导出功能

yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java
... ... @@ -15,4 +15,6 @@ public interface DictTypeConstants {
15 15  
16 16 String NOTIFY_STATUS = "pay_notify_status"; // 回调状态
17 17  
  18 + String TRANSFER_STATUS = "pay_transfer_status"; // 转账状态
  19 +
18 20 }
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java
... ... @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestParam;
25 25 import org.springframework.web.bind.annotation.RestController;
26 26  
27 27 import java.io.IOException;
28   -import java.util.ArrayList;
29 28 import java.util.List;
30 29 import java.util.Map;
31 30  
... ... @@ -78,13 +77,8 @@ public class PayRefundController {
78 77 @PreAuthorize("@ss.hasPermission('pay:refund:export')")
79 78 @ApiAccessLog(operateType = EXPORT)
80 79 public void exportRefundExcel(@Valid PayRefundExportReqVO exportReqVO,
81   - HttpServletResponse response) throws IOException {
  80 + HttpServletResponse response) throws IOException {
82 81 List<PayRefundDO> list = refundService.getRefundList(exportReqVO);
83   - if (CollectionUtil.isEmpty(list)) {
84   - ExcelUtils.write(response, "退款订单.xls", "数据",
85   - PayRefundExcelVO.class, new ArrayList<>());
86   - return;
87   - }
88 82  
89 83 // 拼接返回
90 84 Map<Long, PayAppDO> appMap = appService.getAppMap(convertList(list, PayRefundDO::getAppId));
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java
1 1 package cn.iocoder.yudao.module.pay.controller.admin.transfer;
2 2  
  3 +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
3 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6   -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageItemRespVO;
  7 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
7 8 import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO;
8 9 import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferRespVO;
  10 +import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
9 11 import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
  12 +import cn.iocoder.yudao.module.pay.service.app.PayAppService;
10 13 import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService;
11 14 import io.swagger.v3.oas.annotations.Operation;
12 15 import io.swagger.v3.oas.annotations.tags.Tag;
13 16 import jakarta.annotation.Resource;
  17 +import jakarta.servlet.http.HttpServletResponse;
14 18 import jakarta.validation.Valid;
15 19 import org.springframework.security.access.prepost.PreAuthorize;
16 20 import org.springframework.validation.annotation.Validated;
... ... @@ -19,7 +23,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
19 23 import org.springframework.web.bind.annotation.RequestParam;
20 24 import org.springframework.web.bind.annotation.RestController;
21 25  
  26 +import java.io.IOException;
  27 +import java.util.Map;
  28 +
  29 +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
22 30 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  31 +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
  32 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
23 33  
24 34 @Tag(name = "管理后台 - 转账单")
25 35 @RestController
... ... @@ -29,22 +39,53 @@ public class PayTransferController {
29 39  
30 40 @Resource
31 41 private PayTransferService payTransferService;
  42 + @Resource
  43 + private PayAppService payAppService;
32 44  
33 45 @GetMapping("/get")
34 46 @Operation(summary = "获得转账订单")
35 47 @PreAuthorize("@ss.hasPermission('pay:transfer:query')")
36 48 public CommonResult<PayTransferRespVO> getTransfer(@RequestParam("id") Long id) {
37 49 PayTransferDO transfer = payTransferService.getTransfer(id);
38   - return success(BeanUtils.toBean(transfer, PayTransferRespVO.class));
  50 + if (transfer == null) {
  51 + return success(new PayTransferRespVO());
  52 + }
  53 +
  54 + // 拼接数据
  55 + PayAppDO app = payAppService.getApp(transfer.getAppId());
  56 + return success(BeanUtils.toBean(transfer, PayTransferRespVO.class, transferVO -> {
  57 + if (app != null) {
  58 + transferVO.setAppName(app.getName());
  59 + }
  60 + }));
39 61 }
40 62  
41   - // TODO @芋艿:get 和 page 的返回,是不是统一融合
42 63 @GetMapping("/page")
43 64 @Operation(summary = "获得转账订单分页")
44 65 @PreAuthorize("@ss.hasPermission('pay:transfer:query')")
45   - public CommonResult<PageResult<PayTransferPageItemRespVO>> getTransferPage(@Valid PayTransferPageReqVO pageVO) {
  66 + public CommonResult<PageResult<PayTransferRespVO>> getTransferPage(@Valid PayTransferPageReqVO pageVO) {
46 67 PageResult<PayTransferDO> pageResult = payTransferService.getTransferPage(pageVO);
47   - return success(BeanUtils.toBean(pageResult, PayTransferPageItemRespVO.class));
  68 +
  69 + // 拼接数据
  70 + Map<Long, PayAppDO> apps = payAppService.getAppMap(convertList(pageResult.getList(), PayTransferDO::getAppId));
  71 + return success(BeanUtils.toBean(pageResult, PayTransferRespVO.class, transferVO -> {
  72 + if (apps.containsKey(transferVO.getAppId())) {
  73 + transferVO.setAppName(apps.get(transferVO.getAppId()).getName());
  74 + }
  75 + }));
  76 + }
  77 +
  78 + @GetMapping("/export-excel")
  79 + @Operation(summary = "导出转账订单 Excel")
  80 + @PreAuthorize("@ss.hasPermission('pay:transfer:export')")
  81 + @ApiAccessLog(operateType = EXPORT)
  82 + public void exportTransfer(PayTransferPageReqVO pageReqVO,
  83 + HttpServletResponse response) throws IOException {
  84 + pageReqVO.setPageSize(PAGE_SIZE_NONE);
  85 + PageResult<PayTransferRespVO> pageResult = getTransferPage(pageReqVO).getData();
  86 +
  87 + // 导出 Excel
  88 + ExcelUtils.write(response, "转账订单.xls", "数据", PayTransferRespVO.class, pageResult.getList());
48 89 }
49 90  
50 91 }
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageItemRespVO.java deleted
1   -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -
6   -import java.time.LocalDateTime;
7   -
8   -/**
9   - * @author jason
10   - */
11   -@Schema(description = "管理后台 - 转账单分页项 Response VO")
12   -@Data
13   -public class PayTransferPageItemRespVO {
14   -
15   - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2931")
16   - private Long id;
17   -
18   - @Schema(description = "转账单号", requiredMode = Schema.RequiredMode.REQUIRED)
19   - private String no;
20   -
21   - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12831")
22   - private Long appId;
23   -
24   - @Schema(description = "转账渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24833")
25   - private Long channelId;
26   -
27   - @Schema(description = "转账渠道编码", requiredMode = Schema.RequiredMode.REQUIRED)
28   - private String channelCode;
29   -
30   - @Schema(description = "商户转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17481")
31   - private String merchantOrderId;
32   -
33   - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
34   - private Integer type;
35   -
36   - @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
37   - private Integer status;
38   -
39   - @Schema(description = "转账成功时间")
40   - private LocalDateTime successTime;
41   -
42   - @Schema(description = "转账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "964")
43   - private Integer price;
44   -
45   - @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED)
46   - private String subject;
47   -
48   - @Schema(description = "收款人姓名", example = "王五")
49   - private String userName;
50   -
51   - @Schema(description = "支付宝登录号", example = "29245")
52   - private String alipayLogonId;
53   -
54   - @Schema(description = "微信 openId", example = "26589")
55   - private String openid;
56   -
57   - @Schema(description = "渠道转账单号")
58   - private String channelTransferNo;
59   -
60   - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
61   - private LocalDateTime createTime;
62   -}
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageReqVO.java
... ... @@ -32,6 +32,9 @@ public class PayTransferPageReqVO extends PageParam {
32 32 @Schema(description = "收款人姓名", example = "王五")
33 33 private String userName;
34 34  
  35 + @Schema(description = "收款人账号", example = "26589")
  36 + private String userAccount;
  37 +
35 38 @Schema(description = "渠道转账单号")
36 39 private String channelTransferNo;
37 40  
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferRespVO.java
1 1 package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo;
2 2  
  3 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  4 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert;
  6 +import cn.iocoder.yudao.module.pay.enums.DictTypeConstants;
  7 +
  8 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  9 +import com.alibaba.excel.annotation.ExcelProperty;
3 10 import io.swagger.v3.oas.annotations.media.Schema;
4 11 import lombok.*;
5 12 import java.time.LocalDateTime;
... ... @@ -7,53 +14,65 @@ import java.util.Map;
7 14  
8 15 @Schema(description = "管理后台 - 转账单 Response VO")
9 16 @Data
  17 +@ExcelIgnoreUnannotated
10 18 public class PayTransferRespVO {
11 19  
  20 + @ExcelProperty("转账单编号")
12 21 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2931")
13 22 private Long id;
14 23  
  24 + @ExcelProperty("转账单号")
15 25 @Schema(description = "转账单号", requiredMode = Schema.RequiredMode.REQUIRED)
16 26 private String no;
17 27  
18 28 @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12831")
19 29 private Long appId;
20 30  
  31 + @ExcelProperty("应用名称")
  32 + @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  33 + private String appName;
  34 +
21 35 @Schema(description = "转账渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24833")
22 36 private Long channelId;
23 37  
  38 + @ExcelProperty(value = "转账渠道", converter = DictConvert.class)
  39 + @DictFormat(DictTypeConstants.CHANNEL_CODE)
24 40 @Schema(description = "转账渠道编码", requiredMode = Schema.RequiredMode.REQUIRED)
25 41 private String channelCode;
26 42  
  43 + @ExcelProperty("商户转账单编号")
27 44 @Schema(description = "商户转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17481")
28   - private String merchantOrderId;
29   -
30   - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
31   - private Integer type;
  45 + private String merchantTransferId;
32 46  
  47 + @ExcelProperty(value = "转账状态", converter = DictConvert.class)
  48 + @DictFormat(DictTypeConstants.TRANSFER_STATUS)
33 49 @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
34 50 private Integer status;
35 51  
  52 + @ExcelProperty("转账成功时间")
36 53 @Schema(description = "转账成功时间")
37 54 private LocalDateTime successTime;
38 55  
39 56 @Schema(description = "转账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "964")
  57 + @ExcelProperty(value = "转账金额", converter = MoneyConvert.class)
40 58 private Integer price;
41 59  
42   - @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED)
  60 + @ExcelProperty("转账标题")
  61 + @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "冲冲冲!")
43 62 private String subject;
44 63  
45 64 @Schema(description = "收款人姓名", example = "王五")
  65 + @ExcelProperty("收款人姓名")
46 66 private String userName;
47 67  
48   - @Schema(description = "支付宝登录号", example = "29245")
49   - private String alipayLogonId;
50   -
51   - @Schema(description = "微信 openId", example = "26589")
52   - private String openid;
  68 + @Schema(description = "收款人账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26589")
  69 + @ExcelProperty("收款人账号")
  70 + private String userAccount;
53 71  
54 72 @Schema(description = "异步通知商户地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
55 73 private String notifyUrl;
56 74  
  75 + @ExcelProperty("用户 IP")
57 76 @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED)
58 77 private String userIp;
59 78  
... ... @@ -61,11 +80,13 @@ public class PayTransferRespVO {
61 80 private Map<String, String> channelExtras;
62 81  
63 82 @Schema(description = "渠道转账单号")
  83 + @ExcelProperty("渠道转账单号")
64 84 private String channelTransferNo;
65 85  
66 86 @Schema(description = "调用渠道的错误码")
67 87 private String channelErrorCode;
68 88  
  89 + @ExcelProperty("渠道错误提示")
69 90 @Schema(description = "调用渠道的错误提示")
70 91 private String channelErrorMsg;
71 92  
... ... @@ -73,6 +94,7 @@ public class PayTransferRespVO {
73 94 private String channelNotifyData;
74 95  
75 96 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  97 + @ExcelProperty("创建时间")
76 98 private LocalDateTime createTime;
77 99  
78 100 }
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java
... ... @@ -39,6 +39,7 @@ public interface PayTransferMapper extends BaseMapperX&lt;PayTransferDO&gt; {
39 39 .eqIfPresent(PayTransferDO::getMerchantTransferId, reqVO.getMerchantOrderId())
40 40 .eqIfPresent(PayTransferDO::getStatus, reqVO.getStatus())
41 41 .likeIfPresent(PayTransferDO::getUserName, reqVO.getUserName())
  42 + .likeIfPresent(PayTransferDO::getUserAccount, reqVO.getUserAccount())
42 43 .eqIfPresent(PayTransferDO::getChannelTransferNo, reqVO.getChannelTransferNo())
43 44 .betweenIfPresent(PayTransferDO::getCreateTime, reqVO.getCreateTime())
44 45 .orderByDesc(PayTransferDO::getId));
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java
1 1 package cn.iocoder.yudao.module.pay.service.app;
2 2  
  3 +import cn.hutool.core.collection.CollUtil;
3 4 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO;
... ... @@ -17,6 +18,7 @@ import org.springframework.stereotype.Service;
17 18 import org.springframework.validation.annotation.Validated;
18 19  
19 20 import java.util.Collection;
  21 +import java.util.Collections;
20 22 import java.util.List;
21 23  
22 24 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
... ... @@ -116,6 +118,9 @@ public class PayAppServiceImpl implements PayAppService {
116 118  
117 119 @Override
118 120 public List<PayAppDO> getAppList(Collection<Long> ids) {
  121 + if (CollUtil.isEmpty(ids)) {
  122 + return Collections.emptyList();
  123 + }
119 124 return appMapper.selectBatchIds(ids);
120 125 }
121 126  
... ...