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;