q-koa 7.9.6 → 7.9.9
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
|
@@ -795,11 +795,11 @@ class APP {
|
|
|
795
795
|
}
|
|
796
796
|
await next()
|
|
797
797
|
})
|
|
798
|
-
|
|
798
|
+
const handleRouter = async (ctx) => {
|
|
799
799
|
const appName = router.opts.prefix.substring(1)
|
|
800
800
|
const { app } = ctx
|
|
801
801
|
|
|
802
|
-
const { controller, fn } = ctx.params
|
|
802
|
+
const { controller, fn, sub } = ctx.params
|
|
803
803
|
if (_.get(app, `${appName}.model.${controller}`) && fn === 'mock') {
|
|
804
804
|
return ctx.SUCCESS(await app[appName].mock[controller]())
|
|
805
805
|
}
|
|
@@ -1724,7 +1724,10 @@ class APP {
|
|
|
1724
1724
|
})
|
|
1725
1725
|
}
|
|
1726
1726
|
}
|
|
1727
|
-
}
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
router.post('/:controller/:fn', handleRouter)
|
|
1730
|
+
router.post('/:controller/:fn/:sub', handleRouter)
|
|
1728
1731
|
}
|
|
1729
1732
|
}
|
|
1730
1733
|
|
|
@@ -1008,13 +1008,14 @@ exports.sendMessage = async (ctx) => {
|
|
|
1008
1008
|
exports.refund = async (ctx) => {
|
|
1009
1009
|
const { app, appName } = getAppByCtx(ctx)
|
|
1010
1010
|
const appConfig = getConfig(app)
|
|
1011
|
-
const { id, prefix = '', price } = ctx.request.body
|
|
1011
|
+
const { id, prefix = '', price, pay_config = 'weixin_pay' } = ctx.request.body
|
|
1012
1012
|
|
|
1013
1013
|
await app.service.weixin.refund({
|
|
1014
1014
|
ctx,
|
|
1015
1015
|
id,
|
|
1016
|
-
prefix
|
|
1016
|
+
prefix,
|
|
1017
1017
|
price,
|
|
1018
|
+
pay_config,
|
|
1018
1019
|
})
|
|
1019
1020
|
ctx.SUCCESS('ok')
|
|
1020
1021
|
}
|
|
@@ -1049,7 +1050,7 @@ const getRefundResultJson = async ({ req_info, app_key }) => {
|
|
|
1049
1050
|
exports.refund_notify = async (ctx) => {
|
|
1050
1051
|
const { app } = getAppByCtx(ctx)
|
|
1051
1052
|
const result = ctx.request.xmlBody
|
|
1052
|
-
const pay_config = ctx.
|
|
1053
|
+
const pay_config = ctx.params.sub || 'weixin_pay'
|
|
1053
1054
|
|
|
1054
1055
|
const appConfig = getConfig(app)
|
|
1055
1056
|
const { key } = await appConfig.getObject(pay_config)
|
|
@@ -27,7 +27,7 @@ exports.refund = async ({
|
|
|
27
27
|
pfx: await fsPromise.readFile(
|
|
28
28
|
path.resolve(
|
|
29
29
|
__dirname,
|
|
30
|
-
`${process.cwd()}/app/${appName}/plugins/weixin/apiclient_cert.p12`
|
|
30
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${pay_config}/apiclient_cert.p12`
|
|
31
31
|
)
|
|
32
32
|
), // 微信商户平台证书
|
|
33
33
|
})
|
|
@@ -50,7 +50,7 @@ exports.refund = async ({
|
|
|
50
50
|
refund_fee: Math.round((refund_fee || price) * 100),
|
|
51
51
|
notify_url: `https://${
|
|
52
52
|
site_host || 'api.kuashou.com'
|
|
53
|
-
}/${appName}/weixin/refund_notify
|
|
53
|
+
}/${appName}/weixin/refund_notify/${pay_config}`,
|
|
54
54
|
})
|
|
55
55
|
if (result_code === 'SUCCESS') {
|
|
56
56
|
return true
|