added catalog calculate join to show only available item types
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4628c8ab6f
commit
82259eee16
|
@ -31,13 +31,36 @@ module.exports = Self => {
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
|
||||||
|
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.item');
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`CREATE TEMPORARY TABLE tmp.item
|
||||||
|
(PRIMARY KEY (itemFk)) ENGINE = MEMORY
|
||||||
|
SELECT DISTINCT
|
||||||
|
i.id AS itemFk,
|
||||||
|
i.typeFk,
|
||||||
|
it.categoryFk
|
||||||
|
FROM vn.item i
|
||||||
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
JOIN vn.itemCategory ic ON ic.id = it.categoryFk`);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
let order = await app.models.Order.findById(orderId);
|
let order = await app.models.Order.findById(orderId);
|
||||||
stmt = new ParameterizedSQL('call vn.available_calc(?, ?, ?)', [
|
stmt = new ParameterizedSQL('call vn.available_calc(?, ?, ?)', [
|
||||||
order.landed,
|
order.landed,
|
||||||
order.addressFk,
|
order.addressFk,
|
||||||
order.agencyModeFk
|
order.agencyModeFk
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
stmts.push(new ParameterizedSQL(
|
||||||
|
'CALL vn.catalog_calculate(?, ?, ?)', [
|
||||||
|
order.landed,
|
||||||
|
order.addressFk,
|
||||||
|
order.agencyModeFk,
|
||||||
|
]
|
||||||
|
));
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
SELECT it.id, it.name, ic.name categoryName
|
SELECT it.id, it.name, ic.name categoryName
|
||||||
FROM tmp.availableCalc ac
|
FROM tmp.availableCalc ac
|
||||||
|
@ -45,6 +68,7 @@ module.exports = Self => {
|
||||||
JOIN item i ON i.id = a.item_id
|
JOIN item i ON i.id = a.item_id
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
|
JOIN tmp.ticketCalculateItem tci ON tci.itemFk = i.id
|
||||||
WHERE it.categoryFk = ?
|
WHERE it.categoryFk = ?
|
||||||
GROUP BY it.id`, [itemCategoryId]
|
GROUP BY it.id`, [itemCategoryId]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue