Browse Source
文档把出库下单的契约定死了,替换掉此前按命名习惯猜的字段: - 路径 /saleorder/OrderCreate → /v1/saleOrder/create - 响应只有 data.orderId(仓内部数字 id),没有字符串单号; 幂等结果引用改存这个 id - 必填扩到 10 项:来源单号、完整收件地址、联系人电话、销售平台、商品行 OutboundCommand 补 API 123 需要的维度: - salesPlatform 改必填,类型用渠道域的 Platform 枚举,由适配器映射到 仓方平台码。仓按平台做路由与面单归属,不给就猜错,所以宁可构造期失败 - 新增 carrierCode / shipServiceLevel / latestShipDate / estimatedDeliveryTime / currency / packages - ShipTo 补 addressLine3(运去哪要求地址最多三行) 新增 OutboundPackageSpec:多包裹拆单,尺寸 cm、重量 g、含包裹内 SKU 与 打包耗材编码。不传则由仓按默认规则打包。 未接的部分保持原样:FindOrderInfor / OrderCancel 仍是旧假设, 取消预判与包裹查询等查询类接口等文档再对齐。 Co-Authored-By: Claude <noreply@anthropic.com>feature/supplier-lingxing
10 changed files with 551 additions and 89 deletions
@ -0,0 +1,160 @@
@@ -0,0 +1,160 @@
|
||||
package common.ecommerce.warehouse.model; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 出库包裹拆分信息。 |
||||
* |
||||
* <p>仓支持多包裹拆单;{@link #skuInfos()} 为空且只有一个包裹时表示所有 SKU 装同一箱。 |
||||
* 尺寸单位 cm、重量单位 g,与仓库域其它模型一致。</p> |
||||
*/ |
||||
public final class OutboundPackageSpec { |
||||
|
||||
private final String refNo; |
||||
private final double lengthCm; |
||||
private final double widthCm; |
||||
private final double heightCm; |
||||
private final double weightGrams; |
||||
private final List<SkuInfo> skuInfos; |
||||
/** |
||||
* 打包耗材:20 不使用耗材 / 21 纸箱打包 / 22 快递袋打包。 |
||||
* |
||||
* <p>仓方必填;未指定时留空列表由适配器按平台默认补齐。</p> |
||||
*/ |
||||
private final List<Integer> materialTypes; |
||||
|
||||
private OutboundPackageSpec(Builder b) { |
||||
this.refNo = b.refNo; |
||||
this.lengthCm = requirePositive(b.lengthCm, "lengthCm"); |
||||
this.widthCm = requirePositive(b.widthCm, "widthCm"); |
||||
this.heightCm = requirePositive(b.heightCm, "heightCm"); |
||||
this.weightGrams = requirePositive(b.weightGrams, "weightGrams"); |
||||
for (SkuInfo sku : b.skuInfos) { |
||||
if (sku == null) { |
||||
throw new IllegalArgumentException("skuInfos must not contain null"); |
||||
} |
||||
} |
||||
this.skuInfos = Collections.unmodifiableList(new ArrayList<SkuInfo>(b.skuInfos)); |
||||
this.materialTypes = Collections.unmodifiableList(new ArrayList<Integer>(b.materialTypes)); |
||||
} |
||||
|
||||
public static Builder builder() { |
||||
return new Builder(); |
||||
} |
||||
|
||||
/** 包裹参考号;运去哪要求与附件里的 packageNo 一致。 */ |
||||
public String refNo() { |
||||
return refNo; |
||||
} |
||||
|
||||
public double lengthCm() { |
||||
return lengthCm; |
||||
} |
||||
|
||||
public double widthCm() { |
||||
return widthCm; |
||||
} |
||||
|
||||
public double heightCm() { |
||||
return heightCm; |
||||
} |
||||
|
||||
public double weightGrams() { |
||||
return weightGrams; |
||||
} |
||||
|
||||
/** 本包裹内的 SKU 与数量;空列表表示所有 SKU 都在这一箱。 */ |
||||
public List<SkuInfo> skuInfos() { |
||||
return skuInfos; |
||||
} |
||||
|
||||
/** 打包耗材编码;空列表表示未指定。 */ |
||||
public List<Integer> materialTypes() { |
||||
return materialTypes; |
||||
} |
||||
|
||||
private static double requirePositive(double v, String n) { |
||||
if (v <= 0) { |
||||
throw new IllegalArgumentException(n + " must be positive"); |
||||
} |
||||
return v; |
||||
} |
||||
|
||||
/** 包裹内一个 SKU 的数量。 */ |
||||
public static final class SkuInfo { |
||||
|
||||
private final String sku; |
||||
private final int qty; |
||||
|
||||
public SkuInfo(String sku, int qty) { |
||||
if (sku == null || sku.trim().isEmpty()) { |
||||
throw new IllegalArgumentException("sku must not be blank"); |
||||
} |
||||
if (qty <= 0) { |
||||
throw new IllegalArgumentException("qty must be positive"); |
||||
} |
||||
this.sku = sku.trim(); |
||||
this.qty = qty; |
||||
} |
||||
|
||||
public String sku() { |
||||
return sku; |
||||
} |
||||
|
||||
public int qty() { |
||||
return qty; |
||||
} |
||||
} |
||||
|
||||
public static final class Builder { |
||||
|
||||
private String refNo; |
||||
private double lengthCm; |
||||
private double widthCm; |
||||
private double heightCm; |
||||
private double weightGrams; |
||||
private final List<SkuInfo> skuInfos = new ArrayList<SkuInfo>(); |
||||
private final List<Integer> materialTypes = new ArrayList<Integer>(); |
||||
|
||||
public Builder refNo(String refNo) { |
||||
this.refNo = refNo; |
||||
return this; |
||||
} |
||||
|
||||
public Builder lengthCm(double v) { |
||||
this.lengthCm = v; |
||||
return this; |
||||
} |
||||
|
||||
public Builder widthCm(double v) { |
||||
this.widthCm = v; |
||||
return this; |
||||
} |
||||
|
||||
public Builder heightCm(double v) { |
||||
this.heightCm = v; |
||||
return this; |
||||
} |
||||
|
||||
public Builder weightGrams(double v) { |
||||
this.weightGrams = v; |
||||
return this; |
||||
} |
||||
|
||||
public Builder sku(String sku, int qty) { |
||||
this.skuInfos.add(new SkuInfo(sku, qty)); |
||||
return this; |
||||
} |
||||
|
||||
public Builder materialType(int code) { |
||||
this.materialTypes.add(code); |
||||
return this; |
||||
} |
||||
|
||||
public OutboundPackageSpec build() { |
||||
return new OutboundPackageSpec(this); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue