detail-notify-service.js 987 Bytes


'use strict';

const api = require('./detail-notify-api');
const _ = require('lodash');

const add = api.addNotifyAsync;
const cancel = api.cancelNotifyAsync;

const show = (sku, uid) => {
    return api.getNotifyStatusAsync(sku, uid).then((result) => {
        if (result.code === 200) {
            if (!_.isEmpty(result.data)) {
                return {
                    code: 200,
                    data: {
                        status: 'Y'
                    },
                    message: '已添加通知'
                };
            } else {
                return {
                    code: 200,
                    data: {
                        status: 'N'
                    },
                    message: '没有添加通知'
                };
            }
        } else {
            return {
                code: 401,
                message: '服务器错误'
            };
        }
    });
};

module.exports = {
    add,
    show,
    cancel
};