Browse Source
沿用feature/supplier-lingxinga8dfb08的两层结构(core 底层枚举 + 平台枚举 toCore),补上信仓侧: 新增 xincang.enums: - XincangOrderStatus 订单 state 0/1/2/3/4/5/6/7/8/10/11/12 → OutboundStatus - XincangTransferState 转运 state 0~7 → TransferStatus - XincangForecastStatus 预报 state 0~9 → InboundStatus(信仓预报即头程入库单) - XincangOrderType order_type common/wayfair,不映射 core: core 已有 LabelMode 表达同一语义,但信仓按渠道平台判定,不做枚举级归一 core 枚举按「只增不改」处理,避免影响其他仓: - OutboundStatus 追加 8 个值(code 100~170,rank 9~16) - TransferStatus 追加 5 个值(code 170~210) - 既有常量的 code / rank / 方法体一律未动 顺带修两处: - XincangTransferMapper 补 sourceProvider(XINCANG),符合a8dfb08的 「rawStatus 必须与 sourceProvider 成对落库」契约 - rawStatus 改从枚举 rawCode() 取,不再手写 "0" 转运列表与详情的 state 码表不一致(列表少「待贴标」且后续前移), 以更完整的详情码表为准,类注释里写明冲突与调整方式。 Co-Authored-By: Claude Code <noreply@anthropic.com>
10 changed files with 434 additions and 13 deletions
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
package common.ecommerce.xincang.enums; |
||||
|
||||
import common.ecommerce.warehouse.enums.InboundStatus; |
||||
|
||||
/** |
||||
* 信仓预报(头程入库)状态({@code forecast.forecast_detail} 的 {@code state})。 |
||||
* |
||||
* <p>码表来自 Apifox「OMS接口文档V2」预报详情: |
||||
* 0 建仓中 / 1 出运中 / 2 预报完成 / 3 在海上 / 4 送仓中 / 5 卸柜中 / |
||||
* 6 清点中 / 7 上架中 / 8 上架完成 / 9 已驳回。</p> |
||||
* |
||||
* <p>信仓没有独立的「入库单」接口,预报单即头程入库单,这里映射到统一的 |
||||
* {@link InboundStatus}。映射口径:</p> |
||||
* <ul> |
||||
* <li>0 建仓中 → 草稿(尚未提交)</li> |
||||
* <li>1 出运中 / 3 在海上 → 在途</li> |
||||
* <li>2 预报完成 → 待发货(预报已确认,等待实际发运)</li> |
||||
* <li>6 清点中 → 收货中;7 上架中 → 上架中;8 上架完成 → 已完成</li> |
||||
* </ul> |
||||
* |
||||
* <p>未知码归 {@link #UNKNOWN},不猜。</p> |
||||
*/ |
||||
public enum XincangForecastStatus { |
||||
|
||||
/** 0 建仓中。 */ |
||||
BUILDING("0", InboundStatus.DRAFT), |
||||
/** 1 出运中。 */ |
||||
SHIPPING("1", InboundStatus.IN_TRANSIT), |
||||
/** 2 预报完成。 */ |
||||
FORECAST_DONE("2", InboundStatus.PENDING_SHIPMENT), |
||||
/** 3 在海上。 */ |
||||
ON_SEA("3", InboundStatus.IN_TRANSIT), |
||||
/** 4 送仓中。 */ |
||||
DELIVERING("4", InboundStatus.IN_TRANSIT), |
||||
/** 5 卸柜中。 */ |
||||
UNLOADING("5", InboundStatus.RECEIVING), |
||||
/** 6 清点中。 */ |
||||
COUNTING("6", InboundStatus.RECEIVING), |
||||
/** 7 上架中。 */ |
||||
SHELVING("7", InboundStatus.STORING), |
||||
/** 8 上架完成。 */ |
||||
SHELVED("8", InboundStatus.COMPLETED), |
||||
/** 9 已驳回。 */ |
||||
REJECTED("9", InboundStatus.REJECTED), |
||||
/** 无法识别。 */ |
||||
UNKNOWN(null, InboundStatus.UNKNOWN); |
||||
|
||||
private final String rawCode; |
||||
private final InboundStatus core; |
||||
|
||||
XincangForecastStatus(String rawCode, InboundStatus core) { |
||||
this.rawCode = rawCode; |
||||
this.core = core; |
||||
} |
||||
|
||||
/** 信仓状态码;null 表示无法识别。 */ |
||||
public String rawCode() { |
||||
return rawCode; |
||||
} |
||||
|
||||
/** 对应的底层状态。 */ |
||||
public InboundStatus toCore() { |
||||
return core; |
||||
} |
||||
|
||||
/** 信仓状态码 → 平台枚举。 */ |
||||
public static XincangForecastStatus of(String rawStatus) { |
||||
if (rawStatus == null || rawStatus.trim().isEmpty()) { |
||||
return UNKNOWN; |
||||
} |
||||
String s = rawStatus.trim(); |
||||
for (XincangForecastStatus v : values()) { |
||||
if (s.equals(v.rawCode)) { |
||||
return v; |
||||
} |
||||
} |
||||
return UNKNOWN; |
||||
} |
||||
|
||||
/** 信仓状态码 → 底层状态。 */ |
||||
public static InboundStatus toCore(String rawStatus) { |
||||
return of(rawStatus).toCore(); |
||||
} |
||||
} |
||||
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
package common.ecommerce.xincang.enums; |
||||
|
||||
import common.ecommerce.warehouse.enums.OutboundStatus; |
||||
|
||||
/** |
||||
* 信仓出库订单状态(订单列表 / 详情 / 删除接口的 {@code state})。 |
||||
* |
||||
* <p>码表来自 Apifox「OMS接口文档V2」订单详情: |
||||
* 0 待审核 / 1 待发货 / 2 拣货中 / 3 已拣货 / 4 已贴单 / 5 已发货 / |
||||
* 6 已拦截 / 7 缺货 / 8 已取消 / 10 已删除 / 11 审核中 / 12 审核失败。</p> |
||||
* |
||||
* <p>未知码归 {@link #UNKNOWN},<b>不猜</b>;原始值由调用方一起保存 |
||||
* ({@code rawStatus} + {@code sourceProvider})。</p> |
||||
*/ |
||||
public enum XincangOrderStatus { |
||||
|
||||
/** 0 待审核。 */ |
||||
PENDING_REVIEW("0", OutboundStatus.PENDING_REVIEW), |
||||
/** 1 待发货。 */ |
||||
PENDING_SHIPMENT("1", OutboundStatus.PENDING_SHIPMENT), |
||||
/** 2 拣货中。 */ |
||||
PICKING("2", OutboundStatus.PICKING), |
||||
/** 3 已拣货。 */ |
||||
PICKED("3", OutboundStatus.PICKED), |
||||
/** 4 已贴单(面单已出)。 */ |
||||
LABEL_READY("4", OutboundStatus.LABEL_READY), |
||||
/** 5 已发货。 */ |
||||
SHIPPED("5", OutboundStatus.SHIPPED), |
||||
/** 6 已拦截。 */ |
||||
INTERCEPTED("6", OutboundStatus.INTERCEPTED), |
||||
/** 7 缺货。 */ |
||||
OUT_OF_STOCK("7", OutboundStatus.OUT_OF_STOCK), |
||||
/** 8 已取消。 */ |
||||
CANCELLED("8", OutboundStatus.CANCELLED), |
||||
/** 10 已删除。 */ |
||||
DELETED("10", OutboundStatus.DELETED), |
||||
/** 11 审核中。 */ |
||||
REVIEWING("11", OutboundStatus.REVIEWING), |
||||
/** 12 审核失败。 */ |
||||
REVIEW_FAILED("12", OutboundStatus.REVIEW_FAILED), |
||||
/** 无法识别。 */ |
||||
UNKNOWN(null, OutboundStatus.UNKNOWN); |
||||
|
||||
private final String rawCode; |
||||
private final OutboundStatus core; |
||||
|
||||
XincangOrderStatus(String rawCode, OutboundStatus core) { |
||||
this.rawCode = rawCode; |
||||
this.core = core; |
||||
} |
||||
|
||||
/** 信仓状态码;null 表示无法识别。 */ |
||||
public String rawCode() { |
||||
return rawCode; |
||||
} |
||||
|
||||
/** 对应的底层状态。 */ |
||||
public OutboundStatus toCore() { |
||||
return core; |
||||
} |
||||
|
||||
/** 信仓状态码 → 平台枚举。 */ |
||||
public static XincangOrderStatus of(String rawStatus) { |
||||
if (rawStatus == null || rawStatus.trim().isEmpty()) { |
||||
return UNKNOWN; |
||||
} |
||||
String s = rawStatus.trim(); |
||||
for (XincangOrderStatus v : values()) { |
||||
if (s.equals(v.rawCode)) { |
||||
return v; |
||||
} |
||||
} |
||||
return UNKNOWN; |
||||
} |
||||
|
||||
/** 信仓状态码 → 底层状态。 */ |
||||
public static OutboundStatus toCore(String rawStatus) { |
||||
return of(rawStatus).toCore(); |
||||
} |
||||
|
||||
/** 底层状态 → 信仓状态码;无对应时返回 null(调用方决定是否拒绝)。 */ |
||||
public static String codeOf(OutboundStatus status) { |
||||
if (status == null) { |
||||
return null; |
||||
} |
||||
for (XincangOrderStatus v : values()) { |
||||
if (v.core == status) { |
||||
return v.rawCode; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
package common.ecommerce.xincang.enums; |
||||
|
||||
/** |
||||
* 信仓下单的订单类型({@code api.add_order_multiple} 的 {@code order_type})。 |
||||
* |
||||
* <p>信仓只接受两个值:{@code common}(非自供面单)与 {@code wayfair}(自供面单)。</p> |
||||
* |
||||
* <p><b>只在这里出现,不映射到 core</b>:这是「由谁提供面单」的仓方协议开关, |
||||
* core 已有 {@code LabelMode} 表达同一业务语义(仓出单 / 平台面单)。 |
||||
* 两者的判定口径不同——core 看 {@code LabelMode},信仓看渠道平台是不是 Wayfair—— |
||||
* 所以由适配器按自己的规则选择,不做枚举级映射,也不把仓方字符串塞进 core。</p> |
||||
*/ |
||||
public enum XincangOrderType { |
||||
|
||||
/** 非自供面单(默认)。 */ |
||||
COMMON("common"), |
||||
/** 自供面单;{@code gzh} 与 {@code face_base64} 必填。 */ |
||||
WAYFAIR("wayfair"); |
||||
|
||||
private final String rawCode; |
||||
|
||||
XincangOrderType(String rawCode) { |
||||
this.rawCode = rawCode; |
||||
} |
||||
|
||||
/** 信仓原值。 */ |
||||
public String rawCode() { |
||||
return rawCode; |
||||
} |
||||
|
||||
/** 是否需要随单提供跟踪号与面单文件。 */ |
||||
public boolean requiresSelfLabel() { |
||||
return this == WAYFAIR; |
||||
} |
||||
|
||||
/** 信仓原值 → 平台枚举;未知返回 null(调用方按错误处理)。 */ |
||||
public static XincangOrderType of(String rawCode) { |
||||
if (rawCode == null) { |
||||
return null; |
||||
} |
||||
String s = rawCode.trim(); |
||||
for (XincangOrderType v : values()) { |
||||
if (v.rawCode.equals(s)) { |
||||
return v; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
package common.ecommerce.xincang.enums; |
||||
|
||||
import common.ecommerce.warehouse.enums.TransferStatus; |
||||
|
||||
/** |
||||
* 信仓转运单状态({@code fba.fbalist} / {@code fba.fba_detail} 的 {@code state})。 |
||||
* |
||||
* <p>码表来自 Apifox「OMS接口文档V2」转运详情: |
||||
* 0 待审核 / 1 待处理 / 2 待拣货 / 3 待贴标 / 4 待打托 / 5 待发货 / 6 已发货 / 7 已取消。</p> |
||||
* |
||||
* <p><b>列表接口与详情接口的码表不一致</b>:列表的 {@code state} 说明里写的是 |
||||
* 「0 待审核 1 待处理 2 带拣货 3 待打托 4 待发货 5 已发货 9 取消」(少了「待贴标」、 |
||||
* 后续码值整体前移)。详情接口的码表与 {@code state_name} 说明更完整,这里以<b>详情码表</b> |
||||
* 为准;联调时如果列表返回的 {@code state} 对不上,原始值仍在 {@code rawStatus} 里, |
||||
* 只需调整本枚举,不动调用方。</p> |
||||
*/ |
||||
public enum XincangTransferState { |
||||
|
||||
/** 0 待审核。 */ |
||||
PENDING_REVIEW("0", TransferStatus.PENDING_REVIEW), |
||||
/** 1 待处理。 */ |
||||
PENDING_PROCESSING("1", TransferStatus.PENDING_PROCESSING), |
||||
/** 2 待拣货。 */ |
||||
PENDING_PICK("2", TransferStatus.PENDING_PICK), |
||||
/** 3 待贴标。 */ |
||||
PENDING_LABELING("3", TransferStatus.PENDING_LABELING), |
||||
/** 4 待打托。 */ |
||||
PENDING_PALLETIZING("4", TransferStatus.PENDING_PALLETIZING), |
||||
/** 5 待发货。 */ |
||||
PENDING_OUTBOUND("5", TransferStatus.PENDING_OUTBOUND), |
||||
/** 6 已发货。 */ |
||||
SHIPPED("6", TransferStatus.SHIPPED), |
||||
/** 7 已取消。 */ |
||||
CANCELLED("7", TransferStatus.CANCELLED), |
||||
/** 无法识别。 */ |
||||
UNKNOWN(null, TransferStatus.UNKNOWN); |
||||
|
||||
private final String rawCode; |
||||
private final TransferStatus core; |
||||
|
||||
XincangTransferState(String rawCode, TransferStatus core) { |
||||
this.rawCode = rawCode; |
||||
this.core = core; |
||||
} |
||||
|
||||
/** 信仓状态码;null 表示无法识别。 */ |
||||
public String rawCode() { |
||||
return rawCode; |
||||
} |
||||
|
||||
/** 对应的底层状态。 */ |
||||
public TransferStatus toCore() { |
||||
return core; |
||||
} |
||||
|
||||
/** 信仓状态码 → 平台枚举。 */ |
||||
public static XincangTransferState of(String rawStatus) { |
||||
if (rawStatus == null || rawStatus.trim().isEmpty()) { |
||||
return UNKNOWN; |
||||
} |
||||
String s = rawStatus.trim(); |
||||
for (XincangTransferState v : values()) { |
||||
if (s.equals(v.rawCode)) { |
||||
return v; |
||||
} |
||||
} |
||||
return UNKNOWN; |
||||
} |
||||
|
||||
/** 信仓状态码 → 底层状态。 */ |
||||
public static TransferStatus toCore(String rawStatus) { |
||||
return of(rawStatus).toCore(); |
||||
} |
||||
|
||||
/** 底层状态 → 信仓状态码;无对应时返回 null。 */ |
||||
public static String codeOf(TransferStatus status) { |
||||
if (status == null) { |
||||
return null; |
||||
} |
||||
for (XincangTransferState v : values()) { |
||||
if (v.core == status) { |
||||
return v.rawCode; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
package common.ecommerce.xincang.enums; |
||||
|
||||
import common.ecommerce.warehouse.enums.InboundStatus; |
||||
import common.ecommerce.warehouse.enums.OutboundStatus; |
||||
import common.ecommerce.warehouse.enums.TransferStatus; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.*; |
||||
|
||||
/** |
||||
* 信仓平台枚举 → core 底层枚举的映射。 |
||||
* |
||||
* <p>码表来自 Apifox「OMS接口文档V2」,1:1 对应;认不出的值一律归 UNKNOWN,不猜。</p> |
||||
*/ |
||||
class XincangEnumsTest { |
||||
|
||||
@Test |
||||
void orderStatusMapsEveryDocumentedCode() { |
||||
assertEquals(OutboundStatus.PENDING_REVIEW, XincangOrderStatus.toCore("0")); |
||||
assertEquals(OutboundStatus.PENDING_SHIPMENT, XincangOrderStatus.toCore("1")); |
||||
assertEquals(OutboundStatus.PICKING, XincangOrderStatus.toCore("2")); |
||||
assertEquals(OutboundStatus.PICKED, XincangOrderStatus.toCore("3")); |
||||
assertEquals(OutboundStatus.LABEL_READY, XincangOrderStatus.toCore("4")); |
||||
assertEquals(OutboundStatus.SHIPPED, XincangOrderStatus.toCore("5")); |
||||
assertEquals(OutboundStatus.INTERCEPTED, XincangOrderStatus.toCore("6")); |
||||
assertEquals(OutboundStatus.OUT_OF_STOCK, XincangOrderStatus.toCore("7")); |
||||
assertEquals(OutboundStatus.CANCELLED, XincangOrderStatus.toCore("8")); |
||||
assertEquals(OutboundStatus.DELETED, XincangOrderStatus.toCore("10")); |
||||
assertEquals(OutboundStatus.REVIEWING, XincangOrderStatus.toCore("11")); |
||||
assertEquals(OutboundStatus.REVIEW_FAILED, XincangOrderStatus.toCore("12")); |
||||
} |
||||
|
||||
@Test |
||||
void unknownOrderStatusIsNotGuessed() { |
||||
assertEquals(OutboundStatus.UNKNOWN, XincangOrderStatus.toCore("99")); |
||||
assertEquals(OutboundStatus.UNKNOWN, XincangOrderStatus.toCore("")); |
||||
assertEquals(OutboundStatus.UNKNOWN, XincangOrderStatus.toCore(null)); |
||||
} |
||||
|
||||
@Test |
||||
void transferStateMapsEveryDocumentedCode() { |
||||
assertEquals(TransferStatus.PENDING_REVIEW, XincangTransferState.toCore("0")); |
||||
assertEquals(TransferStatus.PENDING_PROCESSING, XincangTransferState.toCore("1")); |
||||
assertEquals(TransferStatus.PENDING_PICK, XincangTransferState.toCore("2")); |
||||
assertEquals(TransferStatus.PENDING_LABELING, XincangTransferState.toCore("3")); |
||||
assertEquals(TransferStatus.PENDING_PALLETIZING, XincangTransferState.toCore("4")); |
||||
assertEquals(TransferStatus.PENDING_OUTBOUND, XincangTransferState.toCore("5")); |
||||
assertEquals(TransferStatus.SHIPPED, XincangTransferState.toCore("6")); |
||||
assertEquals(TransferStatus.CANCELLED, XincangTransferState.toCore("7")); |
||||
} |
||||
|
||||
@Test |
||||
void unknownTransferStateIsNotGuessed() { |
||||
assertEquals(TransferStatus.UNKNOWN, XincangTransferState.toCore("9")); |
||||
assertEquals(TransferStatus.UNKNOWN, XincangTransferState.toCore(null)); |
||||
} |
||||
|
||||
@Test |
||||
void forecastStatusMapsToInboundStatus() { |
||||
assertEquals(InboundStatus.DRAFT, XincangForecastStatus.toCore("0")); |
||||
assertEquals(InboundStatus.IN_TRANSIT, XincangForecastStatus.toCore("1")); |
||||
assertEquals(InboundStatus.PENDING_SHIPMENT, XincangForecastStatus.toCore("2")); |
||||
assertEquals(InboundStatus.IN_TRANSIT, XincangForecastStatus.toCore("3")); |
||||
assertEquals(InboundStatus.RECEIVING, XincangForecastStatus.toCore("6")); |
||||
assertEquals(InboundStatus.STORING, XincangForecastStatus.toCore("7")); |
||||
assertEquals(InboundStatus.COMPLETED, XincangForecastStatus.toCore("8")); |
||||
assertEquals(InboundStatus.REJECTED, XincangForecastStatus.toCore("9")); |
||||
assertEquals(InboundStatus.UNKNOWN, XincangForecastStatus.toCore("99")); |
||||
} |
||||
|
||||
@Test |
||||
void orderTypeDrivesSelfLabelRequirement() { |
||||
assertEquals("common", XincangOrderType.COMMON.rawCode()); |
||||
assertEquals("wayfair", XincangOrderType.WAYFAIR.rawCode()); |
||||
assertFalse(XincangOrderType.COMMON.requiresSelfLabel()); |
||||
assertTrue(XincangOrderType.WAYFAIR.requiresSelfLabel()); |
||||
assertEquals(XincangOrderType.WAYFAIR, XincangOrderType.of("wayfair")); |
||||
assertNull(XincangOrderType.of("unknown")); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue