q-koa 13.4.1 → 13.4.3

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.
package/core/app.js CHANGED
@@ -23,7 +23,23 @@ const jwt = require('jsonwebtoken')
23
23
  const verify = util.promisify(jwt.verify)
24
24
  const fsExtra = require('fs-extra')
25
25
  const { getObject, getAppConfig, formatLiteralObj } = require('./file/utils')
26
-
26
+ const redisVirtual = {
27
+ hSet: () => {
28
+ console.log('redisVirtual hSet')
29
+ },
30
+ hGet: () => {
31
+ console.log('redisVirtual hGet')
32
+ },
33
+ set: () => {
34
+ console.log('redisVirtual set')
35
+ },
36
+ get: () => {
37
+ console.log('redisVirtual get')
38
+ },
39
+ publish: () => {
40
+ console.log('redisVirtual publish')
41
+ },
42
+ }
27
43
  const restc = require('./restc')
28
44
  const APP_DIR = 'app'
29
45
  const PLUGINS_DIR = 'plugins'
@@ -467,6 +483,7 @@ class APP {
467
483
  } else {
468
484
  this.app[appName] = {
469
485
  sequelize: db,
486
+ redisClient: redisVirtual,
470
487
  appConfig: _.defaultsDeep(
471
488
  configExist ? require(path.resolve(__dirname, configPath)) : {},
472
489
  this.config.app,
@@ -686,7 +703,53 @@ class APP {
686
703
  const indexes = _.cloneDeep(
687
704
  _.get(this.app[appName].config[folder], 'indexList', [])
688
705
  )
706
+ let hookList = _.cloneDeep(
707
+ _.get(this.app[appName].config[folder], 'hookList', [])
708
+ )
709
+ if (
710
+ hookList.some((h) =>
711
+ ['afterDestroy', 'beforeDestroy'].includes(h)
712
+ ) &&
713
+ !hookList.includes('beforeBulkDestroy')
714
+ ) {
715
+ hookList = [...hookList, 'beforeBulkDestroy']
716
+ }
717
+ let reduceHook = {}
718
+ for (let i = 0; i < hookList.length; i++) {
719
+ const hook = hookList[i]
720
+ reduceHook = {
721
+ ...reduceHook,
722
+ [hook]: (target, t) => {
723
+ if (['beforeBulkDestroy'].includes(hook)) {
724
+ target.individualHooks = true
725
+ }
726
+ try {
727
+ this.app[appName].service &&
728
+ this.app[appName].service[folder] &&
729
+ this.app[appName].service[folder][hook] &&
730
+ this.app[appName].service[folder][hook]({
731
+ app: this.app[appName],
732
+ model: folder,
733
+ hook,
734
+ ...(target.toJSON
735
+ ? {
736
+ target: target.toJSON(),
737
+ }
738
+ : {
739
+ target,
740
+ }),
741
+ ...t,
742
+ })
743
+ } catch (e) {
744
+ console.log(e)
745
+ }
689
746
 
747
+ if (['beforeBulkDestroy'].includes(hook)) {
748
+ return target
749
+ }
750
+ },
751
+ }
752
+ }
690
753
  const instance = this.app[appName].sequelize.define(
691
754
  folder,
692
755
  attributes,
@@ -701,6 +764,7 @@ class APP {
701
764
  plural: `${folder}s`,
702
765
  },
703
766
  hooks: {
767
+ ...reduceHook,
704
768
  beforeCreate: (res, t) => {
705
769
  try {
706
770
  if (folder === 'log') {
@@ -1120,7 +1184,7 @@ class APP {
1120
1184
  } = ctx.request.body
1121
1185
  if (['findOne', 'findAll', 'findAndCountAll'].includes(fn)) {
1122
1186
  if (!_.isEmpty(other)) {
1123
- throw new Error('参数不合理,条件需要放在where里')
1187
+ throw new Error('参数不合理')
1124
1188
  }
1125
1189
  }
1126
1190
 
package/core/config.js CHANGED
@@ -7,6 +7,7 @@ module.exports = {
7
7
  dir: 'public',
8
8
  },
9
9
  is_check_admin: false,
10
+ is_token_name: true,
10
11
  log: {
11
12
  request: true,
12
13
  },
@@ -67,6 +68,7 @@ module.exports = {
67
68
  'log/create',
68
69
  'log/upsert',
69
70
  'auto/minute',
71
+ 'auto/second',
70
72
  ].every((item) => {
71
73
  return !ctx.request.url.includes(item)
72
74
  })
@@ -3,7 +3,7 @@ module.exports = {
3
3
  belongs: 'auth',
4
4
  multiple: false,
5
5
  order: [],
6
- select: [],
6
+ select: ['name'],
7
7
  excludes: ['query', 'post'],
8
8
  reference: [
9
9
  {
@@ -24,9 +24,15 @@ exports.login = async (ctx) => {
24
24
  result = hasUser
25
25
  }
26
26
 
27
+ const is_token_name = app.appConfig.is_token_name
28
+
27
29
  const tokenResult = {
28
30
  id: result.id,
29
- name: result.name,
31
+ ...(is_token_name
32
+ ? {
33
+ name: result.name,
34
+ }
35
+ : {}),
30
36
  mp_user: result.mp_user
31
37
  ? {
32
38
  openid: result.mp_user && result.mp_user.openid,
@@ -439,12 +439,15 @@ exports.verify = async (ctx) => {
439
439
  ctx.SUCCESS(result)
440
440
  }
441
441
 
442
- const expressFn = async ({ app, express_number: _express_number }) => {
442
+ const expressFn = async ({ app, express_number: _express_number, mobile }) => {
443
443
  const appConfig = getConfig(app)
444
- const { app_code, express_mobile } = await appConfig.getObject('express')
444
+ const { app_code, express_mobile: default_express_mobile } =
445
+ await appConfig.getObject('express')
445
446
 
446
447
  const express_number = _express_number.replace(/\t/, '').trim()
447
448
 
449
+ const express_mobile = mobile || default_express_mobile
450
+
448
451
  const lastFour = express_mobile
449
452
  .split('')
450
453
  .slice(express_mobile.length - 4, express_mobile.length)
@@ -501,7 +504,7 @@ const expressFn = async ({ app, express_number: _express_number }) => {
501
504
  exports.express = async (ctx) => {
502
505
  const { app } = getAppByCtx(ctx)
503
506
 
504
- const { express_number } = ctx.request.body
507
+ const { express_number, mobile } = ctx.request.body
505
508
 
506
509
  if (Array.isArray(express_number)) {
507
510
  const result = await Promise.all(
@@ -518,6 +521,7 @@ exports.express = async (ctx) => {
518
521
  const result = await expressFn({
519
522
  app,
520
523
  express_number,
524
+ mobile,
521
525
  })
522
526
 
523
527
  return ctx.SUCCESS(result)
@@ -674,3 +678,66 @@ exports.gpt = async (ctx) => {
674
678
  })
675
679
  await sleep(1000000)
676
680
  }
681
+
682
+ exports.copyDB = async (ctx) => {
683
+ const { app, appName: currentAppName } = getAppByCtx(ctx)
684
+ const {
685
+ host = '',
686
+ ori_appname = '',
687
+ break_list = [],
688
+ limit = 3000,
689
+ } = ctx.request.body
690
+ if (!host) {
691
+ throw new Error(`?host`)
692
+ }
693
+ const list = Object.keys(app.model)
694
+ const appName = ori_appname || currentAppName
695
+
696
+ for (const model of list) {
697
+ if (break_list.includes(model)) {
698
+ console.log(`跳过`)
699
+ continue
700
+ }
701
+ const count = await app.model[model].count()
702
+ if (count > 0) {
703
+ console.log(`有数据,跳过`)
704
+ continue
705
+ }
706
+ await app.model[model].sync({
707
+ force: true,
708
+ })
709
+ const url = `${host}/${appName}/${model}/findAll`
710
+ for (let i = 0; i < 10000; i++) {
711
+ console.log(`page-${i}`)
712
+ const { code, data } = await axios
713
+ .post(url, {
714
+ offset: i * limit,
715
+ limit,
716
+ where: {
717
+ id: {
718
+ $gt: 0,
719
+ },
720
+ },
721
+ ...(model === 'setting'
722
+ ? {
723
+ raw: true,
724
+ }
725
+ : {}),
726
+ autoInclude: false,
727
+ })
728
+ .then((res) => res.data)
729
+
730
+ if (code !== 200) {
731
+ break
732
+ }
733
+ await app.model[model].bulkCreate(data)
734
+ if (data.length < limit) {
735
+ break
736
+ }
737
+ }
738
+
739
+ console.log(`${model}结束`)
740
+ }
741
+
742
+ ctx.SUCCESS('ok')
743
+ }
@@ -147,9 +147,15 @@ exports.login_callback = async (ctx) => {
147
147
  ],
148
148
  })
149
149
 
150
+ const is_token_name = app.appConfig.is_token_name
151
+
150
152
  const tokenResult = {
151
153
  id: result.id,
152
- name: result.name,
154
+ ...(is_token_name
155
+ ? {
156
+ name: result.name,
157
+ }
158
+ : {}),
153
159
  h5_user: result.h5_user
154
160
  ? {
155
161
  openid: result.h5_user && result.h5_user.openid,
@@ -219,3 +219,10 @@ exports.alias = {
219
219
  return name + model
220
220
  },
221
221
  }
222
+
223
+ exports.hookList = {
224
+ type: Sequelize.JSON,
225
+ comment: 'hook',
226
+ allowNull: false,
227
+ defaultValue: [],
228
+ }
@@ -111,6 +111,7 @@ exports.loadModel = async ({ app, appName }) => {
111
111
  deleteCheckList: config.deleteCheckList,
112
112
  bulkCreateList: config.bulkCreateList,
113
113
  indexList: config.indexList,
114
+ hookList: config.hookList,
114
115
  list: attributes.map((attr, index) => {
115
116
  const name = attr.match(/exports.(.*)=/)[1].trim()
116
117
  let defaultValue = ''
@@ -3,7 +3,14 @@ module.exports = {
3
3
  belongs: 'auth',
4
4
  multiple: false,
5
5
  order: [],
6
- select: [],
6
+ select: [
7
+ {
8
+ key: 'model_id',
9
+ },
10
+ {
11
+ key: 'name',
12
+ },
13
+ ],
7
14
  excludes: [],
8
15
  defaultOrder: [],
9
16
  comment: {},
@@ -157,3 +157,47 @@ exports.html = async (ctx) => {
157
157
  </body>
158
158
  </html>`
159
159
  }
160
+
161
+ exports.getList = async (ctx, _data) => {
162
+ const { app, appName } = getAppByCtx(ctx)
163
+
164
+ const { type = 'is_custom' } = _data || ctx.request.body
165
+
166
+ const settingList = await app.model.setting.findAll({
167
+ where: {
168
+ $or: [
169
+ {
170
+ is_front: true,
171
+ },
172
+ type
173
+ ? {
174
+ extra: {
175
+ [type]: true,
176
+ },
177
+ }
178
+ : null,
179
+ ].filter(Boolean),
180
+ },
181
+ attributes: {
182
+ exclude: [
183
+ 'name',
184
+ 'created_at',
185
+ 'updated_at',
186
+ 'createdid',
187
+ 'is_cache',
188
+ 'is_front',
189
+ 'is_control',
190
+ 'extra',
191
+ ],
192
+ },
193
+ })
194
+
195
+ const payLoad = settingList.map((item) => {
196
+ return lodash.omit(item.toJSON(), [
197
+ 'type',
198
+ item.parent_id === 0 ? '' : 'id',
199
+ ])
200
+ })
201
+ ctx.SUCCESS(payLoad)
202
+ return payLoad
203
+ }
@@ -141,7 +141,13 @@ exports.extra = {
141
141
  sortOrder: 9,
142
142
  set: function (value) {
143
143
  try {
144
- const dataValue = typeof value === 'object' ? value : JSON.parse(value)
144
+ const dataValue =
145
+ value === null
146
+ ? {}
147
+ : typeof value === 'object'
148
+ ? value
149
+ : JSON.parse(value)
150
+
145
151
  this.setDataValue('extra', dataValue)
146
152
  } catch {
147
153
  throw new Error('extra值不合法')
@@ -230,12 +230,19 @@ exports.customRouter = async (ctx) => {
230
230
  return list
231
231
  }
232
232
 
233
- exports.showTables = async (ctx) => {
233
+ exports.showTables = async (ctx, _data) => {
234
234
  const { app, appName } = getAppByCtx(ctx)
235
+ const { omit = [] } = _data || ctx.request.body
235
236
 
237
+ const mapFn = (item) => {
238
+ if (omit.length === 0) return item
239
+ return lodash.omit(item.toJSON ? item.toJSON() : item, omit)
240
+ }
236
241
  if (app.cache && app.cache.get('showTables')) {
237
- ctx.SUCCESS(app.cache.get('showTables'))
238
- return app.cache.get('showTables')
242
+ const cacheResult = app.cache.get('showTables')
243
+ const payLoad = cacheResult.map(mapFn)
244
+ ctx.SUCCESS(payLoad)
245
+ return payLoad
239
246
  }
240
247
 
241
248
  const pluginDir = path.resolve(
@@ -315,7 +322,13 @@ exports.showTables = async (ctx) => {
315
322
  // 可排序字段
316
323
  order: lodash.get(target, 'order', []),
317
324
  // 默认排序
318
- defaultOrder: lodash.get(target, 'defaultOrder', []),
325
+ defaultOrder: getValueByModelName(
326
+ target,
327
+ 'defaultOrder',
328
+ [],
329
+ model,
330
+ _model
331
+ ),
319
332
  // 下拉筛选
320
333
  select: getValueByModelName(target, 'select', [], model, _model),
321
334
  // 是否可以选择批量删除
@@ -356,19 +369,25 @@ exports.showTables = async (ctx) => {
356
369
  // can be mock boolean
357
370
  mock,
358
371
  // reference model query
359
- referenceSelect: lodash.get(target, 'referenceSelect', []),
372
+ referenceSelect: getValueByModelName(
373
+ target,
374
+ 'referenceSelect',
375
+ [],
376
+ model,
377
+ _model
378
+ ),
360
379
  // 是否可以选择批量删除
361
380
  availableSort: lodash.get(target, 'availableSort', false),
362
381
  // 用于后台管理不要查询太多数据,常用于表多的model
363
382
  autoData: lodash.get(target, 'autoData', null),
364
383
  // 有些model需要前置查询其它model数据
365
- initList: lodash.get(target, 'initList', []),
384
+ initList: getValueByModelName(target, 'initList', [], model, _model),
366
385
  // 有些table需要前置查询数据
367
386
  initTableList: lodash.get(target, 'initTableList', []),
368
387
  // 局部更新列表
369
388
  editInline: lodash.get(target, 'editInline', {}),
370
389
  // 有些model需要前置查询其它model数据
371
- comment: lodash.get(target, 'comment', {}),
390
+ comment: getValueByModelName(target, 'comment', {}, model, _model),
372
391
  // 默认查询,覆盖之前
373
392
  modelQuery: lodash.get(target, 'modelQuery', {}),
374
393
  // 默认更新,覆盖之前
@@ -386,9 +405,10 @@ exports.showTables = async (ctx) => {
386
405
  }
387
406
  })
388
407
 
389
- ctx.SUCCESS(models)
390
- app.cache && app.cache.set('showTables', models)
391
- return models
408
+ const payLoad = models.map(mapFn)
409
+ ctx.SUCCESS(payLoad)
410
+ app.cache && app.cache.set('showTables', models.map(mapFn))
411
+ return payLoad
392
412
  }
393
413
 
394
414
  exports.getTable = async (ctx) => {
@@ -80,6 +80,7 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
80
80
  const omit = data && data.omit ? data.omit : []
81
81
  const pick = data && data.pick ? data.pick : []
82
82
  const cacheData = app.cache.get(`${model}`) || []
83
+
83
84
  const cacheList = cacheData
84
85
  .map((i) => (i.toJSON ? i.toJSON() : i))
85
86
  .filter((c) => {
@@ -160,10 +160,15 @@ exports.login = async (ctx) => {
160
160
  ...app.include.user,
161
161
  ],
162
162
  })
163
+ const is_token_name = app.appConfig.is_token_name
163
164
 
164
165
  const tokenResult = {
165
166
  id: result.id,
166
- name: result.name,
167
+ ...(is_token_name
168
+ ? {
169
+ name: result.name,
170
+ }
171
+ : {}),
167
172
  mp_user: result.mp_user
168
173
  ? {
169
174
  openid: result.mp_user && result.mp_user.openid,
@@ -8,6 +8,8 @@ exports.login = async (ctx) => {
8
8
 
9
9
  const config = _config || ctx.request.header.config || 'weixin_mp'
10
10
 
11
+ const is_token_name = app.appConfig.is_token_name
12
+
11
13
  const where =
12
14
  process.env.NODE_ENV !== 'production'
13
15
  ? {
@@ -41,7 +43,11 @@ exports.login = async (ctx) => {
41
43
  if (_config === 'none') {
42
44
  const tokenResult = {
43
45
  id: result.id,
44
- name: result.name,
46
+ ...(is_token_name
47
+ ? {
48
+ name: result.name,
49
+ }
50
+ : {}),
45
51
  }
46
52
  const token = await app.sign({
47
53
  user: tokenResult,
@@ -192,7 +198,11 @@ exports.login = async (ctx) => {
192
198
 
193
199
  const tokenResult = {
194
200
  id: result.id,
195
- name: result.name,
201
+ ...(is_token_name
202
+ ? {
203
+ name: result.name,
204
+ }
205
+ : {}),
196
206
  mp_user: result.mp_user
197
207
  ? {
198
208
  openid: result.mp_user && result.mp_user.openid,
@@ -315,11 +325,12 @@ exports.checkLogin = async (ctx) => {
315
325
  const config = _config || 'weixin_mp'
316
326
  const appConfig = getConfig(app)
317
327
  if (ctx.request[`${appName}-user`] && ctx.request[`${appName}-user`].id) {
328
+ const { app_id: appid } = await appConfig.getObject(config)
318
329
  const h5_user_include = config.includes('h5')
319
330
  ? {
320
331
  model: app.model.h5_user,
321
332
  where: {
322
- appid: (await appConfig.getObject(config)).app_id,
333
+ appid,
323
334
  },
324
335
  attributes: {
325
336
  exclude: ['created_at', 'updated_at', 'createdid'],
@@ -332,7 +343,7 @@ exports.checkLogin = async (ctx) => {
332
343
  ? {
333
344
  model: app.model.mp_user,
334
345
  where: {
335
- appid: (await appConfig.getObject(config)).app_id,
346
+ appid,
336
347
  },
337
348
  }
338
349
  : {
@@ -428,9 +439,15 @@ exports.checkLogin = async (ctx) => {
428
439
  }
429
440
  }
430
441
 
442
+ const is_token_name = app.appConfig.is_token_name
443
+
431
444
  const tokenResult = {
432
445
  id: result.id,
433
- name: result.name,
446
+ ...(is_token_name
447
+ ? {
448
+ name: result.name,
449
+ }
450
+ : {}),
434
451
  mp_user: result.mp_user
435
452
  ? {
436
453
  openid: result.mp_user && result.mp_user.openid,
@@ -451,6 +468,7 @@ exports.checkLogin = async (ctx) => {
451
468
  }
452
469
  : {}),
453
470
  }
471
+
454
472
  const token = await app.sign({
455
473
  user: tokenResult,
456
474
  })
@@ -130,9 +130,15 @@ exports.mp_getPhone = async (ctx) => {
130
130
  ].filter((item) => item.model),
131
131
  })
132
132
 
133
+ const is_token_name = app.appConfig.is_token_name
134
+
133
135
  const tokenResult = {
134
136
  id: result.id,
135
- name: result.name,
137
+ ...(is_token_name
138
+ ? {
139
+ name: result.name,
140
+ }
141
+ : {}),
136
142
  mp_user: result.mp_user
137
143
  ? {
138
144
  openid: result.mp_user && result.mp_user.openid,
@@ -251,9 +257,15 @@ exports.mp_getPhoneNew = async (ctx) => {
251
257
  ].filter((item) => item.model),
252
258
  })
253
259
 
260
+ const is_token_name = app.appConfig.is_token_name
261
+
254
262
  const tokenResult = {
255
263
  id: result.id,
256
- name: result.name,
264
+ ...(is_token_name
265
+ ? {
266
+ name: result.name,
267
+ }
268
+ : {}),
257
269
  mp_user: result.mp_user
258
270
  ? {
259
271
  openid: result.mp_user && result.mp_user.openid,
@@ -492,9 +504,15 @@ exports.mp_login = async (ctx) => {
492
504
 
493
505
  if (!(result && result.id)) throw new Error('登录失败')
494
506
 
507
+ const is_token_name = app.appConfig.is_token_name
508
+
495
509
  const tokenResult = {
496
510
  id: result.id,
497
- name: result.name,
511
+ ...(is_token_name
512
+ ? {
513
+ name: result.name,
514
+ }
515
+ : {}),
498
516
  mp_user: result.mp_user
499
517
  ? {
500
518
  openid: result.mp_user && result.mp_user.openid,
@@ -671,9 +689,15 @@ exports.h5_login_callback = async (ctx) => {
671
689
  ].filter((item) => item.model),
672
690
  })
673
691
 
692
+ const is_token_name = app.appConfig.is_token_name
693
+
674
694
  const tokenResult = {
675
695
  id: result.id,
676
- name: result.name,
696
+ ...(is_token_name
697
+ ? {
698
+ name: result.name,
699
+ }
700
+ : {}),
677
701
  mp_user: result.mp_user
678
702
  ? {
679
703
  openid: result.mp_user && result.mp_user.openid,
@@ -805,9 +829,15 @@ exports.h5_login_info_callback = async (ctx) => {
805
829
  ].filter((item) => item.model),
806
830
  })
807
831
 
832
+ const is_token_name = app.appConfig.is_token_name
833
+
808
834
  const tokenResult = {
809
835
  id: result.id,
810
- name: result.name,
836
+ ...(is_token_name
837
+ ? {
838
+ name: result.name,
839
+ }
840
+ : {}),
811
841
  mp_user: result.mp_user
812
842
  ? {
813
843
  openid: result.mp_user && result.mp_user.openid,
@@ -2044,6 +2074,7 @@ exports.getCommentInfo = async (ctx, _data) => {
2044
2074
  const {
2045
2075
  content: {
2046
2076
  orderInfo: { busiOrderId },
2077
+ content,
2047
2078
  },
2048
2079
  } = info
2049
2080
 
@@ -2060,6 +2091,7 @@ exports.getCommentInfo = async (ctx, _data) => {
2060
2091
  const result = {
2061
2092
  prefix,
2062
2093
  order_id,
2094
+ content,
2063
2095
  }
2064
2096
  ctx.SUCCESS(result)
2065
2097
  return result
@@ -687,7 +687,7 @@ exports.pc_pay = async ({
687
687
  pay_config = 'weixin_pay',
688
688
  out_trade_no: _out_trade_no,
689
689
  is_admin = false,
690
- type = 'SCAN-WEIXIN',
690
+ type = 'PC-WEIXIN',
691
691
  prefix = '',
692
692
  }) => {
693
693
  if (!ctx) throw new Error('?ctx')
@@ -65,6 +65,12 @@ const getShipTemplateUrl =
65
65
  const uploadShipUrl =
66
66
  'https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=%s'
67
67
 
68
+ const uploadPreShipUrl =
69
+ 'https://api.weixin.qq.com/wxa/sec/order/opspecialorder?access_token=%s'
70
+
71
+ const getShipOrderListUrl =
72
+ 'https://api.weixin.qq.com/wxa/sec/order/get_order_list?access_token=%s'
73
+
68
74
  const setMsgJumpPathUrl =
69
75
  'https://api.weixin.qq.com/wxa/sec/order/set_msg_jump_path?access_token=%s'
70
76
 
@@ -786,6 +792,44 @@ module.exports = class Singleton {
786
792
  return result
787
793
  }
788
794
 
795
+ async uploadPreShip(payLoad) {
796
+ const access_token = await this.getAccessToken()
797
+ const url = util.format(uploadPreShipUrl, access_token)
798
+
799
+ const result = await axios
800
+ .post(url, {
801
+ ...payLoad,
802
+ })
803
+ .then((res) => res.data)
804
+ if (result.errcode) {
805
+ if (result.errcode === 40001) {
806
+ cache.reset()
807
+ return await this.uploadPreShip(payLoad)
808
+ }
809
+ throw new Error(`${result.errcode};${result.errmsg}`)
810
+ }
811
+ return result
812
+ }
813
+
814
+ async getShipOrderList(payLoad) {
815
+ const access_token = await this.getAccessToken()
816
+ const url = util.format(getShipOrderListUrl, access_token)
817
+
818
+ const result = await axios
819
+ .post(url, {
820
+ ...payLoad,
821
+ })
822
+ .then((res) => res.data)
823
+ if (result.errcode) {
824
+ if (result.errcode === 40001) {
825
+ cache.reset()
826
+ return await this.getShipOrderList(payLoad)
827
+ }
828
+ throw new Error(`${result.errcode};${result.errmsg}`)
829
+ }
830
+ return result
831
+ }
832
+
789
833
  async uploadImage(payLoad) {
790
834
  const access_token = await this.getAccessToken()
791
835
  const { upload_type, resp_type, ...rest } = payLoad
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "13.4.1",
3
+ "version": "13.4.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {