Authored by zhangxiaoru

获取优惠劵重构

... ... @@ -88,3 +88,17 @@ exports.receive = (req, res, next) => {
res.jsonp(result);
}).catch(next);
};
/**
* 获取优惠券
*/
exports.couponSend = (req, res, next) => {
let callback = req.query.callback,
token = req.query.token || '',
uid = req.user.uid,
app = req.query.app;
model.couponSend(uid, token, app).then(result => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -357,3 +357,35 @@ exports.receiveCoupon = (receiveData, uid) => {
return returnData;
});
};
exports.couponSend = (uid, token, app) => {
let resultData = {
code: 403,
message: '参数错误',
data: ''
};
// APP时用参数中的ID
if (!uid) {
uid = app.uid ? app.uid : 0;
}
if (uid === '' || uid === 0 || token === '' || token === 0) {
return false;
}
return api.get('', {
method: 'app.coupons.couponSend',
uid: uid,
coupon_send_token: token
}).then(result => {
if (result && result.code === 200) {
resultData = result;
} else {
resultData.code = 404;
resultData.message = '出错啦~';
}
return resultData;
});
};
... ...
... ... @@ -234,4 +234,6 @@ router.get('/annual-account', annualAccount.index);
router.get('/annual-account/share', annualAccount.share);
router.get('/app-downloads', appDownloads.index);
router.get('/couponSend', couponFloor.couponSend); // 获取优惠券
module.exports = router;
... ...
'use strict';
const md5 = require('md5');
const PRIVATE_KEY = 'fd4ad5fcsa0de589af23234ks1923ks';
const v1 = (req, res) => {
let result = {
code: 400,
message: 'Config Success',
data: {}
};
let version = req.body.app_version || '';
switch (version) {
case '4.0.1':
result.data.url = 'http://cdn.yoho.cn/app-reactnative/4.0.1/main.zip';
result.data.rnv = '101';
result.data.minv = '4.0.1';
result.data.filecode = md5('dffb998e43a33215b4c47a4ccd3cf619yohorn2016');
result.md5 = md5(PRIVATE_KEY + ':' + JSON.stringify(result.data));
break;
case '4.1.0':
result.data.url = 'http://cdn.yoho.cn/app-downfiles/index.android.bundle.zip';
result.data.rnv = '101';
result.data.minv = '4.1.0';
result.data.filecode = md5('47c47db1eec6159f940e2018d3a83676yohorn2016');
result.md5 = md5(PRIVATE_KEY + ':' + JSON.stringify(result.data));
break;
default:
result.data.url = '';
result.data.rnv = '';
result.data.minv = '';
result.data.filecode = '';
result.md5 = md5(PRIVATE_KEY + ':' + JSON.stringify(result.data));
}
return res.json(result);
};
module.exports = {
v1
};
... ...
... ... @@ -15,10 +15,12 @@ var multipartMiddleware = multipart();
const uploadApi = require(cRoot + '/upload.js');
const hotfix = require(`${cRoot}/hotfix`);
const apple = require(`${cRoot}/apple`);
const rn = require(`${cRoot}/rn`);
// routers
router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg);
router.post('/hf/v1', hotfix.v1);
router.post('/rn/v1', rn.v1);
router.get('/.well-known/apple-app-site-association', apple.appSiteAssociation);
... ...
... ... @@ -43,4 +43,3 @@ function scrollHandler() {
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
... ...