verify level1

This commit is contained in:
chaosBreaking
2019-10-10 22:27:49 +08:00
parent e04e097115
commit 5601223085
2 changed files with 48 additions and 11 deletions

View File

@@ -6,6 +6,8 @@ const Action = require('./action.model');
* [1] 挖矿收益
* [2] 社区奖励
* [3] 提币
* [4] 邀请人奖励
* [5] 请求实名认证
*/
function createAction (actCode, data) {
switch (actCode) {
@@ -14,6 +16,7 @@ function createAction (actCode, data) {
case 2: return createGroupRewardAction(data);
case 3: return createWithdrawAction(data);
case 4: return createFollerDepositAward(data);
case 5: return createVerifyRequest(data);
}
}
@@ -85,6 +88,18 @@ function createFollerDepositAward(data = {}) {
});
}
function createVerifyRequest(data = {}) {
// 充值奖励推荐人
const { userId, level, detail = {} } = data;
return new Action({
userId,
type: 5,
level,
op: 2,
detail
});
}
module.exports = {
createAction,
};

View File

@@ -5,6 +5,8 @@ const changePwd = require('../sign/sign.controller').changePasswd;
const Crypto = require('../../utils/crypto');
const { parseForm } = require('../../utils/form');
const { USER_FILE_DIR: userFileDir } = require('../../../configSec.js');
const { createAction } = require('../action/action.handler');
const { createTicket } = require('../ticket/ticket.handler');
const fs = require('fs');
if (!fs.existsSync(userFileDir)) {
@@ -152,16 +154,36 @@ module.exports = {
},
async verify (req, res) {
const { userId } = res.locals.user;
const form = await parseForm(req, {
tag: userId,
uploadDir: userFileDir,
maxFileSize: 20 * 1024 * 1024, // 限制文件体积最大20m
keepExtensions: true,
encoding: 'utf-8'
});
console.log(form);
return res.json({
code: 0
});
const user = await User.findById(userId);
if (!user.verified) {
// 未进行过认证
const verifyLevel = 1;
const form = await parseForm(req, {
tag: userId,
uploadDir: userFileDir,
maxFileSize: 20 * 1024 * 1024, // 限制文件体积最大20m
keepExtensions: true,
encoding: 'utf-8'
});
const { pic1, pic2 } = form.data;
const { name, nation, idType, idNo } = form.fields || {};
if (!pic1 || !pic2 || !name || !nation || !idType || !idNo) return res.json({
code: 1,
msg: '缺少必要信息'
});
const action = createAction(5, {
userId,
level: verifyLevel,
detail: { name, nation, idType, idNo, pic1: pic1.path, pic2: pic2.path }
});
action.save();
return res.json({
code: 0,
msg: '审核信息已提交'
});
}
if (user.verified && +user.verifyLevel === 1) {
}
}
};