q-koa 8.1.8 → 8.2.1

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
@@ -134,7 +134,7 @@ class APP {
134
134
  const verify = util.promisify(jwt.verify)
135
135
  const { url, host, ip, method } = ctx.request
136
136
 
137
- if (ctx.request.header['user-agent'].startsWith('Tencent Security')) {
137
+ if (ctx.request.header['user-agent'] && ctx.request.header['user-agent'].startsWith('Tencent Security')) {
138
138
  return ctx.ERROR('error')
139
139
  }
140
140
  if (this.config.blackList.includes(ip)) {
@@ -255,7 +255,11 @@ class APP {
255
255
  starter.on('loadAll', async () => {
256
256
  const appName = this.config.includes[0]
257
257
  this.server = this.app.listen(this.port, () => {
258
- console.log(`${moment().format('HH:mm:ss')} server is running at http://localhost:${this.port}`)
258
+ console.log(
259
+ `${moment().format(
260
+ 'HH:mm:ss'
261
+ )} server is running at http://localhost:${this.port}`
262
+ )
259
263
  console.log(
260
264
  `first app is http://localhost:3001/${appName}/setting/findOne`
261
265
  )
@@ -167,3 +167,10 @@ exports.deleteCheckList = {
167
167
  allowNull: false,
168
168
  defaultValue: [],
169
169
  }
170
+
171
+ exports.bulkCreateList = {
172
+ type: Sequelize.JSON,
173
+ comment: '批量更新字段',
174
+ allowNull: false,
175
+ defaultValue: [],
176
+ }
@@ -86,6 +86,7 @@ exports.loadModel = async ({ app, appName }) => {
86
86
  modelQuery: config.modelQuery,
87
87
  editInline: config.editInline,
88
88
  deleteCheckList: config.deleteCheckList,
89
+ bulkCreateList: config.bulkCreateList,
89
90
  list: attributes.map((attr, index) => {
90
91
  const name = attr.match(/exports.(.*)=/)[1].trim()
91
92
  let defaultValue = ''
@@ -166,8 +166,6 @@ exports.showTables = async (ctx) => {
166
166
  autoData: lodash.get(target, 'autoData', null),
167
167
  // 有些model需要前置查询其它model数据
168
168
  initList: lodash.get(target, 'initList', []),
169
- // 批量修改
170
- bulkCreateList: lodash.get(target, 'bulkCreateList', []),
171
169
  // 局部更新列表
172
170
  editInline: lodash.get(target, 'editInline', {}),
173
171
  // 有些model需要前置查询其它model数据
@@ -943,16 +943,11 @@ exports.url_link = async (ctx) => {
943
943
  const { app } = getAppByCtx(ctx)
944
944
 
945
945
  const { page, scene, config = 'weixin_mp' } = ctx.request.body
946
- const appConfig = getConfig(app)
947
- const { app_id, app_secrect } = await appConfig.getObject(config)
948
- const weixinMp = new WeixinMp({
949
- appid: app_id,
950
- secrect: app_secrect,
951
- })
952
- weixinMp.init()
953
- const result = await weixinMp.createUrlLink({
946
+ const result = await app.service.weixin.url_link({
947
+ app,
954
948
  page,
955
949
  scene,
950
+ config,
956
951
  })
957
952
  ctx.SUCCESS(result)
958
953
  }
@@ -1088,8 +1083,11 @@ exports.refund_notify = async (ctx) => {
1088
1083
 
1089
1084
  const refund_price = Number(refund_fee) / 100
1090
1085
 
1091
- const prefix =
1092
- out_trade_no.split('_').length === 4 ? out_trade_no.split('_')[1] : ''
1086
+ let prefix = ''
1087
+ if (out_trade_no.split('_')[1].includes('-')) {
1088
+ const arr = out_trade_no.split('_')[1].split('-')
1089
+ ;[prefix] = arr
1090
+ }
1093
1091
 
1094
1092
  const order_id = out_refund_no.includes('_')
1095
1093
  ? Number(out_refund_no.split('_')[0])
@@ -34,7 +34,7 @@ exports.refund = async ({
34
34
  })
35
35
  const orderModel = prefix ? `${prefix}_order` : 'order'
36
36
  const out_trade_no = prefix
37
- ? `${appName}_${prefix}_${id}_MP-WEIXIN`
37
+ ? `${appName}_${prefix}-${id}_MP-WEIXIN`
38
38
  : `${appName}_${id}_MP-WEIXIN`
39
39
  const orderDetail = await app.model[orderModel].findOne({
40
40
  where: {
@@ -63,9 +63,14 @@ exports.refund = async ({
63
63
  }
64
64
  }
65
65
 
66
- exports.cash = async ({ ctx, id, user_id, number }) => {
66
+ exports.cash = async ({
67
+ ctx,
68
+ id,
69
+ user_id,
70
+ number,
71
+ pay_config = 'weixin_pay',
72
+ }) => {
67
73
  const { app, appName } = getAppByCtx(ctx)
68
- const { pay_config = 'weixin_pay' } = ctx.request.body
69
74
  const appConfig = getConfig(app)
70
75
  const { mchId, key, appId } = await appConfig.getObject(pay_config)
71
76
 
@@ -177,3 +182,18 @@ exports.qr_code = async ({
177
182
  }
178
183
  }
179
184
  }
185
+
186
+ exports.url_link = async ({ app, page, scene, config = 'weixin_mp' }) => {
187
+ const appConfig = getConfig(app)
188
+ const { app_id, app_secrect } = await appConfig.getObject(config)
189
+ const weixinMp = new WeixinMp({
190
+ appid: app_id,
191
+ secrect: app_secrect,
192
+ })
193
+ weixinMp.init()
194
+ const result = await weixinMp.createUrlLink({
195
+ page,
196
+ scene,
197
+ })
198
+ return result
199
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "8.1.8",
3
+ "version": "8.2.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {