diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f469e893a..992598fb5 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -197,6 +197,18 @@ module.exports = function(Self) { * Shortcut to VnMySQL.executeP() */ rawSql(query, params, options, cb) { + const userId = options.userId; + if (userId) { + params.unshift(userId); + return this.dataSource.connector.executeP( + `CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?)); + ${query}; + CALL account.myUser_logout();`, + params, + options, + cb + ); + } return this.dataSource.connector.executeP(query, params, options, cb); }, diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 9739f5985..c2de55c96 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -29,7 +29,7 @@ module.exports = function(Self) { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object')