Authored by huangyi

修改api

... ... @@ -27,8 +27,8 @@ const whSurfController = {
let data = valid(req.body, {
act_id: {type: 'number', empty: false},
uid: {type: 'number', empty: false},
sessionKey: {type: 'string', empty: true},
appVersion: {type: 'string', empty: true},
sessionKey: {type: 'string', empty: false},
appVersion: {type: 'string', empty: false},
appSessionType: {type: 'string', empty: true}
});
let result = await req.ctx(wheelSurfModel).goPrize(data);
... ... @@ -37,6 +37,20 @@ const whSurfController = {
} catch (e) {
res.json(e);
}
},
getUserPrize: async function(req, res) {
try {
let data = valid(req.body, {
act_id: {type: 'number', empty: false},
uid: {type: 'number', empty: false},
});
let result = await req.ctx(wheelSurfModel).getUserPrize(data);
res.json({code: 200, data: result, result: true});
} catch (e) {
res.json(e);
}
}
};
... ...
... ... @@ -2,6 +2,7 @@
const {ActWheelSurfConf, ActWheelSurfPrize, ActWheelSurfUser, Activity} = require('../../../db');
const md5 = require('yoho-md5');
const _ = require('lodash');
const logger = global.yoho.logger;
class ActWheelSurfModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -208,11 +209,26 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
return Promise.reject({code: 304, result: false, msg: '用户使用次数不足'});
}
} catch (e) {
return Promise.reject({code: 305, result: false, msg: '服务错误,请稍等'});
}
}
getUserPrize(obj) {
try {
ActWheelSurfUser.findAll({include: [{
model: ActWheelSurfPrize,
as: 'ActWheelSurfPrize',
}, {
model: ActWheelSurfConf,
as: 'ActWheelSurfConf',
}],
where: obj
});
} catch (e) {
return Promise.reject({code: 305, result: false, msg: '服务错误,请稍等'});
}
}
}
module.exports = ActWheelSurfModel;
... ...
... ... @@ -65,6 +65,7 @@ router.get('/shoes/getBase64ImageData', shoes.getImageData);
// wheelSurf
router.post('/activity/wheelSurf/conf', wheelSurf.getNowConf);
router.post('/activity/wheelSurf/start', wheelSurf.goPrize);
router.post('/activity/wheelSurf/user/prize', wheelSurf.getUserPrize);
// 公共服务
router.get('/common/resource', common.getResource);
... ...