spider-top-sell-task.js
1019 Bytes
const priceCompare = require('../utils/price-compare');
const { queryTopSellProductRelations } = require('../libs/ufo-product-api');
const ddAlert = require('../libs/dingding-alert');
const { logger } = require('../libs/logger');
module.exports = async(time) => {
//获取要比价是skn对比关系
let productRelationsArr = {};
let sknsData = [];
try {
// 获取所有要比价的商品对应关系
const productRelations = await queryTopSellProductRelations();
if (productRelations) {
productRelationsArr = JSON.parse(productRelations).data;
}
productRelationsArr.forEach(relations => {
sknsData.push({'productId' : relations.channelProductId, 'yhId': relations.productId});
});
}catch(error) {
logger.error(`[热销top1000]`+error);
ddAlert(`监控提醒 :[热销top1000] pop服务接口 queryAllChannelProductRelations 异常,请查看! @15101660386 `, 'bjSpider');
return false;
}
//进行比价
priceCompare(time, sknsData, '热销top1000');
}