q-koa 13.8.8 → 13.8.9

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.
@@ -450,6 +450,7 @@ const expressFn = async ({ app, express_number: _express_number, mobile }) => {
450
450
  const { app_code, express_mobile: default_express_mobile } =
451
451
  await appConfig.getObject('express')
452
452
 
453
+ if (!_express_number) throw new Error('快递单号不能为空')
453
454
  const express_number = _express_number.replace(/\t/, '').trim()
454
455
 
455
456
  const express_mobile = mobile || default_express_mobile
@@ -466,7 +467,7 @@ const expressFn = async ({ app, express_number: _express_number, mobile }) => {
466
467
  express_number,
467
468
  },
468
469
  })
469
- if (history) {
470
+ if (history && history.result && history.result.updateTime) {
470
471
  const diffNoLong = moment().diff(moment(history.updated_at), 'hours') < 1
471
472
  const isTooLong =
472
473
  moment().diff(moment(history.result.updateTime), 'days') > 30
@@ -518,6 +519,7 @@ exports.express = async (ctx) => {
518
519
  return expressFn({
519
520
  app,
520
521
  express_number: item,
522
+ mobile,
521
523
  })
522
524
  })
523
525
  )
@@ -41,15 +41,15 @@ exports.loadModel = async ({ app, appName }) => {
41
41
  ? require(configPath)
42
42
  : require(defaultConfigPath)
43
43
 
44
- const modelFile =
45
- defaultModelExist || modelExist
46
- ? (await fsPromise.readFile(filePath, 'utf-8'))
47
- ? await fsPromise.readFile(filePath, 'utf-8')
48
- : await fsPromise.readFile(defaultFilePath, 'utf-8')
49
- : null
44
+ let modelFile = null
45
+ if (modelExist) {
46
+ modelFile = await fsPromise.readFile(filePath, 'utf-8')
47
+ } else if (defaultModelExist) {
48
+ modelFile = await fsPromise.readFile(defaultFilePath, 'utf-8')
49
+ }
50
50
 
51
51
  const model = modelFile
52
- ? (await fsPromise.readFile(filePath, 'utf-8'))
52
+ ? modelExist
53
53
  ? require(filePath)
54
54
  : require(defaultFilePath)
55
55
  : {}
@@ -235,11 +235,11 @@ exports.loadModel = async ({ app, appName }) => {
235
235
  const promise2 = app.model.model_attributes.bulkCreate(
236
236
  dataList
237
237
  .filter((item) => item.list.every((t) => t.type))
238
- .reduce((a, b) => [...a, ...b.list], [])
238
+ .flatMap((b) => b.list)
239
239
  )
240
240
 
241
241
  await Promise.all([promise1, promise2])
242
- console.log('lodaModel success!')
242
+ console.log('loadModel success!')
243
243
  if (currentDisabledFindAllList.length > 0) {
244
244
  console.warn(`当前disabledFindAllList不为空,查看需清空`)
245
245
  } else {
@@ -30,9 +30,6 @@ exports.copyOther = async (ctx) => {
30
30
 
31
31
  const findType = list.find((item) => item.code === type)
32
32
  if (findType && findType.parent_id) {
33
- if (!findType) {
34
- throw new Error(`当前找不到${type}`)
35
- }
36
33
  await app.model.setting.upsert({
37
34
  id: findType.id,
38
35
  value: copyType.value,
@@ -261,13 +261,7 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
261
261
  })
262
262
  )
263
263
 
264
- const obj = result.reduce(
265
- (a, b) => ({
266
- ...a,
267
- ...b,
268
- }),
269
- {}
270
- )
264
+ const obj = Object.assign({}, ...result)
271
265
  if (obj.setting && apiVersion && !cacheVersion) {
272
266
  console.log(`version没有后端缓存`)
273
267
  }
@@ -413,7 +413,7 @@ exports.cash = async ({
413
413
  })
414
414
 
415
415
  if (!user) throw new Error('找不到该用户')
416
- if (!user.mp_user.openid) throw new Error('找不到该用户openid')
416
+ if (!user.mp_user || !user.mp_user.openid) throw new Error('找不到该用户openid')
417
417
 
418
418
  const { mchId, key, appId, partner_key } = await getAppConfig({
419
419
  app,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "13.8.8",
3
+ "version": "13.8.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {