New file |
| | |
| | | package com.ruoyi.order.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | public enum OrderStatus { |
| | | /** |
| | | * 1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价 |
| | | */ |
| | | PENDING_SHIPMENT(1, "待发货"), |
| | | PENDING_RECEIPT(2, "待收货"), |
| | | PENDING_USE(3, "待使用"), |
| | | COMPLETED(4, "已完成"), |
| | | CANCELLED(5, "已取消"), |
| | | REFUNDED(6, "已退款"), |
| | | AFTER_SALE(7, "售后中"), |
| | | RATED(8, "已评价"); |
| | | |
| | | private final int code; |
| | | private final String description; |
| | | |
| | | OrderStatus(int code, String description) { |
| | | this.code = code; |
| | | this.description = description; |
| | | } |
| | | |
| | | // 根据代码获取对应的OrderStatus |
| | | public static OrderStatus fromCode(int code) { |
| | | for (OrderStatus status : values()) { |
| | | if (status.getCode() == code) { |
| | | return status; |
| | | } |
| | | } |
| | | throw new IllegalArgumentException("Unknown order status code: " + code); |
| | | } |
| | | } |