Authored by TaoHuang

fix(coupon): change field name

@@ -73,7 +73,7 @@ exports.bottombar = function(req, res, next) { @@ -73,7 +73,7 @@ exports.bottombar = function(req, res, next) {
73 */ 73 */
74 exports.couponSend = (req, res, next) => { 74 exports.couponSend = (req, res, next) => {
75 let token = req.query.token || '', 75 let token = req.query.token || '',
76 - coupontype = req.query.coupontype, 76 + couponType = req.query.couponType,
77 uid = req.user.uid, 77 uid = req.user.uid,
78 app = req.query.app || {}; 78 app = req.query.app || {};
79 79
@@ -103,7 +103,7 @@ exports.couponSend = (req, res, next) => { @@ -103,7 +103,7 @@ exports.couponSend = (req, res, next) => {
103 if (uid === '' || uid === 0 || token === '' || token === 0) { 103 if (uid === '' || uid === 0 || token === '' || token === 0) {
104 return res.jsonp(resultData); 104 return res.jsonp(resultData);
105 } 105 }
106 - const promise = coupontype === 'ufo' ? 106 + const promise = couponType === 'ufo' ?
107 req.ctx(model).couponSendUFO(uid, token) : 107 req.ctx(model).couponSendUFO(uid, token) :
108 req.ctx(model).couponSend(uid, token); 108 req.ctx(model).couponSend(uid, token);
109 109
@@ -122,7 +122,7 @@ exports.couponSend = (req, res, next) => { @@ -122,7 +122,7 @@ exports.couponSend = (req, res, next) => {
122 */ 122 */
123 exports.couponCheck = (req, res, next) => { 123 exports.couponCheck = (req, res, next) => {
124 let token = req.query.token || '', 124 let token = req.query.token || '',
125 - coupontype = req.query.coupontype, 125 + couponType = req.query.couponType,
126 uid = req.user.uid, 126 uid = req.user.uid,
127 app = req.query.app || {}; 127 app = req.query.app || {};
128 128
@@ -153,7 +153,7 @@ exports.couponCheck = (req, res, next) => { @@ -153,7 +153,7 @@ exports.couponCheck = (req, res, next) => {
153 return res.jsonp(resultData); 153 return res.jsonp(resultData);
154 } 154 }
155 155
156 - req.ctx(model).couponCheck(uid, token, coupontype).then(result => { 156 + req.ctx(model).couponCheck(uid, token, couponType).then(result => {
157 res.set({ 157 res.set({
158 'Cache-Control': 'no-cache', 158 'Cache-Control': 'no-cache',
159 Pragma: 'no-cache', 159 Pragma: 'no-cache',
@@ -174,6 +174,7 @@ exports.couponCheck = (req, res, next) => { @@ -174,6 +174,7 @@ exports.couponCheck = (req, res, next) => {
174 174
175 exports.couponCheckMiddle = (req, res, next) => { 175 exports.couponCheckMiddle = (req, res, next) => {
176 let token = req.query.token || ''; 176 let token = req.query.token || '';
  177 + let couponType = req.query.couponType;
177 let uid = req.user.uid; 178 let uid = req.user.uid;
178 let resultData = { 179 let resultData = {
179 code: 403, 180 code: 403,
@@ -185,7 +186,7 @@ exports.couponCheckMiddle = (req, res, next) => { @@ -185,7 +186,7 @@ exports.couponCheckMiddle = (req, res, next) => {
185 return res.jsonp(resultData); 186 return res.jsonp(resultData);
186 } 187 }
187 188
188 - req.ctx(model).couponCheck(uid, token).then(result => { 189 + req.ctx(model).couponCheck(uid, token, couponType).then(result => {
189 if (result.error) { 190 if (result.error) {
190 res.set({ 191 res.set({
191 'Cache-Control': 'no-cache', 192 'Cache-Control': 'no-cache',
@@ -618,9 +618,10 @@ class featureModel extends global.yoho.BaseModel { @@ -618,9 +618,10 @@ class featureModel extends global.yoho.BaseModel {
618 result.error = 404; 618 result.error = 404;
619 result.code = 404; 619 result.code = 404;
620 result.message = '出错啦~'; 620 result.message = '出错啦~';
  621 + return result;
621 } 622 }
622 623
623 - const couponObj = result.data.find(i => i.couponIdToken === token); 624 + const isRequired = result.data.some(i => i.checkRequired);
624 625
625 if (!couponObj) { 626 if (!couponObj) {
626 return { 627 return {
@@ -628,7 +629,9 @@ class featureModel extends global.yoho.BaseModel { @@ -628,7 +629,9 @@ class featureModel extends global.yoho.BaseModel {
628 }; 629 };
629 } 630 }
630 631
631 - return couponObj; 632 + return {
  633 + checkRequired: isRequired
  634 + };
632 } 635 }
633 636
634 /** 637 /**