q-koa 10.0.5 → 10.0.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.
package/core/app.js
CHANGED
|
@@ -993,6 +993,10 @@ class APP {
|
|
|
993
993
|
const postInclude = nodeVm.runInNewContext(_str)
|
|
994
994
|
const strInclude = postInclude(app[appName])
|
|
995
995
|
// const postInclude = include.toFunction();
|
|
996
|
+
|
|
997
|
+
if (!Array.isArray(strInclude))
|
|
998
|
+
throw new Error(`可能include不是一个数组`)
|
|
999
|
+
|
|
996
1000
|
myInclude =
|
|
997
1001
|
app[appName] &&
|
|
998
1002
|
app[appName].include &&
|
|
@@ -26,6 +26,7 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
|
|
|
26
26
|
include,
|
|
27
27
|
excludeInclude,
|
|
28
28
|
autoInclude = true,
|
|
29
|
+
is_cache = false,
|
|
29
30
|
} = route
|
|
30
31
|
|
|
31
32
|
if (url.includes('http')) {
|
|
@@ -54,6 +55,27 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
|
|
|
54
55
|
|
|
55
56
|
const [model, fn] = url.split('/')
|
|
56
57
|
|
|
58
|
+
if (is_cache && app.cache && app.cache.get(`${model}`)) {
|
|
59
|
+
const cacheData = app.cache.get(`${model}`) || []
|
|
60
|
+
const cacheList = cacheData
|
|
61
|
+
.filter((c) => {
|
|
62
|
+
const target = data && data.where ? data.where : {}
|
|
63
|
+
return Object.keys(target).every((key) => {
|
|
64
|
+
return c[key] === target[key]
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
.map((c) => {
|
|
68
|
+
const omit = data && data.omit ? data.omit : []
|
|
69
|
+
const pick = data && data.pick ? data.pick : []
|
|
70
|
+
return pick.length > 0
|
|
71
|
+
? lodash.pick(c, pick)
|
|
72
|
+
: lodash.omit(c, omit)
|
|
73
|
+
})
|
|
74
|
+
return Promise.resolve({
|
|
75
|
+
[item]: cacheList,
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
57
79
|
let myInclude
|
|
58
80
|
|
|
59
81
|
if (include) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getAppByCtx, getConfig } = require('q-koa')
|
|
1
|
+
const { getAppByCtx, getConfig, lodash } = require('q-koa')
|
|
2
2
|
const { Pay } = require('@sigodenjs/wechatpay')
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const fsPromise = require('fs/promises')
|
|
@@ -62,6 +62,16 @@ exports.refund = async ({
|
|
|
62
62
|
if (result_code === 'SUCCESS') {
|
|
63
63
|
return true
|
|
64
64
|
} else {
|
|
65
|
+
console.error({
|
|
66
|
+
...rest,
|
|
67
|
+
out_trade_no,
|
|
68
|
+
out_refund_no: id + '_' + type,
|
|
69
|
+
total_fee: Math.round((total_fee || refund_fee || price) * 100),
|
|
70
|
+
refund_fee: Math.round((refund_fee || price) * 100),
|
|
71
|
+
notify_url: `https://${
|
|
72
|
+
site_host || 'api.kuashou.com'
|
|
73
|
+
}/${appName}/weixin/refund_notify/${pay_config}`,
|
|
74
|
+
})
|
|
65
75
|
throw new Error(err_code_des)
|
|
66
76
|
}
|
|
67
77
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const { getAppByCtx, getConfig } = require('q-koa')
|
|
2
|
-
|
|
3
|
-
exports.upsert = async (ctx) => {
|
|
4
|
-
const { app } = getAppByCtx(ctx)
|
|
5
|
-
const appConfig = getConfig(app)
|
|
6
|
-
appConfig.update('application')
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
exports.bulkCreate = async (ctx) => {
|
|
10
|
-
const { app } = getAppByCtx(ctx)
|
|
11
|
-
const appConfig = getConfig(app)
|
|
12
|
-
appConfig.update('application')
|
|
13
|
-
}
|