accept array in params
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b421038bbe
commit
a136d8b03d
|
@ -40,7 +40,6 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const salesIds = [];
|
||||
const params = [];
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager');
|
||||
|
@ -50,23 +49,19 @@ module.exports = Self => {
|
|||
if (!hasValidRole)
|
||||
throw new UserError(`You don't have privileges to create pay back`);
|
||||
|
||||
sales.forEach(sale => {
|
||||
for (let sale of sales)
|
||||
salesIds.push(sale.id);
|
||||
params.push('?');
|
||||
});
|
||||
|
||||
const paramsString = params.join();
|
||||
|
||||
const query = `
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
|
||||
CREATE TEMPORARY TABLE tmp.sale
|
||||
SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount
|
||||
FROM sale s
|
||||
WHERE s.id IN (${paramsString});
|
||||
CALL vn.ticket_doRefund(${ticketId}, @newTicket);
|
||||
WHERE s.id IN (?);
|
||||
CALL vn.ticket_doRefund(?, @newTicket);
|
||||
DROP TEMPORARY TABLE tmp.sale;`;
|
||||
|
||||
await Self.rawSql(query, salesIds, myOptions);
|
||||
await Self.rawSql(query, [salesIds, ticketId], myOptions);
|
||||
const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions);
|
||||
ticketId = newTicket.id;
|
||||
|
||||
|
|
|
@ -35,11 +35,8 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const salesIds = [];
|
||||
const params = [];
|
||||
sales.forEach(sale => {
|
||||
for (let sale of sales)
|
||||
salesIds.push(sale.id);
|
||||
params.push('?');
|
||||
});
|
||||
|
||||
const isEditable = await models.Ticket.isEditable(ctx, sales[0].ticketFk, myOptions);
|
||||
if (!isEditable)
|
||||
|
@ -49,14 +46,12 @@ module.exports = Self => {
|
|||
if (!canEditSale)
|
||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
||||
|
||||
const paramsString = params.join();
|
||||
|
||||
const query = `
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
|
||||
CREATE TEMPORARY TABLE tmp.recalculateSales
|
||||
SELECT s.id
|
||||
FROM sale s
|
||||
WHERE s.id IN (${paramsString});
|
||||
WHERE s.id IN (?);
|
||||
CALL vn.sale_recalcComponent(null);
|
||||
DROP TEMPORARY TABLE tmp.recalculateSales;`;
|
||||
|
||||
|
|
|
@ -30,14 +30,6 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const params = [];
|
||||
const paramsSql = [date, date, date];
|
||||
for (id of zonesId) {
|
||||
params.push('?');
|
||||
paramsSql.push(id);
|
||||
}
|
||||
|
||||
const paramsString = params.join();
|
||||
query = `
|
||||
SELECT *
|
||||
FROM (
|
||||
|
@ -56,10 +48,10 @@ module.exports = Self => {
|
|||
OR ? BETWEEN started AND ended
|
||||
OR INSTR(weekDays, SUBSTRING(DAYNAME(?), 1, 3) ) > 0
|
||||
)
|
||||
AND z.id IN (${paramsString})
|
||||
AND z.id IN (?)
|
||||
ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z
|
||||
GROUP BY z.id`;
|
||||
|
||||
return await Self.rawSql(query, paramsSql, myOptions);
|
||||
return Self.rawSql(query, [date, date, date, zonesId], myOptions);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue