wheel-surf.js 1.5 KB
/**
 * 大转盘活动controller
 * @author: leo <qi.li@yoho.cn>
 * @date: 26/09/2018
 */
const wheelSurfModel = require('../models/wheel-surf');
const valid = require('../../../utils/validator');

const whSurfController = {
  getNowConf: async function(req, res) {
    try {
      let data = valid(req.body, {
        act_id: {type: 'number', empty: false},
        uid: {type: 'number', empty: true},
      });
      let result = await req.ctx(wheelSurfModel).getNowConf(data);

      res.json({code: 200, data: result, result: true});
    } catch (e) {
      res.json(e);
    }
  },

  goPrize: async function(req, res) {
        // 校验用户登录
    try {
      let data = valid(req.body, {
        act_id: {type: 'number', empty: false},
        uid: {type: 'number', empty: false},
        sessionKey: {type: 'string', empty: false},
        appVersion: {type: 'string', empty: false},
        appSessionType: {type: 'string', empty: true}
      });
      let result = await req.ctx(wheelSurfModel).goPrize(data);

      res.json({code: 200, data: result, result: true});
    } 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);
    }
  }
};

module.exports = whSurfController;