From e7a934f13f6b486605b70c6310cdf5a00a1f6c76 Mon Sep 17 00:00:00 2001 From: lxy Date: Wed, 30 Apr 2025 14:40:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=89=A9=E6=B5=81=E3=80=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=B7=B2=E7=BB=91=E5=AE=9A=E7=9A=84=E7=89=A9=E6=B5=81=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/service/wechat/WechatMp.d.ts | 26 ++++++++++-------- es/service/wechat/WechatMp.js | 24 ++++++++++++++++ es/types/Wechat.d.ts | 18 ++++++++++-- lib/service/wechat/WechatMp.d.ts | 26 ++++++++++-------- lib/service/wechat/WechatMp.js | 24 ++++++++++++++++ lib/types/Wechat.d.ts | 18 ++++++++++-- src/service/wechat/WechatMp.ts | 47 ++++++++++++++++++++++++-------- src/types/Wechat.ts | 26 ++++++++++++++++-- 8 files changed, 169 insertions(+), 40 deletions(-) diff --git a/es/service/wechat/WechatMp.d.ts b/es/service/wechat/WechatMp.d.ts index a0f536d..5d68462 100644 --- a/es/service/wechat/WechatMp.d.ts +++ b/es/service/wechat/WechatMp.d.ts @@ -52,14 +52,7 @@ type UploadShippingInfo = { openid: string; }; }; -type notifyConfirmReceiveData = { - transaction_id?: string; - merchant_id?: string; - sub_merchant_id?: string; - merchant_trade_no?: string; - received_time: number; -}; -import { AddExpressOrderData, CancelExpressOrderData, getExpressPathData, getExpressOrderData } from '../../types/Wechat'; +import { AddExpressOrderData, CancelExpressOrderData, GetExpressPathData, GetExpressOrderData, NotifyConfirmReceiveData, BindExpressAccountData } from '../../types/Wechat'; export declare class WechatMpInstance { appId: string; appSecret?: string; @@ -207,7 +200,7 @@ export declare class WechatMpInstance { * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html * @param data */ - getExpressPath(data: getExpressPathData): Promise<{ + getExpressPath(data: GetExpressPathData): Promise<{ path_item_num: number; path_item_list: Array<{ action_time: number; @@ -220,12 +213,23 @@ export declare class WechatMpInstance { * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getOrder.html * @param data */ - getExpressOrder(data: getExpressOrderData): Promise; + getExpressOrder(data: GetExpressOrderData): Promise; /** * 确认收货提醒 * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html * @param data */ - notifyConfirmReceive(data: notifyConfirmReceiveData): Promise; + notifyConfirmReceive(data: NotifyConfirmReceiveData): Promise; + /** + * 绑定/解绑物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/bindAccount.html + * @param data + */ + bindExpressAccount(data: BindExpressAccountData): Promise; + /** + * 获取所有绑定的物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getAllAccount.html + */ + getExpressAccount(): Promise; } export {}; diff --git a/es/service/wechat/WechatMp.js b/es/service/wechat/WechatMp.js index 853e642..1714f78 100644 --- a/es/service/wechat/WechatMp.js +++ b/es/service/wechat/WechatMp.js @@ -462,4 +462,28 @@ export class WechatMpInstance { body: JSON.stringify(data), }); } + /** + * 绑定/解绑物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/bindAccount.html + * @param data + */ + async bindExpressAccount(data) { + const token = await this.getAccessToken(); + const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/business/account/bind?access_token=${token}`, { + method: 'POST', + body: JSON.stringify(data), + }); + return result; + } + /** + * 获取所有绑定的物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getAllAccount.html + */ + async getExpressAccount() { + const token = await this.getAccessToken(); + const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/business/account/getall?access_token=${token}`, { + method: 'GET' + }); + return result; + } } diff --git a/es/types/Wechat.d.ts b/es/types/Wechat.d.ts index 042288f..9c69320 100644 --- a/es/types/Wechat.d.ts +++ b/es/types/Wechat.d.ts @@ -110,12 +110,12 @@ export type CancelExpressOrderData = { waybill_id: string; order_id: string; }; -export type getExpressPathData = { +export type GetExpressPathData = { openid?: string; delivery_id: string; waybill_id: string; }; -export type getExpressOrderData = { +export type GetExpressOrderData = { order_id: string; openid?: string; delivery_id: string; @@ -123,4 +123,18 @@ export type getExpressOrderData = { print_type?: number; custom_remark?: string; }; +export type NotifyConfirmReceiveData = { + transaction_id?: string; + merchant_id?: string; + sub_merchant_id?: string; + merchant_trade_no?: string; + received_time: number; +}; +export type BindExpressAccountData = { + type: 'bind' | 'unbind'; + biz_id: string; + delivery_id: string; + password?: string; + remark_content?: string; +}; export {}; diff --git a/lib/service/wechat/WechatMp.d.ts b/lib/service/wechat/WechatMp.d.ts index a0f536d..5d68462 100644 --- a/lib/service/wechat/WechatMp.d.ts +++ b/lib/service/wechat/WechatMp.d.ts @@ -52,14 +52,7 @@ type UploadShippingInfo = { openid: string; }; }; -type notifyConfirmReceiveData = { - transaction_id?: string; - merchant_id?: string; - sub_merchant_id?: string; - merchant_trade_no?: string; - received_time: number; -}; -import { AddExpressOrderData, CancelExpressOrderData, getExpressPathData, getExpressOrderData } from '../../types/Wechat'; +import { AddExpressOrderData, CancelExpressOrderData, GetExpressPathData, GetExpressOrderData, NotifyConfirmReceiveData, BindExpressAccountData } from '../../types/Wechat'; export declare class WechatMpInstance { appId: string; appSecret?: string; @@ -207,7 +200,7 @@ export declare class WechatMpInstance { * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html * @param data */ - getExpressPath(data: getExpressPathData): Promise<{ + getExpressPath(data: GetExpressPathData): Promise<{ path_item_num: number; path_item_list: Array<{ action_time: number; @@ -220,12 +213,23 @@ export declare class WechatMpInstance { * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getOrder.html * @param data */ - getExpressOrder(data: getExpressOrderData): Promise; + getExpressOrder(data: GetExpressOrderData): Promise; /** * 确认收货提醒 * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html * @param data */ - notifyConfirmReceive(data: notifyConfirmReceiveData): Promise; + notifyConfirmReceive(data: NotifyConfirmReceiveData): Promise; + /** + * 绑定/解绑物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/bindAccount.html + * @param data + */ + bindExpressAccount(data: BindExpressAccountData): Promise; + /** + * 获取所有绑定的物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getAllAccount.html + */ + getExpressAccount(): Promise; } export {}; diff --git a/lib/service/wechat/WechatMp.js b/lib/service/wechat/WechatMp.js index b08dc77..6e95fa2 100644 --- a/lib/service/wechat/WechatMp.js +++ b/lib/service/wechat/WechatMp.js @@ -466,5 +466,29 @@ class WechatMpInstance { body: JSON.stringify(data), }); } + /** + * 绑定/解绑物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/bindAccount.html + * @param data + */ + async bindExpressAccount(data) { + const token = await this.getAccessToken(); + const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/business/account/bind?access_token=${token}`, { + method: 'POST', + body: JSON.stringify(data), + }); + return result; + } + /** + * 获取所有绑定的物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getAllAccount.html + */ + async getExpressAccount() { + const token = await this.getAccessToken(); + const result = await this.access(`https://api.weixin.qq.com/cgi-bin/express/business/account/getall?access_token=${token}`, { + method: 'GET' + }); + return result; + } } exports.WechatMpInstance = WechatMpInstance; diff --git a/lib/types/Wechat.d.ts b/lib/types/Wechat.d.ts index 042288f..9c69320 100644 --- a/lib/types/Wechat.d.ts +++ b/lib/types/Wechat.d.ts @@ -110,12 +110,12 @@ export type CancelExpressOrderData = { waybill_id: string; order_id: string; }; -export type getExpressPathData = { +export type GetExpressPathData = { openid?: string; delivery_id: string; waybill_id: string; }; -export type getExpressOrderData = { +export type GetExpressOrderData = { order_id: string; openid?: string; delivery_id: string; @@ -123,4 +123,18 @@ export type getExpressOrderData = { print_type?: number; custom_remark?: string; }; +export type NotifyConfirmReceiveData = { + transaction_id?: string; + merchant_id?: string; + sub_merchant_id?: string; + merchant_trade_no?: string; + received_time: number; +}; +export type BindExpressAccountData = { + type: 'bind' | 'unbind'; + biz_id: string; + delivery_id: string; + password?: string; + remark_content?: string; +}; export {}; diff --git a/src/service/wechat/WechatMp.ts b/src/service/wechat/WechatMp.ts index 3949330..da52391 100644 --- a/src/service/wechat/WechatMp.ts +++ b/src/service/wechat/WechatMp.ts @@ -71,15 +71,8 @@ type UploadShippingInfo = { } } -type notifyConfirmReceiveData = { - transaction_id?: string; - merchant_id?: string; - sub_merchant_id?: string; - merchant_trade_no?: string; - received_time: number; -} -import { AddExpressOrderData, CancelExpressOrderData, getExpressPathData, getExpressOrderData } from '../../types/Wechat'; +import { AddExpressOrderData, CancelExpressOrderData, GetExpressPathData, GetExpressOrderData, NotifyConfirmReceiveData, BindExpressAccountData } from '../../types/Wechat'; export class WechatMpInstance { appId: string; @@ -710,7 +703,7 @@ export class WechatMpInstance { * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html * @param data */ - async getExpressPath(data: getExpressPathData) { + 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}`, @@ -738,7 +731,7 @@ export class WechatMpInstance { * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getOrder.html * @param data */ - async getExpressOrder(data: getExpressOrderData) { + async getExpressOrder(data: GetExpressOrderData) { const token = await this.getAccessToken(); const result = await this.access( `https://api.weixin.qq.com/cgi-bin/express/business/order/get?access_token=${token}`, @@ -755,7 +748,7 @@ export class WechatMpInstance { * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html * @param data */ - async notifyConfirmReceive(data: notifyConfirmReceiveData) { + async notifyConfirmReceive(data: NotifyConfirmReceiveData) { const token = await this.getAccessToken(); await this.access( `https://api.weixin.qq.com/wxa/sec/order/notify_confirm_receive?access_token=${token}`, @@ -765,4 +758,36 @@ export class WechatMpInstance { } ); } + + /** + * 绑定/解绑物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/bindAccount.html + * @param data + */ + async bindExpressAccount(data: BindExpressAccountData) { + const token = await this.getAccessToken(); + const result = await this.access( + `https://api.weixin.qq.com/cgi-bin/express/business/account/bind?access_token=${token}`, + { + method: 'POST', + body: JSON.stringify(data), + } + ); + return result; + } + + /** + * 获取所有绑定的物流账号 + * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getAllAccount.html + */ + async getExpressAccount() { + const token = await this.getAccessToken(); + const result = await this.access( + `https://api.weixin.qq.com/cgi-bin/express/business/account/getall?access_token=${token}`, + { + method: 'GET' + } + ) + return result; + } } diff --git a/src/types/Wechat.ts b/src/types/Wechat.ts index 1e6ef9e..a07a3de 100644 --- a/src/types/Wechat.ts +++ b/src/types/Wechat.ts @@ -145,7 +145,7 @@ export type CancelExpressOrderData = { // 查询运单轨迹 // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getPath.html -export type getExpressPathData = { +export type GetExpressPathData = { openid?: string; delivery_id: string, waybill_id: string, @@ -153,11 +153,31 @@ export type getExpressPathData = { //获取运单数据 // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/getOrder.html -export type getExpressOrderData = { +export type GetExpressOrderData = { order_id: string; openid?: string; delivery_id: string; waybill_id?: string; print_type?: number; custom_remark?: string; -} \ No newline at end of file +} + +//确认收货提醒 +//https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html +export type NotifyConfirmReceiveData = { + transaction_id?: string; + merchant_id?: string; + sub_merchant_id?: string; + merchant_trade_no?: string; + received_time: number; +} + +//绑定/解绑物流账号 +//https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/express/express-by-business/bindAccount.html +export type BindExpressAccountData = { + type: 'bind' | 'unbind'; + biz_id: string; + delivery_id: string; + password?: string; + remark_content?: string; +}