Authored by TaoHuang

fix(coupon): change field name

... ... @@ -73,7 +73,7 @@ exports.bottombar = function(req, res, next) {
*/
exports.couponSend = (req, res, next) => {
let token = req.query.token || '',
coupontype = req.query.coupontype,
couponType = req.query.couponType,
uid = req.user.uid,
app = req.query.app || {};
... ... @@ -103,7 +103,7 @@ exports.couponSend = (req, res, next) => {
if (uid === '' || uid === 0 || token === '' || token === 0) {
return res.jsonp(resultData);
}
const promise = coupontype === 'ufo' ?
const promise = couponType === 'ufo' ?
req.ctx(model).couponSendUFO(uid, token) :
req.ctx(model).couponSend(uid, token);
... ... @@ -122,7 +122,7 @@ exports.couponSend = (req, res, next) => {
*/
exports.couponCheck = (req, res, next) => {
let token = req.query.token || '',
coupontype = req.query.coupontype,
couponType = req.query.couponType,
uid = req.user.uid,
app = req.query.app || {};
... ... @@ -153,7 +153,7 @@ exports.couponCheck = (req, res, next) => {
return res.jsonp(resultData);
}
req.ctx(model).couponCheck(uid, token, coupontype).then(result => {
req.ctx(model).couponCheck(uid, token, couponType).then(result => {
res.set({
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
... ... @@ -174,6 +174,7 @@ exports.couponCheck = (req, res, next) => {
exports.couponCheckMiddle = (req, res, next) => {
let token = req.query.token || '';
let couponType = req.query.couponType;
let uid = req.user.uid;
let resultData = {
code: 403,
... ... @@ -185,7 +186,7 @@ exports.couponCheckMiddle = (req, res, next) => {
return res.jsonp(resultData);
}
req.ctx(model).couponCheck(uid, token).then(result => {
req.ctx(model).couponCheck(uid, token, couponType).then(result => {
if (result.error) {
res.set({
'Cache-Control': 'no-cache',
... ...
... ... @@ -618,9 +618,10 @@ class featureModel extends global.yoho.BaseModel {
result.error = 404;
result.code = 404;
result.message = '出错啦~';
return result;
}
const couponObj = result.data.find(i => i.couponIdToken === token);
const isRequired = result.data.some(i => i.checkRequired);
if (!couponObj) {
return {
... ... @@ -628,7 +629,9 @@ class featureModel extends global.yoho.BaseModel {
};
}
return couponObj;
return {
checkRequired: isRequired
};
}
/**
... ...