增加小程序物流接口
This commit is contained in:
parent
8f9271bdfd
commit
05382ad5b2
|
|
@ -52,7 +52,7 @@ type UploadShippingInfo = {
|
|||
};
|
||||
}>;
|
||||
};
|
||||
import { AddExpressOrderData, CancelExpressOrderData } from '../../types/Wechat';
|
||||
import { AddExpressOrderData, CancelExpressOrderData, getExpressPathData, getWaybillTokenData } from '../../types/Wechat';
|
||||
export declare class WechatMpInstance {
|
||||
appId: string;
|
||||
appSecret?: string;
|
||||
|
|
@ -195,5 +195,30 @@ export declare class WechatMpInstance {
|
|||
* @param data
|
||||
*/
|
||||
cancelExpressOrder(data: CancelExpressOrderData): Promise<void>;
|
||||
/**
|
||||
* 查询运单轨迹
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html
|
||||
* @param data
|
||||
*/
|
||||
getExpressPath(data: getExpressPathData): Promise<{
|
||||
path_item_num: number;
|
||||
path_item_list: Array<{
|
||||
action_time: number;
|
||||
action_type: number;
|
||||
action_msg: string;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* 获取运单token
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
getWaybillToken(data: getWaybillTokenData): Promise<string>;
|
||||
/**
|
||||
* 获取运单状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
getExpressState(waybillToken: string): Promise<any>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -420,4 +420,50 @@ export class WechatMpInstance {
|
|||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 查询运单轨迹
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html
|
||||
* @param data
|
||||
*/
|
||||
async getExpressPath(data) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
const { path_item_num, path_item_list } = result;
|
||||
return {
|
||||
path_item_num,
|
||||
path_item_list,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 获取运单token
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
async getWaybillToken(data) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/trace_waybill?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
const { waybill_token } = result;
|
||||
return waybill_token;
|
||||
}
|
||||
/**
|
||||
* 获取运单状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
async getExpressState(waybillToken) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/query_trace?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
waybill_token: waybillToken,
|
||||
}),
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,4 +110,25 @@ export type CancelExpressOrderData = {
|
|||
waybill_id: string;
|
||||
order_id: string;
|
||||
};
|
||||
export type getExpressPathData = {
|
||||
openId?: string;
|
||||
delivery_id: string;
|
||||
waybill_id: string;
|
||||
};
|
||||
export type getWaybillTokenData = {
|
||||
openId?: string;
|
||||
sender_phone?: string;
|
||||
receiver_phone: string;
|
||||
delivery_id?: string;
|
||||
waybill_id: string;
|
||||
goods_info: {
|
||||
detail_list: {
|
||||
goods_name: string;
|
||||
goods_img_url: string;
|
||||
goods_desc?: string;
|
||||
}[];
|
||||
};
|
||||
trans_id?: string;
|
||||
order_detail_path?: string;
|
||||
};
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ type UploadShippingInfo = {
|
|||
};
|
||||
}>;
|
||||
};
|
||||
import { AddExpressOrderData, CancelExpressOrderData } from '../../types/Wechat';
|
||||
import { AddExpressOrderData, CancelExpressOrderData, getExpressPathData, getWaybillTokenData } from '../../types/Wechat';
|
||||
export declare class WechatMpInstance {
|
||||
appId: string;
|
||||
appSecret?: string;
|
||||
|
|
@ -195,5 +195,30 @@ export declare class WechatMpInstance {
|
|||
* @param data
|
||||
*/
|
||||
cancelExpressOrder(data: CancelExpressOrderData): Promise<void>;
|
||||
/**
|
||||
* 查询运单轨迹
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html
|
||||
* @param data
|
||||
*/
|
||||
getExpressPath(data: getExpressPathData): Promise<{
|
||||
path_item_num: number;
|
||||
path_item_list: Array<{
|
||||
action_time: number;
|
||||
action_type: number;
|
||||
action_msg: string;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* 获取运单token
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
getWaybillToken(data: getWaybillTokenData): Promise<string>;
|
||||
/**
|
||||
* 获取运单状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
getExpressState(waybillToken: string): Promise<any>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -424,5 +424,51 @@ class WechatMpInstance {
|
|||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 查询运单轨迹
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html
|
||||
* @param data
|
||||
*/
|
||||
async getExpressPath(data) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
const { path_item_num, path_item_list } = result;
|
||||
return {
|
||||
path_item_num,
|
||||
path_item_list,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 获取运单token
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
async getWaybillToken(data) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/trace_waybill?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
const { waybill_token } = result;
|
||||
return waybill_token;
|
||||
}
|
||||
/**
|
||||
* 获取运单状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
async getExpressState(waybillToken) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/query_trace?access_token=${token}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
waybill_token: waybillToken,
|
||||
}),
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.WechatMpInstance = WechatMpInstance;
|
||||
|
|
|
|||
|
|
@ -110,4 +110,25 @@ export type CancelExpressOrderData = {
|
|||
waybill_id: string;
|
||||
order_id: string;
|
||||
};
|
||||
export type getExpressPathData = {
|
||||
openId?: string;
|
||||
delivery_id: string;
|
||||
waybill_id: string;
|
||||
};
|
||||
export type getWaybillTokenData = {
|
||||
openId?: string;
|
||||
sender_phone?: string;
|
||||
receiver_phone: string;
|
||||
delivery_id?: string;
|
||||
waybill_id: string;
|
||||
goods_info: {
|
||||
detail_list: {
|
||||
goods_name: string;
|
||||
goods_img_url: string;
|
||||
goods_desc?: string;
|
||||
}[];
|
||||
};
|
||||
trans_id?: string;
|
||||
order_detail_path?: string;
|
||||
};
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ type UploadShippingInfo = {
|
|||
}>;
|
||||
}
|
||||
|
||||
import { AddExpressOrderData, CancelExpressOrderData } from '../../types/Wechat';
|
||||
import { AddExpressOrderData, CancelExpressOrderData, getExpressPathData, getWaybillTokenData } from '../../types/Wechat';
|
||||
|
||||
export class WechatMpInstance {
|
||||
appId: string;
|
||||
|
|
@ -695,4 +695,71 @@ export class WechatMpInstance {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询运单轨迹
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html
|
||||
* @param data
|
||||
*/
|
||||
async getExpressPath(data: getExpressPathData) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=${token}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
}
|
||||
);
|
||||
|
||||
const { path_item_num, path_item_list } = result;
|
||||
return {
|
||||
path_item_num,
|
||||
path_item_list,
|
||||
} as {
|
||||
path_item_num: number;
|
||||
path_item_list: Array<{
|
||||
action_time: number,
|
||||
action_type: number,
|
||||
action_msg: string,
|
||||
}>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单token
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
async getWaybillToken(data: getWaybillTokenData) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/trace_waybill?access_token=${token}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
}
|
||||
);
|
||||
const { waybill_token } = result;
|
||||
return waybill_token as string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单状态
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
* @param data
|
||||
*/
|
||||
async getExpressState(waybillToken: string) {
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/query_trace?access_token=${token}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
waybill_token: waybillToken,
|
||||
}),
|
||||
}
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,22 +12,22 @@ export type WechatPublicEventData = {
|
|||
CreateTime: number;
|
||||
MsgID: string;
|
||||
MsgType:
|
||||
| 'text'
|
||||
| 'image'
|
||||
| 'voice'
|
||||
| 'video'
|
||||
| 'location'
|
||||
| 'link'
|
||||
| 'event'; // 消息类型; event接收事件推送
|
||||
| 'text'
|
||||
| 'image'
|
||||
| 'voice'
|
||||
| 'video'
|
||||
| 'location'
|
||||
| 'link'
|
||||
| 'event'; // 消息类型; event接收事件推送
|
||||
// 接收事件
|
||||
Event?:
|
||||
| 'subscribe'
|
||||
| 'unsubscribe'
|
||||
| 'SCAN'
|
||||
| 'LOCATION'
|
||||
| 'CLICK'
|
||||
| 'VIEW'
|
||||
| 'TEMPLATESENDJOBFINISH'; // MsgType是event
|
||||
| 'subscribe'
|
||||
| 'unsubscribe'
|
||||
| 'SCAN'
|
||||
| 'LOCATION'
|
||||
| 'CLICK'
|
||||
| 'VIEW'
|
||||
| 'TEMPLATESENDJOBFINISH'; // MsgType是event
|
||||
EventKey?: string; // 事件KEY值,subscribe: qrscene_为前缀,后面为二维码的参数值; SCAN: 一个32位无符号整数,即创建二维码时的二维码scene_id; CLICK: 自定义菜单接口中KEY值对应; VIEW: 设置的跳转URL;
|
||||
Ticket?: string; // subscribe 二维码的ticket,可用来换取二维码图片
|
||||
Latitude?: string; // LOCATION 地理位置纬度
|
||||
|
|
@ -141,4 +141,31 @@ export type CancelExpressOrderData = {
|
|||
delivery_id: string;
|
||||
waybill_id: string;
|
||||
order_id: string;
|
||||
};
|
||||
};
|
||||
|
||||
// 查询运单轨迹
|
||||
// https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html
|
||||
export type getExpressPathData = {
|
||||
openId?: string;
|
||||
delivery_id: string,
|
||||
waybill_id: string,
|
||||
}
|
||||
|
||||
//传运单
|
||||
// https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
|
||||
export type getWaybillTokenData = {
|
||||
openId?: string;
|
||||
sender_phone?: string;
|
||||
receiver_phone: string;
|
||||
delivery_id?: string,
|
||||
waybill_id: string,
|
||||
goods_info: {
|
||||
detail_list: {
|
||||
goods_name: string,
|
||||
goods_img_url: string,
|
||||
goods_desc?: string,
|
||||
}[]
|
||||
},
|
||||
trans_id?: string, //当前非必填 https://developers.weixin.qq.com/community/develop/doc/000e2e2c284a089a965d8f2765bc00?highLine=trans_id
|
||||
order_detail_path?: string,
|
||||
}
|
||||
Loading…
Reference in New Issue