第一次提交
This commit is contained in:
38
fastbee-pay/fastbee-pay-api/pom.xml
Normal file
38
fastbee-pay/fastbee-pay-api/pom.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.fastbee.pay</groupId>
|
||||
<artifactId>fastbee-pay</artifactId>
|
||||
<version>3.8.5</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.fastbee.pay.api</groupId>
|
||||
<artifactId>fastbee-pay-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.fastbee</groupId>-->
|
||||
<!-- <artifactId>fastbee-common</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.projectlombok</groupId>-->
|
||||
<!-- <artifactId>lombok</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.fastbee.pay.framework</groupId>
|
||||
<artifactId>fastbee-pay-framework</artifactId>
|
||||
<version>3.8.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,34 @@
|
||||
package com.fastbee.pay.api.api.notify.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 支付单的通知 Request DTO
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PayOrderNotifyReqDTO {
|
||||
|
||||
/**
|
||||
* 商户订单编号
|
||||
*/
|
||||
@NotEmpty(message = "商户订单号不能为空")
|
||||
private String merchantOrderId;
|
||||
|
||||
/**
|
||||
* 支付订单编号
|
||||
*/
|
||||
@NotNull(message = "支付订单编号不能为空")
|
||||
private Long payOrderId;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.fastbee.pay.api.api.notify.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 退款单的通知 Request DTO
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PayRefundNotifyReqDTO {
|
||||
|
||||
/**
|
||||
* 商户退款单编号
|
||||
*/
|
||||
@NotEmpty(message = "商户退款单编号不能为空")
|
||||
private String merchantOrderId;
|
||||
|
||||
/**
|
||||
* 支付退款编号
|
||||
*/
|
||||
@NotNull(message = "支付退款编号不能为空")
|
||||
private Long payRefundId;
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位符,无特殊作用
|
||||
*/
|
||||
package com.fastbee.pay.api.api.notify;
|
@ -0,0 +1,32 @@
|
||||
package com.fastbee.pay.api.api.order;
|
||||
|
||||
import com.fastbee.pay.api.api.order.dto.PayOrderCreateReqDTO;
|
||||
import com.fastbee.pay.api.api.order.dto.PayOrderRespDTO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 支付单 API 接口
|
||||
*
|
||||
* @author LeeYan9
|
||||
* @since 2022-08-26
|
||||
*/
|
||||
public interface PayOrderApi {
|
||||
|
||||
/**
|
||||
* 创建支付单
|
||||
*
|
||||
* @param reqDTO 创建请求
|
||||
* @return 支付单编号
|
||||
*/
|
||||
Long createOrder(@Valid PayOrderCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 获得支付单
|
||||
*
|
||||
* @param id 支付单编号
|
||||
* @return 支付单
|
||||
*/
|
||||
PayOrderRespDTO getOrder(Long id);
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.fastbee.pay.api.api.order.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;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 支付单创建 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayOrderCreateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
@NotNull(message = "应用编号不能为空")
|
||||
private Long appId;
|
||||
/**
|
||||
* 用户 IP
|
||||
*/
|
||||
@NotEmpty(message = "用户 IP 不能为空")
|
||||
private String userIp;
|
||||
|
||||
// ========== 商户相关字段 ==========
|
||||
|
||||
/**
|
||||
* 商户订单编号
|
||||
*/
|
||||
@NotEmpty(message = "商户订单编号不能为空")
|
||||
private String merchantOrderId;
|
||||
/**
|
||||
* 商品标题
|
||||
*/
|
||||
@NotEmpty(message = "商品标题不能为空")
|
||||
@Length(max = 32, message = "商品标题不能超过 32")
|
||||
private String subject;
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
@Length(max = 128, message = "商品描述信息长度不能超过128")
|
||||
private String body;
|
||||
|
||||
// ========== 订单相关字段 ==========
|
||||
|
||||
/**
|
||||
* 支付金额,单位:分
|
||||
*/
|
||||
@NotNull(message = "支付金额不能为空")
|
||||
@DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零")
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 支付过期时间
|
||||
*/
|
||||
@NotNull(message = "支付过期时间不能为空")
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.fastbee.pay.api.api.order.dto;
|
||||
|
||||
import com.fastbee.pay.api.enums.order.PayOrderStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 支付单信息 Response DTO
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Data
|
||||
public class PayOrderRespDTO {
|
||||
|
||||
/**
|
||||
* 订单编号,数据库自增
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 渠道编码
|
||||
* 枚举 PayChannelEnum
|
||||
*/
|
||||
private String channelCode;
|
||||
|
||||
// ========== 商户相关字段 ==========
|
||||
/**
|
||||
* 商户订单编号
|
||||
* 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一
|
||||
*/
|
||||
private String merchantOrderId;
|
||||
|
||||
// ========== 订单相关字段 ==========
|
||||
/**
|
||||
* 支付金额,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 支付状态
|
||||
* 枚举 {@link PayOrderStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
// ========== 渠道相关字段 ==========
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.fastbee.pay.api.api.refund;
|
||||
|
||||
import com.fastbee.pay.api.api.refund.dto.PayRefundCreateReqDTO;
|
||||
import com.fastbee.pay.api.api.refund.dto.PayRefundRespDTO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 退款单 API 接口
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
public interface PayRefundApi {
|
||||
|
||||
/**
|
||||
* 创建退款单
|
||||
*
|
||||
* @param reqDTO 创建请求
|
||||
* @return 退款单编号
|
||||
*/
|
||||
Long createRefund(@Valid PayRefundCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 获得退款单
|
||||
*
|
||||
* @param id 退款单编号
|
||||
* @return 退款单
|
||||
*/
|
||||
PayRefundRespDTO getRefund(Long id);
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.fastbee.pay.api.api.refund.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 退款单创建 Request DTO
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayRefundCreateReqDTO {
|
||||
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
@NotNull(message = "应用编号不能为空")
|
||||
private Long appId;
|
||||
/**
|
||||
* 用户 IP
|
||||
*/
|
||||
@NotEmpty(message = "用户 IP 不能为空")
|
||||
private String userIp;
|
||||
|
||||
// ========== 商户相关字段 ==========
|
||||
/**
|
||||
* 商户订单编号
|
||||
*/
|
||||
@NotEmpty(message = "商户订单编号不能为空")
|
||||
private String merchantOrderId;
|
||||
|
||||
/**
|
||||
* 商户退款编号
|
||||
*/
|
||||
@NotEmpty(message = "商户退款编号不能为空")
|
||||
private String merchantRefundId;
|
||||
|
||||
/**
|
||||
* 退款描述
|
||||
*/
|
||||
@NotEmpty(message = "退款描述不能为空")
|
||||
@Length(max = 128, message = "退款描述长度不能超过 128")
|
||||
private String reason;
|
||||
|
||||
// ========== 订单相关字段 ==========
|
||||
|
||||
/**
|
||||
* 退款金额,单位:分
|
||||
*/
|
||||
@NotNull(message = "退款金额不能为空")
|
||||
@Min(value = 1, message = "退款金额必须大于零")
|
||||
private Integer price;
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.fastbee.pay.api.api.refund.dto;
|
||||
|
||||
import com.fastbee.pay.api.enums.refund.PayRefundStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 退款单信息 Response DTO
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Data
|
||||
public class PayRefundRespDTO {
|
||||
|
||||
/**
|
||||
* 退款单编号
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
// ========== 退款相关字段 ==========
|
||||
/**
|
||||
* 退款状态
|
||||
* 枚举 {@link PayRefundStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 退款金额,单位:分
|
||||
*/
|
||||
private Integer refundPrice;
|
||||
|
||||
// ========== 商户相关字段 ==========
|
||||
/**
|
||||
* 商户订单编号
|
||||
*/
|
||||
private String merchantOrderId;
|
||||
/**
|
||||
* 退款成功时间
|
||||
*/
|
||||
private LocalDateTime successTime;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.fastbee.pay.api.enums;
|
||||
|
||||
/**
|
||||
* Pay 字典类型的枚举类
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
public interface DictTypeConstants {
|
||||
|
||||
String CHANNEL_CODE = "pay_channel_code"; // 支付渠道编码
|
||||
|
||||
String ORDER_STATUS = "pay_order_status"; // 支付渠道
|
||||
|
||||
String REFUND_STATUS = "pay_order_status"; // 退款状态
|
||||
|
||||
String NOTIFY_STATUS = "pay_notify_status"; // 回调状态
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.fastbee.pay.api.enums;
|
||||
|
||||
import com.fastbee.common.exception.ErrorCode;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Pay 错误码 Core 枚举类
|
||||
* pay 系统,使用 1-007-000-000 段
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
|
||||
// ========== APP 模块 1007000000 ==========
|
||||
ErrorCode APP_NOT_FOUND = new ErrorCode(1007000000, MessageUtils.message("app.not.found"));
|
||||
ErrorCode APP_IS_DISABLE = new ErrorCode(1007000002, MessageUtils.message("app.is.disable"));
|
||||
ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1007000003, MessageUtils.message("app.exist.order.cant.delete"));
|
||||
ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1007000004, MessageUtils.message("app.exist.refund.cant.delete"));
|
||||
|
||||
// ========== CHANNEL 模块 1007001000 ==========
|
||||
ErrorCode CHANNEL_NOT_FOUND = new ErrorCode(1007001000, MessageUtils.message("channel.not.found"));
|
||||
ErrorCode CHANNEL_IS_DISABLE = new ErrorCode(1007001001, MessageUtils.message("channel.is.disable"));
|
||||
ErrorCode CHANNEL_EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1007001004, MessageUtils.message("channel.exists.same.channel.error"));
|
||||
|
||||
// ========== ORDER 模块 1007002000 ==========
|
||||
ErrorCode ORDER_NOT_FOUND = new ErrorCode(1007002000, MessageUtils.message("order.not.found"));
|
||||
ErrorCode ORDER_STATUS_IS_NOT_WAITING = new ErrorCode(1007002001, MessageUtils.message("order.status.is.not.waiting"));
|
||||
ErrorCode ORDER_STATUS_IS_SUCCESS = new ErrorCode(1007002002, MessageUtils.message("order.status.is.success"));
|
||||
ErrorCode ORDER_IS_EXPIRED = new ErrorCode(1007002003, MessageUtils.message("order.is.expired"));
|
||||
ErrorCode ORDER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1007002004, MessageUtils.message("order.submit.channel.error"));
|
||||
ErrorCode ORDER_REFUND_FAIL_STATUS_ERROR = new ErrorCode(1007002005, MessageUtils.message("order.refund.fail.status.error"));
|
||||
|
||||
// ========== ORDER 模块(拓展单) 1007003000 ==========
|
||||
ErrorCode ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1007003000, MessageUtils.message("order.extension.not.found"));
|
||||
ErrorCode ORDER_EXTENSION_STATUS_IS_NOT_WAITING = new ErrorCode(1007003001, MessageUtils.message("order.extension.status.is.not.waiting"));
|
||||
ErrorCode ORDER_EXTENSION_IS_PAID = new ErrorCode(1007003002, MessageUtils.message("order.extension.is.paid"));
|
||||
|
||||
// ========== 支付模块(退款) 1007006000 ==========
|
||||
ErrorCode REFUND_PRICE_EXCEED = new ErrorCode(1007006000, MessageUtils.message("refund.price.exceed"));
|
||||
ErrorCode REFUND_HAS_REFUNDING = new ErrorCode(1007006002, MessageUtils.message("refund.has.refunding"));
|
||||
ErrorCode REFUND_EXISTS = new ErrorCode(1007006003, MessageUtils.message("refund.exists"));
|
||||
ErrorCode REFUND_NOT_FOUND = new ErrorCode(1007006004, MessageUtils.message("refund.not.found"));
|
||||
ErrorCode REFUND_STATUS_IS_NOT_WAITING = new ErrorCode(1007006005, MessageUtils.message("refund.statue.is.not.waiting"));
|
||||
|
||||
// ========== 示例订单 1007900000 ==========
|
||||
ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1007900000, MessageUtils.message("demo.order.not.found"));
|
||||
ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007900001, MessageUtils.message("demo.order.update.paid.status.not.unpaid"));
|
||||
ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1007900002, MessageUtils.message("demo.order.update.paid.fail.pay.order.id.error"));
|
||||
ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1007900003, MessageUtils.message("demo.order.update.paid.fail.pay.order.status.not.success"));
|
||||
ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1007900004, MessageUtils.message("demo.order.update.paid.fail.pay.price.not.match"));
|
||||
ErrorCode DEMO_ORDER_REFUND_FAIL_NOT_PAID = new ErrorCode(1007900005, MessageUtils.message("demo.order.refund.fail.not.paid"));
|
||||
ErrorCode DEMO_ORDER_REFUND_FAIL_REFUNDED = new ErrorCode(1007900006, MessageUtils.message("demo.order.refund.fail.refunded"));
|
||||
ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1007900007, MessageUtils.message("demo.order.refund.fail.refund.not.found"));
|
||||
ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_SUCCESS = new ErrorCode(1007900008, MessageUtils.message("demo.order.refund.fail.refund.not.success"));
|
||||
ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1007900009, MessageUtils.message("demo.order.refund.fail.refund.order.id.error"));
|
||||
ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1007900010, MessageUtils.message("demo.order.refund.fail.refund.price.not.match"));
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.fastbee.pay.api.enums.member;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 钱包操作类型枚举
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum WalletOperateTypeEnum {
|
||||
TOP_UP_INC(1, "充值增加"),
|
||||
ORDER_DEC(2, "订单消费扣除");
|
||||
// TODO 其它类型
|
||||
|
||||
private final Integer type;
|
||||
|
||||
private final String desc;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.fastbee.pay.api.enums.member;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 钱包交易大类枚举
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum WalletTransactionGategoryEnum {
|
||||
TOP_UP(1, "充值"),
|
||||
SPENDING(2, "支出");
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private final Integer category;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private final String desc;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.fastbee.pay.api.enums.notify;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 支付通知状态枚举
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayNotifyStatusEnum {
|
||||
|
||||
WAITING(0, "等待通知"),
|
||||
SUCCESS(10, "通知成功"),
|
||||
FAILURE(20, "通知失败"), // 多次尝试,彻底失败
|
||||
REQUEST_SUCCESS(21, "请求成功,但是结果失败"),
|
||||
REQUEST_FAILURE(22, "请求失败"),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.fastbee.pay.api.enums.notify;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 支付通知类型
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayNotifyTypeEnum {
|
||||
|
||||
ORDER(1, "支付单"),
|
||||
REFUND(2, "退款单"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final Integer type;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.fastbee.pay.api.enums.order;
|
||||
|
||||
import com.fastbee.common.core.text.IntArrayValuable;
|
||||
import com.fastbee.common.utils.object.ObjectUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 支付订单的状态枚举
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayOrderStatusEnum implements IntArrayValuable {
|
||||
|
||||
WAITING(0, "未支付"),
|
||||
SUCCESS(10, "支付成功"),
|
||||
REFUND(20, "已退款"),
|
||||
CLOSED(30, "支付关闭"), // 注意:全部退款后,还是 REFUND 状态
|
||||
;
|
||||
|
||||
private final Integer status;
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否支付成功
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 是否支付成功
|
||||
*/
|
||||
public static boolean isSuccess(Integer status) {
|
||||
return Objects.equals(status, SUCCESS.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否支付成功或者已退款
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 是否支付成功或者已退款
|
||||
*/
|
||||
public static boolean isSuccessOrRefund(Integer status) {
|
||||
return ObjectUtils.equalsAny(status,
|
||||
SUCCESS.getStatus(), REFUND.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否支付关闭
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 是否支付关闭
|
||||
*/
|
||||
public static boolean isClosed(Integer status) {
|
||||
return Objects.equals(status, CLOSED.getStatus());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.fastbee.pay.api.enums.refund;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 渠道的退款状态枚举
|
||||
*
|
||||
* @author fastbee
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayRefundStatusEnum {
|
||||
|
||||
WAITING(0, "未退款"),
|
||||
SUCCESS(10, "退款成功"),
|
||||
FAILURE(20, "退款失败");
|
||||
|
||||
private final Integer status;
|
||||
private final String name;
|
||||
|
||||
public static boolean isSuccess(Integer status) {
|
||||
return Objects.equals(status, SUCCESS.getStatus());
|
||||
}
|
||||
|
||||
public static boolean isFailure(Integer status) {
|
||||
return Objects.equals(status, FAILURE.getStatus());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user