notify.js 1.19 KB
/**
 * 到货通知
 */
'use strict';

const mRoot = '../models';
const notify = require(`${mRoot}/detail-notify-service`);

const add = (req, res, next) => {
    let uid = req.user.uid;
    let skn = req.body.skn;
    let sku = req.body.sku;
    let mobile = req.body.mobile;

    if (!(skn && sku)) {
        res.json({
            code: 401,
            message: '商品信息错误'
        });
    }

    notify.add(skn, sku, uid, mobile).then((result) => {
        return res.json(result);
    }).catch(next);
};

const cancel = (req, res, next) => {
    let uid = req.user.uid;
    let sku = req.body.sku;

    if (!sku) {
        return res.json({
            code: 401,
            message: '商品信息错误'
        });
    }

    notify.cancel(sku, uid).then((result) => {
        return res.json(result);
    }).catch(next);

};

const show = (req, res, next) => {
    let uid = req.user.uid;
    let sku = req.query.sku;

    if (!sku) {
        return res.json({
            code: 401,
            message: '商品信息错误'
        });
    }

    notify.show(sku, uid).then((result) => {
        return res.json(result);
    }).catch(next);
};

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