code review:钱包、充值、转账的实现

This commit is contained in:
zhijiantianya@gmail.com
2023-10-18 18:39:05 +08:00
parent 5842a361e2
commit 00e18a480f
49 changed files with 178 additions and 112 deletions

View File

@ -51,7 +51,9 @@ public class PayTransferUnifiedReqDTO {
private String title;
/**
* 收款方信息,转账类型不同,收款方信息不同
* 收款方信息
*
* 转账类型 {@link #type} 不同,收款方信息不同
*/
@NotEmpty(message = "收款方信息 不能为空")
private Map<String, String> payeeInfo;

View File

@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
// TODO @jason看看能不能融合到 AbstractAlipayPayClient 中。
/**
* 支付宝转账的 PayClient 实现类
*
@ -29,6 +30,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
*/
@Slf4j
public class AlipayTransferClient extends AbstractAlipayPayClient {
// TODO @jason方法之间要有空格噢
public AlipayTransferClient(Long channelId, AlipayPayClientConfig config) {
super(channelId, PayChannelEnum.ALIPAY_TRANSFER.getCode(), config);
}
@ -49,16 +51,17 @@ public class AlipayTransferClient extends AbstractAlipayPayClient {
model.setOrderTitle(reqDTO.getTitle()); // 转账业务的标题,用于在支付宝用户的账单里显示。
model.setOutBizNo(reqDTO.getOutTransferNo());
model.setProductCode("TRANS_ACCOUNT_NO_PWD"); // 销售产品码。单笔无密转账固定为 TRANS_ACCOUNT_NO_PWD
model.setBizScene("DIRECT_TRANSFER"); // 业务场景 单笔无密转账固定为 DIRECT_TRANSFER
model.setBizScene("DIRECT_TRANSFER"); // 业务场景 单笔无密转账固定为 DIRECT_TRANSFER
model.setBusinessParams(JsonUtils.toJsonString(reqDTO.getChannelExtras()));
PayTransferTypeEnum transferType = PayTransferTypeEnum.ofType(reqDTO.getType());
switch(transferType){
case WX_BALANCE :
case WALLET_BALANCE : {
switch(transferType) {
case WX_BALANCE:
case WALLET_BALANCE: {
log.error("[doUnifiedTransfer],支付宝转账不支持的转账类型{}", transferType);
throw new UnsupportedOperationException(String.format("支付宝转账不支持转账类型: %s",transferType.getName()));
}
case ALIPAY_BALANCE : {
// TODO @jason是不是不用传递 transferType 参数哈?因为应该已经明确是支付宝啦?
case ALIPAY_BALANCE: {
// ② 个性化的参数
Participant payeeInfo = new Participant();
payeeInfo.setIdentityType("ALIPAY_LOGON_ID");
@ -90,7 +93,7 @@ public class AlipayTransferClient extends AbstractAlipayPayClient {
return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()),
response.getOutBizNo(), response);
}
case BANK_CARD : {
case BANK_CARD: {
Participant payeeInfo = new Participant();
payeeInfo.setIdentityType("BANKCARD_ACCOUNT");
throw new UnsupportedOperationException("待实现");
@ -100,4 +103,5 @@ public class AlipayTransferClient extends AbstractAlipayPayClient {
}
}
}
}

View File

@ -70,4 +70,5 @@ public class MockPayClient extends AbstractPayClient<NonePayClientConfig> {
protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) {
throw new UnsupportedOperationException("待实现");
}
}

View File

@ -28,6 +28,7 @@ public enum PayChannelEnum {
ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class),
ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class),
ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class),
// TODO @jason是不是按照微信聊的合并回 ALIPAY_PC因为支付宝、微信都是多种支付方式选择其中的一种即可
ALIPAY_TRANSFER("alipay_transfer", "支付宝转账", AlipayPayClientConfig.class),
MOCK("mock", "模拟支付", NonePayClientConfig.class),

View File

@ -18,10 +18,10 @@ public enum PayTransferStatusRespEnum {
/**
* TODO 转账到银行卡. 会有T+0 T+1 到账的请情况。 还未实现
* TODO @jason可以看看其它开源项目针对这个场景处理策略是怎么样的例如说每天主动轮询这个状态的单子
*/
IN_PROGRESS(10, "转账进行中"),
SUCCESS(20, "转账成功"),
/**
* 转账关闭 (失败,或者其它情况)

View File

@ -15,6 +15,7 @@ import java.util.Arrays;
@AllArgsConstructor
@Getter
public enum PayTransferTypeEnum implements IntArrayValuable {
ALIPAY_BALANCE(1, "支付宝余额"),
WX_BALANCE(2, "微信余额"),
BANK_CARD(3, "银行卡"),
@ -33,7 +34,9 @@ public enum PayTransferTypeEnum implements IntArrayValuable {
return ARRAYS;
}
// TODO @jason是不是 typeOf 更符合预期哈?
public static PayTransferTypeEnum ofType(Integer type) {
return ArrayUtil.firstMatch(item -> item.getType().equals(type), values());
}
}