index.js
790 Bytes
const _ = require('lodash');
const {mysqlPool} = require('../libs/mysql');
const spSize = require('../data/spSize.json');
module.exports.getSpecialSizeProducts = async() => {
const specialSizeProducts = await mysqlPool.query('select id from product where brand_id in (2, 6) and max_sort_id = 40');
const products = {};
_.each(specialSizeProducts, product => {
products[product.id] = true;
});
return products;
};
module.exports.getSize = (size, sizeRelation, isSpecialSize) => {
if (!isSpecialSize) {
return sizeRelation[size];
}
const relationSize = spSize[size];
if (relationSize) {
const findSize = sizeRelation[_.trim(relationSize)];
if (findSize) {
return {sizeId: findSize.sizeId, relationSize};
}
}
return sizeRelation[size];
};