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.
58 lines
2.4 KiB
58 lines
2.4 KiB
|
2 weeks ago
|
package common.ecommerce.xincang.adapter;
|
||
|
|
|
||
|
|
import common.ecommerce.warehouse.enums.TransferStatus;
|
||
|
|
import common.ecommerce.warehouse.enums.TransferType;
|
||
|
|
import common.ecommerce.warehouse.enums.WarehouseProvider;
|
||
|
|
import common.ecommerce.warehouse.model.TransferOrder;
|
||
|
|
import common.ecommerce.xincang.dto.XincangDtos;
|
||
|
|
import common.ecommerce.xincang.enums.XincangTransferState;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 信仓转运详情报文 → 统一模型({@code GET fba.fba_detail})。
|
||
|
|
*
|
||
|
|
* <p>信仓的转运 = 从信仓发往平台仓,统一模型里固定为 {@link TransferType#OUTBOUND}。</p>
|
||
|
|
*/
|
||
|
|
public final class XincangTransferDetailMapper {
|
||
|
|
|
||
|
|
private XincangTransferDetailMapper() {
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 转运详情 → {@link TransferOrder}。
|
||
|
|
*
|
||
|
|
* @param detail 详情;调用方保证非 null
|
||
|
|
*/
|
||
|
|
public static TransferOrder toOrder(XincangDtos.TransferDetail detail) {
|
||
|
|
TransferStatus status = XincangTransferState.toCore(detail.state);
|
||
|
|
return TransferOrder.builder()
|
||
|
|
// 双号:fba_no 是业务侧单号,order_no 是仓侧单号
|
||
|
|
.transferRequestNo(XincangOrderDetailMapper.firstNonBlank(
|
||
|
|
detail.fbaNo, detail.orderNo))
|
||
|
|
.providerTransferNo(XincangOrderDetailMapper.blankToNull(detail.orderNo))
|
||
|
|
.fromWarehouseCode(XincangOrderDetailMapper.blankToNull(detail.fromWarehouseName))
|
||
|
|
.toWarehouseCode(XincangOrderDetailMapper.blankToNull(detail.destWarehouseName))
|
||
|
|
.type(TransferType.OUTBOUND)
|
||
|
|
.status(status)
|
||
|
|
.rawStatus(detail.state)
|
||
|
|
.sourceProvider(WarehouseProvider.XINCANG)
|
||
|
|
.totalQuantity(totalQuantityOf(detail))
|
||
|
|
.estimatedOutboundAt(XincangOrderDetailMapper.parseDate(detail.preSendTime))
|
||
|
|
.remark(XincangOrderDetailMapper.blankToNull(detail.remark))
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 明细件数合计;明细缺失时返回 0(未知,不猜)。 */
|
||
|
|
static int totalQuantityOf(XincangDtos.TransferDetail detail) {
|
||
|
|
if (detail.products == null || detail.products.isEmpty()) {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
int total = 0;
|
||
|
|
for (XincangDtos.TransferDetailProduct product : detail.products) {
|
||
|
|
if (product != null) {
|
||
|
|
total += XincangOrderDetailMapper.parsePositiveInt(product.skuCount);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return total;
|
||
|
|
}
|
||
|
|
}
|