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.
71 lines
2.6 KiB
71 lines
2.6 KiB
|
5 days ago
|
package common.ecommerce.edayun.adapter;
|
||
|
|
|
||
|
|
import common.ecommerce.edayun.dto.EdayunBolDtos;
|
||
|
|
import common.ecommerce.warehouse.model.BolDocument;
|
||
|
|
|
||
|
|
import java.time.Instant;
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.Collections;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 易达云 BOL 映射({@code POST /webApi/fbaOrder/v1/getOrderBolList})。
|
||
|
|
*
|
||
|
|
* <p>只是字段搬运 + 时间戳转换;状态码表只有 {@code 11=已妥投} 确认,
|
||
|
|
* 其余靠 {@code statusName} 中文名兜底。</p>
|
||
|
|
*/
|
||
|
|
public final class EdayunBolMapper {
|
||
|
|
|
||
|
|
private EdayunBolMapper() {
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 查询请求。 */
|
||
|
|
public static EdayunBolDtos.GetBolRequest toRequest(String orderNo) {
|
||
|
|
if (orderNo == null || orderNo.trim().isEmpty()) {
|
||
|
|
throw new IllegalArgumentException("edayun needs an orderNo to query BOL list");
|
||
|
|
}
|
||
|
|
EdayunBolDtos.GetBolRequest req = new EdayunBolDtos.GetBolRequest();
|
||
|
|
req.orderNo = orderNo.trim();
|
||
|
|
return req;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 响应 → BOL 列表;没有 BOL 时返回空列表。 */
|
||
|
|
public static List<BolDocument> toDocuments(EdayunBolDtos.GetBolResponse response) {
|
||
|
|
if (response == null || response.data == null
|
||
|
|
|| response.data.bolList == null || response.data.bolList.isEmpty()) {
|
||
|
|
return Collections.emptyList();
|
||
|
|
}
|
||
|
|
List<BolDocument> out = new ArrayList<BolDocument>(response.data.bolList.size());
|
||
|
|
for (EdayunBolDtos.Bol bol : response.data.bolList) {
|
||
|
|
if (bol != null && bol.bolCode != null && !bol.bolCode.trim().isEmpty()) {
|
||
|
|
out.add(toDocument(bol));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return out;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 一张 BOL → 统一单据。 */
|
||
|
|
static BolDocument toDocument(EdayunBolDtos.Bol bol) {
|
||
|
|
return BolDocument.builder()
|
||
|
|
.bolCode(bol.bolCode.trim())
|
||
|
|
.fileUrl(bol.bolFileUrl)
|
||
|
|
.signedFileUrl(bol.signBolFileUrl)
|
||
|
|
.podFileUrl(bol.podFileUrl)
|
||
|
|
.podUploadedAt(instantOf(bol.podFileTime))
|
||
|
|
.rawStatus(bol.status)
|
||
|
|
.statusName(bol.statusName)
|
||
|
|
.scheduledPickupDate(bol.pickupTime)
|
||
|
|
.actualPickupDate(bol.actualPickupTime)
|
||
|
|
.scheduledPickupQuantity(bol.orderPickupNum)
|
||
|
|
.actualPickupQuantity(bol.actualPickupNum)
|
||
|
|
.truckCompany(bol.truckCompany)
|
||
|
|
.trackingNo(bol.trackingNo)
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 毫秒时间戳 → Instant;0 与 null 都当未给。 */
|
||
|
|
static Instant instantOf(Long millis) {
|
||
|
|
return millis == null || millis <= 0 ? null : Instant.ofEpochMilli(millis);
|
||
|
|
}
|
||
|
|
}
|