Authored by wenjiekong

优惠券id解密、加密

... ... @@ -98,7 +98,7 @@ exports.userAcquireStatus = (req, res, next) => {
uid = req.user.uid;
}
studentsModel.userAcquireStatus(uid, req.couponIds).then(result => {
studentsModel.userAcquireStatus(uid, req.query.couponIds).then(result => {
res.json(result);
}).catch(next);
... ...
... ... @@ -12,10 +12,12 @@
// const camelCase = global.yoho.camelCase;
const api = global.yoho.API;
const queryString = require('querystring');
const _ = require('lodash');
const studentsApi = require('./students-api');
const stuHandler = require('./students-handler');
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
// const productProcess = require(`${utils}/product-process`);
// const _ = require('lodash');
... ... @@ -157,8 +159,25 @@ exports.verifyStudents = (params) => {
* @return
*/
exports.userAcquireStatus = (uid, couponIds) => {
return studentsApi.userAcquireStatus(uid, couponIds).
let ids = '';
for (let i = 0; i < couponIds.length; i++) {
if (i === couponIds.length - 1) {
ids += crypto.decrypt('yoho9646abcdefgh', couponIds[i]);
}else {
ids += crypto.decrypt('yoho9646abcdefgh', couponIds[i]) + ',';
}
}
return studentsApi.userAcquireStatus(uid, ids).
then(result => {
if (result.code === 200) {
_.forEach(result.data, (value) => {
let couponId = value.couponId.toString(),
cryptoId = crypto.encryption('yoho9646abcdefgh', couponId);
value.couponId = cryptoId;
})
}
return result;
});
};
... ...
... ... @@ -565,24 +565,23 @@ $('.ident-select-wrap').one('click', function() {
*/
$(function() {
// 加载优惠券状态
var couponIds = '';
var couponIds = [];
$('.coupon > a').each(function() {
couponIds += $(this).attr('data-id') + ',';
couponIds.push($(this).attr('data-id'));
});
$.ajax({
type: 'GET',
url: '/product/students/userAcquireStatus',
data: {
couponIds: couponIds.substring(0, couponIds.length - 1)
couponIds: couponIds
},
success: function(res) {
var code = res.code,
i,
text;
console.info(res);
if (code === 200) {
for (i = 0; i < res.data.length; i++) {
text = '';
... ...