|
|
|
@ -17,6 +17,7 @@ import common.ecommerce.warehouse.enums.WarehouseProvider; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.Instant; |
|
|
|
import java.time.Instant; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.ZoneId; |
|
|
|
|
|
|
|
import java.time.ZoneOffset; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeParseException; |
|
|
|
import java.time.format.DateTimeParseException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
@ -37,7 +38,13 @@ public final class YqnOutboundMapper { |
|
|
|
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
|
|
|
|
/** 运去哪时间按仓所在地解释;账户未配时回退北京时区。 */ |
|
|
|
/** 运去哪时间按仓所在地解释;账户未配时回退北京时区。 */ |
|
|
|
private static final ZoneId DEFAULT_ZONE = ZoneId.of("Asia/Shanghai"); |
|
|
|
/** |
|
|
|
|
|
|
|
* 兜底时区。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>只在调用方没传 zone 时使用;按 UTC 解释,<b>不猜成北京时间</b>。 |
|
|
|
|
|
|
|
* 正常路径应当由 OMS 经 {@code WarehouseConnection.zone()} 显式指定。</p> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static final ZoneId DEFAULT_ZONE = ZoneOffset.UTC; |
|
|
|
|
|
|
|
|
|
|
|
/** 附件类型:0 面单 / 1 装箱单 / 2 BOL / 3 其他 / 4 箱标 / 5 托盘标 / 6 商品标 / 7 发票 / 8 发货计划。 */ |
|
|
|
/** 附件类型:0 面单 / 1 装箱单 / 2 BOL / 3 其他 / 4 箱标 / 5 托盘标 / 6 商品标 / 7 发票 / 8 发货计划。 */ |
|
|
|
private static final int ATTACH_TYPE_SHIPPING_LABEL = 0; |
|
|
|
private static final int ATTACH_TYPE_SHIPPING_LABEL = 0; |
|
|
|
@ -50,6 +57,14 @@ public final class YqnOutboundMapper { |
|
|
|
|
|
|
|
|
|
|
|
/** 统一命令 → 运去哪创建销售订单请求(API 123)。 */ |
|
|
|
/** 统一命令 → 运去哪创建销售订单请求(API 123)。 */ |
|
|
|
public static YqnCreateOrderDtos.CreateOrderRequest toRequest(OutboundCommand cmd, String warehouseCode) { |
|
|
|
public static YqnCreateOrderDtos.CreateOrderRequest toRequest(OutboundCommand cmd, String warehouseCode) { |
|
|
|
|
|
|
|
return toRequest(cmd, warehouseCode, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param zone 下发时间时使用的时区(仓所在地);null 按 UTC |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static YqnCreateOrderDtos.CreateOrderRequest toRequest(OutboundCommand cmd, String warehouseCode, |
|
|
|
|
|
|
|
ZoneId zone) { |
|
|
|
YqnCreateOrderDtos.CreateOrderRequest req = new YqnCreateOrderDtos.CreateOrderRequest(); |
|
|
|
YqnCreateOrderDtos.CreateOrderRequest req = new YqnCreateOrderDtos.CreateOrderRequest(); |
|
|
|
req.orderNo = cmd.outboundRequestNo(); |
|
|
|
req.orderNo = cmd.outboundRequestNo(); |
|
|
|
req.poNumber = cmd.orderRef(); |
|
|
|
req.poNumber = cmd.orderRef(); |
|
|
|
@ -58,8 +73,8 @@ public final class YqnOutboundMapper { |
|
|
|
req.carrierCode = cmd.carrierCode(); |
|
|
|
req.carrierCode = cmd.carrierCode(); |
|
|
|
req.currency = cmd.currency() == null ? DEFAULT_CURRENCY : cmd.currency(); |
|
|
|
req.currency = cmd.currency() == null ? DEFAULT_CURRENCY : cmd.currency(); |
|
|
|
req.shipServiceLevel = cmd.shipServiceLevel(); |
|
|
|
req.shipServiceLevel = cmd.shipServiceLevel(); |
|
|
|
req.latestShipDate = formatTime(cmd.latestShipDate()); |
|
|
|
req.latestShipDate = formatTime(cmd.latestShipDate(), zone); |
|
|
|
req.estimatedDeliveryTime = formatTime(cmd.estimatedDeliveryTime()); |
|
|
|
req.estimatedDeliveryTime = formatTime(cmd.estimatedDeliveryTime(), zone); |
|
|
|
req.salesPlatform = salesPlatformOf(cmd.salesPlatform()); |
|
|
|
req.salesPlatform = salesPlatformOf(cmd.salesPlatform()); |
|
|
|
req.remark = cmd.remark(); |
|
|
|
req.remark = cmd.remark(); |
|
|
|
// 店铺:仓方按店铺做路由/计费;标准模型对应 shopName
|
|
|
|
// 店铺:仓方按店铺做路由/计费;标准模型对应 shopName
|
|
|
|
@ -130,7 +145,11 @@ public final class YqnOutboundMapper { |
|
|
|
item.lineNo = line.lineNo(); |
|
|
|
item.lineNo = line.lineNo(); |
|
|
|
Money value = line.declareValue(); |
|
|
|
Money value = line.declareValue(); |
|
|
|
if (value != null) { |
|
|
|
if (value != null) { |
|
|
|
item.skuAmount = value.amount().doubleValue(); |
|
|
|
// 运去哪的 skuAmount 是「当前 SKU 总金额」,不是单价:
|
|
|
|
|
|
|
|
// 必须乘以行数量,否则整单申报额少算 quantity 倍
|
|
|
|
|
|
|
|
item.skuAmount = value.amount() |
|
|
|
|
|
|
|
.multiply(java.math.BigDecimal.valueOf(line.quantity())) |
|
|
|
|
|
|
|
.doubleValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
items.add(item); |
|
|
|
items.add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -243,9 +262,17 @@ public final class YqnOutboundMapper { |
|
|
|
return slash < 0 || slash == mime.length() - 1 ? null : mime.substring(slash + 1); |
|
|
|
return slash < 0 || slash == mime.length() - 1 ? null : mime.substring(slash + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 运去哪时间格式 {@code yyyy-MM-dd HH:mm:ss}。 */ |
|
|
|
/** 运去哪时间格式 {@code yyyy-MM-dd HH:mm:ss};按 UTC 输出。 */ |
|
|
|
static String formatTime(Instant instant) { |
|
|
|
static String formatTime(Instant instant) { |
|
|
|
return instant == null ? null : TIME_FORMAT.format(instant.atZone(DEFAULT_ZONE)); |
|
|
|
return formatTime(instant, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 按指定时区格式化下发时间;{@code zone} 为 null 时按 UTC。 */ |
|
|
|
|
|
|
|
static String formatTime(Instant instant, ZoneId zone) { |
|
|
|
|
|
|
|
if (instant == null) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return TIME_FORMAT.format(instant.atZone(zone == null ? DEFAULT_ZONE : zone)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 订单详情 → 统一出库单(API 128)。 */ |
|
|
|
/** 订单详情 → 统一出库单(API 128)。 */ |
|
|
|
|