|
|
|
@ -6,6 +6,7 @@ import common.ecommerce.warehouse.enums.LabelMode; |
|
|
|
import common.ecommerce.warehouse.model.OutboundCommand; |
|
|
|
import common.ecommerce.warehouse.model.OutboundCommand; |
|
|
|
import common.ecommerce.warehouse.model.OutboundLine; |
|
|
|
import common.ecommerce.warehouse.model.OutboundLine; |
|
|
|
import common.ecommerce.warehouse.model.ShipTo; |
|
|
|
import common.ecommerce.warehouse.model.ShipTo; |
|
|
|
|
|
|
|
import common.ecommerce.warehouse.model.WarehouseAttachment; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.Clock; |
|
|
|
import java.time.Clock; |
|
|
|
@ -13,7 +14,6 @@ import java.time.Instant; |
|
|
|
import java.time.ZoneOffset; |
|
|
|
import java.time.ZoneOffset; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -88,7 +88,16 @@ public final class HengjianOutboundMapper { |
|
|
|
req.expectedShipDate = formatTime(cmd.latestShipDate()); |
|
|
|
req.expectedShipDate = formatTime(cmd.latestShipDate()); |
|
|
|
req.isPrime = flagOf(cmd.sfp()); |
|
|
|
req.isPrime = flagOf(cmd.sfp()); |
|
|
|
req.createdAt = formatTime(Instant.now(clock)); |
|
|
|
req.createdAt = formatTime(Instant.now(clock)); |
|
|
|
|
|
|
|
// 客户备注与仓库备注在恒健是两个字段,不能合并
|
|
|
|
req.customerRemark = trimToNull(cmd.remark()); |
|
|
|
req.customerRemark = trimToNull(cmd.remark()); |
|
|
|
|
|
|
|
req.warehouseRemark = trimToNull(cmd.warehouseRemark()); |
|
|
|
|
|
|
|
// 支付时间:调用方给了就发,没给由仓方按当前时间处理
|
|
|
|
|
|
|
|
req.paidAt = formatTime(cmd.paidAt()); |
|
|
|
|
|
|
|
// 提货时间:仅 FBALTL 等自提场景需要,格式 yyyy-MM-dd
|
|
|
|
|
|
|
|
req.pickupTime = cmd.pickupTime() == null ? null : cmd.pickupTime().toString(); |
|
|
|
|
|
|
|
// VC Direct Fulfillment 由调用方显式指定,不按平台推断
|
|
|
|
|
|
|
|
req.isDFOrder = flagOf(cmd.directFulfillment()); |
|
|
|
|
|
|
|
req.thirdPartyAccount = trimToNull(cmd.thirdPartyAccount()); |
|
|
|
|
|
|
|
|
|
|
|
ShipTo shipTo = cmd.shipTo(); |
|
|
|
ShipTo shipTo = cmd.shipTo(); |
|
|
|
req.shipToCountry = require(shipTo.countryCode(), "shipTo.countryCode", orderNo); |
|
|
|
req.shipToCountry = require(shipTo.countryCode(), "shipTo.countryCode", orderNo); |
|
|
|
@ -173,6 +182,14 @@ public final class HengjianOutboundMapper { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static List<HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem> toAttachInfoItems( |
|
|
|
private static List<HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem> toAttachInfoItems( |
|
|
|
OutboundCommand cmd, String orderNo) { |
|
|
|
OutboundCommand cmd, String orderNo) { |
|
|
|
|
|
|
|
// 1) 通用附件列表:支持 URL 与 base64、7 种类型
|
|
|
|
|
|
|
|
List<HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem> out = |
|
|
|
|
|
|
|
new ArrayList<HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem>(); |
|
|
|
|
|
|
|
for (WarehouseAttachment att : cmd.attachments()) { |
|
|
|
|
|
|
|
out.add(toAttachItem(att, orderNo)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2) 平台面单快捷入口:与 attachments 可以同时给
|
|
|
|
String content = cmd.labelContentBase64(); |
|
|
|
String content = cmd.labelContentBase64(); |
|
|
|
if (content == null || content.trim().isEmpty()) { |
|
|
|
if (content == null || content.trim().isEmpty()) { |
|
|
|
if (cmd.labelMode() == LabelMode.PLATFORM_LABEL) { |
|
|
|
if (cmd.labelMode() == LabelMode.PLATFORM_LABEL) { |
|
|
|
@ -180,7 +197,7 @@ public final class HengjianOutboundMapper { |
|
|
|
"hengjian order " + orderNo |
|
|
|
"hengjian order " + orderNo |
|
|
|
+ ": labelContentBase64 is required when labelMode=PLATFORM_LABEL"); |
|
|
|
+ ": labelContentBase64 is required when labelMode=PLATFORM_LABEL"); |
|
|
|
} |
|
|
|
} |
|
|
|
return new ArrayList<HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem>(); |
|
|
|
return out; |
|
|
|
} |
|
|
|
} |
|
|
|
if (cmd.labelMode() != LabelMode.PLATFORM_LABEL) { |
|
|
|
if (cmd.labelMode() != LabelMode.PLATFORM_LABEL) { |
|
|
|
throw new IllegalArgumentException( |
|
|
|
throw new IllegalArgumentException( |
|
|
|
@ -196,10 +213,45 @@ public final class HengjianOutboundMapper { |
|
|
|
// 这里统一剥掉,避免把 "data:application/pdf;base64," 当成文件内容解出来
|
|
|
|
// 这里统一剥掉,避免把 "data:application/pdf;base64," 当成文件内容解出来
|
|
|
|
item.file = stripDataUri(content); |
|
|
|
item.file = stripDataUri(content); |
|
|
|
item.type = ATTACH_TYPE_SHIPPING_LABEL; |
|
|
|
item.type = ATTACH_TYPE_SHIPPING_LABEL; |
|
|
|
List<HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem> out = |
|
|
|
|
|
|
|
new ArrayList<HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem>(1); |
|
|
|
|
|
|
|
out.add(item); |
|
|
|
out.add(item); |
|
|
|
return Collections.unmodifiableList(out); |
|
|
|
return out; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 一个通用附件 → 恒健 {@code attachInfoItems} 元素。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>恒健要求 {@code url} 与 {@code file} 二选一、{@code name} 与 {@code type} 必填: |
|
|
|
|
|
|
|
* 缺了本地拒绝,不发出去被仓方挡回来。{@code type} 用仓方原值直传—— |
|
|
|
|
|
|
|
* 统一模型不归一附件分类(各仓口径不同)。</p> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem toAttachItem( |
|
|
|
|
|
|
|
WarehouseAttachment att, String orderNo) { |
|
|
|
|
|
|
|
String name = trimToNull(att.name()); |
|
|
|
|
|
|
|
String type = trimToNull(att.type()); |
|
|
|
|
|
|
|
String url = trimToNull(att.url()); |
|
|
|
|
|
|
|
String content = trimToNull(att.contentBase64()); |
|
|
|
|
|
|
|
if (name == null) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException( |
|
|
|
|
|
|
|
"hengjian order " + orderNo + ": attachment name is required"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (type == null) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException( |
|
|
|
|
|
|
|
"hengjian order " + orderNo + ": attachment type is required for " + name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (url == null && content == null) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException( |
|
|
|
|
|
|
|
"hengjian order " + orderNo + ": attachment " + name |
|
|
|
|
|
|
|
+ " needs url or contentBase64"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem item = |
|
|
|
|
|
|
|
new HengjianCreateOrderDtos.CreateOrderRequest.AttachInfoItem(); |
|
|
|
|
|
|
|
item.name = name; |
|
|
|
|
|
|
|
item.type = type; |
|
|
|
|
|
|
|
// file 优先于 url(仓方语义:给了 file 就忽略 url)
|
|
|
|
|
|
|
|
item.file = content == null ? null : stripDataUri(content); |
|
|
|
|
|
|
|
item.url = content == null ? url : null; |
|
|
|
|
|
|
|
item.remark = trimToNull(att.remark()); |
|
|
|
|
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 去掉 {@code data:xxx/base64,} 头;没有头时原样返回。 */ |
|
|
|
/** 去掉 {@code data:xxx/base64,} 头;没有头时原样返回。 */ |
|
|
|
|