q-koa 13.8.5 → 13.8.7
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')
|
|
@@ -1191,9 +1193,7 @@ module.exports = class Singleton {
|
|
|
1191
1193
|
if (result.errcode) {
|
|
1192
1194
|
if (result.errcode === 40001) {
|
|
1193
1195
|
cache.clear()
|
|
1194
|
-
return await this.b2bPreStore(
|
|
1195
|
-
retail_info_list: list,
|
|
1196
|
-
})
|
|
1196
|
+
return await this.b2bPreStore(list)
|
|
1197
1197
|
}
|
|
1198
1198
|
throw new Error(`${result.errcode};${result.errmsg}`)
|
|
1199
1199
|
}
|
|
@@ -1226,6 +1226,26 @@ module.exports = class Singleton {
|
|
|
1226
1226
|
return result
|
|
1227
1227
|
}
|
|
1228
1228
|
|
|
1229
|
+
async b2bSendMessage({ type = 2, to_user_list = [], data = {} }) {
|
|
1230
|
+
const access_token = await this.getAccessToken()
|
|
1231
|
+
const url = util.format(b2bSendMessageUrl, access_token)
|
|
1232
|
+
|
|
1233
|
+
const result = await axios
|
|
1234
|
+
.post(url, {
|
|
1235
|
+
type,
|
|
1236
|
+
to_user_list,
|
|
1237
|
+
content: JSON.stringify(data),
|
|
1238
|
+
})
|
|
1239
|
+
.then((res) => res.data)
|
|
1240
|
+
if (result.errcode) {
|
|
1241
|
+
if (result.errcode === 40001) {
|
|
1242
|
+
cache.clear()
|
|
1243
|
+
return await this.b2bSendMessage({ type, to_user_list, data })
|
|
1244
|
+
}
|
|
1245
|
+
throw new Error(`${result.errcode};${result.errmsg}`)
|
|
1246
|
+
}
|
|
1247
|
+
return result
|
|
1248
|
+
}
|
|
1229
1249
|
getConfig() {
|
|
1230
1250
|
return this.config
|
|
1231
1251
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q-koa",
|
|
3
|
-
"version": "13.8.
|
|
3
|
+
"version": "13.8.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"vm2": "^3.9.19",
|
|
59
59
|
"xlsx": "^0.18.5",
|
|
60
60
|
"pm2": "^7.0.1",
|
|
61
|
-
"dayjs": "^1.11.13",
|
|
62
61
|
"moment": "^2.30.1",
|
|
63
62
|
"form-data": "^4.0.0",
|
|
64
63
|
"adm-zip": "^0.6.0"
|