coupon.js 546 Bytes
/**
 * Created by TaoHuang on 2016/10/28.
 */

'use strict';

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

const acquire = (req, res, next) => {
    let uid = req.user.uid;
    let cid = req.query.couponId || 0;

    if (!cid) {
        return res.json({
            code: 400,
            message: '优惠券失效!'
        });
    }

    service.acquireAsync(cid, uid).then((result) => {
        return res.json({
            code: 200
        });
    }).catch(next);
};

module.exports = {
    acquire
};