Showing
3 changed files
with
24 additions
and
6 deletions
@@ -98,7 +98,7 @@ exports.userAcquireStatus = (req, res, next) => { | @@ -98,7 +98,7 @@ exports.userAcquireStatus = (req, res, next) => { | ||
98 | uid = req.user.uid; | 98 | uid = req.user.uid; |
99 | } | 99 | } |
100 | 100 | ||
101 | - studentsModel.userAcquireStatus(uid, req.couponIds).then(result => { | 101 | + studentsModel.userAcquireStatus(uid, req.query.couponIds).then(result => { |
102 | res.json(result); | 102 | res.json(result); |
103 | }).catch(next); | 103 | }).catch(next); |
104 | 104 |
@@ -12,10 +12,12 @@ | @@ -12,10 +12,12 @@ | ||
12 | // const camelCase = global.yoho.camelCase; | 12 | // const camelCase = global.yoho.camelCase; |
13 | const api = global.yoho.API; | 13 | const api = global.yoho.API; |
14 | const queryString = require('querystring'); | 14 | const queryString = require('querystring'); |
15 | +const _ = require('lodash'); | ||
15 | 16 | ||
16 | const studentsApi = require('./students-api'); | 17 | const studentsApi = require('./students-api'); |
17 | const stuHandler = require('./students-handler'); | 18 | const stuHandler = require('./students-handler'); |
18 | const helpers = global.yoho.helpers; | 19 | const helpers = global.yoho.helpers; |
20 | +const crypto = global.yoho.crypto; | ||
19 | 21 | ||
20 | // const productProcess = require(`${utils}/product-process`); | 22 | // const productProcess = require(`${utils}/product-process`); |
21 | // const _ = require('lodash'); | 23 | // const _ = require('lodash'); |
@@ -157,8 +159,25 @@ exports.verifyStudents = (params) => { | @@ -157,8 +159,25 @@ exports.verifyStudents = (params) => { | ||
157 | * @return | 159 | * @return |
158 | */ | 160 | */ |
159 | exports.userAcquireStatus = (uid, couponIds) => { | 161 | exports.userAcquireStatus = (uid, couponIds) => { |
160 | - return studentsApi.userAcquireStatus(uid, couponIds). | 162 | + let ids = ''; |
163 | + | ||
164 | + for (let i = 0; i < couponIds.length; i++) { | ||
165 | + if (i === couponIds.length - 1) { | ||
166 | + ids += crypto.decrypt('yoho9646abcdefgh', couponIds[i]); | ||
167 | + }else { | ||
168 | + ids += crypto.decrypt('yoho9646abcdefgh', couponIds[i]) + ','; | ||
169 | + } | ||
170 | + } | ||
171 | + | ||
172 | + return studentsApi.userAcquireStatus(uid, ids). | ||
161 | then(result => { | 173 | then(result => { |
174 | + if (result.code === 200) { | ||
175 | + _.forEach(result.data, (value) => { | ||
176 | + let couponId = value.couponId.toString(), | ||
177 | + cryptoId = crypto.encryption('yoho9646abcdefgh', couponId); | ||
178 | + value.couponId = cryptoId; | ||
179 | + }) | ||
180 | + } | ||
162 | return result; | 181 | return result; |
163 | }); | 182 | }); |
164 | }; | 183 | }; |
@@ -565,24 +565,23 @@ $('.ident-select-wrap').one('click', function() { | @@ -565,24 +565,23 @@ $('.ident-select-wrap').one('click', function() { | ||
565 | */ | 565 | */ |
566 | $(function() { | 566 | $(function() { |
567 | // 加载优惠券状态 | 567 | // 加载优惠券状态 |
568 | - var couponIds = ''; | 568 | + var couponIds = []; |
569 | 569 | ||
570 | $('.coupon > a').each(function() { | 570 | $('.coupon > a').each(function() { |
571 | - couponIds += $(this).attr('data-id') + ','; | 571 | + couponIds.push($(this).attr('data-id')); |
572 | }); | 572 | }); |
573 | 573 | ||
574 | $.ajax({ | 574 | $.ajax({ |
575 | type: 'GET', | 575 | type: 'GET', |
576 | url: '/product/students/userAcquireStatus', | 576 | url: '/product/students/userAcquireStatus', |
577 | data: { | 577 | data: { |
578 | - couponIds: couponIds.substring(0, couponIds.length - 1) | 578 | + couponIds: couponIds |
579 | }, | 579 | }, |
580 | success: function(res) { | 580 | success: function(res) { |
581 | var code = res.code, | 581 | var code = res.code, |
582 | i, | 582 | i, |
583 | text; | 583 | text; |
584 | 584 | ||
585 | - console.info(res); | ||
586 | if (code === 200) { | 585 | if (code === 200) { |
587 | for (i = 0; i < res.data.length; i++) { | 586 | for (i = 0; i < res.data.length; i++) { |
588 | text = ''; | 587 | text = ''; |
-
Please register or login to post a comment