You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.0 KiB
85 lines
3.0 KiB
|
1 week ago
|
package common.ecommerce.edayun.enums;
|
||
|
|
|
||
|
|
import common.ecommerce.warehouse.enums.CancelEligibility;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 易达云取消资格({@code checkCancelStatus} 的 {@code data})。
|
||
|
|
*
|
||
|
|
* <p>文档口径:</p>
|
||
|
|
* <ul>
|
||
|
|
* <li>{@code Published} —— 可以直接取消,<b>不收费</b></li>
|
||
|
|
* <li>{@code Shipment} —— 可以取消,<b>收费</b></li>
|
||
|
|
* <li>{@code UnableCancel} —— 无法取消(状态不允许)</li>
|
||
|
|
* <li>{@code Cancelled} —— 已取消(无需再取消)</li>
|
||
|
|
* <li>拦截类三态 —— 取消动作已在进行中或已完成</li>
|
||
|
|
* </ul>
|
||
|
|
*
|
||
|
|
* <p><b>注意文档笔误</b>:响应说明里 `InterceptSuccess` 出现了两次
|
||
|
|
* (一次是「拦截取消成功」、一次是「拦截取消失败」)。这里按
|
||
|
|
* {@code InterceptFailure} 处理失败——与订单状态字典的命名一致。</p>
|
||
|
|
*/
|
||
|
|
public enum EdayunCancelStatus {
|
||
|
|
|
||
|
|
/** 可以直接取消(不收费)。 */
|
||
|
|
PUBLISHED("Published", CancelEligibility.FREE),
|
||
|
|
/** 可以取消(收费)。 */
|
||
|
|
SHIPMENT("Shipment", CancelEligibility.CHARGED),
|
||
|
|
/** 已取消;再取消没有意义,按不可取消处理。 */
|
||
|
|
CANCELLED("Cancelled", CancelEligibility.BLOCKED),
|
||
|
|
/** 拦截取消中。 */
|
||
|
|
INTERCEPT_PROCESSING("InterceptProcessing", CancelEligibility.BLOCKED),
|
||
|
|
/** 拦截取消成功;同「已取消」。 */
|
||
|
|
INTERCEPT_SUCCESS("InterceptSuccess", CancelEligibility.BLOCKED),
|
||
|
|
/** 拦截取消失败(文档误写成两个 InterceptSuccess)。 */
|
||
|
|
INTERCEPT_FAILURE("InterceptFailure", CancelEligibility.BLOCKED),
|
||
|
|
/** 无法取消(订单状态不允许)。 */
|
||
|
|
UNABLE_CANCEL("UnableCancel", CancelEligibility.BLOCKED),
|
||
|
|
/** 无法识别。 */
|
||
|
|
UNKNOWN(null, CancelEligibility.BLOCKED);
|
||
|
|
|
||
|
|
private final String rawValue;
|
||
|
|
private final CancelEligibility core;
|
||
|
|
|
||
|
|
EdayunCancelStatus(String rawValue, CancelEligibility core) {
|
||
|
|
this.rawValue = rawValue;
|
||
|
|
this.core = core;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 易达云原值;null 表示无法识别。 */
|
||
|
|
public String rawValue() {
|
||
|
|
return rawValue;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 对应的底层资格。 */
|
||
|
|
public CancelEligibility toCore() {
|
||
|
|
return core;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 易达云原值 → 平台枚举。
|
||
|
|
*
|
||
|
|
* <p><b>未知一律归 BLOCKED</b>:取消是有代价的操作(可能收费、且不可逆),
|
||
|
|
* 认不出时宁可拒绝也不能贸然放行。</p>
|
||
|
|
*/
|
||
|
|
public static EdayunCancelStatus of(String rawStatus) {
|
||
|
|
if (rawStatus == null) {
|
||
|
|
return UNKNOWN;
|
||
|
|
}
|
||
|
|
String s = rawStatus.trim();
|
||
|
|
if (s.isEmpty()) {
|
||
|
|
return UNKNOWN;
|
||
|
|
}
|
||
|
|
for (EdayunCancelStatus v : values()) {
|
||
|
|
if (v.rawValue != null && s.equalsIgnoreCase(v.rawValue)) {
|
||
|
|
return v;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return UNKNOWN;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 易达云原值 → 底层资格。 */
|
||
|
|
public static CancelEligibility toCore(String rawStatus) {
|
||
|
|
return of(rawStatus).toCore();
|
||
|
|
}
|
||
|
|
}
|