q-koa 8.1.9 → 8.2.2
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 +10 -3
- package/core/file/plugins/model/model.js +7 -0
- package/core/file/plugins/model/service.js +1 -0
- package/core/file/plugins/system/controller.js +0 -2
- package/core/file/plugins/weixin/controller.js +8 -10
- package/core/file/plugins/weixin/service.js +22 -2
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -18,6 +18,7 @@ const chalk = require('chalk')
|
|
|
18
18
|
const { Random } = require('mockjs')
|
|
19
19
|
const util = require('util')
|
|
20
20
|
const jwt = require('jsonwebtoken')
|
|
21
|
+
const verify = util.promisify(jwt.verify)
|
|
21
22
|
const fsExtra = require('fs-extra')
|
|
22
23
|
const { getObject } = require('./file/utils')
|
|
23
24
|
const restc = require('./restc')
|
|
@@ -131,10 +132,12 @@ class APP {
|
|
|
131
132
|
* jwt中间件
|
|
132
133
|
*/
|
|
133
134
|
this.app.use(async (ctx, next) => {
|
|
134
|
-
const verify = util.promisify(jwt.verify)
|
|
135
135
|
const { url, host, ip, method } = ctx.request
|
|
136
136
|
|
|
137
|
-
if (
|
|
137
|
+
if (
|
|
138
|
+
ctx.request.header['user-agent'] &&
|
|
139
|
+
ctx.request.header['user-agent'].startsWith('Tencent Security')
|
|
140
|
+
) {
|
|
138
141
|
return ctx.ERROR('error')
|
|
139
142
|
}
|
|
140
143
|
if (this.config.blackList.includes(ip)) {
|
|
@@ -255,7 +258,11 @@ class APP {
|
|
|
255
258
|
starter.on('loadAll', async () => {
|
|
256
259
|
const appName = this.config.includes[0]
|
|
257
260
|
this.server = this.app.listen(this.port, () => {
|
|
258
|
-
console.log(
|
|
261
|
+
console.log(
|
|
262
|
+
`${moment().format(
|
|
263
|
+
'HH:mm:ss'
|
|
264
|
+
)} server is running at http://localhost:${this.port}`
|
|
265
|
+
)
|
|
259
266
|
console.log(
|
|
260
267
|
`first app is http://localhost:3001/${appName}/setting/findOne`
|
|
261
268
|
)
|
|
@@ -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
|
|
947
|
-
|
|
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
|
-
|
|
1092
|
-
|
|
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])
|
|
@@ -63,9 +63,14 @@ exports.refund = async ({
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
exports.cash = async ({
|
|
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
|
+
}
|