q-koa 9.3.3 → 9.3.4
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
|
@@ -1819,6 +1819,7 @@ APP.getAppByCtx = (ctx) => {
|
|
|
1819
1819
|
const appName = ctx.router.opts.prefix.substring(1)
|
|
1820
1820
|
|
|
1821
1821
|
let controller = ''
|
|
1822
|
+
let payName = appName
|
|
1822
1823
|
try {
|
|
1823
1824
|
const url = ctx.request.url
|
|
1824
1825
|
const _split = url.split('/')
|
|
@@ -1826,10 +1827,23 @@ APP.getAppByCtx = (ctx) => {
|
|
|
1826
1827
|
} catch (e) {
|
|
1827
1828
|
console.warn(e)
|
|
1828
1829
|
}
|
|
1830
|
+
try {
|
|
1831
|
+
const url = ctx.request.url
|
|
1832
|
+
const referer = ctx.request.header.referer
|
|
1833
|
+
if (!referer.includes(url)) {
|
|
1834
|
+
const arr = ctx.request.header.referer.split('/').reverse()
|
|
1835
|
+
if (arr.length >= 4) {
|
|
1836
|
+
payName = arr[2]
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
} catch (e) {
|
|
1840
|
+
console.warn(e)
|
|
1841
|
+
}
|
|
1829
1842
|
const { [appName]: app } = ctx.app
|
|
1830
1843
|
return {
|
|
1831
1844
|
appName,
|
|
1832
1845
|
app,
|
|
1846
|
+
payName,
|
|
1833
1847
|
controller,
|
|
1834
1848
|
}
|
|
1835
1849
|
}
|
|
@@ -14,7 +14,9 @@ exports.copyOther = async (ctx) => {
|
|
|
14
14
|
const { app, appName } = getAppByCtx(ctx)
|
|
15
15
|
|
|
16
16
|
const { type, source } = ctx.request.body
|
|
17
|
-
const url =
|
|
17
|
+
const url = source.startsWith('http')
|
|
18
|
+
? source
|
|
19
|
+
: `http://localhost:3001/${source}/setting/findAll`
|
|
18
20
|
const result = await axios.post(url).then((res) => res.data)
|
|
19
21
|
if (result.code !== 200) {
|
|
20
22
|
throw new Error(result.message + url)
|
|
@@ -24,11 +26,21 @@ exports.copyOther = async (ctx) => {
|
|
|
24
26
|
|
|
25
27
|
if (!copyType) throw new Error('克隆方找不到')
|
|
26
28
|
|
|
27
|
-
const copyList = data.filter((item) => item.parent_id === copyType.id)
|
|
28
|
-
|
|
29
29
|
const list = await app.model.setting.findAll()
|
|
30
30
|
|
|
31
31
|
const findType = list.find((item) => item.code === type)
|
|
32
|
+
if (findType && findType.parent_id) {
|
|
33
|
+
if (!findType) {
|
|
34
|
+
throw new Error(`当前找不到${type}`)
|
|
35
|
+
}
|
|
36
|
+
await app.model.setting.upsert({
|
|
37
|
+
id: findType.id,
|
|
38
|
+
value: copyType.value,
|
|
39
|
+
})
|
|
40
|
+
return ctx.SUCCESS('ok')
|
|
41
|
+
}
|
|
42
|
+
const copyList = data.filter((item) => item.parent_id === copyType.id)
|
|
43
|
+
|
|
32
44
|
if (!findType) {
|
|
33
45
|
const { id, ...rest } = copyType
|
|
34
46
|
const newParent = await app.model.setting.create({
|
|
@@ -782,7 +782,7 @@ exports.h5_pay = async (ctx) => {
|
|
|
782
782
|
}
|
|
783
783
|
|
|
784
784
|
exports.mp_pay = async (ctx) => {
|
|
785
|
-
const { app, appName } = getAppByCtx(ctx)
|
|
785
|
+
const { app, appName, payName } = getAppByCtx(ctx)
|
|
786
786
|
const {
|
|
787
787
|
name,
|
|
788
788
|
order_id,
|
|
@@ -843,12 +843,12 @@ exports.mp_pay = async (ctx) => {
|
|
|
843
843
|
const out_trade_no = _out_trade_no
|
|
844
844
|
? _out_trade_no
|
|
845
845
|
: prefix
|
|
846
|
-
? `${
|
|
847
|
-
: `${
|
|
846
|
+
? `${payName}_${prefix}-${order_id}_${type}`
|
|
847
|
+
: `${payName}_${order_id}_${type}`
|
|
848
848
|
|
|
849
849
|
const notify_url = `https://${
|
|
850
850
|
site_host || 'api.kuashou.com'
|
|
851
|
-
}/${
|
|
851
|
+
}/${payName}/weixin/notify`
|
|
852
852
|
const prePayResult = await pay({
|
|
853
853
|
openid: userDetail.openid,
|
|
854
854
|
body: name,
|