shop-service.js 2.7 KB
'use strict';
const _ = require('lodash');

/**
 * 获取一级品类
 * @return type []
 */
function applyAction() {
    return this.get({
        data: {
            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 []
 */
function getTwoCategory(id) {

    return this.get({
        data: {
            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 []
 */
function insertApply(param) {

    return this.get({
        data: {
            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 = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);

        this.applyAction = applyAction.bind(this);
        this.getTwoCategory = getTwoCategory.bind(this);
        this.insertApply = insertApply.bind(this);
    }
};