Showing
3 changed files
with
34 additions
and
3 deletions
@@ -27,8 +27,8 @@ const whSurfController = { | @@ -27,8 +27,8 @@ const whSurfController = { | ||
27 | let data = valid(req.body, { | 27 | let data = valid(req.body, { |
28 | act_id: {type: 'number', empty: false}, | 28 | act_id: {type: 'number', empty: false}, |
29 | uid: {type: 'number', empty: false}, | 29 | uid: {type: 'number', empty: false}, |
30 | - sessionKey: {type: 'string', empty: true}, | ||
31 | - appVersion: {type: 'string', empty: true}, | 30 | + sessionKey: {type: 'string', empty: false}, |
31 | + appVersion: {type: 'string', empty: false}, | ||
32 | appSessionType: {type: 'string', empty: true} | 32 | appSessionType: {type: 'string', empty: true} |
33 | }); | 33 | }); |
34 | let result = await req.ctx(wheelSurfModel).goPrize(data); | 34 | let result = await req.ctx(wheelSurfModel).goPrize(data); |
@@ -37,6 +37,20 @@ const whSurfController = { | @@ -37,6 +37,20 @@ const whSurfController = { | ||
37 | } catch (e) { | 37 | } catch (e) { |
38 | res.json(e); | 38 | res.json(e); |
39 | } | 39 | } |
40 | + }, | ||
41 | + | ||
42 | + getUserPrize: async function(req, res) { | ||
43 | + try { | ||
44 | + let data = valid(req.body, { | ||
45 | + act_id: {type: 'number', empty: false}, | ||
46 | + uid: {type: 'number', empty: false}, | ||
47 | + }); | ||
48 | + let result = await req.ctx(wheelSurfModel).getUserPrize(data); | ||
49 | + | ||
50 | + res.json({code: 200, data: result, result: true}); | ||
51 | + } catch (e) { | ||
52 | + res.json(e); | ||
53 | + } | ||
40 | } | 54 | } |
41 | }; | 55 | }; |
42 | 56 |
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | const {ActWheelSurfConf, ActWheelSurfPrize, ActWheelSurfUser, Activity} = require('../../../db'); | 2 | const {ActWheelSurfConf, ActWheelSurfPrize, ActWheelSurfUser, Activity} = require('../../../db'); |
3 | const md5 = require('yoho-md5'); | 3 | const md5 = require('yoho-md5'); |
4 | const _ = require('lodash'); | 4 | const _ = require('lodash'); |
5 | +const logger = global.yoho.logger; | ||
5 | 6 | ||
6 | class ActWheelSurfModel extends global.yoho.BaseModel { | 7 | class ActWheelSurfModel extends global.yoho.BaseModel { |
7 | constructor(ctx) { | 8 | constructor(ctx) { |
@@ -208,11 +209,26 @@ class ActWheelSurfModel extends global.yoho.BaseModel { | @@ -208,11 +209,26 @@ class ActWheelSurfModel extends global.yoho.BaseModel { | ||
208 | return Promise.reject({code: 304, result: false, msg: '用户使用次数不足'}); | 209 | return Promise.reject({code: 304, result: false, msg: '用户使用次数不足'}); |
209 | } | 210 | } |
210 | } catch (e) { | 211 | } catch (e) { |
211 | - | 212 | + |
212 | return Promise.reject({code: 305, result: false, msg: '服务错误,请稍等'}); | 213 | return Promise.reject({code: 305, result: false, msg: '服务错误,请稍等'}); |
213 | } | 214 | } |
214 | } | 215 | } |
215 | 216 | ||
217 | + getUserPrize(obj) { | ||
218 | + try { | ||
219 | + ActWheelSurfUser.findAll({include: [{ | ||
220 | + model: ActWheelSurfPrize, | ||
221 | + as: 'ActWheelSurfPrize', | ||
222 | + }, { | ||
223 | + model: ActWheelSurfConf, | ||
224 | + as: 'ActWheelSurfConf', | ||
225 | + }], | ||
226 | + where: obj | ||
227 | + }); | ||
228 | + } catch (e) { | ||
229 | + return Promise.reject({code: 305, result: false, msg: '服务错误,请稍等'}); | ||
230 | + } | ||
231 | + } | ||
216 | } | 232 | } |
217 | 233 | ||
218 | module.exports = ActWheelSurfModel; | 234 | module.exports = ActWheelSurfModel; |
@@ -65,6 +65,7 @@ router.get('/shoes/getBase64ImageData', shoes.getImageData); | @@ -65,6 +65,7 @@ router.get('/shoes/getBase64ImageData', shoes.getImageData); | ||
65 | // wheelSurf | 65 | // wheelSurf |
66 | router.post('/activity/wheelSurf/conf', wheelSurf.getNowConf); | 66 | router.post('/activity/wheelSurf/conf', wheelSurf.getNowConf); |
67 | router.post('/activity/wheelSurf/start', wheelSurf.goPrize); | 67 | router.post('/activity/wheelSurf/start', wheelSurf.goPrize); |
68 | +router.post('/activity/wheelSurf/user/prize', wheelSurf.getUserPrize); | ||
68 | 69 | ||
69 | // 公共服务 | 70 | // 公共服务 |
70 | router.get('/common/resource', common.getResource); | 71 | router.get('/common/resource', common.getResource); |
-
Please register or login to post a comment