后端:增加部分退款逻辑
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
package cn.iocoder.mall.pay.api;
|
||||
|
||||
public interface PayDemoService {
|
||||
|
||||
String updatePaySuccess(String orderId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.mall.pay.api;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundSubmitBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayRefundSubmitDTO;
|
||||
|
||||
public interface PayRefundService {
|
||||
|
||||
CommonResult<PayRefundSubmitBO> submitRefund(PayRefundSubmitDTO payRefundSubmitDTO);
|
||||
|
||||
/**
|
||||
* 更新退款支付成功
|
||||
*
|
||||
* 该接口用于不同支付平台,退款成功后,回调该接口
|
||||
*
|
||||
* @param payChannel 支付渠道
|
||||
* @param params 回调参数。
|
||||
* 因为不同平台,能够提供的参数不同,所以使用 String 类型统一接收,然后在使用不同的 AbstractPaySDK 进行处理。
|
||||
* @return 是否支付成功
|
||||
*/
|
||||
CommonResult<Boolean> updateRefundSuccess(Integer payChannel, String params);
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.iocoder.mall.pay.api;
|
||||
|
||||
public interface RefundService {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.iocoder.mall.pay.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 退款单结果 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayRefundSubmitBO {
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
}
|
||||
@@ -11,12 +11,20 @@ public enum PayErrorCodeEnum {
|
||||
PAY_APP_NOT_FOUND(1004000000, "App 不存在"),
|
||||
PAY_APP_IS_DISABLE(1004000001, "App 已经被禁用"),
|
||||
|
||||
// ========== TRANSACTION 模块 ==========
|
||||
// ========== TRANSACTION PAY 模块 ==========
|
||||
PAY_TRANSACTION_NOT_FOUND(100401000, "支付交易单不存在"),
|
||||
PAY_TRANSACTION_STATUS_IS_NOT_WAITING(100401001, "支付交易单不处于待支付"),
|
||||
PAY_TRANSACTION_EXTENSION_NOT_FOUND(100401002, "支付交易拓展单不存在"),
|
||||
PAY_TRANSACTION_EXTENSION_STATUS_IS_NOT_WAITING(100401003, "支付交易拓展单不处于待支付"),
|
||||
PAY_TRANSACTION_ERROR_USER(100401004, "支付交易单用户不正确"),
|
||||
PAY_TRANSACTION_STATUS_IS_NOT_SUCCESS(100401002, "支付交易单不处于已支付"),
|
||||
PAY_TRANSACTION_ERROR_USER(100401003, "支付交易单用户不正确"),
|
||||
|
||||
PAY_TRANSACTION_EXTENSION_NOT_FOUND(100401050, "支付交易拓展单不存在"),
|
||||
PAY_TRANSACTION_EXTENSION_STATUS_IS_NOT_WAITING(100401051, "支付交易拓展单不处于待支付"),
|
||||
PAY_TRANSACTION_EXTENSION_STATUS_IS_NOT_SUCCESS(100401052, "支付交易单不处于已支付"),
|
||||
|
||||
// ========== TRANSACTION REFUND 模块 ==========
|
||||
PAY_REFUND_PRICE_EXCEED(100402000, "退款金额超过支付交易单可退金额"),
|
||||
PAY_REFUND_NOT_FOUND(100402001, "退款单不存在"),
|
||||
PAY_REFUND_STATUS_NOT_WAITING(100402002, "退款单不处于待处理"),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.iocoder.mall.pay.api.constant;
|
||||
|
||||
/**
|
||||
* 支付通知类型
|
||||
*/
|
||||
public enum PayNotifyType {
|
||||
|
||||
TRANSACTION(1, "支付"),
|
||||
REFUND(2, "退款"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer value;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String name;
|
||||
|
||||
PayNotifyType(Integer value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public PayNotifyType setValue(Integer value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public PayNotifyType setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.iocoder.mall.pay.api.constant;
|
||||
|
||||
/**
|
||||
* 支付退款状态枚举
|
||||
*/
|
||||
public enum PayRefundStatus {
|
||||
|
||||
WAITING(1, "处理中"),
|
||||
SUCCESS(2, "成功"),
|
||||
FAILURE(3, "失败"), // 例如说,支付单超时
|
||||
;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer value;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String name;
|
||||
|
||||
PayRefundStatus(Integer value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public PayRefundStatus setValue(Integer value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public PayRefundStatus setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ package cn.iocoder.mall.pay.api.constant;
|
||||
*/
|
||||
public enum PayTransactionStatusEnum {
|
||||
|
||||
WAITTING(1, "等待支付"),
|
||||
WAITING(1, "等待支付"),
|
||||
SUCCESS(2, "支付成功"),
|
||||
CANCEL(3, "取消支付"), // 例如说,支付单超时
|
||||
;
|
||||
@@ -42,4 +42,4 @@ public enum PayTransactionStatusEnum {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.iocoder.mall.pay.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 支付退款创建 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayRefundSubmitDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
@NotEmpty(message = "应用编号不能为空")
|
||||
private String appId;
|
||||
/**
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
@NotEmpty(message = "IP 不能为空")
|
||||
private String createIp;
|
||||
/**
|
||||
* 业务线的订单编号
|
||||
*/
|
||||
@NotEmpty(message = "订单号不能为空")
|
||||
private String orderId;
|
||||
/**
|
||||
* 退款描述
|
||||
*/
|
||||
@NotEmpty(message = "退款描述不能为空")
|
||||
@Length(max = 128, message = "退款描述长度不能超过128")
|
||||
private String orderDescription;
|
||||
/**
|
||||
* 支付金额,单位:分。
|
||||
*/
|
||||
@NotNull(message = "金额不能为空")
|
||||
@DecimalMin(value = "0", inclusive = false, message = "金额必须大于零")
|
||||
private Integer price;
|
||||
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package cn.iocoder.mall.pay.api.dto;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package cn.iocoder.mall.pay.api.message;
|
||||
|
||||
/**
|
||||
* 支付退款成功的消息对象
|
||||
*/
|
||||
public class PayRefundSuccessMessage {
|
||||
|
||||
public static final String TOPIC = "PAY_REFUND_SUCCESS";
|
||||
|
||||
/**
|
||||
* 任务编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 退款单编号
|
||||
*/
|
||||
private Integer refundId;
|
||||
/**
|
||||
* 交易编号
|
||||
*/
|
||||
private Integer transactionId;
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 应用订单编号
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 当前通知次数
|
||||
*/
|
||||
private Integer notifyTimes;
|
||||
/**
|
||||
* 通知地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public PayRefundSuccessMessage setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public PayRefundSuccessMessage setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public PayRefundSuccessMessage setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNotifyTimes() {
|
||||
return notifyTimes;
|
||||
}
|
||||
|
||||
public PayRefundSuccessMessage setNotifyTimes(Integer notifyTimes) {
|
||||
this.notifyTimes = notifyTimes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNotifyUrl() {
|
||||
return notifyUrl;
|
||||
}
|
||||
|
||||
public PayRefundSuccessMessage setNotifyUrl(String notifyUrl) {
|
||||
this.notifyUrl = notifyUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public PayRefundSuccessMessage setTransactionId(Integer transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package cn.iocoder.mall.pay.api.message;
|
||||
/**
|
||||
* 支付交易单支付成功的消息对象
|
||||
*/
|
||||
public class PayTransactionPaySuccessMessage {
|
||||
public class PayTransactionSuccessMessage {
|
||||
|
||||
public static final String TOPIC = "PAY_TRANSACTION_PAY_SUCCESS";
|
||||
public static final String TOPIC = "PAY_TRANSACTION_SUCCESS";
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
* 任务编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public class PayTransactionPaySuccessMessage {
|
||||
return id;
|
||||
}
|
||||
|
||||
public PayTransactionPaySuccessMessage setId(Integer id) {
|
||||
public PayTransactionSuccessMessage setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class PayTransactionPaySuccessMessage {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public PayTransactionPaySuccessMessage setAppId(String appId) {
|
||||
public PayTransactionSuccessMessage setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
return this;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class PayTransactionPaySuccessMessage {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public PayTransactionPaySuccessMessage setOrderId(String orderId) {
|
||||
public PayTransactionSuccessMessage setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class PayTransactionPaySuccessMessage {
|
||||
return notifyTimes;
|
||||
}
|
||||
|
||||
public PayTransactionPaySuccessMessage setNotifyTimes(Integer notifyTimes) {
|
||||
public PayTransactionSuccessMessage setNotifyTimes(Integer notifyTimes) {
|
||||
this.notifyTimes = notifyTimes;
|
||||
return this;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class PayTransactionPaySuccessMessage {
|
||||
return notifyUrl;
|
||||
}
|
||||
|
||||
public PayTransactionPaySuccessMessage setNotifyUrl(String notifyUrl) {
|
||||
public PayTransactionSuccessMessage setNotifyUrl(String notifyUrl) {
|
||||
this.notifyUrl = notifyUrl;
|
||||
return this;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class PayTransactionPaySuccessMessage {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public PayTransactionPaySuccessMessage setTransactionId(Integer transactionId) {
|
||||
public PayTransactionSuccessMessage setTransactionId(Integer transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
return this;
|
||||
}
|
||||
Reference in New Issue
Block a user