q-koa 7.7.2 → 7.7.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.
Files changed (62) hide show
  1. package/core/app.js +13 -9
  2. package/core/file/plugins/administrator/controller.js +1 -1
  3. package/core/file/plugins/administrator/model.js +7 -9
  4. package/core/file/plugins/administrator/validate.js +1 -1
  5. package/core/file/plugins/alipay/controller.js +1 -1
  6. package/core/file/plugins/cloudfunction/model.js +3 -3
  7. package/core/file/plugins/common/controller.js +9 -5
  8. package/core/file/plugins/common/validate.js +14 -13
  9. package/core/file/plugins/douyin/controller.js +1 -7
  10. package/core/file/plugins/douyin/validate.js +17 -19
  11. package/core/file/plugins/douyin_user/model.js +1 -1
  12. package/core/file/plugins/good_sku/controller.js +1 -1
  13. package/core/file/plugins/h5_user/model.js +1 -1
  14. package/core/file/plugins/lang/model.js +3 -3
  15. package/core/file/plugins/language/model.js +5 -6
  16. package/core/file/plugins/log/controller.js +1 -1
  17. package/core/file/plugins/log/model.js +1 -1
  18. package/core/file/plugins/model/controller.js +8 -5
  19. package/core/file/plugins/model/model.js +1 -1
  20. package/core/file/plugins/model/service.js +11 -11
  21. package/core/file/plugins/model/validate.js +10 -13
  22. package/core/file/plugins/model_attributes/model.js +1 -1
  23. package/core/file/plugins/mp_user/model.js +1 -1
  24. package/core/file/plugins/permission/model.js +1 -1
  25. package/core/file/plugins/role/controller.js +1 -1
  26. package/core/file/plugins/role/model.js +1 -1
  27. package/core/file/plugins/role_permission/controller.js +1 -1
  28. package/core/file/plugins/role_permission/model.js +7 -8
  29. package/core/file/plugins/routes/controller.js +1 -1
  30. package/core/file/plugins/routes/model.js +1 -1
  31. package/core/file/plugins/setting/afterExecute.js +1 -1
  32. package/core/file/plugins/setting/controller.js +1 -1
  33. package/core/file/plugins/setting/model.js +1 -1
  34. package/core/file/plugins/setting/validate.js +13 -19
  35. package/core/file/plugins/system/controller.js +5 -8
  36. package/core/file/plugins/system/service.js +1 -1
  37. package/core/file/plugins/system/validate.js +20 -14
  38. package/core/file/plugins/todolist/model.js +1 -1
  39. package/core/file/plugins/toutiao/controller.js +1 -6
  40. package/core/file/plugins/toutiao_user/model.js +1 -1
  41. package/core/file/plugins/user/afterExecute.js +38 -33
  42. package/core/file/plugins/user/controller.js +1 -1
  43. package/core/file/plugins/user/model.js +29 -18
  44. package/core/file/plugins/user/test.js +53 -38
  45. package/core/file/plugins/user/validate.js +7 -8
  46. package/core/file/plugins/video/controller.js +4 -6
  47. package/core/file/plugins/video/validate.js +4 -4
  48. package/core/file/plugins/weixin/controller.js +2 -2
  49. package/core/file/plugins/weixin/service.js +4 -3
  50. package/core/file/plugins/weixin/validate.js +26 -27
  51. package/core/file/services/aliSms.js +29 -28
  52. package/core/file/services/alipay.js +1 -1
  53. package/core/file/services/amap.js +6 -6
  54. package/core/file/services/douyin.js +1 -1
  55. package/core/file/services/express.js +4 -4
  56. package/core/file/services/geo.js +1 -1
  57. package/core/file/services/toutiao.js +3 -3
  58. package/core/file/services/weixin.js +21 -12
  59. package/core/file/services/weixinMP.js +3 -2
  60. package/core/file/utils/index.js +1 -1
  61. package/core/restc/lib/index.js +4 -1
  62. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- const { getAppByCtx } = require('multiple-quick-koa')
1
+ const { getAppByCtx } = require('q-koa')
2
2
  const axios = require('axios')
3
3
 
4
4
  exports.bulkUpdate = async (ctx) => {
@@ -1,4 +1,4 @@
1
- const { Sequelize, Random, lodash, moment } = require('multiple-quick-koa')
1
+ const { Sequelize, Random, lodash, moment } = require('q-koa')
2
2
 
3
3
  exports.name = {
4
4
  type: Sequelize.STRING(),
@@ -1,5 +1,4 @@
1
- const { Validator,getAppByCtx } = require('multiple-quick-koa');
2
-
1
+ const { Validator, getAppByCtx } = require('q-koa')
3
2
 
4
3
  exports.bulkUpdate = async (ctx) => {
5
4
  const params = {
@@ -8,22 +7,17 @@ exports.bulkUpdate = async (ctx) => {
8
7
  required: true,
9
8
  message: '请输入list',
10
9
  },
11
- };
12
- await new Validator(params).validate(ctx.request.body);
13
- };
10
+ }
11
+ await new Validator(params).validate(ctx.request.body)
12
+ }
14
13
 
15
- exports.upsert = async ctx => {
16
- const {
17
- app
18
- } = getAppByCtx(ctx);
14
+ exports.upsert = async (ctx) => {
15
+ const { app } = getAppByCtx(ctx)
19
16
 
20
- const {
21
- id,
22
- parent_id
23
- } = ctx.request.body
17
+ const { id, parent_id } = ctx.request.body
24
18
 
25
19
  if (id && parent_id && id === parent_id) throw new Error('不能分类到自己')
26
- };
20
+ }
27
21
 
28
22
  exports.copyOther = async (ctx) => {
29
23
  const params = {
@@ -32,11 +26,11 @@ exports.copyOther = async (ctx) => {
32
26
  required: true,
33
27
  message: '请输入type, 需要复制哪个code',
34
28
  },
35
- source:{
29
+ source: {
36
30
  type: 'string',
37
31
  required: true,
38
32
  message: '请输入source, 需要从哪个项目复制哪个(记得开启)',
39
- }
40
- };
41
- await new Validator(params).validate(ctx.request.body);
42
- };
33
+ },
34
+ }
35
+ await new Validator(params).validate(ctx.request.body)
36
+ }
@@ -1,14 +1,10 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
+ const fsPromise = require('fs/promises')
3
4
  const { VM } = require('vm2')
4
5
  const axios = require('axios')
5
6
  const cheerio = require('cheerio')
6
- const {
7
- lodash,
8
- getAppByCtx,
9
- getConfig,
10
- Sequelize,
11
- } = require('multiple-quick-koa')
7
+ const { lodash, getAppByCtx, getConfig, Sequelize } = require('q-koa')
12
8
 
13
9
  exports.initModel = async (ctx) => {
14
10
  const { app } = getAppByCtx(ctx)
@@ -62,7 +58,8 @@ exports.showTables = async (ctx) => {
62
58
  `${process.cwd()}/app/${appName}/plugins`
63
59
  )
64
60
  let aliasModelList = []
65
- fs.readdirSync(pluginDir).forEach((folder) => {
61
+ const allList = await fsPromise.readdir(pluginDir)
62
+ allList.forEach((folder) => {
66
63
  const isFolder = fs.lstatSync(path.resolve(pluginDir, folder)).isDirectory()
67
64
  const hasConfig = fs.existsSync(
68
65
  path.resolve(
@@ -254,7 +251,7 @@ exports.getImage = async (ctx) => {
254
251
  __dirname,
255
252
  `${process.cwd()}/public/upload`
256
253
  )}`
257
- const files = fs.readdirSync(targetDir)
254
+ const files = await fsPromise.readdir(targetDir)
258
255
  const images = files.filter((file) =>
259
256
  /\w(\.gif|\.jpeg|\.png|\.jpg|\.bmp)/i.test(file)
260
257
  )
@@ -1,4 +1,4 @@
1
- const { getConfig, lodash } = require('multiple-quick-koa')
1
+ const { getConfig, lodash } = require('q-koa')
2
2
  const formatPostFunction = (str) => `eval(${str})`
3
3
  const nodeVm = require('vm')
4
4
 
@@ -1,4 +1,4 @@
1
- const { Validator, getAppByCtx } = require('multiple-quick-koa');
1
+ const { Validator, getAppByCtx } = require('q-koa')
2
2
 
3
3
  exports.initModel = async (ctx) => {
4
4
  const params = {
@@ -7,34 +7,40 @@ exports.initModel = async (ctx) => {
7
7
  required: true,
8
8
  message: '请输入model',
9
9
  },
10
- };
11
- await new Validator(params).validate(ctx.request.body);
12
- };
10
+ }
11
+ await new Validator(params).validate(ctx.request.body)
12
+ }
13
13
 
14
14
  exports.showAllSchemas = async (ctx) => {
15
- const {app,appName} = getAppByCtx(ctx)
15
+ const { app, appName } = getAppByCtx(ctx)
16
16
 
17
17
  const params = {
18
18
  model: {
19
19
  type: 'string',
20
20
  required: true,
21
21
  message: '请输入model',
22
- validator: (rule, value) => ((app[appName].model && app[appName].model[value]) ? Promise.resolve() : Promise.reject('没有这个模型')),
22
+ validator: (rule, value) =>
23
+ app[appName].model && app[appName].model[value]
24
+ ? Promise.resolve()
25
+ : Promise.reject('没有这个模型'),
23
26
  },
24
- };
25
- await new Validator(params).validate(ctx.request.body);
26
- };
27
+ }
28
+ await new Validator(params).validate(ctx.request.body)
29
+ }
27
30
 
28
31
  exports.dropModel = async (ctx) => {
29
- const {app,appName} = getAppByCtx(ctx)
32
+ const { app, appName } = getAppByCtx(ctx)
30
33
 
31
34
  const params = {
32
35
  model: {
33
36
  type: 'string',
34
37
  required: true,
35
38
  message: '请输入model',
36
- validator: (rule, value) => ((app[appName].model && app[appName].model[value]) ? Promise.resolve() : Promise.reject('没有这个模型')),
39
+ validator: (rule, value) =>
40
+ app[appName].model && app[appName].model[value]
41
+ ? Promise.resolve()
42
+ : Promise.reject('没有这个模型'),
37
43
  },
38
- };
39
- await new Validator(params).validate(ctx.request.body);
40
- };
44
+ }
45
+ await new Validator(params).validate(ctx.request.body)
46
+ }
@@ -1,4 +1,4 @@
1
- const { Sequelize, Random } = require('multiple-quick-koa')
1
+ const { Sequelize, Random } = require('q-koa')
2
2
 
3
3
  exports.name = {
4
4
  type: Sequelize.STRING,
@@ -1,9 +1,4 @@
1
- const {
2
- getAppByCtx,
3
- getConfig,
4
- getService,
5
- lodash,
6
- } = require('multiple-quick-koa')
1
+ const { getAppByCtx, getConfig, getService, lodash } = require('q-koa')
7
2
 
8
3
  const util = require('util')
9
4
  const axios = require('axios')
@@ -1,4 +1,4 @@
1
- const { Sequelize } = require('multiple-quick-koa')
1
+ const { Sequelize } = require('q-koa')
2
2
 
3
3
  exports.openid = {
4
4
  type: Sequelize.STRING,
@@ -1,38 +1,43 @@
1
- const {
2
- getAppByCtx,
3
- getConfig,
4
- } = require('multiple-quick-koa');
1
+ const { getAppByCtx, getConfig } = require('q-koa')
5
2
 
6
3
  exports.destroy = async (ctx) => {
7
- const {
8
- app,
9
- } = getAppByCtx(ctx);
4
+ const { app } = getAppByCtx(ctx)
10
5
 
11
- const {
12
- id,
13
- } = ctx.request.body;
14
-
15
- app.model.mp_user && app.model.mp_user.destroy({
16
- where: {
17
- user_id: id,
18
- },
19
- }).then(() => {
20
- console.log(`删除${id}`);
21
- }).catch(console.log);
6
+ const { id } = ctx.request.body
22
7
 
23
- app.model.h5_user && app.model.h5_user.destroy({
24
- where: {
25
- user_id: id,
26
- },
27
- }).then(() => {
28
- console.log(`删除${id}`);
29
- }).catch(console.log);
8
+ app.model.mp_user &&
9
+ app.model.mp_user
10
+ .destroy({
11
+ where: {
12
+ user_id: id,
13
+ },
14
+ })
15
+ .then(() => {
16
+ console.log(`删除${id}`)
17
+ })
18
+ .catch(console.log)
30
19
 
31
- app.model.toutiao_user && app.model.toutiao_user.destroy({
32
- where: {
33
- user_id: id,
34
- },
35
- }).then(() => {
36
- console.log(`删除${id}`);
37
- }).catch(console.log);
38
- };
20
+ app.model.h5_user &&
21
+ app.model.h5_user
22
+ .destroy({
23
+ where: {
24
+ user_id: id,
25
+ },
26
+ })
27
+ .then(() => {
28
+ console.log(`删除${id}`)
29
+ })
30
+ .catch(console.log)
31
+
32
+ app.model.toutiao_user &&
33
+ app.model.toutiao_user
34
+ .destroy({
35
+ where: {
36
+ user_id: id,
37
+ },
38
+ })
39
+ .then(() => {
40
+ console.log(`删除${id}`)
41
+ })
42
+ .catch(console.log)
43
+ }
@@ -1,5 +1,5 @@
1
1
  const md5 = require('js-md5')
2
- const { getAppByCtx, getConfig } = require('multiple-quick-koa')
2
+ const { getAppByCtx, getConfig } = require('q-koa')
3
3
 
4
4
  exports.login = async (ctx) => {
5
5
  const { app, appName } = getAppByCtx(ctx)
@@ -1,5 +1,5 @@
1
- const { Sequelize, Random } = require('multiple-quick-koa');
2
- const md5 = require('js-md5');
1
+ const { Sequelize, Random } = require('q-koa')
2
+ const md5 = require('js-md5')
3
3
 
4
4
  exports.nick_name = {
5
5
  type: Sequelize.STRING,
@@ -8,7 +8,7 @@ exports.nick_name = {
8
8
  is_mock: false,
9
9
  defaultValue: '',
10
10
  sortOrder: 1,
11
- };
11
+ }
12
12
  exports.name = {
13
13
  type: Sequelize.STRING,
14
14
  comment: '名字',
@@ -18,12 +18,18 @@ exports.name = {
18
18
  sortOrder: 2,
19
19
  mock: () => Random.word(5),
20
20
  get: function () {
21
- return this.getDataValue('nick_name') || (this.getDataValue('mp_user') && this.getDataValue('mp_user').nick_name) ||
22
- (this.getDataValue('h5_user') && this.getDataValue('h5_user').nick_name) ||
23
- (this.getDataValue('toutiao_user') && this.getDataValue('toutiao_user').nick_name) ||
24
- '匿名用户'
21
+ return (
22
+ this.getDataValue('nick_name') ||
23
+ (this.getDataValue('mp_user') &&
24
+ this.getDataValue('mp_user').nick_name) ||
25
+ (this.getDataValue('h5_user') &&
26
+ this.getDataValue('h5_user').nick_name) ||
27
+ (this.getDataValue('toutiao_user') &&
28
+ this.getDataValue('toutiao_user').nick_name) ||
29
+ '匿名用户'
30
+ )
25
31
  },
26
- };
32
+ }
27
33
 
28
34
  exports.image = {
29
35
  type: Sequelize.VIRTUAL,
@@ -33,20 +39,25 @@ exports.image = {
33
39
  defaultValue: '',
34
40
  sortOrder: 3,
35
41
  get: function () {
36
- return this.getDataValue('avatar') || (this.getDataValue('mp_user') && this.getDataValue('mp_user').avatar) ||
42
+ return (
43
+ this.getDataValue('avatar') ||
44
+ (this.getDataValue('mp_user') && this.getDataValue('mp_user').avatar) ||
37
45
  (this.getDataValue('h5_user') && this.getDataValue('h5_user').avatar) ||
38
- (this.getDataValue('toutiao_user') && this.getDataValue('toutiao_user').avatar) ||
46
+ (this.getDataValue('toutiao_user') &&
47
+ this.getDataValue('toutiao_user').avatar) ||
39
48
  '//p0.meituan.net/codeman/bc1b8f0172cf718719edfb130ba171912425.jpg@120w_120h_1c_1e'
49
+ )
40
50
  },
41
- };
51
+ }
42
52
 
43
53
  exports.avatar = {
44
54
  type: Sequelize.STRING,
45
55
  comment: '头像',
46
56
  allowNull: false,
47
- defaultValue: '//p0.meituan.net/codeman/bc1b8f0172cf718719edfb130ba171912425.jpg@120w_120h_1c_1e',
57
+ defaultValue:
58
+ '//p0.meituan.net/codeman/bc1b8f0172cf718719edfb130ba171912425.jpg@120w_120h_1c_1e',
48
59
  mock: () => Random.image('100x100', Random.color(), Random.cword()),
49
- };
60
+ }
50
61
 
51
62
  exports.code = {
52
63
  type: Sequelize.STRING(6),
@@ -54,14 +65,14 @@ exports.code = {
54
65
  comment: '验证码',
55
66
  defaultValue: '',
56
67
  mock: () => Random.string('number', 4),
57
- };
68
+ }
58
69
 
59
70
  exports.sex_id = {
60
71
  type: Sequelize.INTEGER(11),
61
72
  allowNull: false,
62
73
  defaultValue: 4,
63
74
  comment: '性别',
64
- };
75
+ }
65
76
 
66
77
  exports.password = {
67
78
  type: Sequelize.STRING(),
@@ -70,7 +81,7 @@ exports.password = {
70
81
  defaultValue: '7b17d87eb787c51b4da25ec1bed26c8d',
71
82
  set(value) {
72
83
  this.setDataValue('password', md5(value))
73
- }
84
+ },
74
85
  // validate: {
75
86
  // notNull: {
76
87
  // msg: '密码不允许为空',
@@ -79,7 +90,7 @@ exports.password = {
79
90
  // msg: '密码不允许为空',
80
91
  // },
81
92
  // },
82
- };
93
+ }
83
94
 
84
95
  exports.mobile = {
85
96
  type: Sequelize.STRING(),
@@ -93,4 +104,4 @@ exports.mobile = {
93
104
  // },
94
105
  // },
95
106
  mock: () => Random.natural(13000000000, 19999999999),
96
- };
107
+ }
@@ -1,71 +1,86 @@
1
- const axios = require('axios');
2
- const APP = require('multiple-quick-koa');
3
- const APP_CONFIG = require('../../config');
4
- const config = require('./config');
1
+ const axios = require('axios')
2
+ const APP = require('q-koa')
3
+ const APP_CONFIG = require('../../config')
4
+ const config = require('./config')
5
5
 
6
- const modelName = __dirname.split('/').reverse()[0];
6
+ const modelName = __dirname.split('/').reverse()[0]
7
7
  const service = axios.create({
8
8
  baseURL: `http://localhost:${APP_CONFIG.port}/${modelName}`,
9
- });
10
- service.interceptors.request.use((config) => { config.headers['Client-Type'] = 2; return config; });
9
+ })
10
+ service.interceptors.request.use((config) => {
11
+ config.headers['Client-Type'] = 2
12
+ return config
13
+ })
11
14
 
12
- service.interceptors.response.use(response => response.data, error => Promise.reject(error));
15
+ service.interceptors.response.use(
16
+ (response) => response.data,
17
+ (error) => Promise.reject(error)
18
+ )
13
19
 
14
- const sleep = time => new Promise(resolve => setTimeout(resolve, time * 1000));
20
+ const sleep = (time) =>
21
+ new Promise((resolve) => setTimeout(resolve, time * 1000))
15
22
 
16
23
  describe(`${config.name}/${modelName}`, () => {
17
24
  beforeAll(async () => {
18
25
  try {
19
- await axios.post('/');
26
+ await axios.post('/')
20
27
  } catch (e) {
21
- console.log('正在启动服务器');
22
- const app = new APP(APP_CONFIG);
23
- await app.start();
28
+ console.log('正在启动服务器')
29
+ const app = new APP(APP_CONFIG)
30
+ await app.start()
24
31
  }
25
- });
32
+ })
26
33
 
27
34
  test('错误登录', async () => {
28
35
  const res = await service.post('login', {
29
36
  name: 'chenlin1',
30
37
  password: 'sugar23',
31
- });
32
- expect(res.code).toBe(500);
33
- });
38
+ })
39
+ expect(res.code).toBe(500)
40
+ })
34
41
 
35
42
  test('正确登录', async () => {
36
43
  const res = await service.post('login', {
37
44
  name: 'chenlin',
38
45
  password: 'sugar23',
39
- });
40
- expect(res.code).toBe(200);
41
- });
46
+ })
47
+ expect(res.code).toBe(200)
48
+ })
42
49
 
43
50
  test('获取token', async () => {
44
- const { data: { token } } = await service.post('login', {
51
+ const {
52
+ data: { token },
53
+ } = await service.post('login', {
45
54
  name: 'chenlin',
46
55
  password: 'sugar23',
47
- });
48
- expect(Boolean(token)).toBe(true);
49
- });
56
+ })
57
+ expect(Boolean(token)).toBe(true)
58
+ })
50
59
 
51
60
  test('没有token信息', async () => {
52
- const res = await service.post('getInfo', {});
53
- expect(res.code).toBe(401);
54
- });
61
+ const res = await service.post('getInfo', {})
62
+ expect(res.code).toBe(401)
63
+ })
55
64
 
56
65
  test('获取用户信息', async () => {
57
- const { data: { token } } = await service.post('login', {
66
+ const {
67
+ data: { token },
68
+ } = await service.post('login', {
58
69
  name: 'chenlin',
59
70
  password: 'sugar23',
60
- });
71
+ })
61
72
 
62
- const res = await service.post('getInfo', {}, {
63
- headers: {
64
- 'Client-Type': 2,
65
- 'X-Token': token,
66
- },
67
- });
73
+ const res = await service.post(
74
+ 'getInfo',
75
+ {},
76
+ {
77
+ headers: {
78
+ 'Client-Type': 2,
79
+ 'X-Token': token,
80
+ },
81
+ }
82
+ )
68
83
 
69
- expect(res.code).toBe(200);
70
- });
71
- });
84
+ expect(res.code).toBe(200)
85
+ })
86
+ })
@@ -1,4 +1,4 @@
1
- const { Validator } = require('multiple-quick-koa');
1
+ const { Validator } = require('q-koa')
2
2
 
3
3
  exports.login = async (ctx) => {
4
4
  const params = {
@@ -12,10 +12,9 @@ exports.login = async (ctx) => {
12
12
  required: true,
13
13
  message: '请输入密码',
14
14
  },
15
- };
16
- await new Validator(params).validate(ctx.request.body);
17
- };
18
-
15
+ }
16
+ await new Validator(params).validate(ctx.request.body)
17
+ }
19
18
 
20
19
  exports.register = async (ctx) => {
21
20
  const params = {
@@ -39,6 +38,6 @@ exports.register = async (ctx) => {
39
38
  required: true,
40
39
  message: '请输入昵称',
41
40
  },
42
- };
43
- await new Validator(params).validate(ctx.request.body);
44
- };
41
+ }
42
+ await new Validator(params).validate(ctx.request.body)
43
+ }
@@ -1,15 +1,13 @@
1
1
  const qqVideo = require('../../services/qqVideo')
2
- const { getAppByCtx } = require('multiple-quick-koa')
2
+ const { getAppByCtx } = require('q-koa')
3
3
 
4
- exports.qq = async ctx => {
4
+ exports.qq = async (ctx) => {
5
5
  const { app, appName } = getAppByCtx(ctx)
6
6
 
7
- const {
8
- vid
9
- } = ctx.request.body
7
+ const { vid } = ctx.request.body
10
8
 
11
9
  const video = await qqVideo(vid)
12
10
  // if (true) throw new Error('账号密码错误');
13
11
 
14
12
  return ctx.SUCCESS(video)
15
- }
13
+ }
@@ -1,4 +1,4 @@
1
- const { Validator } = require('multiple-quick-koa');
1
+ const { Validator } = require('q-koa')
2
2
 
3
3
  exports.qq = async (ctx) => {
4
4
  const params = {
@@ -7,6 +7,6 @@ exports.qq = async (ctx) => {
7
7
  required: true,
8
8
  message: '请输入腾讯vid',
9
9
  },
10
- };
11
- await new Validator(params).validate(ctx.request.body);
12
- };
10
+ }
11
+ await new Validator(params).validate(ctx.request.body)
12
+ }
@@ -1,9 +1,9 @@
1
- const { lodash, getAppByCtx, getConfig } = require('multiple-quick-koa')
1
+ const { lodash, getAppByCtx, getConfig } = require('q-koa')
2
2
 
3
3
  const path = require('path')
4
4
  const axios = require('axios')
5
5
  const OAuth = require('wechat-oauth')
6
- const WXPay = require('weixin-pay')
6
+ const WXPay = require('weixin-pay-fork')
7
7
  const WeixinPay = require('../../services/weixinPay')
8
8
  const WeixinMp = require('../../services/weixinMP')
9
9
  const Weixin = require('../../services/weixin')
@@ -1,7 +1,8 @@
1
- const { getAppByCtx, getConfig } = require('multiple-quick-koa')
1
+ const { getAppByCtx, getConfig } = require('q-koa')
2
2
  const { Pay } = require('@sigodenjs/wechatpay')
3
3
  const fs = require('fs')
4
4
  const path = require('path')
5
+ const fsPromise = require('fs/promises')
5
6
 
6
7
  exports.refund = async ({
7
8
  ctx,
@@ -21,7 +22,7 @@ exports.refund = async ({
21
22
  appId: appId,
22
23
  mchId: mchId,
23
24
  key: key, // 微信商户平台API密钥,
24
- pfx: fs.readFileSync(
25
+ pfx: await fsPromise.readFile(
25
26
  path.resolve(
26
27
  __dirname,
27
28
  `${process.cwd()}/app/${appName}/plugins/weixin/apiclient_cert.p12`
@@ -71,7 +72,7 @@ exports.cash = async ({ ctx, id, user_id, number }) => {
71
72
  appId: appId,
72
73
  mchId: mchId,
73
74
  key: key, // 微信商户平台API密钥,
74
- pfx: fs.readFileSync(
75
+ pfx: await fsPromise.readFile(
75
76
  path.resolve(
76
77
  __dirname,
77
78
  `${process.cwd()}/app/${appName}/plugins/weixin/apiclient_cert.p12`