fix(express): 视频号取号补 extend_props 空值保护并修正京东/小红书入参

- 视频号(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>
This commit is contained in:
liufumingren 2026-10-27 19:01:21 +08:00
parent c02f2f0d56
commit 8adede7ec7

View File

@ -827,6 +827,13 @@ class ExpressPlatformService extends MainService {
await this.cleanupFailedWaybillOrders(allFailedOrders, `字典接口失败: ${dictErrorMessage}`); await this.cleanupFailedWaybillOrders(allFailedOrders, `字典接口失败: ${dictErrorMessage}`);
throw new Error(`菠萝派字典接口返回错误: ${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); console.log('listByWarehousePlatformCode', listByWarehousePlatformCode);
const order_bizcontent = { const order_bizcontent = {
orders: orders.map(order_tmp => { orders: orders.map(order_tmp => {
@ -877,16 +884,16 @@ class ExpressPlatformService extends MainService {
ordertime: order.place_order_time || '', ordertime: order.place_order_time || '',
customername: '测试', customername: '测试',
ordersource: matchedPlatform.ordersource || '', ordersource: matchedPlatform.ordersource || '',
inputsite: order.sys_platform_code === 'XHS' ? '' : listByWarehousePlatformCode.site_code || '', inputsite: listByWarehousePlatformCode.site_code || '',
sitecode: listByWarehousePlatformCode.site_code || '', sitecode: listByWarehousePlatformCode.site_code || '',
shipperno: order.sys_platform_code === 'XHS' ? '' : listByWarehousePlatformCode.shipperno || '', shipperno: listByWarehousePlatformCode.shipperno || '',
customercode: order.sys_platform_code === 'XHS' ? '' : listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '', customercode: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.shipperno || '' : listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '',
sender: { sender: {
Company: listByWarehousePlatformCode.shop_name || '', Company: listByWarehousePlatformCode.shop_name || '',
name: listByWarehousePlatformCode.sender_name || '', name: listByWarehousePlatformCode.sender_name || '',
phone: order.sys_platform_code === 'XHS' ? undefined : listByWarehousePlatformCode.sender_tel || '', phone: order.sys_platform_code === 'XHS' ? undefined : listByWarehousePlatformCode.sender_tel || '',
mobile: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.sender_tel : undefined, mobile: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.sender_tel : undefined,
country: 'CN', country: '',
city: listByWarehousePlatformCode.city_name || '', city: listByWarehousePlatformCode.city_name || '',
province: listByWarehousePlatformCode.province_name || '', province: listByWarehousePlatformCode.province_name || '',
area: listByWarehousePlatformCode.district_name || '', area: listByWarehousePlatformCode.district_name || '',
@ -921,7 +928,11 @@ class ExpressPlatformService extends MainService {
}; };
console.log('matchedPlatform.platid', matchedPlatform.platid); console.log('matchedPlatform.platid', matchedPlatform.platid);
console.log('startPlayload', playload); console.log('startPlayload', playload);
if(playload.providercode === 'JD'){
playload.pickUpDate = pickUpDate;
playload.pickUpEndDate = pickUpEndDate;
playload.shipperno = listByWarehousePlatformCode.shipperno || '';
}
if (Number(matchedPlatform.platid) === 673) { if (Number(matchedPlatform.platid) === 673) {
playload.BizVersion = '2'; playload.BizVersion = '2';
playload.brandno = listByWarehousePlatformCode.brandno === 'SF' ? listByWarehousePlatformCode.brandno : undefined; 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); playload.object_Id = toUint64(order.warehouse_id, order.id, order_tmp.business_key);
if (!order.extend_props.ewaybill_order_code) { // extend_props 可能为 null,先做空值保护,避免直接抛 TypeError 掩盖业务错误
throw new Error('订单数据错误,参数不全缺失extend_props.ewaybill_order_code,请复制次信息给ERP方反馈'); 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.transtype = '0';
playload.Mallmaskid = order.buyer_nick; playload.Mallmaskid = order.buyer_nick;