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.
513 lines
23 KiB
513 lines
23 KiB
|
1 week ago
|
package common.ecommerce.yqn.probe;
|
||
|
|
|
||
|
|
import common.ecommerce.http.JacksonJsonCodec;
|
||
|
|
import common.ecommerce.http.OkHttpTransport;
|
||
|
|
import common.ecommerce.shared.error.ChannelException;
|
||
|
|
import common.ecommerce.shared.model.Platform;
|
||
|
|
import common.ecommerce.shared.spi.ChannelSecret;
|
||
|
|
import common.ecommerce.warehouse.model.DestructionCommand;
|
||
|
|
import common.ecommerce.warehouse.enums.LabelMode;
|
||
|
|
import common.ecommerce.warehouse.enums.TransferType;
|
||
|
|
import common.ecommerce.warehouse.enums.WarehouseProvider;
|
||
|
|
import common.ecommerce.warehouse.model.DestructionOrder;
|
||
|
|
import common.ecommerce.warehouse.model.InboundCommand;
|
||
|
|
import common.ecommerce.warehouse.model.InboundLine;
|
||
|
|
import common.ecommerce.warehouse.model.InboundOrder;
|
||
|
|
import common.ecommerce.warehouse.model.InboundReceipt;
|
||
|
|
import common.ecommerce.warehouse.model.OutboundCommand;
|
||
|
|
import common.ecommerce.warehouse.model.OutboundLine;
|
||
|
|
import common.ecommerce.warehouse.model.OutboundOrder;
|
||
|
|
import common.ecommerce.warehouse.model.OutboundReceipt;
|
||
|
|
import common.ecommerce.warehouse.model.OutboundRef;
|
||
|
|
import common.ecommerce.warehouse.model.ReturnCommand;
|
||
|
|
import common.ecommerce.warehouse.model.ShipTo;
|
||
|
|
import common.ecommerce.warehouse.model.TransferCommand;
|
||
|
|
import common.ecommerce.warehouse.model.TransferOrder;
|
||
|
|
import common.ecommerce.warehouse.model.WarehouseReturn;
|
||
|
|
import common.ecommerce.warehouse.sdk.WarehouseConnection;
|
||
|
|
import common.ecommerce.warehouse.sdk.WarehouseContext;
|
||
|
|
import common.ecommerce.yqn.YqnConstants;
|
||
|
|
import common.ecommerce.yqn.adapter.YqnAdapter;
|
||
|
|
import org.junit.jupiter.api.Assumptions;
|
||
|
|
import org.junit.jupiter.api.MethodOrderer;
|
||
|
|
import org.junit.jupiter.api.Order;
|
||
|
|
import org.junit.jupiter.api.Test;
|
||
|
|
import org.junit.jupiter.api.TestMethodOrder;
|
||
|
|
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||
|
|
|
||
|
|
import java.time.Clock;
|
||
|
|
import java.time.Instant;
|
||
|
|
import java.time.LocalDate;
|
||
|
|
import java.util.UUID;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 运去哪<b>全链路</b>联调探针:按业务流程把每个接口都走一遍。
|
||
|
|
*
|
||
|
|
* <p>默认跳过,需显式开启:</p>
|
||
|
|
*
|
||
|
|
* <pre>
|
||
|
|
* mvn -pl warehouse-sdk-yqn -DfailIfNoTests=false \
|
||
|
|
* -Dyqn.probe.all=true \
|
||
|
|
* -Dyqn.probe.token=你的x-api-key \
|
||
|
|
* -Dyqn.probe.providerWarehouseId=RF_NY_US \
|
||
|
|
* -Dyqn.probe.warehouseCode=YQN-RF_NY_US \
|
||
|
|
* -Dtest=YqnFullFlowProbeTest test
|
||
|
|
* </pre>
|
||
|
|
*
|
||
|
|
* <p><b>会真实创建单据</b>(出库 / 入库 / 调拨 / 退货 / 销毁),仅限 PR 测试环境。
|
||
|
|
* 单号带 {@code PROBE-<时间戳>} 前缀便于识别与清理。</p>
|
||
|
|
*
|
||
|
|
* <p>方法按 {@code @Order} 串起来:出库创建 → 查详情;调拨创建即验证;
|
||
|
|
* 入库创建 → 查详情 → 打箱标 / SKU 标。任何一步失败只打印不中断,
|
||
|
|
* 后面还会继续跑,便于一次看全。</p>
|
||
|
|
*/
|
||
|
|
@EnabledIfSystemProperty(named = "yqn.probe.all", matches = "true")
|
||
|
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||
|
|
class YqnFullFlowProbeTest {
|
||
|
|
|
||
|
|
private static final String TOKEN = System.getProperty("yqn.probe.token", "");
|
||
|
|
private static final String BASE_URL = opt("yqn.probe.baseUrl", YqnConstants.PR_BASE_URL);
|
||
|
|
private static final String AUX_URL = opt("yqn.probe.auxBaseUrl", YqnConstants.AUX_BASE_URL_PR);
|
||
|
|
private static final String WAREHOUSE_CODE = opt("yqn.probe.warehouseCode", "YQN-RF_NY_US");
|
||
|
|
private static final String PROVIDER_WAREHOUSE = opt("yqn.probe.providerWarehouseId", "RF_NY_US");
|
||
|
|
private static final String SKU = opt("yqn.probe.sku", "DM00001");
|
||
|
|
/** 测试发货方式。 */
|
||
|
|
private static final String CARRIER_CODE = opt("yqn.probe.carrierCode", "WLC-FEDEX");
|
||
|
|
|
||
|
|
/** 本次运行的唯一后缀,避免与历史数据冲突。 */
|
||
|
|
private static final String RUN = "PROBE-" + System.currentTimeMillis();
|
||
|
|
|
||
|
|
private static String outboundNo;
|
||
|
|
private static String inboundNo;
|
||
|
|
|
||
|
|
// ---------------------------------------------------------------- 出库
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(1)
|
||
|
|
void createOutbound() {
|
||
|
|
assumeToken();
|
||
|
|
run("POST /v1/saleOrder/create", () -> {
|
||
|
|
OutboundReceipt receipt = adapter().create(ctx(), outboundCommand());
|
||
|
|
outboundNo = receipt.outboundRequestNo();
|
||
|
|
System.out.println("[outbound.create] requestNo=" + receipt.outboundRequestNo()
|
||
|
|
+ " providerOrderId=" + receipt.providerOrderId()
|
||
|
|
+ " rawStatus=" + receipt.rawStatus());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(2)
|
||
|
|
void getOutboundDetail() {
|
||
|
|
assumeToken();
|
||
|
|
Assumptions.assumeTrue(outboundNo != null, "出库单未创建成功,跳过详情查询");
|
||
|
|
run("POST /v1/saleOrder/findOne", () -> {
|
||
|
|
OutboundOrder order = adapter().get(ctx(), OutboundRef.ofRequestNo(outboundNo));
|
||
|
|
if (order == null) {
|
||
|
|
System.out.println("[outbound.get] 未找到 " + outboundNo);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
System.out.println("[outbound.get] status=" + order.status()
|
||
|
|
+ " rawStatus=" + order.rawStatus()
|
||
|
|
+ " carrierCode=" + order.carrierCode()
|
||
|
|
+ " tracking=" + order.trackingNumber()
|
||
|
|
+ " paidAt=" + order.paidAt());
|
||
|
|
System.out.println(" lines=" + order.lines().size()
|
||
|
|
+ " attachments=" + order.attachments().size()
|
||
|
|
+ " serialNumbers=" + order.serialNumbers().size()
|
||
|
|
+ " signatureRequired=" + order.signatureRequired()
|
||
|
|
+ " insured=" + order.insured()
|
||
|
|
+ " labelMode=" + order.labelMode());
|
||
|
|
for (OutboundLine l : order.lines()) {
|
||
|
|
System.out.println(" line sku=" + l.providerSku()
|
||
|
|
+ " qty=" + l.quantity()
|
||
|
|
+ " totalAmount=" + l.totalAmount()
|
||
|
|
+ " ordIds=" + l.platformOrderItemIds());
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(3)
|
||
|
|
void cancelOutbound() {
|
||
|
|
assumeToken();
|
||
|
|
Assumptions.assumeTrue(outboundNo != null, "出库单未创建成功,跳过取消");
|
||
|
|
run("POST /v1/saleOrder/cancel", () -> {
|
||
|
|
common.ecommerce.warehouse.model.CancelResult result =
|
||
|
|
adapter().cancel(ctx(), common.ecommerce.warehouse.model.CancelCommand.builder()
|
||
|
|
.outboundRequestNo(outboundNo).build());
|
||
|
|
System.out.println("[outbound.cancel] cancelled=" + result.cancelled()
|
||
|
|
+ " eligibility=" + result.eligibility()
|
||
|
|
+ " rawStatus=" + result.rawStatus());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// ---------------------------------------------------------------- 库存 / 费用 / 试算
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(4)
|
||
|
|
void queryInventory() {
|
||
|
|
assumeToken();
|
||
|
|
run("GET /v2/inventory/get_inventory_by_page", () -> {
|
||
|
|
common.ecommerce.shared.support.Page<common.ecommerce.warehouse.model.InventorySnapshot> page =
|
||
|
|
adapter().query(ctx(), common.ecommerce.warehouse.model.InventoryQuery.builder()
|
||
|
|
.pageSize(5).build());
|
||
|
|
System.out.println("[inventory] " + page.size() + " 条, cursor=" + page.nextCursor());
|
||
|
|
for (common.ecommerce.warehouse.model.InventorySnapshot s : page.items()) {
|
||
|
|
System.out.println(" sku=" + s.providerSku() + " avail=" + s.available()
|
||
|
|
+ " onHand=" + s.onHand() + " type=" + s.inventoryType());
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(5)
|
||
|
|
void estimateFee() {
|
||
|
|
assumeToken();
|
||
|
|
run("POST /v1/saleOrder/calculate", () -> {
|
||
|
|
java.util.List<common.ecommerce.warehouse.model.FeeEstimateResult> list =
|
||
|
|
adapter().estimate(ctx(), common.ecommerce.warehouse.model.FeeEstimateQuery.builder()
|
||
|
|
.warehouseCode(PROVIDER_WAREHOUSE)
|
||
|
|
.lengthCm(new java.math.BigDecimal("30"))
|
||
|
|
.widthCm(new java.math.BigDecimal("20"))
|
||
|
|
.heightCm(new java.math.BigDecimal("10"))
|
||
|
|
.weightGrams(new java.math.BigDecimal("500"))
|
||
|
|
.receiveCountry("US").receiveState("NY").receiveCity("New York")
|
||
|
|
.receivePostal("10001").receiveAddress("1 Main St")
|
||
|
|
.logisticsServiceCode("FedEx_FEDEX_GROUND")
|
||
|
|
.build());
|
||
|
|
System.out.println("[estimate] " + list.size() + " 个仓");
|
||
|
|
for (common.ecommerce.warehouse.model.FeeEstimateResult r : list) {
|
||
|
|
System.out.println(" warehouse=" + r.shipOrgWarehouseCode()
|
||
|
|
+ " carriers=" + r.carriers().size());
|
||
|
|
for (common.ecommerce.warehouse.model.FeeEstimateResult.CarrierQuote q : r.carriers()) {
|
||
|
|
System.out.println(" " + q.logisticsServiceCode()
|
||
|
|
+ " total=" + q.totalRate()
|
||
|
|
+ " items=" + q.costItems().size());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(6)
|
||
|
|
void queryFeeDetail() {
|
||
|
|
assumeToken();
|
||
|
|
Assumptions.assumeTrue(outboundNo != null, "出库单未创建成功,跳过结算明细");
|
||
|
|
run("POST /v1/warehouse/operation/costs/detail", () -> {
|
||
|
|
java.util.List<common.ecommerce.warehouse.model.BillingDocument> list =
|
||
|
|
adapter().settlements(ctx(), common.ecommerce.warehouse.model.FeeQuery.builder()
|
||
|
|
.saleOrderNo(outboundNo).build());
|
||
|
|
System.out.println("[fees] " + list.size() + " 条");
|
||
|
|
for (common.ecommerce.warehouse.model.BillingDocument d : list) {
|
||
|
|
System.out.println(" name=" + d.feeName() + " type=" + d.feeType()
|
||
|
|
+ " amount=" + d.amount() + " estimated=" + d.estimated());
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// ---------------------------------------------------------------- 入库
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(7)
|
||
|
|
void createInbound() {
|
||
|
|
assumeToken();
|
||
|
|
run("POST /v1/inbound/createInboundPlan", () -> {
|
||
|
|
InboundReceipt receipt = adapter().create(ctx(), inboundCommand());
|
||
|
|
inboundNo = receipt.providerInboundId();
|
||
|
|
System.out.println("[inbound.create] requestNo=" + receipt.inboundRequestNo()
|
||
|
|
+ " providerInboundId=" + receipt.providerInboundId());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(8)
|
||
|
|
void getInboundPlan() {
|
||
|
|
assumeToken();
|
||
|
|
Assumptions.assumeTrue(inboundNo != null, "入库单未创建成功,跳过查询");
|
||
|
|
run("POST /v1/inbound/getInboundPlanInfo", () -> {
|
||
|
|
InboundOrder order = adapter().get(ctx(), inboundNo);
|
||
|
|
if (order == null) {
|
||
|
|
System.out.println("[inbound.get] 未找到 " + inboundNo);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
System.out.println("[inbound.get] status=" + order.status()
|
||
|
|
+ " planned=" + order.plannedQuantity()
|
||
|
|
+ " packed=" + order.packedQuantity()
|
||
|
|
+ " received=" + order.receivedQuantity()
|
||
|
|
+ " boxes=" + order.boxCount()
|
||
|
|
+ " containers=" + order.containers().size()
|
||
|
|
+ " lineName=" + order.lineName()
|
||
|
|
+ " shipmentId=" + order.shipmentId());
|
||
|
|
for (common.ecommerce.warehouse.model.InboundOrderBatch b : order.batches()) {
|
||
|
|
System.out.println(" batch phase=" + b.phase() + " carton=" + b.cartonNo()
|
||
|
|
+ " qty=" + b.quantity());
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(9)
|
||
|
|
void printBoxLabel() {
|
||
|
|
assumeToken();
|
||
|
|
Assumptions.assumeTrue(inboundNo != null, "入库单未创建成功,跳过箱标");
|
||
|
|
run("POST /v1/inbound/generateBoxLabel", () -> {
|
||
|
|
common.ecommerce.warehouse.model.LabelPrintTask task =
|
||
|
|
adapter().printBoxLabel(ctx(),
|
||
|
|
common.ecommerce.warehouse.model.BoxLabelCommand.builder()
|
||
|
|
.providerInboundNo(inboundNo)
|
||
|
|
.inboundRequestNo(RUN + "-IN")
|
||
|
|
.build());
|
||
|
|
System.out.println("[boxLabel] taskNo=" + task.taskNo()
|
||
|
|
+ " providerInboundNo=" + task.providerInboundNo());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(10)
|
||
|
|
void printSkuLabel() {
|
||
|
|
assumeToken();
|
||
|
|
Assumptions.assumeTrue(inboundNo != null, "入库单未创建成功,跳过 SKU 标");
|
||
|
|
run("POST /v1/inbound/generateItemLabel", () -> {
|
||
|
|
common.ecommerce.warehouse.model.LabelPrintTask task =
|
||
|
|
adapter().printSkuLabel(ctx(),
|
||
|
|
common.ecommerce.warehouse.model.SkuLabelCommand.builder()
|
||
|
|
.providerInboundNo(inboundNo)
|
||
|
|
.inboundRequestNo(RUN + "-IN")
|
||
|
|
.sizeType(common.ecommerce.warehouse.enums.SkuLabelSizeType.SIZE_70_30)
|
||
|
|
.showEn(true)
|
||
|
|
.build());
|
||
|
|
System.out.println("[skuLabel] taskNo=" + task.taskNo());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// ---------------------------------------------------------------- 调拨 / 退货 / 销毁
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(11)
|
||
|
|
void createTransfer() {
|
||
|
|
assumeToken();
|
||
|
|
run("POST /v2/transferOutboundPlan/create", () -> {
|
||
|
|
TransferOrder order = adapter().create(ctx(), transferCommand());
|
||
|
|
System.out.println("[transfer.create] providerNo=" + order.providerTransferNo()
|
||
|
|
+ " status=" + order.status() + " rawStatus=" + order.rawStatus()
|
||
|
|
+ " totalQty=" + order.totalQuantity()
|
||
|
|
+ " totalWeightKg=" + order.totalWeightKg()
|
||
|
|
+ " totalVolumeCbm=" + order.totalVolumeCbm()
|
||
|
|
+ " fromTitle=" + order.fromWarehouseTitle()
|
||
|
|
+ " toTitle=" + order.toWarehouseTitle());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(12)
|
||
|
|
void createReturn() {
|
||
|
|
assumeToken();
|
||
|
|
run("POST /v3/saleReturn/createSaleReturnPlan", () -> {
|
||
|
|
WarehouseReturn ret = adapter().create(ctx(), returnCommand());
|
||
|
|
System.out.println("[return.create] requestNo=" + ret.returnRequestNo()
|
||
|
|
+ " providerReturnId=" + ret.providerReturnId()
|
||
|
|
+ " status=" + ret.status());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Test
|
||
|
|
@Order(13)
|
||
|
|
void getReturnPlan() {
|
||
|
|
assumeToken();
|
||
|
|
String returnNo = System.getProperty("yqn.probe.returnOrderNo", "");
|
||
|
|
Assumptions.assumeTrue(!returnNo.trim().isEmpty(),
|
||
|
|
"未提供 -Dyqn.probe.returnOrderNo,跳过退货计划查询");
|
||
|
|
run("POST /v3/saleReturn/getInboundPlanInfo", () -> {
|
||
|
|
WarehouseReturn ret = adapter().getReturn(ctx(), returnNo);
|
||
|
|
if (ret == null) {
|
||
|
|
System.out.println("[return.get] 未找到 " + returnNo);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
System.out.println("[return.get] status=" + ret.status() + " rawStatus=" + ret.rawStatus()
|
||
|
|
+ " inspected=" + ret.inspectedQuantity() + " lines=" + ret.lines().size());
|
||
|
|
for (WarehouseReturn.ReturnLine l : ret.lines()) {
|
||
|
|
System.out.println(" lineId=" + l.lineId() + " sku=" + l.providerSku()
|
||
|
|
+ " qty=" + l.quantity() + " suggested=" + l.suggestedDisposition());
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 销毁需要不可售库存:先查一下,没有就跳过(不是代码问题)。 */
|
||
|
|
@Test
|
||
|
|
@Order(14)
|
||
|
|
void createDestruction() {
|
||
|
|
assumeToken();
|
||
|
|
boolean hasUnsellable = false;
|
||
|
|
try {
|
||
|
|
common.ecommerce.shared.support.Page<common.ecommerce.warehouse.model.InventorySnapshot> page =
|
||
|
|
adapter().query(ctx(), common.ecommerce.warehouse.model.InventoryQuery.builder()
|
||
|
|
.inventoryType(1).pageSize(20).build());
|
||
|
|
for (common.ecommerce.warehouse.model.InventorySnapshot snap : page.items()) {
|
||
|
|
if (snap.inventoryType() == 1 && snap.available() > 0) {
|
||
|
|
hasUnsellable = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} catch (RuntimeException e) {
|
||
|
|
System.out.println("[destruction] 查不可售库存失败,跳过: " + e.getMessage());
|
||
|
|
}
|
||
|
|
Assumptions.assumeTrue(hasUnsellable,
|
||
|
|
"该仓没有不可售库存,销毁计划需要不可售 SKU,跳过");
|
||
|
|
run("POST /v1/destroyPlan/createDestroyPlan", () -> {
|
||
|
|
DestructionOrder order = adapter().create(ctx(), destructionCommand());
|
||
|
|
System.out.println("[destruction.create] providerNo=" + order.providerDestructionId()
|
||
|
|
+ " status=" + order.status());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// ---------------------------------------------------------------- 商品
|
||
|
|
|
||
|
|
/** 商品建档:测试 SKU 已存在且状态可能不允许编辑,失败属业务约束。 */
|
||
|
|
@Test
|
||
|
|
@Order(15)
|
||
|
|
void saveProduct() {
|
||
|
|
assumeToken();
|
||
|
|
String probeSku = System.getProperty("yqn.probe.newSku", "");
|
||
|
|
Assumptions.assumeTrue(!probeSku.trim().isEmpty(),
|
||
|
|
"未提供 -Dyqn.probe.newSku(新建 SKU),跳过商品建档");
|
||
|
|
run("POST /v1/product/save", () -> {
|
||
|
|
common.ecommerce.warehouse.capability.WarehouseProductCapable.ProductResult result =
|
||
|
|
adapter().createOrUpdate(ctx(),
|
||
|
|
common.ecommerce.warehouse.capability.WarehouseProduct.builder()
|
||
|
|
.omsSku(probeSku)
|
||
|
|
.name("探针商品")
|
||
|
|
.nameEn("Probe Product")
|
||
|
|
.packingType(0)
|
||
|
|
.lengthCm(30).widthCm(20).heightCm(10).weightGrams(500)
|
||
|
|
.requireSn(0)
|
||
|
|
.build());
|
||
|
|
System.out.println("[product.save] sku=" + result.providerSku()
|
||
|
|
+ " status=" + result.status() + " rawStatus=" + result.rawStatus());
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// ---------------------------------------------------------------- 命令构造
|
||
|
|
|
||
|
|
private static OutboundCommand outboundCommand() {
|
||
|
|
return OutboundCommand.builder()
|
||
|
|
.outboundRequestNo(RUN + "-OUT")
|
||
|
|
.orderRef(RUN + "-REF")
|
||
|
|
.carrier("FEDEX")
|
||
|
|
.carrierCode(CARRIER_CODE)
|
||
|
|
.warehouseId(PROVIDER_WAREHOUSE)
|
||
|
|
.salesPlatform(Platform.AMAZON_SC)
|
||
|
|
.currency("USD")
|
||
|
|
.shipServiceLevel("Standard-48 Hours")
|
||
|
|
.shipTo(ShipTo.builder()
|
||
|
|
.name("Probe User").phone("+1-555-0100")
|
||
|
|
.countryCode("US").stateOrProvince("NY").city("New York")
|
||
|
|
.addressLine1("1 Probe St").postalCode("10001")
|
||
|
|
.build())
|
||
|
|
.line(OutboundLine.builder()
|
||
|
|
.lineNo("1").omsSku(SKU).quantity(1)
|
||
|
|
.declareName("Probe Goods").declareNameEn("Probe Goods")
|
||
|
|
.declareValue(common.ecommerce.shared.support.Money.of("10.00", "USD"))
|
||
|
|
.build())
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
private static InboundCommand inboundCommand() {
|
||
|
|
return InboundCommand.builder()
|
||
|
|
.inboundRequestNo(RUN + "-IN")
|
||
|
|
.warehouseId(PROVIDER_WAREHOUSE)
|
||
|
|
.inventoryType(0)
|
||
|
|
.currency("USD")
|
||
|
|
.estimateArriveDate(LocalDate.now().plusDays(7))
|
||
|
|
.expectArriveDate(LocalDate.now().plusDays(7))
|
||
|
|
.originCountry("CN")
|
||
|
|
.shipperName("Probe Shipper").shipperContact("Probe").shipperPhone("+86-555-0100")
|
||
|
|
.shipperAddress("Probe Address")
|
||
|
|
.line(InboundLine.builder().omsSku(SKU).quantity(1).build())
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
private static TransferCommand transferCommand() {
|
||
|
|
return TransferCommand.builder()
|
||
|
|
.transferRequestNo(RUN + "-TR")
|
||
|
|
.type(TransferType.WAREHOUSE_TO_WAREHOUSE)
|
||
|
|
.fromWarehouseCode(PROVIDER_WAREHOUSE)
|
||
|
|
.toWarehouseCode(PROVIDER_WAREHOUSE)
|
||
|
|
.inventoryType(0)
|
||
|
|
.carrierType(1)
|
||
|
|
.transportationType(2)
|
||
|
|
.estimateOutboundDate(LocalDate.now().plusDays(3))
|
||
|
|
.estimateInboundDate(LocalDate.now().plusDays(7))
|
||
|
|
.remark("probe")
|
||
|
|
.line(SKU, 1)
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
private static ReturnCommand returnCommand() {
|
||
|
|
return ReturnCommand.builder()
|
||
|
|
.returnRequestNo(RUN + "-RT")
|
||
|
|
.warehouseId(PROVIDER_WAREHOUSE)
|
||
|
|
.saleOrderNo(RUN + "-OUT")
|
||
|
|
.returnTrackingNo("PROBE-TRK-" + System.currentTimeMillis())
|
||
|
|
.carrierCode(CARRIER_CODE)
|
||
|
|
.estimatedReceiveDate(LocalDate.now().plusDays(5))
|
||
|
|
.returnReason("probe")
|
||
|
|
.line(SKU, 1, common.ecommerce.warehouse.enums.ReturnDealMethod.PHOTO_CONFIRM)
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
private static DestructionCommand destructionCommand() {
|
||
|
|
return DestructionCommand.builder()
|
||
|
|
.destructionNo(RUN + "-DS")
|
||
|
|
.warehouseId(PROVIDER_WAREHOUSE)
|
||
|
|
.inventoryType(1)
|
||
|
|
.hopeDestroyDate(LocalDate.now().plusDays(10))
|
||
|
|
.remark("probe")
|
||
|
|
.line(SKU, 1)
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
// ---------------------------------------------------------------- helpers
|
||
|
|
|
||
|
|
private static WarehouseContext ctx() {
|
||
|
|
return WarehouseContext.of(WAREHOUSE_CODE, WarehouseProvider.YQN, PROVIDER_WAREHOUSE,
|
||
|
|
WarehouseConnection.of(BASE_URL, AUX_URL,
|
||
|
|
ChannelSecret.builder().appSecret(TOKEN).build()),
|
||
|
|
"probe-" + UUID.randomUUID(), Clock.systemUTC());
|
||
|
|
}
|
||
|
|
|
||
|
|
private static YqnAdapter adapter() {
|
||
|
|
return new YqnAdapter(new OkHttpTransport("common-ecommerce-yqn-probe"),
|
||
|
|
new JacksonJsonCodec());
|
||
|
|
}
|
||
|
|
|
||
|
|
private static void assumeToken() {
|
||
|
|
Assumptions.assumeTrue(!TOKEN.trim().isEmpty(), "未提供 -Dyqn.probe.token,跳过");
|
||
|
|
}
|
||
|
|
|
||
|
|
private static void run(String api, Runnable r) {
|
||
|
|
System.out.println("\n================ yqn / " + api + " ================");
|
||
|
|
try {
|
||
|
|
r.run();
|
||
|
|
System.out.println("[OK] " + api);
|
||
|
|
} catch (RuntimeException e) {
|
||
|
|
String msg = e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage();
|
||
|
|
System.out.println("[ERROR] " + e.getClass().getSimpleName() + ": "
|
||
|
|
+ (msg.length() <= 400 ? msg : msg.substring(0, 400) + "…"));
|
||
|
|
if (e instanceof ChannelException) {
|
||
|
|
ChannelException ce = (ChannelException) e;
|
||
|
|
System.out.println(" platformCode=" + ce.platformCode()
|
||
|
|
+ " retryable=" + ce.retryable());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private static String opt(String name, String fallback) {
|
||
|
|
String value = System.getProperty(name, "");
|
||
|
|
if (value == null) {
|
||
|
|
return fallback;
|
||
|
|
}
|
||
|
|
String trimmed = value.trim();
|
||
|
|
return trimmed.isEmpty() ? fallback : trimmed;
|
||
|
|
}
|
||
|
|
}
|