coupon.js
502 Bytes
/**
* Created by TaoHuang on 2016/10/28.
*/
'use strict';
const service = require('../models/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: '优惠券失效!'
});
}
req.ctx(service).acquireAsync(cid, uid).then((result) => {
return res.json(result);
}).catch(next);
};
module.exports = {
acquire
};