feat: Orders 加 10 地址/店铺字段 + labelPdfUrl(SDS/RIIN mapper+db)
This commit is contained in:
+29
-2
@@ -128,6 +128,9 @@ class OrderUpsertInput:
|
||||
"merchantId", "countryRegion", "factoryName", "systemName", "systemStatus",
|
||||
"platformName", "platformStatus", "createdAt", "orderedAt", "confirmedAt",
|
||||
"completedAt", "shipDeadline",
|
||||
"consigneeName", "destinationCountry", "stateProvince", "city",
|
||||
"addressLine1", "addressLine2", "addressLine3", "postalCode", "storeName",
|
||||
"labelPdfUrl",
|
||||
)
|
||||
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
@@ -183,6 +186,16 @@ def map_riin_order(raw: Any) -> OrderUpsertInput:
|
||||
confirmedAt=confirmed_at,
|
||||
completedAt=completed_at,
|
||||
shipDeadline=ship_deadline,
|
||||
consigneeName=raw.consignee_name,
|
||||
destinationCountry=raw.receiver_country,
|
||||
stateProvince=raw.receiver_province,
|
||||
city=raw.receiver_city,
|
||||
addressLine1=raw.address,
|
||||
addressLine2=raw.receiver_district,
|
||||
addressLine3=raw.receiver_town,
|
||||
postalCode=raw.post_code,
|
||||
storeName=raw.platform_shop_name,
|
||||
labelPdfUrl=None,
|
||||
)
|
||||
|
||||
|
||||
@@ -234,12 +247,15 @@ def map_sds_order(raw: Any, channel_type_map: dict[int, str | None], pre_courier
|
||||
courier_source = channel_type_map[lid]
|
||||
|
||||
courier_no: str | None = None
|
||||
label_pdf_url: str | None = None
|
||||
if raw.parcel_list:
|
||||
first = raw.parcel_list[0]
|
||||
try:
|
||||
courier_no = first["logistics"]["carriage"]["no"]
|
||||
carriage = first["logistics"]["carriage"]
|
||||
courier_no = carriage.get("no")
|
||||
label_pdf_url = carriage.get("laberPdf") or carriage.get("labelPdf")
|
||||
except (TypeError, KeyError, IndexError):
|
||||
courier_no = None
|
||||
pass
|
||||
|
||||
factory_name: str | None = None
|
||||
for item in raw.items or []:
|
||||
@@ -251,6 +267,7 @@ def map_sds_order(raw: Any, channel_type_map: dict[int, str | None], pre_courier
|
||||
|
||||
confirmed_at = _parse(getattr(raw, "gmt_confirm_time", None), f"SDS order {raw.no} gmtConfirmTime")
|
||||
area_name = raw.issuing_bay_area.name if raw.issuing_bay_area else None
|
||||
addr = raw.address
|
||||
return OrderUpsertInput(
|
||||
orderNo=raw.no,
|
||||
outOrderNo=raw.out_order_no,
|
||||
@@ -269,6 +286,16 @@ def map_sds_order(raw: Any, channel_type_map: dict[int, str | None], pre_courier
|
||||
confirmedAt=confirmed_at,
|
||||
completedAt=completed_at,
|
||||
shipDeadline=ship_deadline,
|
||||
consigneeName=addr.consignee if addr else None,
|
||||
destinationCountry=addr.country if addr else None,
|
||||
stateProvince=addr.province if addr else None,
|
||||
city=addr.city if addr else None,
|
||||
addressLine1=addr.address_detail1 if addr else None,
|
||||
addressLine2=addr.address_detail2 if addr else None,
|
||||
addressLine3=addr.address_detail3 if addr else None,
|
||||
postalCode=addr.postcode if addr else None,
|
||||
storeName=raw.merchant_store.name if raw.merchant_store else None,
|
||||
labelPdfUrl=label_pdf_url,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user