Authored by 毕凯

更换加密解密算法

1 'use strict'; 1 'use strict';
2 2
3 const _ = require('lodash'); 3 const _ = require('lodash');
4 -const Hashids = require('hashids');  
5 const utils = '../../../utils'; 4 const utils = '../../../utils';
6 const resourcesProcess = require(`${utils}/resources-process`); 5 const resourcesProcess = require(`${utils}/resources-process`);
7 -const hashids = new Hashids('a64b42acf75a45f8d'); 6 +
  7 +const crypto = global.yoho.crypto;
  8 +const key = 'a64b42acf75a45f8';
8 9
9 class CouponList extends global.yoho.BaseModel { 10 class CouponList extends global.yoho.BaseModel {
10 constructor(ctx) { 11 constructor(ctx) {
@@ -30,7 +31,7 @@ class CouponList extends global.yoho.BaseModel { @@ -30,7 +31,7 @@ class CouponList extends global.yoho.BaseModel {
30 _.forEach(result.data, group => { 31 _.forEach(result.data, group => {
31 _.forEach(group.personalityShopCouponBos, coupon => { 32 _.forEach(group.personalityShopCouponBos, coupon => {
32 if (coupon.couponId) { 33 if (coupon.couponId) {
33 - coupon.couponId = hashids.encode(coupon.couponId); 34 + coupon.couponId = crypto.encryption(key, coupon.couponId + '');
34 } 35 }
35 }); 36 });
36 }); 37 });
@@ -41,7 +42,7 @@ class CouponList extends global.yoho.BaseModel { @@ -41,7 +42,7 @@ class CouponList extends global.yoho.BaseModel {
41 42
42 receive(params) { 43 receive(params) {
43 if (params.couponid && !_.isNumber(params.couponid)) { 44 if (params.couponid && !_.isNumber(params.couponid)) {
44 - params.couponid = hashids.decode(params.couponid)[0]; 45 + params.couponid = crypto.decrypt(key, params.couponid);
45 } 46 }
46 let options = { 47 let options = {
47 data: { 48 data: {
@@ -54,7 +54,6 @@ @@ -54,7 +54,6 @@
54 "fast-safe-stringify": "^1.2.0", 54 "fast-safe-stringify": "^1.2.0",
55 "feed": "^1.1.0", 55 "feed": "^1.1.0",
56 "geetest": "^4.1.2", 56 "geetest": "^4.1.2",
57 - "hashids": "^1.1.2",  
58 "lodash": "^4.17.4", 57 "lodash": "^4.17.4",
59 "memory-cache": "^0.2.0", 58 "memory-cache": "^0.2.0",
60 "moment": "^2.18.1", 59 "moment": "^2.18.1",