Showing
6 changed files
with
92 additions
and
1 deletions
@@ -88,3 +88,17 @@ exports.receive = (req, res, next) => { | @@ -88,3 +88,17 @@ exports.receive = (req, res, next) => { | ||
88 | res.jsonp(result); | 88 | res.jsonp(result); |
89 | }).catch(next); | 89 | }).catch(next); |
90 | }; | 90 | }; |
91 | + | ||
92 | +/** | ||
93 | + * 获取优惠券 | ||
94 | + */ | ||
95 | +exports.couponSend = (req, res, next) => { | ||
96 | + let callback = req.query.callback, | ||
97 | + token = req.query.token || '', | ||
98 | + uid = req.user.uid, | ||
99 | + app = req.query.app; | ||
100 | + | ||
101 | + model.couponSend(uid, token, app).then(result => { | ||
102 | + res.json(result); | ||
103 | + }).catch(next); | ||
104 | +}; |
@@ -357,3 +357,35 @@ exports.receiveCoupon = (receiveData, uid) => { | @@ -357,3 +357,35 @@ exports.receiveCoupon = (receiveData, uid) => { | ||
357 | return returnData; | 357 | return returnData; |
358 | }); | 358 | }); |
359 | }; | 359 | }; |
360 | + | ||
361 | +exports.couponSend = (uid, token, app) => { | ||
362 | + let resultData = { | ||
363 | + code: 403, | ||
364 | + message: '参数错误', | ||
365 | + data: '' | ||
366 | + }; | ||
367 | + | ||
368 | + // APP时用参数中的ID | ||
369 | + if (!uid) { | ||
370 | + uid = app.uid ? app.uid : 0; | ||
371 | + } | ||
372 | + | ||
373 | + if (uid === '' || uid === 0 || token === '' || token === 0) { | ||
374 | + return false; | ||
375 | + } | ||
376 | + | ||
377 | + return api.get('', { | ||
378 | + method: 'app.coupons.couponSend', | ||
379 | + uid: uid, | ||
380 | + coupon_send_token: token | ||
381 | + }).then(result => { | ||
382 | + if (result && result.code === 200) { | ||
383 | + resultData = result; | ||
384 | + } else { | ||
385 | + resultData.code = 404; | ||
386 | + resultData.message = '出错啦~'; | ||
387 | + } | ||
388 | + | ||
389 | + return resultData; | ||
390 | + }); | ||
391 | +}; |
@@ -234,4 +234,6 @@ router.get('/annual-account', annualAccount.index); | @@ -234,4 +234,6 @@ router.get('/annual-account', annualAccount.index); | ||
234 | router.get('/annual-account/share', annualAccount.share); | 234 | router.get('/annual-account/share', annualAccount.share); |
235 | router.get('/app-downloads', appDownloads.index); | 235 | router.get('/app-downloads', appDownloads.index); |
236 | 236 | ||
237 | +router.get('/couponSend', couponFloor.couponSend); // 获取优惠券 | ||
238 | + | ||
237 | module.exports = router; | 239 | module.exports = router; |
apps/api/controllers/rn.js
0 → 100644
1 | +'use strict'; | ||
2 | +const md5 = require('md5'); | ||
3 | +const PRIVATE_KEY = 'fd4ad5fcsa0de589af23234ks1923ks'; | ||
4 | + | ||
5 | +const v1 = (req, res) => { | ||
6 | + let result = { | ||
7 | + code: 400, | ||
8 | + message: 'Config Success', | ||
9 | + data: {} | ||
10 | + }; | ||
11 | + | ||
12 | + let version = req.body.app_version || ''; | ||
13 | + | ||
14 | + switch (version) { | ||
15 | + case '4.0.1': | ||
16 | + result.data.url = 'http://cdn.yoho.cn/app-reactnative/4.0.1/main.zip'; | ||
17 | + result.data.rnv = '101'; | ||
18 | + result.data.minv = '4.0.1'; | ||
19 | + result.data.filecode = md5('dffb998e43a33215b4c47a4ccd3cf619yohorn2016'); | ||
20 | + result.md5 = md5(PRIVATE_KEY + ':' + JSON.stringify(result.data)); | ||
21 | + break; | ||
22 | + case '4.1.0': | ||
23 | + result.data.url = 'http://cdn.yoho.cn/app-downfiles/index.android.bundle.zip'; | ||
24 | + result.data.rnv = '101'; | ||
25 | + result.data.minv = '4.1.0'; | ||
26 | + result.data.filecode = md5('47c47db1eec6159f940e2018d3a83676yohorn2016'); | ||
27 | + result.md5 = md5(PRIVATE_KEY + ':' + JSON.stringify(result.data)); | ||
28 | + break; | ||
29 | + default: | ||
30 | + result.data.url = ''; | ||
31 | + result.data.rnv = ''; | ||
32 | + result.data.minv = ''; | ||
33 | + result.data.filecode = ''; | ||
34 | + result.md5 = md5(PRIVATE_KEY + ':' + JSON.stringify(result.data)); | ||
35 | + } | ||
36 | + | ||
37 | + return res.json(result); | ||
38 | +}; | ||
39 | + | ||
40 | +module.exports = { | ||
41 | + v1 | ||
42 | +}; |
@@ -15,10 +15,12 @@ var multipartMiddleware = multipart(); | @@ -15,10 +15,12 @@ var multipartMiddleware = multipart(); | ||
15 | const uploadApi = require(cRoot + '/upload.js'); | 15 | const uploadApi = require(cRoot + '/upload.js'); |
16 | const hotfix = require(`${cRoot}/hotfix`); | 16 | const hotfix = require(`${cRoot}/hotfix`); |
17 | const apple = require(`${cRoot}/apple`); | 17 | const apple = require(`${cRoot}/apple`); |
18 | +const rn = require(`${cRoot}/rn`); | ||
18 | 19 | ||
19 | // routers | 20 | // routers |
20 | router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg); | 21 | router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg); |
21 | router.post('/hf/v1', hotfix.v1); | 22 | router.post('/hf/v1', hotfix.v1); |
23 | +router.post('/rn/v1', rn.v1); | ||
22 | 24 | ||
23 | router.get('/.well-known/apple-app-site-association', apple.appSiteAssociation); | 25 | router.get('/.well-known/apple-app-site-association', apple.appSiteAssociation); |
24 | 26 |
-
Please register or login to post a comment