Commit f95f1dfb authored by 刘松's avatar 刘松

update

parent a67aecd0
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,6 +9,11 @@
<link rel="stylesheet" type="text/css" href="/css/antd.min.css">
<link rel="stylesheet" type="text/css" href="/css/main.css">
</head>
<style type="text/css">
body{
font-size: 13px;
}
</style>
<body>
<div id="main" style="height: 100%;"></div>
<a id="bottom"></a>
......
......@@ -120,7 +120,7 @@ class Qd extends React.Component{
}
return (
this.state.username == 'admin' ? <div>
<Button type="primary" icon="export" onClick={ this.createQd.bind(this) } style={{ margin:'10px 0px'}}>
<Button type="primary" icon="plus" onClick={ this.createQd.bind(this) } style={{ margin:'10px 0px'}}>
创建渠道
</Button>
<Spin spinning= { this.state.status == 'pending' }>
......
......@@ -140,11 +140,11 @@ class Schedule extends React.Component{
width: 70,
render: text => <span href="#">{text}</span>,
},{
title: '状态与操作',
title: '投放状态 / 操作',
dataIndex: 'status',
key: 'status',
width: 30,
render: (text,schedule) => <div><Switch checked={ text == 'use' ? true : false } onChange={this.checkUpdate.bind(this,schedule)} /><Button onClick = {this.tklUpdate.bind(this,schedule)}>生成淘口令</Button></div>,
render: (text,schedule) => <div><Switch checked={ text == 'use' ? true : false } onChange={this.checkUpdate.bind(this,schedule)} style = {{'margin-right': '17px'}}/><Button onClick = {this.tklUpdate.bind(this,schedule)}>生成淘口令</Button></div>,
}
];
let data = [];
......@@ -168,8 +168,8 @@ class Schedule extends React.Component{
}
return (
this.state.username == 'admin' ? <div>
<Button type="primary" icon="export" onClick={ this.createSchedule.bind(this) } style={{ margin:'10px 0px'}}>
创建
<Button type="primary" icon="plus" onClick={ this.createSchedule.bind(this) } style={{ margin:'10px 0px'}}>
创建计划
</Button>
<Spin spinning= { this.state.status == 'pending' }>
<Table columns={columns} dataSource = { data } size="middle" pagination={ this.state.pagination } onChange = { this.onChange.bind(this)} bordered/>
......
......@@ -144,15 +144,15 @@ class Agent extends React.Component{
good:links[i].good,
pid:links[i].pid,
target:links[i].target,
qd:(links[i].qd && links[i].qd['user']) || '暂无',
qd:(links[i].qd ) || '暂无',
img:links[i].pic,
create:links[i].createdAt
});
}
return (
this.state.username == 'admin' ? <div>
<Button type="primary" icon="export" onClick={ this.createLink.bind(this) } style={{ margin:'10px 0px'}}>
创建
<Button type="primary" icon="plus" onClick={ this.createLink.bind(this) } style={{ margin:'10px 0px'}}>
创建推广页
</Button>
<Spin spinning= { this.state.status == 'pending' }>
<Table columns={columns} dataSource = { data } size="middle" pagination={ this.state.pagination } onChange = { this.onChange.bind(this)} bordered/>
......
......@@ -57,47 +57,47 @@ class DashBoard extends React.Component{
dataIndex: 'date',
key: 'date',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '淘口令',
dataIndex: 'info',
key: 'info',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},{
title: '请求数',
dataIndex: 'times',
key: 'times',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '推广计划',
dataIndex: 'schedule',
key: 'schedule',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '渠道',
dataIndex: 'qd',
key: 'qd',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},{
title: '最近更新',
dataIndex: 'update',
key: 'update',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
}
];
......
......@@ -64,35 +64,35 @@ class Gather extends React.Component{
dataIndex: 'date',
key: 'date',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '渠道/分发ID',
dataIndex: 'user',
key: 'user',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '请求数',
dataIndex: 'times',
key: 'times',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '导出数',
dataIndex: 'dc_times',
key: 'dc_times',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
},
{
title: '导出率(%)',
dataIndex: 'rate',
key: 'rate',
width: 100,
render: text => <a href="#">{text}</a>,
render: text => <span href="#">{text}</span>,
}
];
......
module.exports = {
host: '0.0.0.0',
port: process.env.PORT ? process.env.PORT : 9401,
mongo:'mongodb://user:password@10.11.3.100:1302/taoarticle',
//mongo:'mongodb://127.0.0.1:27017/taoarticle',
//mongo:'mongodb://user:password@10.11.3.100:1302/taoarticle',
mongo:'mongodb://127.0.0.1:27017/taoarticle',
taobao: {
host:"http://gw.api.taobao.com/router/rest",
appKey:"24594025",//"23580470",//"23390725",
......
......@@ -172,9 +172,25 @@ exports.getTbkls = async (req, res, next) => {
exports.getLinks = async (req, res, next) => {
let {limit = 100,skip = 0,sort = {'updatedAt': -1}} = req.query;
let options = {limit:parseInt(limit),skip:parseInt(skip)*limit,sort};
let links = await Link.find({},null,options).populate('qd','user role');
let links = await Link.find({},null,options);
links = links.map(x => { var d = x.toJSON();d['createdAt'] = dateFormat(d['createdAt']);return d;})
let total = await Link.count({},null);
var tasks = [];
links.forEach(item => {
tasks.push(Schedule.find({status:'use',links:{ '$in':[ item._id ]}}).populate('qd','user').limit(1000));
});
var arrs = await Promise.all(tasks);
arrs.forEach( (x,i) => {
if(x){
links[i]['qd'] = '';
x.forEach( (y,j) =>{
if(y){
y = y.toJSON();
if(links[i]['qd'] += ((j !==0 ? "," : '') +(y.qd ? y.qd.user : '')));
}
});
}
});
res.send({ status:'ok',result:links,pagination:{total:total,skip:skip,limit:limit}});
}
......
......@@ -46,7 +46,9 @@ async function tbklTask () {
//let tkls = await Kouling.find({status:'use'}).populate('link','title target').limit(1000);
// 查询进行中计划
let schedules = await Schedule.find({status:'use'}).limit(500);
schedules.forEach( async item => {
if(schedules.length == 0) console.log(' 更新结束 无任务');
else
schedules.forEach( async item => {
let schedule = item.toJSON()._id;
var qd = item.toJSON().qd;
// console.dir(schedule);
......@@ -58,7 +60,6 @@ async function tbklTask () {
var tasks_log = [];
logs.forEach( item => {
item = item.toJSON();
console.log(item._id);
//console.dir(item);
if(item.link && item.link.title && item.link.target && item.times >= max){
var data = {
......@@ -67,28 +68,25 @@ async function tbklTask () {
schedule:item.schedule,
link:item.link,
status:'use',
creater:qd,
qd:qd,
pic:item.link.pic
}
tasks_new.push(controller.createTbkl(data));
tasks_old.push(Kouling.update({info:item.key,status:{$ne:'disable'}},{$set:{status:'disable'}}));
tasks_old.push(Kouling.update({info:item.key,status:{$ne:'disable'}},{$set:{status:'disable'}},{multi:true}));
tasks_log.push(Log.update({_id:item._id},{$set:{status:'disable'}}));
}
});
if(tasks_new.length&&tasks_old.length&&tasks_log.length){
Promise.all(tasks_old).then(function(arr){
console.log('删除老口令 结束 影响' + arr.length + '条数据');
});
Promise.all(tasks_log).then(function(arr){
console.log('更新log数据 影响' + arr.length + '条数据');
});
Promise.all(tasks_new).then(function(arr){
console.log('增加新口令 结束 影响' + arr.length + '条数据');
});
console.log(' 更新结束 有任务');
var oldArrs = await Promise.all(tasks_old)
var logArrs = await Promise.all(tasks_log);
var newArrs = await Promise.all(tasks_new);
console.log('删除老口令 结束 影响' + oldArrs.length + '条数据');
console.log('更新log数据 影响' + logArrs.length + '条数据');
console.log('增加新口令 结束 影响' + newArrs.length + '条数据');
console.log(' 更新计划'+ item._id +'结束 有任务');
}
else{
console.log(' 更新结束 无任务');
console.log(' 更新结束 '+ item._id +' 无任务');
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment