ufo.js
789 Bytes
const {mysqlPool} = require('../../../libs/mysql');
const {logger} = require('../../../libs/logger');
module.exports = async(third) => {
try {
if (!third) {
return void 0;
}
const skus = await mysqlPool.query(`select si.size_name, min(sp.price) as price from \`storage\` s inner join storage_price sp on s.id = sp.storage_id and sp.status = 1 and sp.price > 0 inner join size si on s.size_id = si.id where s.product_id = ${third.productId} group by si.size_name`);
return {
skus: skus.map(s => {
if (!s.price) {
return void 0;
}
return {
size: s.size_name,
price: s.price
};
}).filter(s => s)
};
} catch (error) {
logger.error(`[price-line-task] ufo spider, ${error}`);
}
};