Commit 36437b19 authored by 刘松's avatar 刘松

update

parent 707050df
This diff is collapsed.
......@@ -39,7 +39,7 @@ class Login extends React.Component{
<div className = 'login-wrapper'>
<Card
className = { 'm' }
title = { '淘口令后台' }
title = { '媒体后台' }
extra = { <span>登陆</span> }
style = {{ width:400,margin:'auto' }}
>
......
......@@ -9,7 +9,7 @@ const MenuItemGroup = Menu.ItemGroup;
const ButtonGroup = Button.Group;
const { Header, Footer, Sider, Content } = Layout;
const mapLocations = ['/manage','/manage/statistics','/manage/setting','/manage/tkl','/manage/schedule']
const mapLocations = ['/manage/statistics','/manage','/manage/setting','/manage/tkl','/manage/schedule']
class Main extends React.Component{
constructor(props){
......@@ -53,7 +53,7 @@ class Main extends React.Component{
<Layout className="layout">
<Header>
<div className="logo" >
<span>淘口令</span>
<span>媒体后台</span>
</div>
<Menu
theme="dark"
......@@ -75,7 +75,7 @@ class Main extends React.Component{
<Content style={{ padding: '0 50px' }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb.Item>{ this.map[ this.props.menu.currentPage ]}</Breadcrumb.Item>
<Breadcrumb.Item>{ this.props.menu.currentPage == '0' ? '数据统计' : (this.props.menu.currentPage == '1' ? '汇总数据' : "配置" )}</Breadcrumb.Item>
<Breadcrumb.Item>{ this.props.menu.currentPage == '0' ? '数据统计' : (this.props.menu.currentPage == '0' ? '汇总数据' : "配置" )}</Breadcrumb.Item>
</Breadcrumb>
<div style={{ background: '#fff', padding: 24, minHeight: 280 }}>{
this.props.children
......
......@@ -69,6 +69,9 @@ class Schedule extends React.Component{
schedules[schedule['key']]['status'] = (schedule['status'] == 'use' ? 'disable' : 'use');
this.setState({schedules:schedules});
}
tklUpdate(){
}
exportData(){
//json2xlsx(data,{sheetName:"基础数据", filename : '基础数据'+moment().format('YYYYMMDD')+'.xlsx'});
......@@ -98,13 +101,6 @@ class Schedule extends React.Component{
width: 100,
render: text => <span href="#">{text}</span>,
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
width: 30,
render: (text,schedule) => <Switch checked={ text == 'use' ? true : false } onChange={this.checkUpdate.bind(this,schedule)} />,
},
{
title: '可用淘口令',
dataIndex: 'tkls',
......@@ -125,6 +121,12 @@ class Schedule extends React.Component{
key: 'create',
width: 70,
render: text => <span href="#">{text}</span>,
},{
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>,
}
];
let data = [];
......
......@@ -75,7 +75,7 @@ class Gather extends React.Component{
render: text => <a href="#">{text}</a>,
},
{
title: '导出率',
title: '导出率(%)',
dataIndex: 'rate',
key: 'rate',
width: 100,
......@@ -96,10 +96,10 @@ class Gather extends React.Component{
data.push({
key:i,
date:qdgathers[i].date,
user:(qdgathers[i].qd && qdgathers[i].qd.user) + '/ ' + (qdgathers[i].qd && qdgathers[i].qd._id),
times:qdgathers[i].times,
dc_times:qdgathers[i].status == 'disable' ? '已归档' :'--',
rate:(qdgathers[i].schedule) || '--'
user:(qdgathers[i].qd && qdgathers[i].qd.user) + ' / ' + (qdgathers[i].qd && qdgathers[i].qd._id),
times:qdgathers[i].times || 0,
dc_times:qdgathers[i].dc_times || 0,
rate:qdgathers[i].dc_times / qdgathers[i].times ? ((qdgathers[i].dc_times / qdgathers[i].times).toFixed(6) * 100).toFixed(3) : 0
});
}
......
......@@ -11,10 +11,17 @@ const schema = mongoose.Schema({
required: true,
ref:'tao-agent'
},
schedules:[],
schedules:{
type:Array,
required:true
},
times:{
type:Number,
required: true
},
dc_times:{
type:Number,
required: false
}
}, {
timestamps: true
......
......@@ -132,7 +132,7 @@ exports.createLink = async (req, res, next) => {
let goodInfo = await tao.getGood(goodQuery['id']);
let title = goodInfo['title'];
let pic = goodInfo['pict_url'] || '';
let target = 'https://uland.taobao.com/coupon/edetail?activityId='+ quanQuery['activityId']+'&itemId='+goodQuery['id']+'&pid='+pid+'&dx=1';
let target = 'https://uland.taobao.com/coupon/edetail?activityId='+ quanQuery['activityId']+'&itemId='+goodQuery['id']+'&pid='+pid+'&dx=1&src=tkm_tkmwz';
tao.saveLink({name,quan,pid,good,title,pic,target},function(e,result){
if(e) throw e;
res.send({result:'ok',result:result})
......
......@@ -41,8 +41,8 @@ async function sendMail(email,body) {
async function tbklTask () {
console.log('定时更新开始 =====> ');
try {
var date = moment().add(-3,'days').format('YYYYMMDD');
var logDate = moment().add(-3,'days').toDate();
var date = moment().add(-1,'days').format('YYYYMMDD');
var logDate = moment().add(-1,'days').toDate();
var list = await Log.aggregate([
{
$match:{
......@@ -64,19 +64,32 @@ async function tbklTask () {
//schedule = schedule.toJSON();
var schedule = _tasks.push(Schedule.findById(item._id));
sum2schedule[item._id] = item.sum;
console.dir(item)
});
Promise.all(_tasks).then(function(arr){
arr.forEach(function(item){
var schedule = item.toJSON();
if(qd2schedule[schedule.qd] && qd2schedule[schedule.qd].length )
qd2schedule[schedule.qd] = qd2schedule[schedule.qd].concat({schedule:item._id,times:sum2schedule[schedule._id]})
else
qd2schedule[schedule.qd] = [{schedule:item._id,times:sum2schedule[schedule._id]}];
if(item){
var schedule = item.toJSON();
console.dir('schedule in in ')
if(qd2schedule[schedule.qd] && qd2schedule[schedule.qd].length )
qd2schedule[schedule.qd] = qd2schedule[schedule.qd].concat({schedule:item._id,times:sum2schedule[schedule._id]})
else
qd2schedule[schedule.qd] = [{schedule:item._id,times:sum2schedule[schedule._id]}];
}
else{
console.dir(item);
}
});
console.dir(qd2schedule);
var tasks = [];
for(var k in qd2schedule){
var qd = k;
var total = qd2schedule[k].reduce(function(a,b){ return a.times + b.times},{times:0});
var total = 0;
for(var j in qd2schedule[k]){
total += qd2schedule[k][j].times;
}
//var total = qd2schedule[k].reduce(function(a,b){ return a.times + b.times},{times:0});
//console.dir({qd:qd,schedules:qd2schedule[k],date:logDate,times:total});
var data = new Data({qd:qd,schedules:qd2schedule[k],date:logDate,times:total});
tasks.push(data.save());
}
......
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