q-koa 13.8.4 → 13.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -113,6 +113,8 @@ const b2bPreStoreUrl =
|
|
|
113
113
|
const b2bFinishUrl =
|
|
114
114
|
'https://api.weixin.qq.com/retail/B2b/finishprofitsharingorder?access_token=%s&pay_sig=%s'
|
|
115
115
|
|
|
116
|
+
const b2bSendMessageUrl =
|
|
117
|
+
'https://api.weixin.qq.com/wxa/business/retailnotifybusiness?access_token=%s'
|
|
116
118
|
const fsPromise = require('fs/promises')
|
|
117
119
|
const { LRUCache } = require('lru-cache')
|
|
118
120
|
const FormData = require('form-data')
|
|
@@ -1226,6 +1228,26 @@ module.exports = class Singleton {
|
|
|
1226
1228
|
return result
|
|
1227
1229
|
}
|
|
1228
1230
|
|
|
1231
|
+
async b2bSendMessage({ type = 2, to_user_list = [], data = {} }) {
|
|
1232
|
+
const access_token = await this.getAccessToken()
|
|
1233
|
+
const url = util.format(b2bSendMessageUrl, access_token)
|
|
1234
|
+
|
|
1235
|
+
const result = await axios
|
|
1236
|
+
.post(url, {
|
|
1237
|
+
type,
|
|
1238
|
+
to_user_list,
|
|
1239
|
+
content: JSON.stringify(data),
|
|
1240
|
+
})
|
|
1241
|
+
.then((res) => res.data)
|
|
1242
|
+
if (result.errcode) {
|
|
1243
|
+
if (result.errcode === 40001) {
|
|
1244
|
+
cache.clear()
|
|
1245
|
+
return await this.b2bSendMessage(options)
|
|
1246
|
+
}
|
|
1247
|
+
throw new Error(`${result.errcode};${result.errmsg}`)
|
|
1248
|
+
}
|
|
1249
|
+
return result
|
|
1250
|
+
}
|
|
1229
1251
|
getConfig() {
|
|
1230
1252
|
return this.config
|
|
1231
1253
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q-koa",
|
|
3
|
-
"version": "13.8.
|
|
3
|
+
"version": "13.8.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"captchapng": "^0.0.1",
|
|
26
26
|
"chalk": "^3.0.0",
|
|
27
27
|
"cheerio": "^1.0.0-rc.3",
|
|
28
|
-
"consola": "^2.11.3",
|
|
29
28
|
"fast-json-stringify": "^2.7.9",
|
|
30
29
|
"fast-xml-parser": "^3.19.0",
|
|
31
30
|
"fs-extra": "^8.1.0",
|
|
@@ -41,7 +40,6 @@
|
|
|
41
40
|
"koa-static": "^5.0.0",
|
|
42
41
|
"koa-useragent": "^4.0.0",
|
|
43
42
|
"koa-xml-body": "^2.1.0",
|
|
44
|
-
"koa-proxies": "^0.12.2",
|
|
45
43
|
"lodash": "^4.17.15",
|
|
46
44
|
"lru-cache": "^11.5.2",
|
|
47
45
|
"mockjs": "^1.0.1-beta3",
|
|
@@ -60,7 +58,6 @@
|
|
|
60
58
|
"vm2": "^3.9.19",
|
|
61
59
|
"xlsx": "^0.18.5",
|
|
62
60
|
"pm2": "^7.0.1",
|
|
63
|
-
"dayjs": "^1.11.13",
|
|
64
61
|
"moment": "^2.30.1",
|
|
65
62
|
"form-data": "^4.0.0",
|
|
66
63
|
"adm-zip": "^0.6.0"
|
|
@@ -69,7 +66,6 @@
|
|
|
69
66
|
"eslint": "^4.19.1",
|
|
70
67
|
"eslint-config-airbnb-base": "^13.2.0",
|
|
71
68
|
"eslint-plugin-import": "^2.18.2",
|
|
72
|
-
"jest": "^24.9.0"
|
|
73
|
-
"ora": "^4.0.3"
|
|
69
|
+
"jest": "^24.9.0"
|
|
74
70
|
}
|
|
75
71
|
}
|