|
|
|
@ -29,6 +29,9 @@ import java.util.Map; |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>签收时间优先用带时区的 {@code received_date},其次 {@code received_date_locale}, |
|
|
|
* <p>签收时间优先用带时区的 {@code received_date},其次 {@code received_date_locale}, |
|
|
|
* 最后退回秒级时间戳;三者都没有时保留 null。</p> |
|
|
|
* 最后退回秒级时间戳;三者都没有时保留 null。</p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p><b>待核对</b>:{@code event_date} 的 {@code yyyy-MM-dd}、{@code sid} 为数值、 |
|
|
|
|
|
|
|
* {@code fba_shipment_id} 为字符串数组,均按官方文档拼接,首次真实调用需确认。</p> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final class FbaReceivedInventorySource implements LingxingInboundReceiptSource { |
|
|
|
public final class FbaReceivedInventorySource implements LingxingInboundReceiptSource { |
|
|
|
|
|
|
|
|
|
|
|
@ -39,11 +42,14 @@ public final class FbaReceivedInventorySource implements LingxingInboundReceiptS |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Page<InboundReceipt> receipts(LingxingCall call, InboundReceiptQuery query) { |
|
|
|
public Page<InboundReceipt> receipts(LingxingCall call, InboundReceiptQuery query) { |
|
|
|
|
|
|
|
// 该接口默认 length=1000 且没有更小的推荐值;再大平台也不接受。
|
|
|
|
int length = query.pageSize() <= 0 ? DEFAULT_PAGE_SIZE |
|
|
|
int length = query.pageSize() <= 0 ? DEFAULT_PAGE_SIZE |
|
|
|
: Math.min(query.pageSize(), MAX_PAGE_SIZE); |
|
|
|
: Math.min(query.pageSize(), MAX_PAGE_SIZE); |
|
|
|
|
|
|
|
// 游标是上一页返回的 offset,首页为 0。
|
|
|
|
int offset = query.cursor() == null ? 0 : Integer.parseInt(query.cursor()); |
|
|
|
int offset = query.cursor() == null ? 0 : Integer.parseInt(query.cursor()); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> body = new LinkedHashMap<String, Object>(); |
|
|
|
Map<String, Object> body = new LinkedHashMap<String, Object>(); |
|
|
|
|
|
|
|
// sid 必填:查询条件没给时用账户的 externalStoreId,绝不省略成「全店铺」。
|
|
|
|
body.put("sid", resolveSid(call, query)); |
|
|
|
body.put("sid", resolveSid(call, query)); |
|
|
|
body.put("offset", offset); |
|
|
|
body.put("offset", offset); |
|
|
|
body.put("length", length); |
|
|
|
body.put("length", length); |
|
|
|
@ -69,6 +75,7 @@ public final class FbaReceivedInventorySource implements LingxingInboundReceiptS |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int nextOffset = offset + dtos.size(); |
|
|
|
int nextOffset = offset + dtos.size(); |
|
|
|
|
|
|
|
// 顶层 total 缺失时退化为「满页即还有下一页」。
|
|
|
|
boolean hasMore = dtos.size() >= length |
|
|
|
boolean hasMore = dtos.size() >= length |
|
|
|
&& (envelope.total() < 0 || nextOffset < envelope.total()); |
|
|
|
&& (envelope.total() < 0 || nextOffset < envelope.total()); |
|
|
|
return Page.of(out, hasMore ? String.valueOf(nextOffset) : null); |
|
|
|
return Page.of(out, hasMore ? String.valueOf(nextOffset) : null); |
|
|
|
@ -98,6 +105,7 @@ public final class FbaReceivedInventorySource implements LingxingInboundReceiptS |
|
|
|
.fnsku(InboundSupport.trimToNull(dto.getFnsku())) |
|
|
|
.fnsku(InboundSupport.trimToNull(dto.getFnsku())) |
|
|
|
.sku(InboundSupport.trimToNull(dto.getSku())) |
|
|
|
.sku(InboundSupport.trimToNull(dto.getSku())) |
|
|
|
.productName(InboundSupport.trimToNull(dto.getProductName())) |
|
|
|
.productName(InboundSupport.trimToNull(dto.getProductName())) |
|
|
|
|
|
|
|
// 领星可能返回负数(库存分类账调整行),原样保留,不做 abs / 归零。
|
|
|
|
.quantity(InboundSupport.intOrZero(dto.getQuantity())) |
|
|
|
.quantity(InboundSupport.intOrZero(dto.getQuantity())) |
|
|
|
.fulfillmentCenterId(InboundSupport.trimToNull(dto.getFulfillmentCenterId())) |
|
|
|
.fulfillmentCenterId(InboundSupport.trimToNull(dto.getFulfillmentCenterId())) |
|
|
|
.receivedAt(receivedAt(dto, zone)) |
|
|
|
.receivedAt(receivedAt(dto, zone)) |
|
|
|
@ -108,6 +116,8 @@ public final class FbaReceivedInventorySource implements LingxingInboundReceiptS |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static PlatformTime receivedAt(FbaReceivedInventoryDto dto, ZoneId zone) { |
|
|
|
private static PlatformTime receivedAt(FbaReceivedInventoryDto dto, ZoneId zone) { |
|
|
|
|
|
|
|
// 优先级:带偏移的 received_date → 本地时区的 received_date_locale → 秒级时间戳。
|
|
|
|
|
|
|
|
// 前两个都按 ISO 解析,只有日期时按北京时间当天 0 点处理。
|
|
|
|
Instant instant = InboundSupport.parseIso(dto.getReceivedDate()); |
|
|
|
Instant instant = InboundSupport.parseIso(dto.getReceivedDate()); |
|
|
|
if (instant == null) { |
|
|
|
if (instant == null) { |
|
|
|
instant = InboundSupport.parseIso(dto.getReceivedDateLocale()); |
|
|
|
instant = InboundSupport.parseIso(dto.getReceivedDateLocale()); |
|
|
|
|