Authored by shuaiguo

feat(feature): 优惠券防刷

... ... @@ -10,6 +10,7 @@ const _ = require('lodash');
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const auth = require('../../doraemon/middleware/auth');
const captcha = require('../../doraemon/middleware/captcha');
const demo = require(`${cRoot}/demo`);
const coupon = require(`${cRoot}/coupon`);
const wechat = require(`${cRoot}/wechat`);
... ... @@ -283,7 +284,7 @@ router.get('/individuation/getShopByIds', individuation.getShopByIds); // 通过
router.get('/feature/:code.html', feature.index);
router.get('/featuresidebar/:code.html', feature.sidebar);
router.get('/featurebottombar/:code.html', feature.bottombar);
router.get('/feature/couponSend', feature.couponSend); // 获取优惠券
router.get('/feature/couponSend', captcha, feature.couponSend); // 获取优惠券
router.get('/feature/webShareCouponSend', feature.webShareCouponSend); // 活动模板分享领取优惠券, 不用分券类型,不用传券ID
router.get('/tide/category', auth, tide.category); // 潮品推介
router.get('/tide/shop', auth, tide.shop); // 潮牌推介
... ...
... ... @@ -51,7 +51,7 @@ module.exports = {
app: 'h5',
appVersion: '6.8.9', // 调用api的版本
appName: 'yohobuywap-node',
port: 6001,
port: 6002,
siteUrl: '//m.yohobuy.com',
assetUrl: '//m.yohobuy.com:5001/yohobuywap-node/',
testCode: 'yoho4946abcdef#$%&!@',
... ... @@ -180,6 +180,12 @@ module.exports = {
LIMITER_IP_TIME: 3600, // 超出访问限制ip限制访问1小时
superCapture: '93c70db61fe276f93ce781ad17dc47cd',
from: from,
captcha: {
secretId: 'AKIDukLhmSz84ylIdh54MRL99xUuLahdtgmc',
secretKey: '2sZ1ECn8DAsSmqiKgt3yd3HOBj293iX7',
AppSecretKey: '0JFkLazLQKZ9sqf276q_lcQ**',
appId: 2008945059
}
};
if (isProduction) {
... ...
/* eslint-disable newline-after-var */
/* eslint-disable quotes */
"use strict";
const tencentcloud = require('tencentcloud-sdk-nodejs');
const CaptchaClient = tencentcloud.captcha.v20190722.Client;
const models = tencentcloud.captcha.v20190722.Models;
const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;
const {secretId, secretKey, AppSecretKey, appId} = global.yoho.config.captcha;
let cred = new Credential(secretId, secretKey);
let httpProfile = new HttpProfile();
httpProfile.endpoint = "captcha.tencentcloudapi.com";
let clientProfile = new ClientProfile();
clientProfile.httpProfile = httpProfile;
let client = new CaptchaClient(cred, 'ap-shanghai', clientProfile);
let captchaReq = new models.DescribeCaptchaResultRequest();
/**
* 优惠券防刷验证码
*/
module.exports = function(req, res, next) {
const params = {
AppSecretKey,
CaptchaAppId: appId,
CaptchaType: 9,
UserIp: req.yoho.clientIp,
Ticket: req.query.ticket,
Randstr: req.query.randstr
};
captchaReq.from_json_string(`${params}`);
// eslint-disable-next-line new-cap
client.DescribeCaptchaResult(captchaReq, function(errMsg) {
if (errMsg) {
return res.jsonp({code: 400, message: errMsg.Message});
}
next();
});
};
... ...
... ... @@ -83,6 +83,7 @@
"request-promise": "^4.2.1",
"semver": "^5.5.0",
"sitemap": "^1.13.0",
"tencentcloud-sdk-nodejs": "^3.0.95",
"uglifyjs-webpack-plugin": "^2.1.3",
"urlencode": "^1.1.0",
"uuid": "^3.2.1",
... ...
... ... @@ -11425,6 +11425,13 @@ tar@^4:
safe-buffer "^5.1.2"
yallist "^3.0.3"
tencentcloud-sdk-nodejs@^3.0.95:
version "3.0.95"
resolved "http://npm.yohops.com/tencentcloud-sdk-nodejs/-/tencentcloud-sdk-nodejs-3.0.95.tgz#1e61451e0c415b61d38e1da2b432b6aaf249d9f8"
integrity sha1-HmFFHgxBW2HTjh2itDK2qvJJ2fg=
dependencies:
request "^2.85.0"
term-size@^1.2.0:
version "1.2.0"
resolved "http://npm.yohops.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69"
... ... @@ -13093,7 +13100,7 @@ yoho-qs@^1.0.1:
resolved "http://npm.yohops.com/yoho-qs/-/yoho-qs-1.0.1.tgz#8e9e559fb05c26f910e09844b9101cf9e231fa44"
integrity sha1-jp5Vn7BcJvkQ4JhEuRAc+eIx+kQ=
yoho-swiper2@0.0.5:
yoho-swiper2@^0.0.5:
version "0.0.5"
resolved "http://npm.yohops.com/yoho-swiper2/-/yoho-swiper2-0.0.5.tgz#7511670b7259d089a142b21860d0542d6191aca0"
integrity sha512-N7ji+zMl21urNA+EHve0qzbr7zEABPqYSUJ+ZTmTRt1VUXNv4l5y2GLwQiMIuOGqsqrhKmrdkDiyYQXLC1ggVQ==
... ...