From 8adede7ec7ab66d4a8a755cdc720292e64992d6c Mon Sep 17 00:00:00 2001 From: liufumingren Date: Tue, 27 Oct 2026 19:01:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(express):=20=E8=A7=86=E9=A2=91=E5=8F=B7?= =?UTF-8?q?=E5=8F=96=E5=8F=B7=E8=A1=A5=20extend=5Fprops=20=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E4=BF=9D=E6=8A=A4=E5=B9=B6=E4=BF=AE=E6=AD=A3=E4=BA=AC?= =?UTF-8?q?=E4=B8=9C/=E5=B0=8F=E7=BA=A2=E4=B9=A6=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 视频号(platid 672)取号前判空 extend_props,避免 null 直接抛 TypeError 掩盖真实业务错误 - JD 取号补充 pickUpDate / pickUpEndDate / shipperno - XHS 透传 site_code / shipperno,sender.country 置空以适配菠萝派要求 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- app/service/systems/express_platform.js | 29 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/app/service/systems/express_platform.js b/app/service/systems/express_platform.js index 3312066..8622428 100644 --- a/app/service/systems/express_platform.js +++ b/app/service/systems/express_platform.js @@ -827,6 +827,13 @@ class ExpressPlatformService extends MainService { await this.cleanupFailedWaybillOrders(allFailedOrders, `字典接口失败: ${dictErrorMessage}`); throw new Error(`菠萝派字典接口返回错误: ${dictErrorMessage}`); } + const last3day = new Date(); + last3day.setDate(last3day.getDate() + 3); + const pickUpDate = this.app.formatDate(last3day); + const last4day = new Date(); + last4day.setDate(last4day.getDate() + 4); + const pickUpEndDate = this.app.formatDate(last4day); + console.log('listByWarehousePlatformCode', listByWarehousePlatformCode); const order_bizcontent = { orders: orders.map(order_tmp => { @@ -877,16 +884,16 @@ class ExpressPlatformService extends MainService { ordertime: order.place_order_time || '', customername: '测试', ordersource: matchedPlatform.ordersource || '', - inputsite: order.sys_platform_code === 'XHS' ? '' : listByWarehousePlatformCode.site_code || '', + inputsite: listByWarehousePlatformCode.site_code || '', sitecode: listByWarehousePlatformCode.site_code || '', - shipperno: order.sys_platform_code === 'XHS' ? '' : listByWarehousePlatformCode.shipperno || '', - customercode: order.sys_platform_code === 'XHS' ? '' : listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '', + shipperno: listByWarehousePlatformCode.shipperno || '', + customercode: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.shipperno || '' : listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '', sender: { Company: listByWarehousePlatformCode.shop_name || '', name: listByWarehousePlatformCode.sender_name || '', phone: order.sys_platform_code === 'XHS' ? undefined : listByWarehousePlatformCode.sender_tel || '', mobile: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.sender_tel : undefined, - country: 'CN', + country: '', city: listByWarehousePlatformCode.city_name || '', province: listByWarehousePlatformCode.province_name || '', area: listByWarehousePlatformCode.district_name || '', @@ -921,7 +928,11 @@ class ExpressPlatformService extends MainService { }; console.log('matchedPlatform.platid', matchedPlatform.platid); console.log('startPlayload', playload); - + if(playload.providercode === 'JD'){ + playload.pickUpDate = pickUpDate; + playload.pickUpEndDate = pickUpEndDate; + playload.shipperno = listByWarehousePlatformCode.shipperno || ''; + } if (Number(matchedPlatform.platid) === 673) { playload.BizVersion = '2'; playload.brandno = listByWarehousePlatformCode.brandno === 'SF' ? listByWarehousePlatformCode.brandno : undefined; @@ -1030,10 +1041,12 @@ class ExpressPlatformService extends MainService { } */ playload.object_Id = toUint64(order.warehouse_id, order.id, order_tmp.business_key); - if (!order.extend_props.ewaybill_order_code) { - throw new Error('订单数据错误,参数不全缺失extend_props.ewaybill_order_code,请复制次信息给ERP方反馈'); + // extend_props 可能为 null,先做空值保护,避免直接抛 TypeError 掩盖业务错误 + const ewaybillOrderCode = order.extend_props && order.extend_props.ewaybill_order_code; + if (!ewaybillOrderCode) { + throw new Error('订单数据错误,参数不全缺失extend_props.ewaybill_order_code,请核实非手工单(视频号手工单分配不了运单号),复制次信息给ERP方反馈'); } - playload.oaid = order.extend_props.ewaybill_order_code || order.oaid || undefined; + playload.oaid = ewaybillOrderCode; playload.transtype = '0'; playload.Mallmaskid = order.buyer_nick;