Commit 4d25e810e3d80bc41d43b62a68b096b5167fed12
1 parent
b91a30dd
feat:【MALL 商城】商城分佣提现,初步对接成功微信支付
Showing
22 changed files
with
162 additions
and
225 deletions
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java
| ... | ... | @@ -7,6 +7,9 @@ package cn.iocoder.yudao.module.trade.enums; |
| 7 | 7 | */ |
| 8 | 8 | public interface DictTypeConstants { |
| 9 | 9 | |
| 10 | + String BROKERAGE_RECORD_STATUS = "brokerage_record_status"; // 佣金记录状态 | |
| 11 | + | |
| 12 | + String BROKERAGE_WITHDRAW_TYPE = "brokerage_withdraw_type"; // 佣金提现类型 | |
| 10 | 13 | String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态 |
| 11 | 14 | |
| 12 | 15 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java
| ... | ... | @@ -3,11 +3,13 @@ package cn.iocoder.yudao.module.trade.controller.app.brokerage; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | +import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; | |
| 7 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; | |
| 6 | 8 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; |
| 7 | 9 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; |
| 8 | 10 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; |
| 9 | -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; | |
| 10 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; |
| 12 | +import cn.iocoder.yudao.module.trade.enums.DictTypeConstants; | |
| 11 | 13 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; |
| 12 | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -36,8 +38,9 @@ public class AppBrokerageRecordController { |
| 36 | 38 | @Operation(summary = "获得分销记录分页") |
| 37 | 39 | public CommonResult<PageResult<AppBrokerageRecordRespVO>> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) { |
| 38 | 40 | PageResult<BrokerageRecordDO> pageResult = brokerageRecordService.getBrokerageRecordPage( |
| 39 | - BrokerageRecordConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); | |
| 40 | - return success(BeanUtils.toBean(pageResult, AppBrokerageRecordRespVO.class)); | |
| 41 | + BeanUtils.toBean(pageReqVO, BrokerageRecordPageReqVO.class).setUserId(getLoginUserId())); | |
| 42 | + return success(BeanUtils.toBean(pageResult, AppBrokerageRecordRespVO.class, recordVO -> | |
| 43 | + recordVO.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_RECORD_STATUS, recordVO.getStatus())))); | |
| 41 | 44 | } |
| 42 | 45 | |
| 43 | 46 | @GetMapping("/get-product-brokerage-price") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.app.brokerage; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.ObjUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; | |
| 8 | +import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi; | |
| 9 | +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; | |
| 10 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; | |
| 5 | 11 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; |
| 6 | 12 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; |
| 7 | 13 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; |
| 8 | -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; | |
| 9 | 14 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; |
| 15 | +import cn.iocoder.yudao.module.trade.enums.DictTypeConstants; | |
| 16 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 17 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; | |
| 10 | 18 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; |
| 11 | 19 | import io.swagger.v3.oas.annotations.Operation; |
| 20 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 12 | 21 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 13 | 22 | import jakarta.annotation.Resource; |
| 14 | 23 | import jakarta.validation.Valid; |
| ... | ... | @@ -16,6 +25,8 @@ import lombok.extern.slf4j.Slf4j; |
| 16 | 25 | import org.springframework.validation.annotation.Validated; |
| 17 | 26 | import org.springframework.web.bind.annotation.*; |
| 18 | 27 | |
| 28 | +import java.util.Objects; | |
| 29 | + | |
| 19 | 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 20 | 31 | import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; |
| 21 | 32 | |
| ... | ... | @@ -29,12 +40,39 @@ public class AppBrokerageWithdrawController { |
| 29 | 40 | @Resource |
| 30 | 41 | private BrokerageWithdrawService brokerageWithdrawService; |
| 31 | 42 | |
| 43 | + @Resource | |
| 44 | + private PayTransferApi payTransferApi; | |
| 45 | + | |
| 32 | 46 | @GetMapping("/page") |
| 33 | 47 | @Operation(summary = "获得分销提现分页") |
| 34 | 48 | public CommonResult<PageResult<AppBrokerageWithdrawRespVO>> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) { |
| 35 | 49 | PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage( |
| 36 | - BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); | |
| 37 | - return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult)); | |
| 50 | + BeanUtils.toBean(pageReqVO, BrokerageWithdrawPageReqVO.class).setUserId(getLoginUserId())); | |
| 51 | + return success(BeanUtils.toBean(pageResult, AppBrokerageWithdrawRespVO.class, withdrawVO -> | |
| 52 | + withdrawVO.setTypeName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_TYPE, withdrawVO.getType())) | |
| 53 | + .setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, withdrawVO.getStatus())))); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @GetMapping("/get") | |
| 57 | + @Operation(summary = "获得佣金提现") | |
| 58 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 59 | + public CommonResult<AppBrokerageWithdrawRespVO> getBrokerageWithdraw(@RequestParam("id") Long id) { | |
| 60 | + BrokerageWithdrawDO withdraw = brokerageWithdrawService.getBrokerageWithdraw(id); | |
| 61 | + if (withdraw == null || ObjUtil.notEqual(withdraw.getUserId(), getLoginUserId())) { | |
| 62 | + return success(null); | |
| 63 | + } | |
| 64 | + // 审核中(转账中),并且是微信转账,需要返回 mchId 用于确认收款 | |
| 65 | + AppBrokerageWithdrawRespVO withdrawVO = BeanUtils.toBean(withdraw, AppBrokerageWithdrawRespVO.class); | |
| 66 | + if (Objects.equals(withdraw.getStatus(), BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus()) | |
| 67 | + && Objects.equals(withdraw.getType(), BrokerageWithdrawTypeEnum.WECHAT_API.getType()) | |
| 68 | + && withdraw.getPayTransferId() != null) { | |
| 69 | + PayTransferRespDTO transfer = payTransferApi.getTransfer(withdraw.getPayTransferId()); | |
| 70 | + if (transfer != null) { | |
| 71 | + withdrawVO.setTransferChannelPackageInfo(transfer.getChannelPackageInfo()) | |
| 72 | + .setTransferChannelMchId(transfer.getChannelMchId()); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + return success(withdrawVO); | |
| 38 | 76 | } |
| 39 | 77 | |
| 40 | 78 | @PostMapping("/create") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java
| ... | ... | @@ -20,11 +20,11 @@ public class AppBrokerageRecordPageReqVO extends PageParam { |
| 20 | 20 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 21 | 21 | private LocalDateTime[] createTime; |
| 22 | 22 | |
| 23 | - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 23 | + @Schema(description = "业务类型", example = "1") | |
| 24 | 24 | @InEnum(value = BrokerageRecordBizTypeEnum.class, message = "业务类型必须是 {value}") |
| 25 | 25 | private Integer bizType; |
| 26 | 26 | |
| 27 | - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 27 | + @Schema(description = "状态", example = "1") | |
| 28 | 28 | @InEnum(value = BrokerageRecordStatusEnum.class, message = "状态必须是 {value}") |
| 29 | 29 | private Integer status; |
| 30 | 30 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java
| ... | ... | @@ -24,6 +24,9 @@ public class AppBrokerageRecordRespVO { |
| 24 | 24 | @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 25 | 25 | private Integer status; |
| 26 | 26 | |
| 27 | + @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "待结算") | |
| 28 | + private String statusName; | |
| 29 | + | |
| 27 | 30 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 28 | 31 | private LocalDateTime createTime; |
| 29 | 32 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java
| ... | ... | @@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 5 | +import cn.iocoder.yudao.module.pay.enums.PayChannelEnum; | |
| 5 | 6 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; |
| 6 | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 8 | +import jakarta.validation.constraints.Min; | |
| 7 | 9 | import lombok.Data; |
| 8 | 10 | import org.hibernate.validator.constraints.URL; |
| 9 | 11 | |
| ... | ... | @@ -22,6 +24,7 @@ public class AppBrokerageWithdrawCreateReqVO { |
| 22 | 24 | |
| 23 | 25 | @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") |
| 24 | 26 | @PositiveOrZero(message = "提现金额不能小于 0") |
| 27 | + @Min(value = 30, message = "微信提现金额不能小于 0.3", groups = {WechatApi.class}) | |
| 25 | 28 | @NotNull(message = "提现金额不能为空") |
| 26 | 29 | private Integer price; |
| 27 | 30 | |
| ... | ... | @@ -43,6 +46,11 @@ public class AppBrokerageWithdrawCreateReqVO { |
| 43 | 46 | @Schema(description = "开户地址", example = "海淀支行") |
| 44 | 47 | private String bankAddress; |
| 45 | 48 | |
| 49 | + @Schema(description = "转账渠道", example = "wx_lite") | |
| 50 | + @NotNull(message = "转账渠道不能为空", groups = {WechatApi.class}) | |
| 51 | + @InEnum(PayChannelEnum.class) | |
| 52 | + private String transferChannelCode; | |
| 53 | + | |
| 46 | 54 | public interface Wallet { |
| 47 | 55 | } |
| 48 | 56 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 6 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; | |
| 7 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 8 | 5 | import lombok.Data; |
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 9 | 11 | |
| 10 | 12 | @Schema(description = "应用 App - 分销提现分页 Request VO") |
| 11 | 13 | @Data |
| 12 | 14 | public class AppBrokerageWithdrawPageReqVO extends PageParam { |
| 13 | 15 | |
| 14 | - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 15 | - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "类型必须是 {value}") | |
| 16 | - private Integer type; | |
| 16 | + @Schema(description = "创建时间") | |
| 17 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 18 | + private LocalDateTime[] createTime; | |
| 19 | + | |
| 17 | 20 | |
| 18 | - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 19 | - @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") | |
| 20 | - private Integer status; | |
| 21 | 21 | |
| 22 | 22 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java
| ... | ... | @@ -12,6 +12,12 @@ public class AppBrokerageWithdrawRespVO { |
| 12 | 12 | @Schema(description = "提现编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") |
| 13 | 13 | private Long id; |
| 14 | 14 | |
| 15 | + @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 16 | + private Integer type; | |
| 17 | + | |
| 18 | + @Schema(description = "提现类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "微信") | |
| 19 | + private String typeName; | |
| 20 | + | |
| 15 | 21 | @Schema(description = "提现状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") |
| 16 | 22 | private Integer status; |
| 17 | 23 | |
| ... | ... | @@ -24,4 +30,15 @@ public class AppBrokerageWithdrawRespVO { |
| 24 | 30 | @Schema(description = "提现时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 25 | 31 | private LocalDateTime createTime; |
| 26 | 32 | |
| 33 | + // ========== 微信转账专属 ========== | |
| 34 | + | |
| 35 | + @Schema(description = "转账单编号", example = "1024") | |
| 36 | + private Long payTransferId; | |
| 37 | + | |
| 38 | + @Schema(description = "渠道 package 信息") | |
| 39 | + private String transferChannelPackageInfo; | |
| 40 | + | |
| 41 | + @Schema(description = "渠道商户号") | |
| 42 | + private String transferChannelMchId; | |
| 43 | + | |
| 27 | 44 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.convert.brokerage; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.math.Money; | |
| 4 | 3 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 4 | import cn.hutool.core.util.StrUtil; |
| 6 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 6 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 8 | 7 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 9 | -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; | |
| 10 | 8 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; |
| 11 | -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; | |
| 12 | -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; | |
| 13 | 9 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; |
| 14 | 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; |
| 15 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; |
| ... | ... | @@ -68,8 +64,6 @@ public interface BrokerageRecordConvert { |
| 68 | 64 | return result; |
| 69 | 65 | } |
| 70 | 66 | |
| 71 | - BrokerageRecordPageReqVO convert(AppBrokerageRecordPageReqVO pageReqVO, Long userId); | |
| 72 | - | |
| 73 | 67 | default PageResult<AppBrokerageUserRankByPriceRespVO> convertPage03(PageResult<AppBrokerageUserRankByPriceRespVO> pageResult, Map<Long, MemberUserRespDTO> userMap) { |
| 74 | 68 | for (AppBrokerageUserRankByPriceRespVO vo : pageResult.getList()) { |
| 75 | 69 | copyTo(userMap.get(vo.getId()), vo); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.convert.brokerage; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; | |
| 5 | 4 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 6 | -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; | |
| 7 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; |
| 8 | -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; | |
| 9 | -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; | |
| 10 | -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; | |
| 11 | 6 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; |
| 12 | -import cn.iocoder.yudao.module.trade.enums.DictTypeConstants; | |
| 13 | 7 | import org.mapstruct.Mapper; |
| 14 | 8 | import org.mapstruct.factory.Mappers; |
| 15 | 9 | |
| ... | ... | @@ -27,8 +21,6 @@ public interface BrokerageWithdrawConvert { |
| 27 | 21 | |
| 28 | 22 | BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class); |
| 29 | 23 | |
| 30 | - BrokerageWithdrawDO convert(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId, Integer feePrice); | |
| 31 | - | |
| 32 | 24 | BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean); |
| 33 | 25 | |
| 34 | 26 | List<BrokerageWithdrawRespVO> convertList(List<BrokerageWithdrawDO> list); |
| ... | ... | @@ -43,15 +35,4 @@ public interface BrokerageWithdrawConvert { |
| 43 | 35 | return result; |
| 44 | 36 | } |
| 45 | 37 | |
| 46 | - PageResult<AppBrokerageWithdrawRespVO> convertPage02(PageResult<BrokerageWithdrawDO> pageResult); | |
| 47 | - | |
| 48 | - default PageResult<AppBrokerageWithdrawRespVO> convertPage03(PageResult<BrokerageWithdrawDO> pageResult) { | |
| 49 | - PageResult<AppBrokerageWithdrawRespVO> result = convertPage02(pageResult); | |
| 50 | - for (AppBrokerageWithdrawRespVO vo : result.getList()) { | |
| 51 | - vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus())); | |
| 52 | - } | |
| 53 | - return result; | |
| 54 | - } | |
| 55 | - | |
| 56 | - BrokerageWithdrawPageReqVO convert(AppBrokerageWithdrawPageReqVO pageReqVO, Long userId); | |
| 57 | 38 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java
| ... | ... | @@ -126,12 +126,5 @@ 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; | |
| 136 | 129 | |
| 137 | 130 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java
| ... | ... | @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 10 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 10 | 11 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 11 | 12 | import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi; |
| 12 | 13 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| ... | ... | @@ -18,7 +19,6 @@ import cn.iocoder.yudao.module.pay.enums.PayChannelEnum; |
| 18 | 19 | import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; |
| 19 | 20 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; |
| 20 | 21 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; |
| 21 | -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; | |
| 22 | 22 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; |
| 23 | 23 | import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; |
| 24 | 24 | import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper; |
| ... | ... | @@ -157,8 +157,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 157 | 157 | |
| 158 | 158 | // 2. 更新提现记录 |
| 159 | 159 | brokerageWithdrawMapper.updateById(new BrokerageWithdrawDO().setId(withdraw.getId()) |
| 160 | - .setPayTransferId(transferRespDTO.getId()).setTransferChannelCode(channelCode) | |
| 161 | - .setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo())); | |
| 160 | + .setPayTransferId(transferRespDTO.getId()).setTransferChannelCode(channelCode)); | |
| 162 | 161 | } |
| 163 | 162 | |
| 164 | 163 | private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) { |
| ... | ... | @@ -190,7 +189,8 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 190 | 189 | // 2.1 计算手续费 |
| 191 | 190 | Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent()); |
| 192 | 191 | // 2.2 创建佣金提现记录 |
| 193 | - BrokerageWithdrawDO withdraw = BrokerageWithdrawConvert.INSTANCE.convert(createReqVO, userId, feePrice); | |
| 192 | + BrokerageWithdrawDO withdraw = BeanUtils.toBean(createReqVO, BrokerageWithdrawDO.class) | |
| 193 | + .setUserId(userId).setFeePrice(feePrice); | |
| 194 | 194 | brokerageWithdrawMapper.insert(withdraw); |
| 195 | 195 | |
| 196 | 196 | // 3. 创建用户佣金记录 | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferRespDTO.java
| ... | ... | @@ -70,5 +70,12 @@ public class PayTransferRespDTO { |
| 70 | 70 | * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> |
| 71 | 71 | */ |
| 72 | 72 | private String channelPackageInfo; |
| 73 | + /** | |
| 74 | + * 渠道商户号 | |
| 75 | + * | |
| 76 | + * 特殊:目前只有微信转账有这个东西!!! | |
| 77 | + * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> | |
| 78 | + */ | |
| 79 | + private String channelMchId; | |
| 73 | 80 | |
| 74 | 81 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.api.transfer; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 4 | +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; |
| 8 | +import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; | |
| 7 | 9 | import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; |
| 10 | +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; | |
| 8 | 11 | import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; |
| 9 | 12 | import jakarta.annotation.Resource; |
| 10 | 13 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -21,6 +24,8 @@ public class PayTransferApiImpl implements PayTransferApi { |
| 21 | 24 | |
| 22 | 25 | @Resource |
| 23 | 26 | private PayTransferService payTransferService; |
| 27 | + @Resource | |
| 28 | + private PayChannelService payChannelService; | |
| 24 | 29 | |
| 25 | 30 | @Override |
| 26 | 31 | public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) { |
| ... | ... | @@ -30,7 +35,15 @@ public class PayTransferApiImpl implements PayTransferApi { |
| 30 | 35 | @Override |
| 31 | 36 | public PayTransferRespDTO getTransfer(Long id) { |
| 32 | 37 | PayTransferDO transfer = payTransferService.getTransfer(id); |
| 33 | - return BeanUtils.toBean(transfer, PayTransferRespDTO.class); | |
| 38 | + if (transfer == null) { | |
| 39 | + return null; | |
| 40 | + } | |
| 41 | + PayChannelDO channel = payChannelService.getChannel(transfer.getChannelId()); | |
| 42 | + String mchId = null; | |
| 43 | + if (channel != null && channel.getConfig() instanceof WxPayClientConfig) { | |
| 44 | + mchId = ((WxPayClientConfig) channel.getConfig()).getMchId(); | |
| 45 | + } | |
| 46 | + return BeanUtils.toBean(transfer, PayTransferRespDTO.class).setChannelMchId(mchId); | |
| 34 | 47 | } |
| 35 | 48 | |
| 36 | 49 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoWithdrawDO.java
| ... | ... | @@ -80,12 +80,5 @@ 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; | |
| 90 | 83 | |
| 91 | 84 | } |
| 92 | 85 | \ 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
| ... | ... | @@ -88,8 +88,7 @@ public class PayDemoTransferServiceImpl implements PayDemoWithdrawService { |
| 88 | 88 | |
| 89 | 89 | // 2.2 更新转账单到 demo 示例提现单,并将状态更新为转账中 |
| 90 | 90 | demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(), |
| 91 | - new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId()) | |
| 92 | - .setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo())); | |
| 91 | + new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId())); | |
| 93 | 92 | return transferRespDTO.getId(); |
| 94 | 93 | } |
| 95 | 94 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java
| ... | ... | @@ -174,7 +174,7 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 174 | 174 | int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(), |
| 175 | 175 | PayTransferStatusEnum.WAITING.getStatus(), |
| 176 | 176 | new PayTransferDO().setStatus(PayTransferStatusEnum.PROCESSING.getStatus()) |
| 177 | - .setChannelPackageInfo(transfer.getChannelPackageInfo())); | |
| 177 | + .setChannelPackageInfo(notify.getChannelPackageInfo())); | |
| 178 | 178 | if (updateCounts == 0) { |
| 179 | 179 | throw exception(PAY_TRANSFER_NOTIFY_FAIL_STATUS_IS_NOT_WAITING); |
| 180 | 180 | } | ... | ... |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java
| ... | ... | @@ -14,7 +14,7 @@ import java.util.Map; |
| 14 | 14 | * |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| 17 | -public interface PayClient { | |
| 17 | +public interface PayClient<Config> { | |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * 获得渠道编号 |
| ... | ... | @@ -23,6 +23,13 @@ public interface PayClient { |
| 23 | 23 | */ |
| 24 | 24 | Long getId(); |
| 25 | 25 | |
| 26 | + /** | |
| 27 | + * 获得渠道配置 | |
| 28 | + * | |
| 29 | + * @return 渠道配置 | |
| 30 | + */ | |
| 31 | + Config getConfig(); | |
| 32 | + | |
| 26 | 33 | // ============ 支付相关 ========== |
| 27 | 34 | |
| 28 | 35 | /** | ... | ... |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/WxPayTransferPartnerNotifyV3Result.java deleted
| 1 | -package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; | |
| 2 | - | |
| 3 | -import com.github.binarywang.wxpay.bean.notify.OriginNotifyResponse; | |
| 4 | -import com.github.binarywang.wxpay.bean.notify.WxPayBaseNotifyV3Result; | |
| 5 | -import com.google.gson.annotations.SerializedName; | |
| 6 | -import lombok.Data; | |
| 7 | -import lombok.NoArgsConstructor; | |
| 8 | - | |
| 9 | -import java.io.Serializable; | |
| 10 | - | |
| 11 | -// TODO @luchi:这个可以复用 wxjava 里的类么? | |
| 12 | -@NoArgsConstructor | |
| 13 | -public class WxPayTransferPartnerNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result<WxPayTransferPartnerNotifyV3Result.TransferNotifyResult> { | |
| 14 | - | |
| 15 | - private static final long serialVersionUID = -1L; | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * 源数据 | |
| 19 | - */ | |
| 20 | - private OriginNotifyResponse rawData; | |
| 21 | - | |
| 22 | - /** | |
| 23 | - * 解密后的数据 | |
| 24 | - */ | |
| 25 | - private TransferNotifyResult result; | |
| 26 | - | |
| 27 | - @Override | |
| 28 | - public void setRawData(OriginNotifyResponse rawData) { | |
| 29 | - this.rawData = rawData; | |
| 30 | - } | |
| 31 | - | |
| 32 | - @Override | |
| 33 | - public void setResult(TransferNotifyResult data) { | |
| 34 | - this.result = data; | |
| 35 | - } | |
| 36 | - | |
| 37 | - public TransferNotifyResult getResult() { | |
| 38 | - return result; | |
| 39 | - } | |
| 40 | - | |
| 41 | - public OriginNotifyResponse getRawData() { | |
| 42 | - return rawData; | |
| 43 | - } | |
| 44 | - | |
| 45 | - @Data | |
| 46 | - @NoArgsConstructor | |
| 47 | - public static class TransferNotifyResult implements Serializable { | |
| 48 | - private static final long serialVersionUID = 1L; | |
| 49 | - | |
| 50 | - /*********************** 公共字段 ******************** | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * 商家批次单号 | |
| 54 | - */ | |
| 55 | - @SerializedName(value = "out_batch_no") | |
| 56 | - protected String outBatchNo; | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * 微信批次单号 | |
| 60 | - */ | |
| 61 | - @SerializedName(value = "batch_id") | |
| 62 | - protected String batchId; | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * 批次状态 | |
| 66 | - */ | |
| 67 | - @SerializedName(value = "batch_status") | |
| 68 | - protected String batchStatus; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * 批次总笔数 | |
| 72 | - */ | |
| 73 | - @SerializedName(value = "total_num") | |
| 74 | - protected Integer totalNum; | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * 批次总金额 | |
| 78 | - */ | |
| 79 | - @SerializedName(value = "total_amount") | |
| 80 | - protected Integer totalAmount; | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * 批次更新时间 | |
| 84 | - */ | |
| 85 | - @SerializedName(value = "update_time") | |
| 86 | - private String updateTime; | |
| 87 | - | |
| 88 | - /*********************** FINISHED ******************** | |
| 89 | - | |
| 90 | - /** | |
| 91 | - * 转账成功金额 | |
| 92 | - */ | |
| 93 | - @SerializedName(value = "success_amount") | |
| 94 | - protected Integer successAmount; | |
| 95 | - | |
| 96 | - /** | |
| 97 | - * 转账成功笔数 | |
| 98 | - */ | |
| 99 | - @SerializedName(value = "success_num") | |
| 100 | - protected Integer successNum; | |
| 101 | - | |
| 102 | - /** | |
| 103 | - * 转账失败金额 | |
| 104 | - */ | |
| 105 | - @SerializedName(value = "fail_amount") | |
| 106 | - protected Integer failAmount; | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * 转账失败笔数 | |
| 110 | - */ | |
| 111 | - @SerializedName(value = "fail_num") | |
| 112 | - protected Integer failNum; | |
| 113 | - | |
| 114 | - /*********************** CLOSED ******************** | |
| 115 | - | |
| 116 | - /** | |
| 117 | - * 商户号 | |
| 118 | - */ | |
| 119 | - @SerializedName(value = "mchid") | |
| 120 | - protected String mchId; | |
| 121 | - | |
| 122 | - /** | |
| 123 | - * 批次关闭原因 | |
| 124 | - */ | |
| 125 | - @SerializedName(value = "close_reason") | |
| 126 | - protected String closeReason; | |
| 127 | - | |
| 128 | - } | |
| 129 | -} |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java
| ... | ... | @@ -23,7 +23,7 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString |
| 23 | 23 | * @author 芋道源码 |
| 24 | 24 | */ |
| 25 | 25 | @Slf4j |
| 26 | -public abstract class AbstractPayClient<Config extends PayClientConfig> implements PayClient { | |
| 26 | +public abstract class AbstractPayClient<Config extends PayClientConfig> implements PayClient<Config> { | |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * 渠道编号 |
| ... | ... | @@ -74,6 +74,11 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 74 | 74 | return channelId; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | + @Override | |
| 78 | + public Config getConfig() { | |
| 79 | + return config; | |
| 80 | + } | |
| 81 | + | |
| 77 | 82 | // ============ 支付相关 ========== |
| 78 | 83 | |
| 79 | 84 | @Override | ... | ... |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java
| ... | ... | @@ -15,13 +15,13 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; |
| 15 | 15 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; |
| 16 | 16 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; |
| 17 | 17 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; |
| 18 | -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.WxPayTransferPartnerNotifyV3Result; | |
| 19 | 18 | import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; |
| 20 | 19 | import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; |
| 21 | 20 | import com.github.binarywang.wxpay.bean.notify.*; |
| 22 | 21 | import com.github.binarywang.wxpay.bean.request.*; |
| 23 | 22 | import com.github.binarywang.wxpay.bean.result.*; |
| 24 | 23 | import com.github.binarywang.wxpay.bean.transfer.TransferBillsGetResult; |
| 24 | +import com.github.binarywang.wxpay.bean.transfer.TransferBillsNotifyResult; | |
| 25 | 25 | import com.github.binarywang.wxpay.bean.transfer.TransferBillsRequest; |
| 26 | 26 | import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult; |
| 27 | 27 | import com.github.binarywang.wxpay.config.WxPayConfig; |
| ... | ... | @@ -355,34 +355,6 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | @Override |
| 358 | - public PayTransferRespDTO doParseTransferNotify(Map<String, String> params, String body, Map<String, String> headers) throws WxPayException { | |
| 359 | - switch (config.getApiVersion()) { | |
| 360 | - case API_VERSION_V3: | |
| 361 | - return parseTransferNotifyV3(body, headers); | |
| 362 | - case API_VERSION_V2: | |
| 363 | - throw new UnsupportedOperationException("V2 版本暂不支持,建议使用 V3 版本"); | |
| 364 | - default: | |
| 365 | - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); | |
| 366 | - } | |
| 367 | - } | |
| 368 | - | |
| 369 | - private PayTransferRespDTO parseTransferNotifyV3(String body, Map<String, String> headers) throws WxPayException { | |
| 370 | - // 1. 解析回调 | |
| 371 | - SignatureHeader signatureHeader = getRequestHeader(headers); | |
| 372 | - // TODO @luchi:这个可以复用 wxjava 里的类么? | |
| 373 | - WxPayTransferPartnerNotifyV3Result response = client.baseParseOrderNotifyV3Result(body, signatureHeader, WxPayTransferPartnerNotifyV3Result.class, WxPayTransferPartnerNotifyV3Result.TransferNotifyResult.class); | |
| 374 | - WxPayTransferPartnerNotifyV3Result.TransferNotifyResult result = response.getResult(); | |
| 375 | - // 2. 构建结果 | |
| 376 | - if (Objects.equals("FINISHED", result.getBatchStatus())) { | |
| 377 | - if (result.getFailNum() <= 0) { | |
| 378 | - return PayTransferRespDTO.successOf(result.getBatchId(), parseDateV3(result.getUpdateTime()), | |
| 379 | - result.getOutBatchNo(), response); | |
| 380 | - } | |
| 381 | - } | |
| 382 | - return PayTransferRespDTO.closedOf(result.getBatchStatus(), result.getCloseReason(), result.getOutBatchNo(), response); | |
| 383 | - } | |
| 384 | - | |
| 385 | - @Override | |
| 386 | 358 | protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException { |
| 387 | 359 | try { |
| 388 | 360 | switch (config.getApiVersion()) { |
| ... | ... | @@ -522,6 +494,37 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC |
| 522 | 494 | response.getOutBillNo(), response); |
| 523 | 495 | } |
| 524 | 496 | |
| 497 | + @Override | |
| 498 | + public PayTransferRespDTO doParseTransferNotify(Map<String, String> params, String body, Map<String, String> headers) throws WxPayException { | |
| 499 | + switch (config.getApiVersion()) { | |
| 500 | + case API_VERSION_V3: | |
| 501 | + return parseTransferNotifyV3(body, headers); | |
| 502 | + case API_VERSION_V2: | |
| 503 | + throw new UnsupportedOperationException("V2 版本暂不支持,建议使用 V3 版本"); | |
| 504 | + default: | |
| 505 | + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); | |
| 506 | + } | |
| 507 | + } | |
| 508 | + | |
| 509 | + private PayTransferRespDTO parseTransferNotifyV3(String body, Map<String, String> headers) throws WxPayException { | |
| 510 | + // 1. 解析回调 | |
| 511 | + SignatureHeader signatureHeader = getRequestHeader(headers); | |
| 512 | + TransferBillsNotifyResult response = client.getTransferService().parseTransferBillsNotifyResult(body, signatureHeader); | |
| 513 | + TransferBillsNotifyResult.DecryptNotifyResult result = response.getResult(); | |
| 514 | + | |
| 515 | + // 2. 创建返回结果 | |
| 516 | + String state = result.getState(); | |
| 517 | + if (ObjectUtils.equalsAny(state, "ACCEPTED", "PROCESSING", "WAIT_USER_CONFIRM", "TRANSFERING")) { | |
| 518 | + return PayTransferRespDTO.processingOf(result.getTransferBillNo(), result.getOutBillNo(), response); | |
| 519 | + } | |
| 520 | + if (Objects.equals("SUCCESS", state)) { | |
| 521 | + return PayTransferRespDTO.successOf(result.getTransferBillNo(), parseDateV3(result.getUpdateTime()), | |
| 522 | + result.getOutBillNo(), response); | |
| 523 | + } | |
| 524 | + return PayTransferRespDTO.closedOf(state, result.getFailReason(), | |
| 525 | + result.getOutBillNo(), response); | |
| 526 | + } | |
| 527 | + | |
| 525 | 528 | // ========== 各种工具方法 ========== |
| 526 | 529 | |
| 527 | 530 | /** | ... | ... |