wechatMp增加了两个物流相关的接口
This commit is contained in:
parent
6438399c2e
commit
4d8b864734
|
|
@ -28,6 +28,30 @@ type MpServeMessageOption = {
|
|||
};
|
||||
type MediaType = 'image' | 'voice' | 'video' | 'thumb';
|
||||
type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption | MpServeMessageOption | ImageServeMessageOption;
|
||||
type UploadShippingInfo = {
|
||||
order_key: {
|
||||
order_number_type: 1 | 2;
|
||||
transaction_id?: string;
|
||||
mchid?: string;
|
||||
out_trade_no?: string;
|
||||
};
|
||||
logistic_type: 1 | 2 | 3 | 4;
|
||||
delivery_mode: 1 | 2;
|
||||
is_all_delivered?: boolean;
|
||||
shipping_list: Array<{
|
||||
tracking_no?: string;
|
||||
express_company?: string;
|
||||
item_desc: string;
|
||||
contact?: {
|
||||
consignor_contact?: string;
|
||||
receiver_contact?: string;
|
||||
};
|
||||
upload_time: string;
|
||||
payer: {
|
||||
openid: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
export declare class WechatMpInstance {
|
||||
appId: string;
|
||||
appSecret?: string;
|
||||
|
|
@ -112,5 +136,41 @@ export declare class WechatMpInstance {
|
|||
expiresAt?: number;
|
||||
expireInterval?: number;
|
||||
}): Promise<any>;
|
||||
/**
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
|
||||
* 发货信息录入
|
||||
*/
|
||||
uploadShippingInfo(info: UploadShippingInfo): Promise<any>;
|
||||
/**
|
||||
* 查询订单的发货状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%89%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%8F%91%E8%B4%A7%E7%8A%B6%E6%80%81
|
||||
* @param info
|
||||
*/
|
||||
getOrderState(info: {
|
||||
transaction_id?: string;
|
||||
merchant_id?: string;
|
||||
sub_merchant_id?: string;
|
||||
merchant_trade_no?: string;
|
||||
}): Promise<{
|
||||
orderState: number;
|
||||
inComplaint: boolean;
|
||||
shipping: {
|
||||
delevery_mode: 1 | 2;
|
||||
logistics_type: 1 | 2 | 3 | 4;
|
||||
finish_shipping: boolean;
|
||||
goods_desc?: string | undefined;
|
||||
finish_shipping_count: 0 | 1 | 2;
|
||||
shipping_list: Array<{
|
||||
tracking_no?: string;
|
||||
express_company?: string;
|
||||
goods_desc: string;
|
||||
upload_time?: number;
|
||||
contact?: {
|
||||
consignor_contact?: string;
|
||||
receiver_contact?: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -339,4 +339,41 @@ export class WechatMpInstance {
|
|||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
|
||||
* 发货信息录入
|
||||
*/
|
||||
async uploadShippingInfo(info) {
|
||||
// 检查一下数据
|
||||
const { order_number_type, transaction_id, mchid, out_trade_no } = info.order_key;
|
||||
assert(order_number_type === 1 && mchid && out_trade_no || order_number_type === 2 && transaction_id);
|
||||
const { delivery_mode, is_all_delivered, shipping_list } = info;
|
||||
assert(delivery_mode === 1 || typeof is_all_delivered === 'boolean');
|
||||
assert(shipping_list.length > 0 && shipping_list.length <= 10);
|
||||
const token = this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(info),
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 查询订单的发货状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%89%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%8F%91%E8%B4%A7%E7%8A%B6%E6%80%81
|
||||
* @param info
|
||||
*/
|
||||
async getOrderState(info) {
|
||||
const token = this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/wxa/sec/order/get_order?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(info),
|
||||
});
|
||||
const { order } = result;
|
||||
const { order_state, in_complaint, shipping } = order;
|
||||
return {
|
||||
orderState: order_state,
|
||||
inComplaint: in_complaint,
|
||||
shipping: shipping
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,30 @@ type MpServeMessageOption = {
|
|||
};
|
||||
type MediaType = 'image' | 'voice' | 'video' | 'thumb';
|
||||
type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption | MpServeMessageOption | ImageServeMessageOption;
|
||||
type UploadShippingInfo = {
|
||||
order_key: {
|
||||
order_number_type: 1 | 2;
|
||||
transaction_id?: string;
|
||||
mchid?: string;
|
||||
out_trade_no?: string;
|
||||
};
|
||||
logistic_type: 1 | 2 | 3 | 4;
|
||||
delivery_mode: 1 | 2;
|
||||
is_all_delivered?: boolean;
|
||||
shipping_list: Array<{
|
||||
tracking_no?: string;
|
||||
express_company?: string;
|
||||
item_desc: string;
|
||||
contact?: {
|
||||
consignor_contact?: string;
|
||||
receiver_contact?: string;
|
||||
};
|
||||
upload_time: string;
|
||||
payer: {
|
||||
openid: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
export declare class WechatMpInstance {
|
||||
appId: string;
|
||||
appSecret?: string;
|
||||
|
|
@ -112,5 +136,41 @@ export declare class WechatMpInstance {
|
|||
expiresAt?: number;
|
||||
expireInterval?: number;
|
||||
}): Promise<any>;
|
||||
/**
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
|
||||
* 发货信息录入
|
||||
*/
|
||||
uploadShippingInfo(info: UploadShippingInfo): Promise<any>;
|
||||
/**
|
||||
* 查询订单的发货状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%89%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%8F%91%E8%B4%A7%E7%8A%B6%E6%80%81
|
||||
* @param info
|
||||
*/
|
||||
getOrderState(info: {
|
||||
transaction_id?: string;
|
||||
merchant_id?: string;
|
||||
sub_merchant_id?: string;
|
||||
merchant_trade_no?: string;
|
||||
}): Promise<{
|
||||
orderState: number;
|
||||
inComplaint: boolean;
|
||||
shipping: {
|
||||
delevery_mode: 1 | 2;
|
||||
logistics_type: 1 | 2 | 3 | 4;
|
||||
finish_shipping: boolean;
|
||||
goods_desc?: string | undefined;
|
||||
finish_shipping_count: 0 | 1 | 2;
|
||||
shipping_list: Array<{
|
||||
tracking_no?: string;
|
||||
express_company?: string;
|
||||
goods_desc: string;
|
||||
upload_time?: number;
|
||||
contact?: {
|
||||
consignor_contact?: string;
|
||||
receiver_contact?: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -343,5 +343,42 @@ class WechatMpInstance {
|
|||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
|
||||
* 发货信息录入
|
||||
*/
|
||||
async uploadShippingInfo(info) {
|
||||
// 检查一下数据
|
||||
const { order_number_type, transaction_id, mchid, out_trade_no } = info.order_key;
|
||||
(0, assert_1.assert)(order_number_type === 1 && mchid && out_trade_no || order_number_type === 2 && transaction_id);
|
||||
const { delivery_mode, is_all_delivered, shipping_list } = info;
|
||||
(0, assert_1.assert)(delivery_mode === 1 || typeof is_all_delivered === 'boolean');
|
||||
(0, assert_1.assert)(shipping_list.length > 0 && shipping_list.length <= 10);
|
||||
const token = this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(info),
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 查询订单的发货状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%89%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%8F%91%E8%B4%A7%E7%8A%B6%E6%80%81
|
||||
* @param info
|
||||
*/
|
||||
async getOrderState(info) {
|
||||
const token = this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/wxa/sec/order/get_order?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(info),
|
||||
});
|
||||
const { order } = result;
|
||||
const { order_state, in_complaint, shipping } = order;
|
||||
return {
|
||||
orderState: order_state,
|
||||
inComplaint: in_complaint,
|
||||
shipping: shipping
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.WechatMpInstance = WechatMpInstance;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,30 @@ type MpServeMessageOption = {
|
|||
type MediaType = 'image' | 'voice' | 'video' | 'thumb';
|
||||
type ServeMessageOption = TextServeMessageOption | NewsServeMessageOption | MpServeMessageOption | ImageServeMessageOption;
|
||||
|
||||
type UploadShippingInfo = {
|
||||
order_key: {
|
||||
order_number_type: 1 | 2,
|
||||
transaction_id?: string;
|
||||
mchid?: string;
|
||||
out_trade_no?: string;
|
||||
};
|
||||
logistic_type: 1 | 2 | 3 | 4;
|
||||
delivery_mode: 1 | 2;
|
||||
is_all_delivered?: boolean;
|
||||
shipping_list: Array<{
|
||||
tracking_no?: string;
|
||||
express_company?: string;
|
||||
item_desc: string;
|
||||
contact?: {
|
||||
consignor_contact?: string;
|
||||
receiver_contact?: string;
|
||||
};
|
||||
upload_time: string;
|
||||
payer: {
|
||||
openid: string;
|
||||
}
|
||||
}>;
|
||||
}
|
||||
|
||||
export class WechatMpInstance {
|
||||
appId: string;
|
||||
|
|
@ -533,4 +557,76 @@ export class WechatMpInstance {
|
|||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3
|
||||
* 发货信息录入
|
||||
*/
|
||||
async uploadShippingInfo(info: UploadShippingInfo) {
|
||||
// 检查一下数据
|
||||
const { order_number_type, transaction_id, mchid, out_trade_no } = info.order_key;
|
||||
assert(order_number_type === 1 && mchid && out_trade_no || order_number_type === 2 && transaction_id);
|
||||
const { delivery_mode, is_all_delivered, shipping_list } = info;
|
||||
assert(delivery_mode === 1 || typeof is_all_delivered === 'boolean');
|
||||
|
||||
assert(shipping_list.length > 0 && shipping_list.length <= 10);
|
||||
|
||||
const token = this.getAccessToken();
|
||||
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=${token}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(info),
|
||||
}
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单的发货状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%89%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%8F%91%E8%B4%A7%E7%8A%B6%E6%80%81
|
||||
* @param info
|
||||
*/
|
||||
async getOrderState(info: {
|
||||
transaction_id?: string;
|
||||
merchant_id?: string;
|
||||
sub_merchant_id?: string;
|
||||
merchant_trade_no?: string;
|
||||
}) {
|
||||
const token = this.getAccessToken();
|
||||
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/wxa/sec/order/get_order?access_token=${token}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(info),
|
||||
}
|
||||
);
|
||||
const { order } = result;
|
||||
|
||||
const { order_state, in_complaint, shipping } = order;
|
||||
|
||||
return {
|
||||
orderState: order_state as number,
|
||||
inComplaint: in_complaint as boolean,
|
||||
shipping: shipping as {
|
||||
delevery_mode: 1 | 2;
|
||||
logistics_type: 1 | 2 | 3 | 4;
|
||||
finish_shipping: boolean;
|
||||
goods_desc?: string;
|
||||
finish_shipping_count: 0 | 1 | 2;
|
||||
shipping_list: Array<{
|
||||
tracking_no?: string;
|
||||
express_company?: string;
|
||||
goods_desc: string;
|
||||
upload_time?: number;
|
||||
contact?: {
|
||||
consignor_contact?: string;
|
||||
receiver_contact?: string;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue