Commit b91a30dd3e29fc652a9efaf9db3cd4a380a4ff41
1 parent
0e7ce637
feat:【PAY 支付】增加 channelPackageInfo 字段,对接微信新的转账 API(太难了!!!!!!!!!!!!!!!!!!!!)
Showing
16 changed files
with
157 additions
and
98 deletions
yudao-dependencies/pom.xml
| ... | ... | @@ -75,7 +75,7 @@ |
| 75 | 75 | <justauth.version>1.16.7</justauth.version> |
| 76 | 76 | <justauth-starter.version>1.4.0</justauth-starter.version> |
| 77 | 77 | <jimureport.version>1.9.4</jimureport.version> |
| 78 | - <weixin-java.version>4.7.4.B</weixin-java.version> | |
| 78 | + <weixin-java.version>4.7.5.B</weixin-java.version> | |
| 79 | 79 | </properties> |
| 80 | 80 | |
| 81 | 81 | <dependencyManagement> | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | - | |
| 7 | -import jakarta.validation.constraints.NotNull; | |
| 8 | -import java.time.LocalDateTime; | |
| 9 | - | |
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 佣金提现 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 14 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 15 | - */ | |
| 16 | -@Data | |
| 17 | -public class BrokerageWithdrawBaseVO { | |
| 18 | - | |
| 19 | - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436") | |
| 20 | - @NotNull(message = "用户编号不能为空") | |
| 21 | - private Long userId; | |
| 22 | - | |
| 23 | - @Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781") | |
| 24 | - @NotNull(message = "提现金额不能为空") | |
| 25 | - private Integer price; | |
| 26 | - | |
| 27 | - @Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") | |
| 28 | - @NotNull(message = "提现手续费不能为空") | |
| 29 | - private Integer feePrice; | |
| 30 | - | |
| 31 | - @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576") | |
| 32 | - @NotNull(message = "当前总佣金不能为空") | |
| 33 | - private Integer totalPrice; | |
| 34 | - | |
| 35 | - @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 36 | - @NotNull(message = "提现类型不能为空") | |
| 37 | - private Integer type; | |
| 38 | - | |
| 39 | - @Schema(description = "真实姓名", example = "赵六") | |
| 40 | - private String userName; | |
| 41 | - | |
| 42 | - @Schema(description = "收款账号", example = "88677912132") | |
| 43 | - private String userAccount; | |
| 44 | - | |
| 45 | - @Schema(description = "银行名称", example = "1") | |
| 46 | - private String bankName; | |
| 47 | - | |
| 48 | - @Schema(description = "开户地址", example = "海淀支行") | |
| 49 | - private String bankAddress; | |
| 50 | - | |
| 51 | - @Schema(description = "收款码", example = "https://www.iocoder.cn") | |
| 52 | - private String qrCodeUrl; | |
| 53 | - | |
| 54 | - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 55 | - @NotNull(message = "状态不能为空") | |
| 56 | - private Integer status; | |
| 57 | - | |
| 58 | - @Schema(description = "审核驳回原因", example = "不对") | |
| 59 | - private String auditReason; | |
| 60 | - | |
| 61 | - @Schema(description = "审核时间") | |
| 62 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 63 | - private LocalDateTime auditTime; | |
| 64 | - | |
| 65 | - @Schema(description = "备注", example = "随便") | |
| 66 | - private String remark; | |
| 67 | - | |
| 68 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java
| ... | ... | @@ -2,27 +2,68 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 7 | 5 | |
| 8 | 6 | import java.time.LocalDateTime; |
| 9 | 7 | |
| 10 | 8 | @Schema(description = "管理后台 - 佣金提现 Response VO") |
| 11 | 9 | @Data |
| 12 | -@EqualsAndHashCode(callSuper = true) | |
| 13 | -@ToString(callSuper = true) | |
| 14 | -public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO { | |
| 10 | +public class BrokerageWithdrawRespVO { | |
| 15 | 11 | |
| 16 | 12 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") |
| 17 | 13 | private Long id; |
| 18 | 14 | |
| 15 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436") | |
| 16 | + private Long userId; | |
| 17 | + | |
| 18 | + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 19 | + private String userNickname; | |
| 20 | + | |
| 21 | + @Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781") | |
| 22 | + private Integer price; | |
| 23 | + | |
| 24 | + @Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") | |
| 25 | + private Integer feePrice; | |
| 26 | + | |
| 27 | + @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576") | |
| 28 | + private Integer totalPrice; | |
| 29 | + | |
| 30 | + @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 31 | + private Integer type; | |
| 32 | + | |
| 33 | + @Schema(description = "真实姓名", example = "赵六") | |
| 34 | + private String userName; | |
| 35 | + | |
| 36 | + @Schema(description = "收款账号", example = "88677912132") | |
| 37 | + private String userAccount; | |
| 38 | + | |
| 39 | + @Schema(description = "银行名称", example = "1") | |
| 40 | + private String bankName; | |
| 41 | + | |
| 42 | + @Schema(description = "开户地址", example = "海淀支行") | |
| 43 | + private String bankAddress; | |
| 44 | + | |
| 45 | + @Schema(description = "收款码", example = "https://www.iocoder.cn") | |
| 46 | + private String qrCodeUrl; | |
| 47 | + | |
| 48 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 49 | + private Integer status; | |
| 50 | + | |
| 51 | + @Schema(description = "审核驳回原因", example = "不对") | |
| 52 | + private String auditReason; | |
| 53 | + | |
| 54 | + @Schema(description = "审核时间") | |
| 55 | + private LocalDateTime auditTime; | |
| 56 | + | |
| 57 | + @Schema(description = "备注", example = "随便") | |
| 58 | + private String remark; | |
| 59 | + | |
| 60 | + @Schema(description = "转账单编号", example = "1024") | |
| 61 | + private Long payTransferId; | |
| 62 | + | |
| 19 | 63 | @Schema(description = "转账错误提示", example = "余额不足") |
| 20 | 64 | private String transferErrorMsg; |
| 21 | 65 | |
| 22 | 66 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 23 | 67 | private LocalDateTime createTime; |
| 24 | 68 | |
| 25 | - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 26 | - private String userNickname; | |
| 27 | - | |
| 28 | 69 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java
| ... | ... | @@ -126,5 +126,12 @@ public class BrokerageWithdrawDO extends BaseDO { |
| 126 | 126 | * 转账错误提示 |
| 127 | 127 | */ |
| 128 | 128 | private String transferErrorMsg; |
| 129 | + /** | |
| 130 | + * 渠道 package 信息 | |
| 131 | + * | |
| 132 | + * 特殊:目前只有微信转账有这个东西!!! | |
| 133 | + * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> | |
| 134 | + */ | |
| 135 | + private String transferChannelPackageInfo; | |
| 129 | 136 | |
| 130 | 137 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java
| ... | ... | @@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 10 | 10 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 11 | 11 | import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi; |
| 12 | 12 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 13 | +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; | |
| 13 | 14 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; |
| 14 | 15 | import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi; |
| 15 | 16 | import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletRespDTO; |
| ... | ... | @@ -152,11 +153,12 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 152 | 153 | .setUserAccount(userAccount).setUserName(userName).setUserIp(getClientIP()) |
| 153 | 154 | .setChannelExtras(channelExtras); |
| 154 | 155 | // 1.3 发起请求 |
| 155 | - Long payTransferId = payTransferApi.createTransfer(transferReqDTO); | |
| 156 | + PayTransferCreateRespDTO transferRespDTO = payTransferApi.createTransfer(transferReqDTO); | |
| 156 | 157 | |
| 157 | 158 | // 2. 更新提现记录 |
| 158 | 159 | brokerageWithdrawMapper.updateById(new BrokerageWithdrawDO().setId(withdraw.getId()) |
| 159 | - .setPayTransferId(payTransferId).setTransferChannelCode(channelCode)); | |
| 160 | + .setPayTransferId(transferRespDTO.getId()).setTransferChannelCode(channelCode) | |
| 161 | + .setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo())); | |
| 160 | 162 | } |
| 161 | 163 | |
| 162 | 164 | private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) { | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.api.transfer; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 4 | - | |
| 4 | +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; | |
| 5 | 5 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; |
| 6 | 6 | import jakarta.validation.Valid; |
| 7 | 7 | |
| ... | ... | @@ -16,9 +16,9 @@ public interface PayTransferApi { |
| 16 | 16 | * 创建转账单 |
| 17 | 17 | * |
| 18 | 18 | * @param reqDTO 创建请求 |
| 19 | - * @return 转账单编号 | |
| 19 | + * @return 创建结果 | |
| 20 | 20 | */ |
| 21 | - Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO); | |
| 21 | + PayTransferCreateRespDTO createTransfer(@Valid PayTransferCreateReqDTO reqDTO); | |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * 获得转账单 | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.api.transfer.dto; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 转账单创建 Response DTO | |
| 7 | + * | |
| 8 | + * @author 芋道源码 | |
| 9 | + */ | |
| 10 | +@Data | |
| 11 | +public class PayTransferCreateRespDTO { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 编号 | |
| 15 | + */ | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | + // ========== 其它字段 ========== | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 渠道 package 信息 | |
| 22 | + * | |
| 23 | + * 特殊:目前只有微信转账有这个东西!!! | |
| 24 | + * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> | |
| 25 | + */ | |
| 26 | + private String channelPackageInfo; | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferRespDTO.java
| ... | ... | @@ -63,4 +63,12 @@ public class PayTransferRespDTO { |
| 63 | 63 | */ |
| 64 | 64 | private String channelErrorMsg; |
| 65 | 65 | |
| 66 | + /** | |
| 67 | + * 渠道 package 信息 | |
| 68 | + * | |
| 69 | + * 特殊:目前只有微信转账有这个东西!!! | |
| 70 | + * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> | |
| 71 | + */ | |
| 72 | + private String channelPackageInfo; | |
| 73 | + | |
| 66 | 74 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.api.transfer; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 4 | 4 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 5 | +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; | |
| 5 | 6 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; |
| 7 | 8 | import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; |
| ... | ... | @@ -22,7 +23,7 @@ public class PayTransferApiImpl implements PayTransferApi { |
| 22 | 23 | private PayTransferService payTransferService; |
| 23 | 24 | |
| 24 | 25 | @Override |
| 25 | - public Long createTransfer(PayTransferCreateReqDTO reqDTO) { | |
| 26 | + public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) { | |
| 26 | 27 | return payTransferService.createTransfer(reqDTO); |
| 27 | 28 | } |
| 28 | 29 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoWithdrawDO.java
| ... | ... | @@ -80,5 +80,12 @@ public class PayDemoWithdrawDO extends BaseDO { |
| 80 | 80 | * 转账错误提示 |
| 81 | 81 | */ |
| 82 | 82 | private String transferErrorMsg; |
| 83 | + /** | |
| 84 | + * 渠道 package 信息 | |
| 85 | + * | |
| 86 | + * 特殊:目前只有微信转账有这个东西!!! | |
| 87 | + * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> | |
| 88 | + */ | |
| 89 | + private String transferChannelPackageInfo; | |
| 83 | 90 | |
| 84 | 91 | } |
| 85 | 92 | \ No newline at end of file | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java
| ... | ... | @@ -135,4 +135,12 @@ public class PayTransferDO extends BaseDO { |
| 135 | 135 | */ |
| 136 | 136 | private String channelNotifyData; |
| 137 | 137 | |
| 138 | + /** | |
| 139 | + * 渠道 package 信息 | |
| 140 | + * | |
| 141 | + * 特殊:目前只有微信转账有这个东西!!! | |
| 142 | + * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> | |
| 143 | + */ | |
| 144 | + private String channelPackageInfo; | |
| 145 | + | |
| 138 | 146 | } |
| 139 | 147 | \ No newline at end of file | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java
| ... | ... | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | 9 | import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi; |
| 10 | 10 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 11 | +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; | |
| 11 | 12 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; |
| 12 | 13 | import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw.PayDemoWithdrawCreateReqVO; |
| 13 | 14 | import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoWithdrawDO; |
| ... | ... | @@ -83,12 +84,13 @@ public class PayDemoTransferServiceImpl implements PayDemoWithdrawService { |
| 83 | 84 | transferReqDTO.setChannelExtras(PayTransferCreateReqDTO.buildWeiXinChannelExtra1000( |
| 84 | 85 | "测试活动", "测试奖励")); |
| 85 | 86 | } |
| 86 | - Long payTransferId = payTransferApi.createTransfer(transferReqDTO); | |
| 87 | + PayTransferCreateRespDTO transferRespDTO = payTransferApi.createTransfer(transferReqDTO); | |
| 87 | 88 | |
| 88 | 89 | // 2.2 更新转账单到 demo 示例提现单,并将状态更新为转账中 |
| 89 | 90 | demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(), |
| 90 | - new PayDemoWithdrawDO().setPayTransferId(payTransferId)); | |
| 91 | - return payTransferId; | |
| 91 | + new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId()) | |
| 92 | + .setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo())); | |
| 93 | + return transferRespDTO.getId(); | |
| 92 | 94 | } |
| 93 | 95 | |
| 94 | 96 | private PayDemoWithdrawDO validateDemoWithdrawCanTransfer(Long id) { | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.pay.service.transfer; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; |
| 5 | 5 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 6 | +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; | |
| 6 | 7 | import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO; |
| 7 | 8 | import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; |
| 8 | 9 | import jakarta.validation.Valid; |
| ... | ... | @@ -20,7 +21,7 @@ public interface PayTransferService { |
| 20 | 21 | * @param reqDTO 创建请求 |
| 21 | 22 | * @return 转账单编号 |
| 22 | 23 | */ |
| 23 | - Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO); | |
| 24 | + PayTransferCreateRespDTO createTransfer(@Valid PayTransferCreateReqDTO reqDTO); | |
| 24 | 25 | |
| 25 | 26 | /** |
| 26 | 27 | * 获取转账单 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java
| ... | ... | @@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifie |
| 12 | 12 | import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; |
| 13 | 13 | import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; |
| 14 | 14 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 15 | +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; | |
| 15 | 16 | import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO; |
| 16 | 17 | import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; |
| 17 | 18 | import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; |
| ... | ... | @@ -62,7 +63,7 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 62 | 63 | private PayNoRedisDAO noRedisDAO; |
| 63 | 64 | |
| 64 | 65 | @Override |
| 65 | - public Long createTransfer(PayTransferCreateReqDTO reqDTO) { | |
| 66 | + public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) { | |
| 66 | 67 | // 1.1 校验 App |
| 67 | 68 | PayAppDO payApp = appService.validPayApp(reqDTO.getAppKey()); |
| 68 | 69 | // 1.2 校验支付渠道是否有效 |
| ... | ... | @@ -88,12 +89,13 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 88 | 89 | transferMapper.updateByIdAndStatus(transfer.getId(), transfer.getStatus(), |
| 89 | 90 | new PayTransferDO().setStatus(PayTransferStatusEnum.WAITING.getStatus())); |
| 90 | 91 | } |
| 92 | + PayTransferRespDTO unifiedTransferResp = null; | |
| 91 | 93 | try { |
| 92 | 94 | // 3. 调用三方渠道发起转账 |
| 93 | 95 | PayTransferUnifiedReqDTO transferUnifiedReq = BeanUtils.toBean(reqDTO, PayTransferUnifiedReqDTO.class) |
| 94 | 96 | .setOutTransferNo(transfer.getNo()) |
| 95 | 97 | .setNotifyUrl(genChannelTransferNotifyUrl(channel)); |
| 96 | - PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq); | |
| 98 | + unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq); | |
| 97 | 99 | // 4. 通知转账结果 |
| 98 | 100 | getSelf().notifyTransfer(channel, unifiedTransferResp); |
| 99 | 101 | } catch (Throwable e) { |
| ... | ... | @@ -102,7 +104,8 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 102 | 104 | // 或者,使用相同 no 再次发起转账请求 |
| 103 | 105 | log.error("[createTransfer][转账编号({}) requestDTO({}) 发生异常]", transfer.getId(), reqDTO, e); |
| 104 | 106 | } |
| 105 | - return transfer.getId(); | |
| 107 | + return new PayTransferCreateRespDTO().setId(transfer.getId()) | |
| 108 | + .setChannelPackageInfo(unifiedTransferResp != null ? unifiedTransferResp.getChannelPackageInfo() : null); | |
| 106 | 109 | } |
| 107 | 110 | |
| 108 | 111 | /** |
| ... | ... | @@ -154,7 +157,7 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 154 | 157 | } |
| 155 | 158 | |
| 156 | 159 | private void notifyTransferProgressing(PayChannelDO channel, PayTransferRespDTO notify) { |
| 157 | - // 1.校验 | |
| 160 | + // 1. 校验 | |
| 158 | 161 | PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo()); |
| 159 | 162 | if (transfer == null) { |
| 160 | 163 | throw exception(PAY_TRANSFER_NOT_FOUND); |
| ... | ... | @@ -170,7 +173,8 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 170 | 173 | // 2. 更新状态 |
| 171 | 174 | int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(), |
| 172 | 175 | PayTransferStatusEnum.WAITING.getStatus(), |
| 173 | - new PayTransferDO().setStatus(PayTransferStatusEnum.PROCESSING.getStatus())); | |
| 176 | + new PayTransferDO().setStatus(PayTransferStatusEnum.PROCESSING.getStatus()) | |
| 177 | + .setChannelPackageInfo(transfer.getChannelPackageInfo())); | |
| 174 | 178 | if (updateCounts == 0) { |
| 175 | 179 | throw exception(PAY_TRANSFER_NOTIFY_FAIL_STATUS_IS_NOT_WAITING); |
| 176 | 180 | } |
| ... | ... | @@ -261,6 +265,9 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 261 | 265 | } |
| 262 | 266 | int count = 0; |
| 263 | 267 | for (PayTransferDO transfer : list) { |
| 268 | + if (!transfer.getId().equals(54L)) { | |
| 269 | + continue; | |
| 270 | + } | |
| 264 | 271 | count += syncTransfer(transfer) ? 1 : 0; |
| 265 | 272 | } |
| 266 | 273 | return count; | ... | ... |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java
| ... | ... | @@ -22,7 +22,6 @@ public class PayTransferRespDTO { |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * 外部转账单号 |
| 25 | - * | |
| 26 | 25 | */ |
| 27 | 26 | private String outTransferNo; |
| 28 | 27 | |
| ... | ... | @@ -51,10 +50,18 @@ public class PayTransferRespDTO { |
| 51 | 50 | private String channelErrorMsg; |
| 52 | 51 | |
| 53 | 52 | /** |
| 53 | + * 渠道 package 信息 | |
| 54 | + * | |
| 55 | + * 特殊:目前只有微信转账有这个东西!!! | |
| 56 | + * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> | |
| 57 | + */ | |
| 58 | + private String channelPackageInfo; | |
| 59 | + | |
| 60 | + /** | |
| 54 | 61 | * 创建【WAITING】状态的转账返回 |
| 55 | 62 | */ |
| 56 | 63 | public static PayTransferRespDTO waitingOf(String channelTransferNo, |
| 57 | - String outTransferNo, Object rawData) { | |
| 64 | + String outTransferNo, Object rawData) { | |
| 58 | 65 | PayTransferRespDTO respDTO = new PayTransferRespDTO(); |
| 59 | 66 | respDTO.status = PayTransferStatusRespEnum.WAITING.getStatus(); |
| 60 | 67 | respDTO.channelTransferNo = channelTransferNo; | ... | ... |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java
| ... | ... | @@ -482,11 +482,19 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC |
| 482 | 482 | // 2.1 执行请求 |
| 483 | 483 | try { |
| 484 | 484 | TransferBillsResult response = client.getTransferService().transferBills(request); |
| 485 | - System.out.println(response); | |
| 486 | 485 | |
| 487 | 486 | // 2.2 创建返回结果 |
| 488 | - // TODO @芋艿:这里要解析下; | |
| 489 | - return PayTransferRespDTO.processingOf(response.getTransferBillNo(), reqDTO.getOutTransferNo(), response); | |
| 487 | + String state = response.getState(); | |
| 488 | + if (ObjectUtils.equalsAny(state, "ACCEPTED", "PROCESSING", "WAIT_USER_CONFIRM", "TRANSFERING")) { | |
| 489 | + return PayTransferRespDTO.processingOf(response.getTransferBillNo(), response.getOutBillNo(), response) | |
| 490 | + .setChannelPackageInfo(response.getPackageInfo()); // 一般情况下,只有 WAIT_USER_CONFIRM 会有! | |
| 491 | + } | |
| 492 | + if (Objects.equals("SUCCESS", state)) { | |
| 493 | + return PayTransferRespDTO.successOf(response.getTransferBillNo(), parseDateV3(response.getCreateTime()), | |
| 494 | + response.getOutBillNo(), response); | |
| 495 | + } | |
| 496 | + return PayTransferRespDTO.closedOf(state, response.getFailReason(), | |
| 497 | + response.getOutBillNo(), response); | |
| 490 | 498 | } catch (WxPayException e) { |
| 491 | 499 | log.error("[doUnifiedTransfer][转账({}) 发起微信支付异常", reqDTO, e); |
| 492 | 500 | String errorCode = getErrorCode(e); |
| ... | ... | @@ -499,7 +507,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC |
| 499 | 507 | @Override |
| 500 | 508 | protected PayTransferRespDTO doGetTransfer(String outTradeNo) throws WxPayException { |
| 501 | 509 | // 1. 执行请求 |
| 502 | - TransferBillsGetResult response = client.getTransferService().getBillsByTransferBillNo(outTradeNo); | |
| 510 | + TransferBillsGetResult response = client.getTransferService().getBillsByOutBillNo(outTradeNo); | |
| 503 | 511 | |
| 504 | 512 | // 2. 创建返回结果 |
| 505 | 513 | String state = response.getState(); | ... | ... |