du.js 624 Bytes
const _ = require('lodash');
const spider = require('../../../libs/spider');
const {logger} = require('../../../libs/logger');

module.exports = async(third) => {
  try {
    if (!third) {
      return void 0;
    }
    const result = await spider.spiderFetch(third.productId);

    if (result.status !== 200) {
      return void 0;
    }
    const {sizeList} = result.data;

    return {
      skus: sizeList.map(s => {
        return {
          size: s.size,
          price: _.get(s, 'item.price', 0) / 100
        };
      })
    };
  } catch (error) {
    logger.error(`[price-line-task] du spider, ${error}`);
  }
};