shop-service.js 2.38 KB
'use strict';
const _ = require('lodash');
const api = global.yoho.API;

/**
 * 获取一级品类
 * @return type []
 */
const applyAction = () => {

    return api.get('', {
        method: 'app.category.queryMax'

    }).then((result) => {
        if (result.code && result.code === 200) {
            let list = [];

            _.forEach(result.data, function(val) {
                list.push({
                    id: val.category_id,
                    name: val.category_name
                });
            });

            return list;
        }
    });
};

/**
 * 获取二级品类
 * @return type []
 */
const getTwoCategory = (id) => {

    return api.get('', {
        method: 'app.category.queryMin',
        parent_id: id
    }).then((result) => {
        if (result.code && result.code === 200) {
            let list = [];

            _.forEach(result.data, function(val) {
                list.push({
                    id: val.category_id,
                    name: val.category_name
                });
            });

            result.data = list;

            return result;
        }
    });
};

/**
 * 添加入驻申请保存
 * @return type []
 */
const insertApply = (param) => {

    return api.get('', {
        method: 'app.shops.insertApply',
        brandName: param.brandName,
        registerStatus: param.registerStatus,
        sellerName: param.sellerName,
        sellerAddress: param.sellerAddress,
        zipCode: param.zipCode,
        contacts: param.contacts,
        contactPhone: param.contactPhone,
        contactEmail: param.contactEmail,
        sellerRole: param.sellerRole,
        brandWebsite: param.brandWebsite,
        onlineShopWebsite: param.onlineShopWebsite,
        categoryInfo: param.categoryInfo,
        billingCycle: param.billingCycle,
        warehouseAddress: param.warehouseAddress,
        producer: param.producer,
        invoiceType: param.invoiceType,
        newCycle: param.newCycle,
        quarterNum: param.quarterNum,
        supplyCycle: param.supplyCycle,
        haveStore: param.haveStore,
        storeInfo: param.storeInfo,
        brandMaterial: param.brandMaterial,
        goodsMaterial: param.goodsMaterial,
        uid: param.uid
    }).then((result) => {

        if (result.code && result.code === 200) {
            return result;
        }
    });
};

module.exports = {
    applyAction,
    getTwoCategory,
    insertApply
};