fix(expressPlatform): 面单下单参数调整
- 菠萝派/淘宝面单 payload 字段调整:tid/transtype/mainsubpaymode 等按平台传参, 移除暂不使用的字段 - 菜鸟取号:oaid 超 128 位时转 caid 传递、tid 改用 pay_no; 调试输出改缓存(Cainiaoquery/Cainiaoresult)
This commit is contained in:
parent
29e7b6ae70
commit
9327611552
@ -707,45 +707,44 @@ class ExpressPlatformService extends MainService {
|
|||||||
object_Id: `${order.warehouse_id.toString(16)}_${order.id}_${order_tmp.business_key}`, // 菠萝派平台要求订单唯一标识必须为字符串
|
object_Id: `${order.warehouse_id.toString(16)}_${order.id}_${order_tmp.business_key}`, // 菠萝派平台要求订单唯一标识必须为字符串
|
||||||
orderno: `${order.warehouse_id.toString(16)}_${order.id}_${order_tmp.business_key}`, // 菠萝派平台要求订单号必须为字符串
|
orderno: `${order.warehouse_id.toString(16)}_${order.id}_${order_tmp.business_key}`, // 菠萝派平台要求订单号必须为字符串
|
||||||
plattradeno: listByWarehousePlatformCode.platform_code === 'DY' && order.from_key === 23060081 && !!order.pay_no ? order.pay_no : order.source_order_codes || order.delivery_order_code || '',
|
plattradeno: listByWarehousePlatformCode.platform_code === 'DY' && order.from_key === 23060081 && !!order.pay_no ? order.pay_no : order.source_order_codes || order.delivery_order_code || '',
|
||||||
ismultiplepieces: order.package_count > 1 ? 1 : 0,
|
tid:listByWarehousePlatformCode.platform_code === 'DY' && order.from_key === 23060081 && !!order.pay_no ? order.pay_no : order.source_order_codes || order.delivery_order_code || '',
|
||||||
logisticno: allocatedWaybillMap.get(`${Number(order.id) || 0}:${Number(order_tmp.business_key) || 0}`) || '',
|
//ismultiplepieces: order.package_count > 1 ? 1 : 0,
|
||||||
logistictype: order.logistics_code || '',
|
//logisticno: allocatedWaybillMap.get(`${Number(order.id) || 0}:${Number(order_tmp.business_key) || 0}`) || '',
|
||||||
|
logistictype: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
||||||
providercode: expressListItem[listByWarehousePlatformCode.platform_code] || order.logistics_code || '',
|
providercode: expressListItem[listByWarehousePlatformCode.platform_code] || order.logistics_code || '',
|
||||||
numpackage: order.package_count || 1,
|
numpackage: order.package_count || '1',
|
||||||
businessType: listByWarehousePlatformCode.product_type,
|
businesstype: listByWarehousePlatformCode.product_type,
|
||||||
|
transtype:'0',
|
||||||
|
transtypecode:'1',
|
||||||
|
mainsubpaymode:'1',
|
||||||
businessplat: order.sys_platform_code === 'KS' ? order.sys_platform_code : 'OTHERS',
|
businessplat: order.sys_platform_code === 'KS' ? order.sys_platform_code : 'OTHERS',
|
||||||
paymode: listByWarehousePlatformCode.paymode ?? 1,
|
paymode: listByWarehousePlatformCode.paymode.toString() ?? '1',
|
||||||
ordertype: listByWarehousePlatformCode.ordertype ?? 'JH_Normal',
|
ordertype: listByWarehousePlatformCode.ordertype ?? 'JH_Normal',
|
||||||
ProviderID: listByWarehousePlatformCode.providerid ?? '',
|
ProviderID:'',
|
||||||
procode: order.procode || '普通商品',
|
//procode: order.procode || '普通商品',
|
||||||
codpaymoney: order.ar_amount ?? null,
|
//codpaymoney: order.ar_amount ?? null,
|
||||||
packagemoney: order.item_amount ?? null,
|
//packagemoney: order.item_amount ?? null,
|
||||||
weight: Number(order.items_weight) || 0, // 单位 g,需确认 PolyAPI 期望单位
|
//weight: Number(order.items_weight) || 0, // 单位 g,需确认 PolyAPI 期望单位
|
||||||
supporpaymoney: order.total_amount ?? null,
|
//supporpaymoney: order.total_amount ?? null,
|
||||||
length: Number(order.length) || 0,
|
//ispickup: listByWarehousePlatformCode.ispickup ?? 0,
|
||||||
width: Number(order.width) || 0,
|
//ProductType: listByWarehousePlatformCode.product_type || '',
|
||||||
height: Number(order.height) || 0,
|
//Sipshopid: listByWarehousePlatformCode.platform_shop_id || '',
|
||||||
volume: Number(order.volume) || 0,
|
|
||||||
ispickup: listByWarehousePlatformCode.ispickup ?? 0,
|
|
||||||
ProductType: listByWarehousePlatformCode.product_type || '',
|
|
||||||
Sipshopid: listByWarehousePlatformCode.platform_shop_id || '',
|
|
||||||
oaid: order.oaid || '',
|
oaid: order.oaid || '',
|
||||||
sys_express_code: listByWarehousePlatformCode.sys_express_code || '',
|
|
||||||
platform_code: listByWarehousePlatformCode.platform_code || '',
|
|
||||||
cpcode: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
cpcode: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
||||||
logisticsproductname: 'JH_02',
|
logisticsproductname: 'JH_02',
|
||||||
dmssorting: 0,
|
//dmssorting: 0,
|
||||||
brandno: listByWarehousePlatformCode.brandno || null,
|
//brandno: listByWarehousePlatformCode.brandno || null,
|
||||||
needencrypt: 1,
|
needencrypt: 1,
|
||||||
|
customername:"测试",
|
||||||
ordersource: matchedPlatform.ordersource || '',
|
ordersource: matchedPlatform.ordersource || '',
|
||||||
inputsite: listByWarehousePlatformCode.site_code || '',
|
//inputsite: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.site_code || '',
|
||||||
sitecode: listByWarehousePlatformCode.site_code || '',
|
sitecode: listByWarehousePlatformCode.site_code || '',
|
||||||
shipperno: listByWarehousePlatformCode.shipperno || '',
|
shipperno: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.shipperno || '',
|
||||||
customercode: listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '',
|
customercode: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '',
|
||||||
sender: {
|
sender: {
|
||||||
company: listByWarehousePlatformCode.shop_name || '',
|
Company: listByWarehousePlatformCode.shop_name || '',
|
||||||
name: listByWarehousePlatformCode.sender_name || '',
|
name: listByWarehousePlatformCode.sender_name || '',
|
||||||
phone: 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: 'CN',
|
||||||
city: listByWarehousePlatformCode.city_name || '',
|
city: listByWarehousePlatformCode.city_name || '',
|
||||||
@ -771,21 +770,21 @@ class ExpressPlatformService extends MainService {
|
|||||||
},
|
},
|
||||||
goods: (order.orderItems && order.orderItems.map(item => ({
|
goods: (order.orderItems && order.orderItems.map(item => ({
|
||||||
productid: item.item_code,
|
productid: item.item_code,
|
||||||
cnname: item.item_name || '商品',
|
cnname: 'sp',
|
||||||
count: item.plan_qty || 0,
|
count: item.plan_qty || 0,
|
||||||
}))) || [],
|
}))) || [],
|
||||||
Mallmaskid: '',
|
//Mallmaskid: '',
|
||||||
|
|
||||||
template_url: listByWarehousePlatformCode.template_id || '',
|
template_url: listByWarehousePlatformCode.template_id || '',
|
||||||
labelformat: listByWarehousePlatformCode.labelformat || '',
|
//labelformat: listByWarehousePlatformCode.labelformat || '',
|
||||||
extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '',
|
//extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '',
|
||||||
};
|
};
|
||||||
console.log('matchedPlatform.platid', matchedPlatform.platid);
|
console.log('matchedPlatform.platid', matchedPlatform.platid);
|
||||||
console.log('startPlayload', playload);
|
console.log('startPlayload', playload);
|
||||||
|
|
||||||
if (Number(matchedPlatform.platid) === 673) {
|
if (Number(matchedPlatform.platid) === 673) {
|
||||||
playload.BizVersion = '2';
|
playload.BizVersion = '2';
|
||||||
playload.brandno = listByWarehousePlatformCode.brandno || '';
|
playload.brandno = listByWarehousePlatformCode.brandno === "SF" ? listByWarehousePlatformCode.brandno : undefined;
|
||||||
}
|
}
|
||||||
if (Number(matchedPlatform.platid) === 544) {
|
if (Number(matchedPlatform.platid) === 544) {
|
||||||
const {
|
const {
|
||||||
@ -898,7 +897,7 @@ class ExpressPlatformService extends MainService {
|
|||||||
playload.mainsubpaymode = '1';
|
playload.mainsubpaymode = '1';
|
||||||
delete playload.plattradeno;
|
delete playload.plattradeno;
|
||||||
}
|
}
|
||||||
playload.ProviderID = listByWarehousePlatformCode.providerid;
|
playload.ProviderID = listByWarehousePlatformCode.providerid || "";
|
||||||
console.log('playload', playload);
|
console.log('playload', playload);
|
||||||
return playload;
|
return playload;
|
||||||
}),
|
}),
|
||||||
@ -1105,7 +1104,7 @@ class ExpressPlatformService extends MainService {
|
|||||||
receivertel: '',
|
receivertel: '',
|
||||||
cargoname: '',
|
cargoname: '',
|
||||||
senddata: '',
|
senddata: '',
|
||||||
weight: '',
|
//weight: '',
|
||||||
eCustomerCode: '',
|
eCustomerCode: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
selleruserid: '',
|
selleruserid: '',
|
||||||
@ -1761,6 +1760,8 @@ class ExpressPlatformService extends MainService {
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
: [];
|
: [];
|
||||||
const recipientMobile = orderDelivery && (orderDelivery.mobile || orderDelivery.tel) || '';
|
const recipientMobile = orderDelivery && (orderDelivery.mobile || orderDelivery.tel) || '';
|
||||||
|
const orderDeliveryOaid = orderDelivery && orderDelivery.oaid ? String(orderDelivery.oaid).trim() : '';
|
||||||
|
const oaidTooLong = orderDeliveryOaid.length > 128;
|
||||||
|
|
||||||
const tradeOrderInfo = {
|
const tradeOrderInfo = {
|
||||||
logistics_services: normalizedExtData,
|
logistics_services: normalizedExtData,
|
||||||
@ -1797,10 +1798,10 @@ class ExpressPlatformService extends MainService {
|
|||||||
mobile: recipientMobile,
|
mobile: recipientMobile,
|
||||||
name: orderDelivery && orderDelivery.name || '',
|
name: orderDelivery && orderDelivery.name || '',
|
||||||
phone: recipientMobile,
|
phone: recipientMobile,
|
||||||
oaid: orderDelivery && orderDelivery.oaid || '',
|
oaid: oaidTooLong ? '' : orderDeliveryOaid,
|
||||||
tid: sourceOrderCodes[0] || '',
|
caid: oaidTooLong ? orderDeliveryOaid : '',
|
||||||
|
tid: orderDelivery.pay_no || '',
|
||||||
},
|
},
|
||||||
oaid: orderDelivery && orderDelivery.oaid || '',
|
|
||||||
user_id: listByWarehousePlatformCode.shop && listByWarehousePlatformCode.shop.owner_id || 0,
|
user_id: listByWarehousePlatformCode.shop && listByWarehousePlatformCode.shop.owner_id || 0,
|
||||||
notify_extend_info: normalizedExtData,
|
notify_extend_info: normalizedExtData,
|
||||||
};
|
};
|
||||||
@ -1842,7 +1843,8 @@ class ExpressPlatformService extends MainService {
|
|||||||
shipping_branch_code: String(listByWarehousePlatformCode.site_code || '').trim(),
|
shipping_branch_code: String(listByWarehousePlatformCode.site_code || '').trim(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
console.log('cainiaoPayload', JSON.stringify(cainiaoPayload));
|
|
||||||
|
await this.app.setCacheAsync('Cainiaoquery', JSON.stringify(cainiaoPayload), 3600);
|
||||||
const requestParams = {
|
const requestParams = {
|
||||||
method: 'cainiao.waybill.ii.get',
|
method: 'cainiao.waybill.ii.get',
|
||||||
app_key: appKey,
|
app_key: appKey,
|
||||||
@ -1865,7 +1867,7 @@ class ExpressPlatformService extends MainService {
|
|||||||
sign,
|
sign,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log('菜鸟取号返回数据', JSON.stringify(response));
|
await this.app.setCacheAsync('Cainiaoresult', JSON.stringify(response), 3600);
|
||||||
|
|
||||||
const responseData = response && Object.prototype.hasOwnProperty.call(response, 'data')
|
const responseData = response && Object.prototype.hasOwnProperty.call(response, 'data')
|
||||||
? response.data
|
? response.data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user