Commit 86598dd177a6b3bdd95e73dccda80bd888416582
1 parent
9095394f
转账 - 动态收款人字段修改
Showing
9 changed files
with
211 additions
and
102 deletions
sql/mysql/pay_wallet.sql
| ... | ... | @@ -5,18 +5,26 @@ DROP TABLE IF EXISTS `pay_transfer`; |
| 5 | 5 | CREATE TABLE `pay_transfer` |
| 6 | 6 | ( |
| 7 | 7 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', |
| 8 | - `type` int NOT NULL COMMENT '类型', | |
| 8 | + `no` varchar(64) NOT NULL COMMENT '转账单号', | |
| 9 | 9 | `app_id` bigint NOT NULL COMMENT '应用编号', |
| 10 | + `channel_id` bigint NOT NULL COMMENT '转账渠道编号', | |
| 11 | + `channel_code` varchar(32) NOT NULL COMMENT '转账渠道编码', | |
| 10 | 12 | `merchant_order_id` varchar(64) NOT NULL COMMENT '商户订单编号', |
| 11 | - `price` int NOT NULL COMMENT '转账金额,单位:分', | |
| 12 | - `subject` varchar(512) NOT NULL COMMENT '转账标题', | |
| 13 | - `payee_info` varchar(512) NOT NULL COMMENT '收款人信息,不同类型和渠道不同', | |
| 13 | + `type` int NOT NULL COMMENT '类型', | |
| 14 | 14 | `status` tinyint NOT NULL COMMENT '转账状态', |
| 15 | 15 | `success_time` datetime NULL COMMENT '转账成功时间', |
| 16 | - `extension_id` bigint NULL COMMENT '转账渠道编号', | |
| 17 | - `no` varchar(64) NULL COMMENT '转账单号', | |
| 18 | - `channel_id` bigint NULL COMMENT '转账渠道编号', | |
| 19 | - `channel_code` varchar(32) NULL COMMENT '转账渠道编码', | |
| 16 | + `price` int NOT NULL COMMENT '转账金额,单位:分', | |
| 17 | + `subject` varchar(512) NOT NULL COMMENT '转账标题', | |
| 18 | + `alipay_logon_id` varchar(64) NULL COMMENT '支付宝登录号', | |
| 19 | + `alipay_account_name` varchar(64) NULL COMMENT '支付宝账号名称', | |
| 20 | + `openid` varchar(64) NULL COMMENT '微信 openId', | |
| 21 | + `wx_account_name` varchar(64) NULL COMMENT '微信账号名称', | |
| 22 | + `notify_url` varchar(64) NULL COMMENT '异步通知商户地址', | |
| 23 | + `channel_extras` varchar(512) NULL DEFAULT NULL COMMENT '渠道的额外参数', | |
| 24 | + `channel_transfer_no` varchar(64) NULL DEFAULT NULL COMMENT '渠道转账单号', | |
| 25 | + `channel_error_code` varchar(128) NULL DEFAULT NULL COMMENT '调用渠道的错误码', | |
| 26 | + `channel_error_msg` varchar(256) NULL DEFAULT NULL COMMENT '调用渠道的错误提示', | |
| 27 | + `channel_notify_data` varchar(4096) NULL DEFAULT NULL COMMENT '渠道的同步/异步通知的内容', | |
| 20 | 28 | `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', |
| 21 | 29 | `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| 22 | 30 | `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', |
| ... | ... | @@ -58,7 +66,10 @@ CREATE TABLE `pay_demo_transfer` ( |
| 58 | 66 | `user_id` bigint UNSIGNED NOT NULL COMMENT '用户编号', |
| 59 | 67 | `price` int NOT NULL COMMENT '转账金额,单位:分', |
| 60 | 68 | `type` int NOT NULL COMMENT '转账类型', |
| 61 | - `payee_info` varchar(512) NOT NULL COMMENT '收款人信息,不同类型和渠道不同', | |
| 69 | + `alipay_logon_id` varchar(64) NULL COMMENT '支付宝登录号', | |
| 70 | + `alipay_account_name` varchar(64) NULL COMMENT '支付宝账号名称', | |
| 71 | + `openid` varchar(64) NULL COMMENT '微信 openId', | |
| 72 | + `wx_account_name` varchar(64) NULL COMMENT '微信账号名称', | |
| 62 | 73 | `transfer_status` tinyint NOT NULL DEFAULT 0 COMMENT '转账状态', |
| 63 | 74 | `pay_transfer_id` bigint NULL DEFAULT NULL COMMENT '转账订单编号', |
| 64 | 75 | `pay_channel_code` varchar(16) NULL DEFAULT NULL COMMENT '转账支付成功渠道', | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java
| ... | ... | @@ -59,6 +59,26 @@ public class PayTransferUnifiedReqDTO { |
| 59 | 59 | private Map<String, String> payeeInfo; |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | + * 支付宝登录号 | |
| 63 | + */ | |
| 64 | + private String alipayLogonId; | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 支付宝账号名称 | |
| 68 | + */ | |
| 69 | + private String alipayAccountName; | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 微信 openId | |
| 73 | + */ | |
| 74 | + private String openid; | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 微信账号名称 | |
| 78 | + */ | |
| 79 | + private String wxAccountName; | |
| 80 | + | |
| 81 | + /** | |
| 62 | 82 | * 支付渠道的额外参数 |
| 63 | 83 | */ |
| 64 | 84 | private Map<String, String> channelExtras; | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java
| ... | ... | @@ -65,15 +65,13 @@ public interface ErrorCodeConstants { |
| 65 | 65 | |
| 66 | 66 | // ========== 转账模块 1-007-009-000 ========== |
| 67 | 67 | ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}"); |
| 68 | - ErrorCode PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY = new ErrorCode(1_007_009_001, "支付宝登录 ID 不能为空"); | |
| 69 | - ErrorCode PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY = new ErrorCode(1_007_009_002, "支付宝账号名称不能为空"); | |
| 70 | - ErrorCode PAY_TRANSFER_NOT_FOUND = new ErrorCode(1_007_009_003, "转账交易单不存在"); | |
| 71 | - ErrorCode PAY_TRANSFER_STATUS_IS_SUCCESS = new ErrorCode(1_007_009_004, "转账单已成功转账"); | |
| 72 | - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_009_005, "转账单不处于待转账"); | |
| 73 | - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_006, "转账单不处于待转账或转账中"); | |
| 74 | - ErrorCode PAY_TRANSFER_EXTENSION_NOT_FOUND = new ErrorCode(1_007_009_007, "转账交易拓展单不存在"); | |
| 75 | - ErrorCode PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH = new ErrorCode(1_007_009_008, "转账类型和转账渠道不匹配"); | |
| 76 | - ErrorCode PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_009, "转账拓展单不处于待转账或转账中"); | |
| 68 | + ErrorCode PAY_TRANSFER_NOT_FOUND = new ErrorCode(1_007_009_001, "转账交易单不存在"); | |
| 69 | + ErrorCode PAY_TRANSFER_STATUS_IS_SUCCESS = new ErrorCode(1_007_009_002, "转账单已成功转账"); | |
| 70 | + ErrorCode PAY_TRANSFER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_009_003, "转账单不处于待转账"); | |
| 71 | + ErrorCode PAY_TRANSFER_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_004, "转账单不处于待转账或转账中"); | |
| 72 | + ErrorCode PAY_TRANSFER_EXTENSION_NOT_FOUND = new ErrorCode(1_007_009_005, "转账交易拓展单不存在"); | |
| 73 | + ErrorCode PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH = new ErrorCode(1_007_009_006, "转账类型和转账渠道不匹配"); | |
| 74 | + ErrorCode PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_007, "转账拓展单不处于待转账或转账中"); | |
| 77 | 75 | |
| 78 | 76 | // ========== 示例订单 1-007-900-000 ========== |
| 79 | 77 | ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1_007_900_000, "示例订单不存在"); | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 5 | import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; |
| 5 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 7 | import lombok.Data; |
| 7 | 8 | |
| 9 | +import javax.validation.Validator; | |
| 8 | 10 | import javax.validation.constraints.Min; |
| 9 | -import javax.validation.constraints.NotEmpty; | |
| 11 | +import javax.validation.constraints.NotBlank; | |
| 10 | 12 | import javax.validation.constraints.NotNull; |
| 11 | -import java.util.Map; | |
| 12 | 13 | |
| 13 | 14 | /** |
| 14 | 15 | * @author jason |
| ... | ... | @@ -22,13 +23,50 @@ public class PayDemoTransferCreateReqVO { |
| 22 | 23 | @InEnum(PayTransferTypeEnum.class) |
| 23 | 24 | private Integer type; |
| 24 | 25 | |
| 26 | + @Schema(description = "转账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 25 | 27 | @NotNull(message = "转账金额不能为空") |
| 26 | 28 | @Min(value = 1, message = "转账金额必须大于零") |
| 27 | 29 | private Integer price; |
| 28 | 30 | |
| 29 | - // TODO @jason:感觉这个动态字段,晚点改;可能要讨论下怎么搞好; | |
| 30 | - @Schema(description = "收款方信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "{'ALIPAY_LOGON_ID':'xxxx'}") | |
| 31 | - @NotEmpty(message = "收款方信息不能为空") | |
| 32 | - private Map<String, String> payeeInfo; | |
| 31 | + // ========== 支付宝,微信转账相关字段 ========== | |
| 32 | + @Schema(description = "支付宝登录号,支持邮箱和手机号格式", example = "test1@@sandbox.com") | |
| 33 | + @NotBlank(message = "支付宝登录号不能为空", groups = {Alipay.class}) | |
| 34 | + private String alipayLogonId; | |
| 35 | + | |
| 36 | + @Schema(description = "支付宝账号名称", example = "test1") | |
| 37 | + @NotBlank(message = "支付宝登录号不能为空", groups = {Alipay.class}) | |
| 38 | + private String alipayAccountName; | |
| 39 | + | |
| 40 | + // ========== 微信转账相关字段 ========== | |
| 41 | + @Schema(description = "微信 openId", example = "oLefc4g5Gxx") | |
| 42 | + @NotBlank(message = "微信 openId 不能为空", groups = {WxPay.class}) | |
| 43 | + private String openid; | |
| 44 | + | |
| 45 | + @Schema(description = "微信账号名称", example = "oLefc4g5Gjxxxxxx") | |
| 46 | + private String wxAccountName; | |
| 47 | + | |
| 48 | + // ========== 转账到银行卡和钱包相关字段 待补充 ========== | |
| 49 | + public interface WxPay { | |
| 50 | + } | |
| 51 | + | |
| 52 | + public interface Alipay { | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void validate(Validator validator) { | |
| 56 | + PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(type); | |
| 57 | + switch (transferType) { | |
| 58 | + case ALIPAY_BALANCE: { | |
| 59 | + ValidationUtils.validate(validator, this, Alipay.class); | |
| 60 | + break; | |
| 61 | + } | |
| 62 | + case WX_BALANCE: { | |
| 63 | + ValidationUtils.validate(validator, this, WxPay.class); | |
| 64 | + break; | |
| 65 | + } | |
| 66 | + default: { | |
| 67 | + throw new UnsupportedOperationException("待实现"); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + } | |
| 33 | 71 | |
| 34 | 72 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoTransferConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.convert.demo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; | |
| 5 | +import org.mapstruct.Mapper; | |
| 6 | +import org.mapstruct.factory.Mappers; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @author jason | |
| 10 | + */ | |
| 11 | +@Mapper | |
| 12 | +public interface PayDemoTransferConvert { | |
| 13 | + | |
| 14 | + PayDemoTransferConvert INSTANCE = Mappers.getMapper(PayDemoTransferConvert.class); | |
| 15 | + | |
| 16 | + PayDemoTransferDO convert(PayDemoTransferCreateReqVO bean); | |
| 17 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.dal.dataobject.demo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; | |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | -import com.baomidou.mybatisplus.annotation.TableField; | |
| 6 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 7 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| 8 | -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | |
| 9 | 8 | import lombok.Data; |
| 10 | 9 | |
| 11 | 10 | import java.time.LocalDateTime; |
| 12 | -import java.util.Map; | |
| 13 | 11 | |
| 14 | 12 | /** |
| 15 | 13 | * 示例转账订单 |
| ... | ... | @@ -39,15 +37,30 @@ public class PayDemoTransferDO extends BaseDO { |
| 39 | 37 | |
| 40 | 38 | /** |
| 41 | 39 | * 转账类型 |
| 40 | + * <p> | |
| 41 | + * 枚举 {@link PayTransferTypeEnum} | |
| 42 | 42 | */ |
| 43 | 43 | private Integer type; |
| 44 | 44 | |
| 45 | - // TODO @jason:要不字段还是弄成正确的平铺开? | |
| 46 | 45 | /** |
| 47 | - * 收款人信息,不同类型和渠道不同 | |
| 46 | + * 支付宝登录号 | |
| 48 | 47 | */ |
| 49 | - @TableField(typeHandler = JacksonTypeHandler.class) | |
| 50 | - private Map<String, String> payeeInfo; | |
| 48 | + private String alipayLogonId; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 支付宝账号名称 | |
| 52 | + */ | |
| 53 | + private String alipayAccountName; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 微信 openId | |
| 57 | + */ | |
| 58 | + private String openid; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 微信账号名称 | |
| 62 | + */ | |
| 63 | + private String wxAccountName; | |
| 51 | 64 | |
| 52 | 65 | /** |
| 53 | 66 | * 转账状态 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java
| ... | ... | @@ -31,33 +31,35 @@ public class PayTransferDO extends BaseDO { |
| 31 | 31 | */ |
| 32 | 32 | @TableId |
| 33 | 33 | private Long id; |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 转账单号 | |
| 37 | + * | |
| 38 | + */ | |
| 39 | + private String no; | |
| 40 | + | |
| 34 | 41 | /** |
| 35 | 42 | * 应用编号 |
| 36 | 43 | * |
| 37 | 44 | * 关联 {@link PayAppDO#getId()} |
| 38 | 45 | */ |
| 39 | 46 | private Long appId; |
| 47 | + | |
| 40 | 48 | /** |
| 41 | 49 | * 转账渠道编号 |
| 42 | 50 | * |
| 43 | 51 | * 关联 {@link PayChannelDO#getId()} |
| 44 | 52 | */ |
| 45 | 53 | private Long channelId; |
| 54 | + | |
| 46 | 55 | /** |
| 47 | 56 | * 转账渠道编码 |
| 48 | 57 | * |
| 49 | 58 | * 枚举 {@link PayChannelEnum} |
| 50 | 59 | */ |
| 51 | 60 | private String channelCode; |
| 52 | - /** | |
| 53 | - * 类型 | |
| 54 | - * | |
| 55 | - * 枚举 {@link PayTransferTypeEnum} | |
| 56 | - */ | |
| 57 | - private Integer type; | |
| 58 | 61 | |
| 59 | 62 | // ========== 商户相关字段 ========== |
| 60 | - | |
| 61 | 63 | /** |
| 62 | 64 | * 商户订单编号 |
| 63 | 65 | * |
| ... | ... | @@ -65,12 +67,20 @@ public class PayTransferDO extends BaseDO { |
| 65 | 67 | */ |
| 66 | 68 | private String merchantOrderId; |
| 67 | 69 | |
| 70 | + // ========== 转账相关字段 ========== | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 类型 | |
| 74 | + * | |
| 75 | + * 枚举 {@link PayTransferTypeEnum} | |
| 76 | + */ | |
| 77 | + private Integer type; | |
| 78 | + | |
| 68 | 79 | /** |
| 69 | 80 | * 转账标题 |
| 70 | 81 | */ |
| 71 | 82 | private String subject; |
| 72 | 83 | |
| 73 | - // ========== 转账相关字段 ========== | |
| 74 | 84 | /** |
| 75 | 85 | * 转账金额,单位:分 |
| 76 | 86 | */ |
| ... | ... | @@ -81,26 +91,70 @@ public class PayTransferDO extends BaseDO { |
| 81 | 91 | * 枚举 {@link PayTransferStatusRespEnum} |
| 82 | 92 | */ |
| 83 | 93 | private Integer status; |
| 94 | + | |
| 84 | 95 | /** |
| 85 | 96 | * 订单转账成功时间 |
| 86 | 97 | */ |
| 87 | 98 | private LocalDateTime successTime; |
| 99 | + | |
| 100 | + // ========== 支付宝转账相关字段 ========== | |
| 88 | 101 | /** |
| 89 | - * 转账成功的转账拓展单编号 | |
| 90 | - * | |
| 91 | - * 关联 {@link PayTransferExtensionDO#getId()} | |
| 102 | + * 支付宝登录号 | |
| 92 | 103 | */ |
| 93 | - private Long extensionId; | |
| 104 | + private String alipayLogonId; | |
| 105 | + | |
| 94 | 106 | /** |
| 95 | - * 转账成功的转账拓展单号 | |
| 96 | - * | |
| 97 | - * 关联 {@link PayTransferExtensionDO#getNo()} | |
| 107 | + * 支付宝账号名称 | |
| 98 | 108 | */ |
| 99 | - private String no; | |
| 109 | + private String alipayAccountName; | |
| 110 | + | |
| 111 | + // ========== 微信转账相关字段 ========== | |
| 112 | + /** | |
| 113 | + * 微信 openId | |
| 114 | + */ | |
| 115 | + private String openid; | |
| 116 | + | |
| 117 | + /** | |
| 118 | + * 微信账号名称 | |
| 119 | + */ | |
| 120 | + private String wxAccountName; | |
| 121 | + | |
| 122 | + // ========== 其它字段 ========== | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * 异步通知地址 | |
| 126 | + */ | |
| 127 | + private String notifyUrl; | |
| 128 | + | |
| 129 | + /** | |
| 130 | + * 用户 IP | |
| 131 | + */ | |
| 132 | + private String userIp; | |
| 133 | + | |
| 100 | 134 | /** |
| 101 | - * 收款人信息,不同类型和渠道不同 | |
| 135 | + * 渠道的额外参数 | |
| 102 | 136 | */ |
| 103 | 137 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 104 | - private Map<String, String> payeeInfo; | |
| 138 | + private Map<String, String> channelExtras; | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * 渠道转账单号 | |
| 142 | + */ | |
| 143 | + private String channelTransferNo; | |
| 144 | + | |
| 145 | + /** | |
| 146 | + * 调用渠道的错误码 | |
| 147 | + */ | |
| 148 | + private String channelErrorCode; | |
| 149 | + /** | |
| 150 | + * 调用渠道的错误提示 | |
| 151 | + */ | |
| 152 | + private String channelErrorMsg; | |
| 153 | + | |
| 154 | + /** | |
| 155 | + * 渠道的同步/异步通知的内容 | |
| 156 | + * | |
| 157 | + */ | |
| 158 | + private String channelNotifyData; | |
| 105 | 159 | |
| 106 | 160 | } |
| 107 | 161 | \ 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
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.demo; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.map.MapUtil; | |
| 4 | -import cn.hutool.core.util.StrUtil; | |
| 5 | -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; | |
| 6 | 3 | import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; |
| 7 | -import cn.iocoder.yudao.module.pay.convert.transfer.PayTransferConvert; | |
| 4 | +import cn.iocoder.yudao.module.pay.convert.demo.PayDemoTransferConvert; | |
| 8 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; |
| 9 | 6 | import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoTransferMapper; |
| 10 | 7 | import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; |
| ... | ... | @@ -14,12 +11,8 @@ import org.springframework.validation.annotation.Validated; |
| 14 | 11 | |
| 15 | 12 | import javax.annotation.Resource; |
| 16 | 13 | import javax.validation.Valid; |
| 17 | -import java.util.Map; | |
| 14 | +import javax.validation.Validator; | |
| 18 | 15 | |
| 19 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 20 | -import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.*; | |
| 21 | -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY; | |
| 22 | -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY; | |
| 23 | 16 | import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum.WAITING; |
| 24 | 17 | |
| 25 | 18 | /** |
| ... | ... | @@ -41,49 +34,18 @@ public class PayDemoTransferServiceImpl implements PayDemoTransferService { |
| 41 | 34 | private PayDemoTransferMapper demoTransferMapper; |
| 42 | 35 | @Resource |
| 43 | 36 | private PayTransferService transferService; |
| 37 | + @Resource | |
| 38 | + private Validator validator; | |
| 44 | 39 | |
| 45 | 40 | @Override |
| 46 | 41 | @Transactional(rollbackFor = Exception.class) |
| 47 | 42 | public Long createDemoTransfer(Long userId, @Valid PayDemoTransferCreateReqVO vo) { |
| 48 | - // 1 校验收款账号 | |
| 49 | - validatePayeeInfo(vo.getType(), vo.getPayeeInfo()); | |
| 50 | - | |
| 43 | + // 1 校验参数 | |
| 44 | + vo.validate(validator); | |
| 51 | 45 | // 2 保存示例转账业务表 |
| 52 | - PayDemoTransferDO demoTransfer = new PayDemoTransferDO().setUserId(userId).setType(vo.getType()) | |
| 53 | - .setPrice(vo.getPrice()).setPayeeInfo(vo.getPayeeInfo()) | |
| 54 | - .setTransferStatus(WAITING.getStatus()); | |
| 46 | + PayDemoTransferDO demoTransfer = PayDemoTransferConvert.INSTANCE.convert(vo) | |
| 47 | + .setUserId(userId).setTransferStatus(WAITING.getStatus()); | |
| 55 | 48 | demoTransferMapper.insert(demoTransfer); |
| 56 | - | |
| 57 | - // 3.1 创建转账单 | |
| 58 | - Long transferId = transferService.createTransfer(PayTransferConvert.INSTANCE.convert(vo) | |
| 59 | - .setAppId(TRANSFER_APP_ID).setTitle("示例转账") | |
| 60 | - .setMerchantOrderId(String.valueOf(demoTransfer.getId()))); | |
| 61 | - // 3.2 更新转账单编号 | |
| 62 | - demoTransferMapper.updateById(new PayDemoTransferDO().setId(demoTransfer.getId()) | |
| 63 | - .setPayTransferId(transferId)); | |
| 64 | 49 | return demoTransfer.getId(); |
| 65 | 50 | } |
| 66 | - | |
| 67 | - // TODO @jason:可以参考 AppBrokerageWithdrawCreateReqVO 搞下字段哈,进行校验 | |
| 68 | - // @jason payeeinfo 字段确定改一下 | |
| 69 | - private void validatePayeeInfo(Integer transferType, Map<String, String> payeeInfo) { | |
| 70 | - PayTransferTypeEnum transferTypeEnum = typeOf(transferType); | |
| 71 | - switch (transferTypeEnum) { | |
| 72 | - case ALIPAY_BALANCE: { | |
| 73 | - if (StrUtil.isEmpty(MapUtil.getStr(payeeInfo, ALIPAY_LOGON_ID))) { | |
| 74 | - throw exception(PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY); | |
| 75 | - } | |
| 76 | - if (StrUtil.isEmpty(MapUtil.getStr(payeeInfo, ALIPAY_ACCOUNT_NAME))) { | |
| 77 | - throw exception(PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY); | |
| 78 | - } | |
| 79 | - break; | |
| 80 | - } | |
| 81 | - case WX_BALANCE: | |
| 82 | - case BANK_CARD: | |
| 83 | - case WALLET_BALANCE: { | |
| 84 | - throw new UnsupportedOperationException("待实现"); | |
| 85 | - } | |
| 86 | - } | |
| 87 | - } | |
| 88 | - | |
| 89 | 51 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java
| ... | ... | @@ -28,7 +28,6 @@ import org.springframework.stereotype.Service; |
| 28 | 28 | import org.springframework.transaction.annotation.Transactional; |
| 29 | 29 | |
| 30 | 30 | import javax.annotation.Resource; |
| 31 | -import java.util.Objects; | |
| 32 | 31 | |
| 33 | 32 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 34 | 33 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -80,7 +79,7 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 80 | 79 | PayTransferUnifiedReqDTO transferUnifiedReq = new PayTransferUnifiedReqDTO() |
| 81 | 80 | .setOutTransferNo(transferExtension.getNo()).setPrice(transfer.getPrice()) |
| 82 | 81 | .setType(transfer.getType()).setTitle(transfer.getSubject()) |
| 83 | - .setPayeeInfo(transfer.getPayeeInfo()).setUserIp(userIp) | |
| 82 | + .setUserIp(userIp) | |
| 84 | 83 | .setChannelExtras(reqVO.getChannelExtras()); |
| 85 | 84 | PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq); |
| 86 | 85 | |
| ... | ... | @@ -139,10 +138,7 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 139 | 138 | if (transfer == null) { |
| 140 | 139 | throw exception(PAY_TRANSFER_NOT_FOUND); |
| 141 | 140 | } |
| 142 | - if (isSuccess(transfer.getStatus()) && Objects.equals(transfer.getExtensionId(), transferExtension.getId())) { | |
| 143 | - log.info("[updateTransferSuccess][transfer({}) 已经是已转账,无需更新]", transfer.getId()); | |
| 144 | - return true; | |
| 145 | - } | |
| 141 | + | |
| 146 | 142 | if (!isPendingStatus(transfer.getStatus())) { |
| 147 | 143 | throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); |
| 148 | 144 | } |
| ... | ... | @@ -151,7 +147,7 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 151 | 147 | CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), |
| 152 | 148 | new PayTransferDO().setStatus(SUCCESS.getStatus()).setSuccessTime(notify.getSuccessTime()) |
| 153 | 149 | .setChannelId(channel.getId()).setChannelCode(channel.getCode()) |
| 154 | - .setExtensionId(transferExtension.getId()).setNo(transferExtension.getNo())); | |
| 150 | + .setNo(transferExtension.getNo())); | |
| 155 | 151 | if (updateCounts == 0) { |
| 156 | 152 | throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); |
| 157 | 153 | } | ... | ... |