|
|
const redbagModel = require('../models/red-envelope');
|
|
|
const headerModel = require('../../../doraemon/models/header'); // 头部model
|
|
|
|
|
|
const valid = require('../../../utils/validator');
|
|
|
const logger = global.yoho.logger;
|
|
|
|
|
|
const redbagPage = async(req, res, next) => {
|
|
|
try {
|
...
|
...
|
@@ -85,10 +86,36 @@ const receiveRedBag = async(req, res, next) => { |
|
|
return next(error);
|
|
|
}
|
|
|
};
|
|
|
const submitWxCode = async(req, res) => {
|
|
|
try {
|
|
|
let obj = {uid: req.user.uid || null,
|
|
|
shareCode: req.body.shareCode || '',
|
|
|
userCode: req.body.userCode || ''};
|
|
|
|
|
|
obj = valid(obj, {
|
|
|
uid: {type: 'uid', empty: false},
|
|
|
shareCode: {type: 'String', empty: false},
|
|
|
userCode: {type: 'String', empty: false}
|
|
|
});
|
|
|
|
|
|
let userInfo = await req.ctx(redbagModel).renderByCs(obj);
|
|
|
|
|
|
obj.userInfo = userInfo.data;
|
|
|
let result = await req.ctx(redbagModel).submitWxCode(obj);
|
|
|
|
|
|
return res.json({code: 200, data: result, result: true});
|
|
|
} catch (e) {
|
|
|
logger.error(e);
|
|
|
return res.json(e);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
redbagPage,
|
|
|
receiveRedBag
|
|
|
receiveRedBag,
|
|
|
submitWxCode
|
|
|
}; |
...
|
...
|
|