q-koa 9.3.1 → 9.3.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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const fsPromise = require('fs/promises')
|
|
4
|
+
const { lodash } = require('q-koa')
|
|
4
5
|
exports.loadModel = async ({ app, appName }) => {
|
|
5
6
|
const data = await fsPromise.readdir(
|
|
6
7
|
path.resolve(__dirname, `${process.cwd()}/app/${appName}/plugins`)
|
|
@@ -15,7 +16,11 @@ exports.loadModel = async ({ app, appName }) => {
|
|
|
15
16
|
})
|
|
16
17
|
)
|
|
17
18
|
)
|
|
18
|
-
|
|
19
|
+
const currentDisabledFindAllList = lodash.get(
|
|
20
|
+
app,
|
|
21
|
+
'appConfig.disabledFindAllList',
|
|
22
|
+
[]
|
|
23
|
+
)
|
|
19
24
|
const dataList = []
|
|
20
25
|
let disabledFindAllList = []
|
|
21
26
|
const result = data.filter(
|
|
@@ -64,7 +69,7 @@ exports.loadModel = async ({ app, appName }) => {
|
|
|
64
69
|
|
|
65
70
|
let countNumber = 0
|
|
66
71
|
if (!['setting', 'auth'].includes(config.belongs)) {
|
|
67
|
-
if (app.model[result[i]]) {
|
|
72
|
+
if (currentDisabledFindAllList.length === 0 && app.model[result[i]]) {
|
|
68
73
|
countNumber = await app.model[result[i]].count()
|
|
69
74
|
}
|
|
70
75
|
if (countNumber >= 500) {
|
|
@@ -223,7 +228,11 @@ exports.loadModel = async ({ app, appName }) => {
|
|
|
223
228
|
|
|
224
229
|
await Promise.all([promise1, promise2])
|
|
225
230
|
console.log('lodaModel success!')
|
|
226
|
-
|
|
231
|
+
if (currentDisabledFindAllList.length > 0) {
|
|
232
|
+
console.warn(`当前disabledFindAllList不为空,查看需清空`)
|
|
233
|
+
} else {
|
|
234
|
+
console.warn(`disabledFindAllList: ${JSON.stringify(disabledFindAllList)}`)
|
|
235
|
+
}
|
|
227
236
|
|
|
228
237
|
if (app.service.routes && app.model.routes) {
|
|
229
238
|
await app.service.routes.initRouter({ app })
|
|
@@ -14,11 +14,12 @@ exports.copyOther = async (ctx) => {
|
|
|
14
14
|
const { app, appName } = getAppByCtx(ctx)
|
|
15
15
|
|
|
16
16
|
const { type, source } = ctx.request.body
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
|
|
17
|
+
const url = `http://localhost:3001/${source}/setting/findAll`
|
|
18
|
+
const result = await axios.post(url).then((res) => res.data)
|
|
19
|
+
if (result.code !== 200) {
|
|
20
|
+
throw new Error(result.message + url)
|
|
21
|
+
}
|
|
22
|
+
const { data } = result
|
|
22
23
|
const copyType = data.find((item) => item.code === type)
|
|
23
24
|
|
|
24
25
|
if (!copyType) throw new Error('克隆方找不到')
|
|
@@ -28,23 +29,37 @@ exports.copyOther = async (ctx) => {
|
|
|
28
29
|
const list = await app.model.setting.findAll()
|
|
29
30
|
|
|
30
31
|
const findType = list.find((item) => item.code === type)
|
|
31
|
-
if (!findType)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
if (!findType) {
|
|
33
|
+
const { id, ...rest } = copyType
|
|
34
|
+
const newParent = await app.model.setting.create({
|
|
35
|
+
...rest,
|
|
36
|
+
})
|
|
37
|
+
await app.model.setting.bulkCreate(
|
|
38
|
+
copyList.map((item) => {
|
|
39
|
+
const { parent, id, ...rest } = item
|
|
40
|
+
return {
|
|
41
|
+
...rest,
|
|
42
|
+
parent_id: newParent.id,
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
} else {
|
|
47
|
+
await app.model.setting.destroy({
|
|
48
|
+
where: {
|
|
44
49
|
parent_id: findType.id,
|
|
45
|
-
}
|
|
50
|
+
},
|
|
46
51
|
})
|
|
47
|
-
|
|
52
|
+
|
|
53
|
+
await app.model.setting.bulkCreate(
|
|
54
|
+
copyList.map((item) => {
|
|
55
|
+
const { parent, id, ...rest } = item
|
|
56
|
+
return {
|
|
57
|
+
...rest,
|
|
58
|
+
parent_id: findType.id,
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
}
|
|
48
63
|
|
|
49
64
|
ctx.SUCCESS('ok')
|
|
50
65
|
}
|
|
@@ -759,13 +759,15 @@ exports.h5_pay = async (ctx) => {
|
|
|
759
759
|
key: key.length > 10 ? key : partner_key,
|
|
760
760
|
mchId,
|
|
761
761
|
})
|
|
762
|
+
|
|
763
|
+
const notify_url = `https://${
|
|
764
|
+
site_host || 'api.kuashou.com'
|
|
765
|
+
}/${appName}/weixin/notify`
|
|
762
766
|
const result = await payObj.run({
|
|
763
767
|
body: name,
|
|
764
768
|
out_trade_no: `${appName}_${order_id}_${type}`,
|
|
765
769
|
total_fee: is_admin || is_dev ? 1 : Math.round(price * 100),
|
|
766
|
-
notify_url
|
|
767
|
-
site_host || 'api.kuashou.com'
|
|
768
|
-
}/${appName}/weixin/notify`,
|
|
770
|
+
notify_url,
|
|
769
771
|
scene_info: `{"h5_info": {"type":"Wap","wap_url": ${
|
|
770
772
|
site_host || 'https://api.kuashou.com'
|
|
771
773
|
},"wap_name": "腾讯充值"}}`,
|
|
@@ -844,6 +846,9 @@ exports.mp_pay = async (ctx) => {
|
|
|
844
846
|
? `${appName}_${prefix}-${order_id}_${type}`
|
|
845
847
|
: `${appName}_${order_id}_${type}`
|
|
846
848
|
|
|
849
|
+
const notify_url = `https://${
|
|
850
|
+
site_host || 'api.kuashou.com'
|
|
851
|
+
}/${appName}/weixin/notify`
|
|
847
852
|
const prePayResult = await pay({
|
|
848
853
|
openid: userDetail.openid,
|
|
849
854
|
body: name,
|
|
@@ -851,9 +856,7 @@ exports.mp_pay = async (ctx) => {
|
|
|
851
856
|
out_trade_no,
|
|
852
857
|
total_fee: is_admin || is_dev ? 1 : Math.round(price * 100),
|
|
853
858
|
spbill_create_ip: '192.168.2.210',
|
|
854
|
-
notify_url
|
|
855
|
-
site_host || 'api.kuashou.com'
|
|
856
|
-
}/${appName}/weixin/notify`,
|
|
859
|
+
notify_url,
|
|
857
860
|
})
|
|
858
861
|
|
|
859
862
|
const checkOrder = (obj) => {
|
|
@@ -892,6 +895,13 @@ exports.mp_pay = async (ctx) => {
|
|
|
892
895
|
if (payResult.trade_state_desc === '支付成功') {
|
|
893
896
|
return ctx.SUCCESS('ok')
|
|
894
897
|
}
|
|
898
|
+
if (payResult.return_msg) {
|
|
899
|
+
throw new Error(
|
|
900
|
+
payResult.return_msg === '签名错误,请检查后再试'
|
|
901
|
+
? payResult.return_msg + '(商户号/APIv2/关联)'
|
|
902
|
+
: payResult.return_msg
|
|
903
|
+
)
|
|
904
|
+
}
|
|
895
905
|
throw new Error(`支付失败,请重试`)
|
|
896
906
|
}
|
|
897
907
|
return ctx.SUCCESS({
|