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 @@ ...@@ -9,6 +9,11 @@
<link rel="stylesheet" type="text/css" href="/css/antd.min.css"> <link rel="stylesheet" type="text/css" href="/css/antd.min.css">
<link rel="stylesheet" type="text/css" href="/css/main.css"> <link rel="stylesheet" type="text/css" href="/css/main.css">
</head> </head>
<style type="text/css">
body{
font-size: 13px;
}
</style>
<body> <body>
<div id="main" style="height: 100%;"></div> <div id="main" style="height: 100%;"></div>
<a id="bottom"></a> <a id="bottom"></a>
......
...@@ -120,7 +120,7 @@ class Qd extends React.Component{ ...@@ -120,7 +120,7 @@ class Qd extends React.Component{
} }
return ( return (
this.state.username == 'admin' ? <div> 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> </Button>
<Spin spinning= { this.state.status == 'pending' }> <Spin spinning= { this.state.status == 'pending' }>
......
...@@ -140,11 +140,11 @@ class Schedule extends React.Component{ ...@@ -140,11 +140,11 @@ class Schedule extends React.Component{
width: 70, width: 70,
render: text => <span href="#">{text}</span>, render: text => <span href="#">{text}</span>,
},{ },{
title: '状态与操作', title: '投放状态 / 操作',
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
width: 30, 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 = []; let data = [];
...@@ -168,8 +168,8 @@ class Schedule extends React.Component{ ...@@ -168,8 +168,8 @@ class Schedule extends React.Component{
} }
return ( return (
this.state.username == 'admin' ? <div> 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> </Button>
<Spin spinning= { this.state.status == 'pending' }> <Spin spinning= { this.state.status == 'pending' }>
<Table columns={columns} dataSource = { data } size="middle" pagination={ this.state.pagination } onChange = { this.onChange.bind(this)} bordered/> <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{ ...@@ -144,15 +144,15 @@ class Agent extends React.Component{
good:links[i].good, good:links[i].good,
pid:links[i].pid, pid:links[i].pid,
target:links[i].target, target:links[i].target,
qd:(links[i].qd && links[i].qd['user']) || '暂无', qd:(links[i].qd ) || '暂无',
img:links[i].pic, img:links[i].pic,
create:links[i].createdAt create:links[i].createdAt
}); });
} }
return ( return (
this.state.username == 'admin' ? <div> 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> </Button>
<Spin spinning= { this.state.status == 'pending' }> <Spin spinning= { this.state.status == 'pending' }>
<Table columns={columns} dataSource = { data } size="middle" pagination={ this.state.pagination } onChange = { this.onChange.bind(this)} bordered/> <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{ ...@@ -57,47 +57,47 @@ class DashBoard extends React.Component{
dataIndex: 'date', dataIndex: 'date',
key: 'date', key: 'date',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '淘口令', title: '淘口令',
dataIndex: 'info', dataIndex: 'info',
key: 'info', key: 'info',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
},{ },{
title: '请求数', title: '请求数',
dataIndex: 'times', dataIndex: 'times',
key: 'times', key: 'times',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '推广计划', title: '推广计划',
dataIndex: 'schedule', dataIndex: 'schedule',
key: 'schedule', key: 'schedule',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '渠道', title: '渠道',
dataIndex: 'qd', dataIndex: 'qd',
key: 'qd', key: 'qd',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
},{ },{
title: '最近更新', title: '最近更新',
dataIndex: 'update', dataIndex: 'update',
key: 'update', key: 'update',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
} }
]; ];
......
...@@ -64,35 +64,35 @@ class Gather extends React.Component{ ...@@ -64,35 +64,35 @@ class Gather extends React.Component{
dataIndex: 'date', dataIndex: 'date',
key: 'date', key: 'date',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '渠道/分发ID', title: '渠道/分发ID',
dataIndex: 'user', dataIndex: 'user',
key: 'user', key: 'user',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '请求数', title: '请求数',
dataIndex: 'times', dataIndex: 'times',
key: 'times', key: 'times',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '导出数', title: '导出数',
dataIndex: 'dc_times', dataIndex: 'dc_times',
key: 'dc_times', key: 'dc_times',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
}, },
{ {
title: '导出率(%)', title: '导出率(%)',
dataIndex: 'rate', dataIndex: 'rate',
key: 'rate', key: 'rate',
width: 100, width: 100,
render: text => <a href="#">{text}</a>, render: text => <span href="#">{text}</span>,
} }
]; ];
......
module.exports = { module.exports = {
host: '0.0.0.0', host: '0.0.0.0',
port: process.env.PORT ? process.env.PORT : 9401, port: process.env.PORT ? process.env.PORT : 9401,
mongo:'mongodb://user:password@10.11.3.100:1302/taoarticle', //mongo:'mongodb://user:password@10.11.3.100:1302/taoarticle',
//mongo:'mongodb://127.0.0.1:27017/taoarticle', mongo:'mongodb://127.0.0.1:27017/taoarticle',
taobao: { taobao: {
host:"http://gw.api.taobao.com/router/rest", host:"http://gw.api.taobao.com/router/rest",
appKey:"24594025",//"23580470",//"23390725", appKey:"24594025",//"23580470",//"23390725",
......
...@@ -172,9 +172,25 @@ exports.getTbkls = async (req, res, next) => { ...@@ -172,9 +172,25 @@ exports.getTbkls = async (req, res, next) => {
exports.getLinks = async (req, res, next) => { exports.getLinks = async (req, res, next) => {
let {limit = 100,skip = 0,sort = {'updatedAt': -1}} = req.query; let {limit = 100,skip = 0,sort = {'updatedAt': -1}} = req.query;
let options = {limit:parseInt(limit),skip:parseInt(skip)*limit,sort}; 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;}) links = links.map(x => { var d = x.toJSON();d['createdAt'] = dateFormat(d['createdAt']);return d;})
let total = await Link.count({},null); 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}}); res.send({ status:'ok',result:links,pagination:{total:total,skip:skip,limit:limit}});
} }
......
...@@ -46,7 +46,9 @@ async function tbklTask () { ...@@ -46,7 +46,9 @@ async function tbklTask () {
//let tkls = await Kouling.find({status:'use'}).populate('link','title target').limit(1000); //let tkls = await Kouling.find({status:'use'}).populate('link','title target').limit(1000);
// 查询进行中计划 // 查询进行中计划
let schedules = await Schedule.find({status:'use'}).limit(500); 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; let schedule = item.toJSON()._id;
var qd = item.toJSON().qd; var qd = item.toJSON().qd;
// console.dir(schedule); // console.dir(schedule);
...@@ -58,7 +60,6 @@ async function tbklTask () { ...@@ -58,7 +60,6 @@ async function tbklTask () {
var tasks_log = []; var tasks_log = [];
logs.forEach( item => { logs.forEach( item => {
item = item.toJSON(); item = item.toJSON();
console.log(item._id);
//console.dir(item); //console.dir(item);
if(item.link && item.link.title && item.link.target && item.times >= max){ if(item.link && item.link.title && item.link.target && item.times >= max){
var data = { var data = {
...@@ -67,28 +68,25 @@ async function tbklTask () { ...@@ -67,28 +68,25 @@ async function tbklTask () {
schedule:item.schedule, schedule:item.schedule,
link:item.link, link:item.link,
status:'use', status:'use',
creater:qd, qd:qd,
pic:item.link.pic pic:item.link.pic
} }
tasks_new.push(controller.createTbkl(data)); 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'}})); tasks_log.push(Log.update({_id:item._id},{$set:{status:'disable'}}));
} }
}); });
if(tasks_new.length&&tasks_old.length&&tasks_log.length){ if(tasks_new.length&&tasks_old.length&&tasks_log.length){
Promise.all(tasks_old).then(function(arr){ var oldArrs = await Promise.all(tasks_old)
console.log('删除老口令 结束 影响' + arr.length + '条数据'); var logArrs = await Promise.all(tasks_log);
}); var newArrs = await Promise.all(tasks_new);
Promise.all(tasks_log).then(function(arr){ console.log('删除老口令 结束 影响' + oldArrs.length + '条数据');
console.log('更新log数据 影响' + arr.length + '条数据'); console.log('更新log数据 影响' + logArrs.length + '条数据');
}); console.log('增加新口令 结束 影响' + newArrs.length + '条数据');
Promise.all(tasks_new).then(function(arr){ console.log(' 更新计划'+ item._id +'结束 有任务');
console.log('增加新口令 结束 影响' + arr.length + '条数据');
});
console.log(' 更新结束 有任务');
} }
else{ 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