...
|
...
|
@@ -6,6 +6,8 @@ |
|
|
|
|
|
const mysqlCli = global.yoho.utils.mysqlCli;
|
|
|
const _ = require('lodash');
|
|
|
const moment = require('moment');
|
|
|
|
|
|
const pager = require('../../../utils/pager');
|
|
|
|
|
|
const TB_USER = 'user';
|
...
|
...
|
@@ -18,7 +20,15 @@ const TB_ACT_ARTICLE_Y100 = 'act_article_y100'; |
|
|
const TABLE_ACT_PRIZE_PRODUCT = 'act_prize_product';
|
|
|
|
|
|
// const TABLE_ACT_PRIZE_PRODUCT_CONTENT = 'act_prize_product_content';
|
|
|
// const TABLE_ACT_PRIZE_PRODUCT_USER = 'act_prize_product_user';
|
|
|
const TABLE_ACT_PRIZE_PRODUCT_USER = 'act_prize_product_user';
|
|
|
|
|
|
const timeFormat = (time) => {
|
|
|
if (_.isNumber(time)) {
|
|
|
time = moment.unix(time);
|
|
|
}
|
|
|
|
|
|
return moment(time).format('YYYY-MM-DD HH:mm:ss');
|
|
|
};
|
|
|
|
|
|
class AdminModel extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
...
|
...
|
@@ -458,11 +468,11 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
* @returns {*}
|
|
|
*/
|
|
|
editZerobuyStatus(id, status) {
|
|
|
if (!id || !status) {
|
|
|
return {
|
|
|
if (!id || !_.inRange(status, 0, 3)) {
|
|
|
return Promise.resolve({
|
|
|
code: 400,
|
|
|
message: '缺少参数'
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return mysqlCli.update(`update ${TABLE_ACT_PRIZE_PRODUCT} set status = :status where id = :id`, {
|
...
|
...
|
@@ -475,6 +485,86 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getZerobuyExportList(id) {
|
|
|
return Promise.all([
|
|
|
mysqlCli.query(`select uid, user_name, prize_code, is_share_take, share_uid, create_time
|
|
|
from ${TABLE_ACT_PRIZE_PRODUCT_USER} where act_prize_id = :id
|
|
|
order by create_time asc`, {id}),
|
|
|
mysqlCli.query(`select 'limit' from ${TABLE_ACT_PRIZE_PRODUCT}
|
|
|
where id = :id limit 1`, {id})
|
|
|
]).then(result => {
|
|
|
let [codes, product] = result;
|
|
|
|
|
|
const limit = _.get(product, '[0].limit', 0);
|
|
|
|
|
|
let users = {};
|
|
|
let userNum = 0;
|
|
|
|
|
|
let rows = [];
|
|
|
let index = 0;
|
|
|
|
|
|
_.forEach(codes, value => {
|
|
|
if (userNum >= limit) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!users[value.uid]) {
|
|
|
userNum++;
|
|
|
users[value.uid] = 1;
|
|
|
}
|
|
|
|
|
|
if (userNum >= limit && !users[value.uid]) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
rows.push([
|
|
|
++index,
|
|
|
value.uid,
|
|
|
value.user_name,
|
|
|
value.prize_code,
|
|
|
value.is_share_take ? '是' : '',
|
|
|
value.share_uid ? value.share_uid : '',
|
|
|
timeFormat(value.create_time)
|
|
|
]);
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
name: 'sheet',
|
|
|
cols: [
|
|
|
{
|
|
|
caption: '编号',
|
|
|
type: 'number'
|
|
|
},
|
|
|
{
|
|
|
caption: 'uid',
|
|
|
type: 'number'
|
|
|
},
|
|
|
{
|
|
|
caption: '昵称',
|
|
|
type: 'string'
|
|
|
},
|
|
|
{
|
|
|
caption: '邀请码',
|
|
|
type: 'string'
|
|
|
},
|
|
|
{
|
|
|
caption: '是否分享获得',
|
|
|
type: 'string'
|
|
|
},
|
|
|
{
|
|
|
caption: '邀请者',
|
|
|
type: 'string'
|
|
|
},
|
|
|
{
|
|
|
caption: '获得时间',
|
|
|
type: 'string'
|
|
|
}
|
|
|
],
|
|
|
rows
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = AdminModel;
|
...
|
...
|
|