...
|
...
|
@@ -27,6 +27,7 @@ const userController = { |
|
|
* @param res
|
|
|
*/
|
|
|
userListPage(req, res) {
|
|
|
|
|
|
res.render('user/list', {
|
|
|
bodyClass: 'nav-md',
|
|
|
module: 'admin',
|
...
|
...
|
@@ -47,6 +48,14 @@ const userController = { |
|
|
});
|
|
|
},
|
|
|
|
|
|
prizeUsersListPage(req, res) {
|
|
|
res.render('user/prize-users-list', {
|
|
|
bodyClass: 'nav-md',
|
|
|
module: 'admin',
|
|
|
page: 'prize-users-list'
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户列表
|
|
|
* @param req
|
...
|
...
|
@@ -126,6 +135,44 @@ const userController = { |
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 中奖用户列表
|
|
|
* @param req
|
|
|
* @param res
|
|
|
* @param next
|
|
|
*/
|
|
|
prizeUsersList(req, res, next) {
|
|
|
const pageNo = req.query.pageNo || 1;
|
|
|
const pageSize = req.query.pageSize || 20;
|
|
|
|
|
|
req.ctx(UserModel).prizeUsersList(pageNo, pageSize).then(list => {
|
|
|
|
|
|
let result = [];
|
|
|
|
|
|
_.each(list, item => {
|
|
|
let data = {};
|
|
|
|
|
|
_.each(item, (val, key) => {
|
|
|
data[camelcase(key)] = val;
|
|
|
});
|
|
|
result.push(data);
|
|
|
});
|
|
|
return result;
|
|
|
}).then(list => {
|
|
|
req.ctx(UserModel).allInfoUsersNum().then(totalCount => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
data: list,
|
|
|
pageNo: +pageNo,
|
|
|
pageSize: +pageSize,
|
|
|
totalCount,
|
|
|
totalPage: Math.ceil(totalCount / pageSize),
|
|
|
message: GET_SUCCESS
|
|
|
});
|
|
|
});
|
|
|
}).catch(next);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户删除
|
|
|
* @param req
|
|
|
* @param res
|
...
|
...
|
@@ -162,6 +209,23 @@ const userController = { |
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 抽奖用户删除
|
|
|
* @param req
|
|
|
* @param res
|
|
|
* @param next
|
|
|
*/
|
|
|
deletePrizeUsers(req, res, next) {
|
|
|
const userId = req.body.userId;
|
|
|
|
|
|
req.ctx(UserModel).deletePrizeUser(userId).then(() => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
message: DO_SUCCESS
|
|
|
});
|
|
|
}).catch(next);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户列表导出
|
|
|
* @param req
|
|
|
* @param res
|
...
|
...
|
@@ -258,8 +322,6 @@ const userController = { |
|
|
_.each(result, item => {
|
|
|
temp = [];
|
|
|
|
|
|
console.log(item);
|
|
|
|
|
|
temp.push(item.id);
|
|
|
temp.push(item.user_name);
|
|
|
temp.push(moment(item.user_birthday).format('YYYY-MM-DD'));
|
...
|
...
|
@@ -278,6 +340,55 @@ const userController = { |
|
|
res.end(exportFile, 'binary');
|
|
|
}).catch(next);
|
|
|
},
|
|
|
exportPrizeUserList(req, res, next) {
|
|
|
let conf = {
|
|
|
name: 'myInfoSheet',
|
|
|
cols: [
|
|
|
{
|
|
|
caption: '用户ID',
|
|
|
type: 'number'
|
|
|
},
|
|
|
{
|
|
|
caption: '昵称',
|
|
|
type: 'string'
|
|
|
},
|
|
|
{
|
|
|
caption: '手机号',
|
|
|
type: 'string'
|
|
|
},
|
|
|
{
|
|
|
caption: '地址',
|
|
|
type: 'string'
|
|
|
},
|
|
|
{
|
|
|
caption: '鞋码',
|
|
|
type: 'number'
|
|
|
}
|
|
|
],
|
|
|
rows: []
|
|
|
};
|
|
|
|
|
|
req.ctx(UserModel).exportPrizeUserList().then(result => {
|
|
|
let temp = [];
|
|
|
|
|
|
_.each(result, item => {
|
|
|
temp = [];
|
|
|
|
|
|
temp.push(item.id);
|
|
|
temp.push(item.user_name);
|
|
|
temp.push(item.user_phone);
|
|
|
temp.push(item.user_address);
|
|
|
temp.push(item.user_shoes_size);
|
|
|
conf.rows.push(temp);
|
|
|
});
|
|
|
|
|
|
let exportFile = excelExport.execute(conf);
|
|
|
|
|
|
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
|
|
|
res.setHeader('Content-Disposition', 'attachment; filename=userInfoList.xlsx');
|
|
|
res.end(exportFile, 'binary');
|
|
|
}).catch(next);
|
|
|
},
|
|
|
userLoginLog(req, res) {
|
|
|
res.render('user/login-log', {
|
|
|
bodyClass: 'nav-md',
|
...
|
...
|
|