q-koa 12.9.1 → 12.9.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.
package/core/app.js
CHANGED
|
@@ -772,6 +772,29 @@ class APP {
|
|
|
772
772
|
})
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
|
+
const start = moment().valueOf()
|
|
776
|
+
for (const fn of ['service', 'controller']) {
|
|
777
|
+
const cloneTarget = this.app[appName][fn]
|
|
778
|
+
|
|
779
|
+
this.app[appName][fn] = Object.keys(cloneTarget).reduce((a, b) => {
|
|
780
|
+
const modelService = cloneTarget[b]
|
|
781
|
+
const newB = Object.keys(modelService).reduce((_a, _b) => {
|
|
782
|
+
const bindFn = modelService[_b].bind(this.app[appName])
|
|
783
|
+
return {
|
|
784
|
+
..._a,
|
|
785
|
+
[_b]: bindFn,
|
|
786
|
+
}
|
|
787
|
+
}, {})
|
|
788
|
+
return {
|
|
789
|
+
...a,
|
|
790
|
+
[b]: newB,
|
|
791
|
+
}
|
|
792
|
+
}, {})
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (is_dev) {
|
|
796
|
+
console.log(moment().valueOf() - start)
|
|
797
|
+
}
|
|
775
798
|
}
|
|
776
799
|
|
|
777
800
|
initModel(appName) {
|
|
@@ -936,6 +959,24 @@ class APP {
|
|
|
936
959
|
]
|
|
937
960
|
for (let i = 0; i < hooksList.length; i++) {
|
|
938
961
|
if (_.get(app, `${appName}.${hooksList[i]}.${controller}.${fn}`)) {
|
|
962
|
+
if (hooksList[i] === 'controller') {
|
|
963
|
+
process.once('unhandledRejection', (reason, promise) => {
|
|
964
|
+
if (
|
|
965
|
+
this.app &&
|
|
966
|
+
this.app[appName] &&
|
|
967
|
+
this.app[appName].model &&
|
|
968
|
+
this.app[appName].model.log
|
|
969
|
+
) {
|
|
970
|
+
this.app[appName].model.log.create({
|
|
971
|
+
url: ctx.request.href,
|
|
972
|
+
body: ctx.request.body,
|
|
973
|
+
message: 'promise unhandledRejection',
|
|
974
|
+
content: reason.stack,
|
|
975
|
+
header: ctx.request.header,
|
|
976
|
+
})
|
|
977
|
+
}
|
|
978
|
+
})
|
|
979
|
+
}
|
|
939
980
|
await app[appName][hooksList[i]][controller][fn](ctx)
|
|
940
981
|
}
|
|
941
982
|
}
|
|
@@ -1203,6 +1203,7 @@ exports.notify = async (ctx) => {
|
|
|
1203
1203
|
// console.log(order_id, '微信支付回调-----', model, order_price, transactionid)
|
|
1204
1204
|
if (app.service[model] && app.service[model].notify) {
|
|
1205
1205
|
await app.service[model].notify({
|
|
1206
|
+
ctx,
|
|
1206
1207
|
app,
|
|
1207
1208
|
order_id,
|
|
1208
1209
|
order: model,
|
|
@@ -496,7 +496,7 @@ exports.handleUserMessage = async ({ app, result }) => {
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
exports.funds_order_pay = async ({ app, result }) => {
|
|
499
|
+
exports.funds_order_pay = async ({ ctx, app, result }) => {
|
|
500
500
|
const appConfig = getConfig(app)
|
|
501
501
|
|
|
502
502
|
if (result.ToUserName) {
|
|
@@ -546,7 +546,7 @@ exports.funds_order_pay = async ({ app, result }) => {
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
-
exports.funds_order_refund = async ({ app, result }) => {
|
|
549
|
+
exports.funds_order_refund = async ({ ctx, app, result }) => {
|
|
550
550
|
const appConfig = getConfig(app)
|
|
551
551
|
|
|
552
552
|
if (result.ToUserName) {
|