brand-service.js 1.16 KB
/**
 * Created by TaoHuang on 2016/6/14.
 */
'use strict';

const Promise = require('bluebird');
const co = Promise.coroutine;
const api = require('./brand-api');

const getBrandByDomainAsync = domain => {
    return co(function*() {
        let brandInfo = yield api.getBrandLogoByDomainAsync(domain);

        if (!brandInfo.data || brandInfo.code !== 200) {
            return {};
        }

        let result = {};

        result.brandId = brandInfo.data.id || '';
        result.node = brandInfo.data.static_content_code || false;
        result.brandBanner = brandInfo.data.brand_banner || '';
        result.brandNameEn = brandInfo.data.brand_name_en || '';
        result.brandNameCn = brandInfo.data.brand_name_cn || '';
        result.brandAbout = brandInfo.data.brand_intro || '';
        result.shopTemplateType = brandInfo.data.shop_template_type ?
            parseInt(brandInfo.data.shop_template_type) : '';
        result.type = brandInfo.data.type ? +brandInfo.data.type : 0;
        result.shopId = brandInfo.data.shop_id || '';

        return result;
    })();
};

module.exports = {
    getBrandByDomainAsync,
    getBannerInfoAsync: api.getBannerInfoAsync
};