Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
kouling-admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘松
kouling-admin
Commits
328c6966
Commit
328c6966
authored
Dec 06, 2017
by
刘松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
36437b19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
503 additions
and
46 deletions
+503
-46
app.js
app.js
+2
-2
app.bundle.js
app/built/app.bundle.js
+0
-0
common.bundle.js
app/built/common.bundle.js
+0
-0
manageRoute.js
app/js/routes/manageRoute.js
+5
-0
main.jsx
app/jsx/main.jsx
+6
-5
qd.jsx
app/jsx/setting/qd.jsx
+177
-0
schedule.jsx
app/jsx/setting/schedule.jsx
+25
-7
taopage.jsx
app/jsx/setting/taopage.jsx
+1
-1
tbk.jsx
app/jsx/setting/tbk.jsx
+3
-3
dashboard.jsx
app/jsx/statistics/dashboard.jsx
+2
-6
gather.jsx
app/jsx/statistics/gather.jsx
+68
-4
config.default.js
config/config.default.js
+1
-1
tao-agent.js
db/mongo/tao-agent.js
+4
-0
tao-nonetkl-log.js
db/mongo/tao-nonetkl-log.js
+23
-0
controller.js
lib/controller.js
+180
-14
cron.js
lib/cron.js
+1
-1
session.js
lib/session.js
+1
-2
index.js
routes/index.js
+4
-0
No files found.
app.js
View file @
328c6966
...
...
@@ -33,8 +33,8 @@ app.use(express.static(__dirname+'/app'));
app
.
use
(
async
function
(
req
,
res
,
next
){
if
(
req
.
url
==
'/session'
||
req
.
url
==
'/'
)
return
next
();
let
sess
=
req
.
cookies
[
'sess'
];
let
flag
=
await
sessions
.
findById
(
sess
)
if
(
flag
)
return
next
();
let
flag
=
await
sessions
.
findById
(
sess
)
;
if
(
flag
)
{
req
[
'session_body'
]
=
flag
.
toJSON
();
return
next
();}
else
res
.
redirect
(
'/'
);
});
app
.
get
(
'/'
,
function
(
req
,
res
){
...
...
app/built/app.bundle.js
View file @
328c6966
This diff is collapsed.
Click to expand it.
app/built/common.bundle.js
View file @
328c6966
This diff is collapsed.
Click to expand it.
app/js/routes/manageRoute.js
View file @
328c6966
...
...
@@ -18,6 +18,10 @@ module.exports = {
{
path
:
'schedule'
,
component
:
require
(
'../../jsx/setting/schedule.jsx'
)
},
{
path
:
'qd'
,
component
:
require
(
'../../jsx/setting/qd.jsx'
)
}
]
}
\ No newline at end of file
app/jsx/main.jsx
View file @
328c6966
...
...
@@ -9,7 +9,7 @@ const MenuItemGroup = Menu.ItemGroup;
const
ButtonGroup
=
Button
.
Group
;
const
{
Header
,
Footer
,
Sider
,
Content
}
=
Layout
;
const
mapLocations
=
[
'/manage/statistics'
,
'/manage'
,
'/manage/setting'
,
'/manage/tkl'
,
'/manage/schedule'
]
const
mapLocations
=
[
'/manage/statistics'
,
'/manage'
,
'/manage/setting'
,
'/manage/tkl'
,
'/manage/schedule'
,
'/manage/qd'
]
class
Main
extends
React
.
Component
{
constructor
(
props
){
...
...
@@ -25,9 +25,9 @@ class Main extends React.Component{
handleClick
(
e
){
//this.props.dispatch(actions.getMenu());
if
(
e
.
key
==
5
){
api
(
'GET'
,
'logout'
,
function
(
res
){
console
.
dir
(
res
)
;
if
(
e
.
key
==
6
){
api
(
'GET'
,
'logout'
).
then
(
function
(
res
){
if
(
res
.
result
==
'ok'
)
location
.
href
=
'/'
;
});
}
else
...
...
@@ -69,7 +69,8 @@ class Main extends React.Component{
<
Menu
.
Item
key=
"2"
>
推广页管理
</
Menu
.
Item
>
<
Menu
.
Item
key=
"3"
>
淘口令
</
Menu
.
Item
>
<
Menu
.
Item
key=
"4"
>
推广计划
</
Menu
.
Item
>
<
Menu
.
Item
key=
"5"
style
={{
float
:'
right
'}}
><
Icon
type=
"logout"
/>
{
this
.
state
.
username
}
</
Menu
.
Item
>
<
Menu
.
Item
key=
"5"
>
渠道管理
</
Menu
.
Item
>
<
Menu
.
Item
key=
"6"
style
={{
float
:'
right
'}}
><
Icon
type=
"logout"
/>
{
this
.
state
.
username
}
</
Menu
.
Item
>
</
Menu
>
</
Header
>
<
Content
style=
{
{
padding
:
'0 50px'
}
}
>
...
...
app/jsx/setting/qd.jsx
0 → 100644
View file @
328c6966
const
React
=
require
(
'react'
);
const
moment
=
require
(
'moment'
);
const
api
=
require
(
'../../js/api'
);
import
json2xlsx
from
'../../js/json2xlsx'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
,
Modal
,
Form
,
Input
,
Switch
}
from
'antd'
;
const
{
RangePicker
}
=
DatePicker
;
const
FormItem
=
Form
.
Item
;
class
Qd
extends
React
.
Component
{
constructor
(
props
){
super
(
props
);
console
.
dir
(
this
.
props
);
this
.
state
=
{
qds
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
20
,
total
:
100
},
modalVisible
:
false
,
username
:
'channel'
};
}
componentDidMount
(){
let
pagination
=
this
.
state
.
pagination
;
if
(
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
]
&&
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]){
this
.
setState
({
username
:
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]});
}
api
(
'GET'
,
'qds?'
+
'skip=0&limit='
+
pagination
.
pageSize
).
then
((
res
)
=>
{
this
.
setState
({
qds
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
},
info
:{
quan
:
''
,
good
:
''
}})
console
.
dir
(
res
.
result
);
});
}
getqds
(
pagination
){
this
.
setState
({
status
:
'pending'
})
api
(
'GET'
,
'qds?'
+
'skip='
+
(
pagination
.
current
-
1
)
+
'&limit='
+
pagination
.
pageSize
).
then
((
res
)
=>
{
this
.
setState
({
qds
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
}})
console
.
dir
(
res
.
result
);
});
}
onChange
(
pagination
)
{
this
.
getqds
(
pagination
);
}
createQd
(){
this
.
setModalVisible
(
true
);
}
handleSubmit
(
e
){
e
.
preventDefault
();
var
self
=
this
;
this
.
props
.
form
.
validateFields
((
err
,
values
)
=>
{
if
(
!
err
)
{
console
.
dir
(
values
);
api
(
'POST'
,
'qd'
,
values
).
then
((
res
)
=>
{
if
(
res
&&
res
.
result
){
self
.
setModalVisible
(
false
);
self
.
getqds
({
limit
:
this
.
state
.
pagination
.
pageSize
,
skip
:
0
});
}
});
}
});
}
setModalVisible
(
b
){
this
.
setState
({
modalVisible
:
b
});
}
exportData
(){
//json2xlsx(data,{sheetName:"基础数据", filename : '基础数据'+moment().format('YYYYMMDD')+'.xlsx'});
}
render
(){
const
{
getFieldDecorator
,
getFieldsError
,
getFieldError
,
isFieldTouched
}
=
this
.
props
.
form
;
const
columns
=
[
{
title
:
'渠道ID(分发ID)'
,
dataIndex
:
'id'
,
key
:
'id'
,
width
:
100
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
title
:
'用户名'
,
dataIndex
:
'user'
,
key
:
'user'
,
width
:
40
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
title
:
'备注信息'
,
dataIndex
:
'info'
,
key
:
'info'
,
width
:
100
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
title
:
'可用计划'
,
dataIndex
:
'schedule'
,
key
:
'schedule'
,
width
:
40
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
title
:
'淘口令数'
,
dataIndex
:
'tkl'
,
key
:
'tkl'
,
width
:
40
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
}
];
let
data
=
[];
let
qds
=
this
.
state
.
qds
;
for
(
let
i
=
0
;
i
<
qds
.
length
;
i
++
){
data
.
push
({
key
:
i
,
id
:
qds
[
i
].
_id
,
user
:
qds
[
i
].
user
,
info
:
qds
[
i
].
info
||
'--'
,
schedule
:(
qds
[
i
].
schedule_count
)
||
0
,
tkl
:(
qds
[
i
].
tkl_count
)
||
0
});
}
return
(
this
.
state
.
username
==
'admin'
?
<
div
>
<
Button
type=
"primary"
icon=
"export"
onClick=
{
this
.
createQd
.
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
/>
</
Spin
>
<
Modal
title=
"渠道创建"
style=
{
{
top
:
30
}
}
visible=
{
this
.
state
.
modalVisible
}
footer
=
{
null
}
onCancel
=
{
this
.
setModalVisible
.
bind
(
this
,
false
)
}
>
<
Form
onSubmit=
{
this
.
handleSubmit
.
bind
(
this
)
}
className=
"login-form"
>
<
FormItem
>
{
getFieldDecorator
(
'user'
,
{
rules
:
[{
required
:
true
,
message
:
'用户名不能为空'
}],
})(
<
Input
prefix=
{
<
span
style=
{
{
fontSize
:
13
}
}
>
用户名
</
span
>
}
placeholder=
"例如:dqd1"
/>
)
}
</
FormItem
>
<
FormItem
>
{
getFieldDecorator
(
'info'
,
{
rules
:
[{
required
:
true
,
message
:
'备注信息不能为空'
}],
})(
<
Input
prefix=
{
<
span
style=
{
{
fontSize
:
13
}
}
>
备注信息
</
span
>
}
placeholder=
"例如:xxx公司"
/>
)
}
</
FormItem
>
<
FormItem
>
{
getFieldDecorator
(
'password'
,
{
rules
:
[{
required
:
true
,
message
:
'密码不能为空'
}],
})(
<
Input
prefix=
{
<
span
style=
{
{
fontSize
:
13
}
}
>
渠道密码
</
span
>
}
placeholder=
"例如:abc123"
/>
)
}
</
FormItem
>
<
FormItem
>
<
Button
type=
"primary"
htmlType=
"submit"
className=
"login-form-button"
>
创建
</
Button
>
</
FormItem
>
</
Form
>
</
Modal
>
</
div
>:
<
Alert
message=
"提示"
description=
"您没有权限"
type=
"warning"
/>
)
}
}
Qd
=
Form
.
create
()(
Qd
);
module
.
exports
=
Qd
;
app/jsx/setting/schedule.jsx
View file @
328c6966
...
...
@@ -4,7 +4,7 @@ const api = require('../../js/api');
import
json2xlsx
from
'../../js/json2xlsx'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
,
Modal
,
Form
,
Input
,
Switch
}
from
'antd'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
,
Modal
,
Form
,
Input
,
Switch
,
message
}
from
'antd'
;
const
{
RangePicker
}
=
DatePicker
;
const
FormItem
=
Form
.
Item
;
...
...
@@ -57,20 +57,38 @@ class Schedule extends React.Component{
api
(
'POST'
,
'schedule'
,
values
).
then
((
res
)
=>
{
if
(
res
&&
res
.
result
){
self
.
setModalVisible
(
false
);
self
.
getschedules
({
limit
:
this
.
state
.
limit
,
skip
:
0
});
self
.
getschedules
({
limit
:
this
.
state
.
pagination
.
pageSize
,
skip
:
0
});
}
});
}
});
}
checkUpdate
(
schedule
){
console
.
dir
(
schedule
);
var
schedules
=
this
.
state
.
schedules
;
schedules
[
schedule
[
'key'
]][
'status'
]
=
(
schedule
[
'status'
]
==
'use'
?
'disable'
:
'use'
);
this
.
setState
({
schedules
:
schedules
});
}
tklUpdate
(){
var
data
=
{
status
:
schedule
[
'status'
]
==
'use'
?
'disable'
:
'use'
,
scheduleId
:
schedule
[
'id'
]
}
var
self
=
this
;
api
(
'POST'
,
'schedule_update'
,
data
).
then
((
res
)
=>
{
if
(
res
&&
res
.
schedule
){
if
(
data
.
status
==
'use'
)
message
.
success
(
'执行成功, 生成'
+
(
res
.
new
?
res
.
new
.
length
:
0
)
+
" 条淘口令"
);
else
message
.
success
(
'执行成功, 删除'
+
(
res
.
remove_result
?
res
.
remove_result
.
nModified
:
0
)
+
" 条淘口令"
);
schedules
[
schedule
[
'key'
]][
'status'
]
=
(
schedule
[
'status'
]
==
'use'
?
'disable'
:
'use'
);
self
.
setState
({
schedules
:
schedules
});
}
//message.success('执行成功, 生成 '+(res.new ? res.new.length : 0) +" 条,删除 "+ (res.remove_result ? res.remove_result.nModified : 0 )+" 条");
});
}
tklUpdate
(
schedule
){
console
.
dir
(
schedule
);
api
(
'POST'
,
'newtkl'
,{
id
:
schedule
.
id
}).
then
((
res
)
=>
{
if
(
res
&&
res
.
result
==
'ok'
)
message
.
success
(
'执行成功, 生成 '
+
(
res
.
new
?
res
.
new
.
length
:
0
)
+
" 条,删除 "
+
(
res
.
remove_result
?
res
.
remove_result
.
nModified
:
0
)
+
" 条"
);
});
}
exportData
(){
...
...
app/jsx/setting/taopage.jsx
View file @
328c6966
...
...
@@ -56,7 +56,7 @@ class Agent extends React.Component{
api
(
'POST'
,
'link'
,
values
).
then
((
res
)
=>
{
if
(
res
&&
res
.
result
){
self
.
setModalVisible
(
false
);
self
.
getLinks
({
limit
:
this
.
state
.
limit
,
skip
:
0
});
self
.
getLinks
({
limit
:
this
.
state
.
pagination
.
pageSize
,
skip
:
0
});
}
});
}
...
...
app/jsx/setting/tbk.jsx
View file @
328c6966
...
...
@@ -4,7 +4,7 @@ const api = require('../../js/api');
import
json2xlsx
from
'../../js/json2xlsx'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
}
from
'antd'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
,
Badge
}
from
'antd'
;
const
{
RangePicker
}
=
DatePicker
;
class
Tbkls
extends
React
.
Component
{
...
...
@@ -80,7 +80,7 @@ class Tbkls extends React.Component{
dataIndex
:
'status'
,
key
:
'status'
,
width
:
40
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>
,
render
:
text
=>
text
==
'use'
?
<
Badge
status=
"processing"
text=
"进行中"
/>
:
<
Badge
status=
"default"
text=
"已失效"
/>
,
},
{
title
:
'创建日期'
,
...
...
@@ -99,7 +99,7 @@ class Tbkls extends React.Component{
good
:(
tbkls
[
i
].
link
&&
tbkls
[
i
].
link
[
'title'
])
||
'--'
,
schedule
:
tbkls
[
i
].
schedule
,
target
:(
tbkls
[
i
].
link
&&
tbkls
[
i
].
link
[
'target'
])
||
'--'
,
status
:
tbkls
[
i
].
status
==
'use'
?
'进行中'
:
'已失效'
,
status
:
tbkls
[
i
].
status
,
create
:
tbkls
[
i
].
createdAt
});
}
...
...
app/jsx/statistics/dashboard.jsx
View file @
328c6966
...
...
@@ -125,7 +125,7 @@ class DashBoard extends React.Component{
}
return
(
this
.
state
.
username
==
'admin'
?
<
div
>
<
div
>
<
RangePicker
onChange=
{
this
.
onChangeRange
.
bind
(
this
)
}
value=
{
ranges
}
format=
{
'YYYYMMDD'
}
style=
{
{
margin
:
'10px 0px'
}
}
/>
<
Button
type=
"primary"
icon=
"export"
onClick=
{
this
.
exportData
.
bind
(
this
)
}
style=
{
{
float
:
'right'
,
margin
:
'10px 0px'
}
}
>
导出数据
...
...
@@ -133,11 +133,7 @@ class DashBoard extends React.Component{
<
Spin
spinning=
{
this
.
state
.
status
==
'pending'
}
>
<
Table
columns=
{
columns
}
dataSource
=
{
data
}
size=
"middle"
pagination=
{
this
.
state
.
pagination
}
onChange
=
{
this
.
onChange
.
bind
(
this
)}
bordered
/>
</
Spin
>
</
div
>:
<
Alert
message=
"提示"
description=
"您没有权限"
type=
"warning"
/>
</
div
>
)
}
}
...
...
app/jsx/statistics/gather.jsx
View file @
328c6966
...
...
@@ -6,7 +6,7 @@ const api = require('../../js/api');
import
json2xlsx
from
'../../js/json2xlsx'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
}
from
'antd'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
,
Popover
}
from
'antd'
;
const
{
RangePicker
}
=
DatePicker
;
class
Gather
extends
React
.
Component
{
...
...
@@ -14,22 +14,35 @@ class Gather extends React.Component{
constructor
(
props
){
super
(
props
);
this
.
range
=
[
moment
().
subtract
(
6
,
'days'
).
format
(
'YYYYMMDD'
),
moment
().
format
(
'YYYYMMDD'
)];
this
.
state
=
{
qdgathers
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
10
,
total
:
100
},
username
:
'channel'
};
this
.
state
=
{
qdgathers
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
10
,
total
:
100
},
username
:
'channel'
,
tody
:{
tkl_count
:
0
,
count
:
0
,
schedule_count
:
0
}
,
none_tkls
:[]
};
}
componentDidMount
(){
let
data
=
{
start
:
moment
().
add
(
-
6
,
'days'
).
format
(
'YYYYMMDD'
),
end
:
moment
().
format
(
'YYYYMMDD'
)};
if
(
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
]
&&
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]){
this
.
setState
({
username
:
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]});
}
api
(
'GET'
,
'gathers/qd'
).
then
((
res
)
=>
{
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
})
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
none_tkls
:
res
.
none_tkls
});
this
.
handle
(
res
.
list
,
res
.
tkl_count
)
console
.
dir
(
res
.
result
);
});
}
handle
(
list
,
tkl_count
){
var
sum
=
0
;
for
(
var
k
in
list
){
sum
+=
(
list
[
k
][
'sum'
]
||
0
);
}
this
.
setState
({
tody
:{
tkl_count
:
tkl_count
,
schedule_count
:
list
.
length
,
count
:
sum
}});
}
getQdGatherss
(
pagination
){
console
.
dir
(
pagination
);
this
.
setState
({
status
:
'pending'
})
api
(
'GET'
,
'gathers/qd?'
+
'skip='
+
(
pagination
.
current
-
1
)
+
'&limit='
+
pagination
.
pageSize
).
then
((
res
)
=>
{
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
}})
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
},
none_tkls
:
res
.
none_tkls
});
this
.
handle
(
res
.
list
,
res
.
tkl_count
);
console
.
dir
(
res
.
result
);
});
}
...
...
@@ -102,9 +115,60 @@ class Gather extends React.Component{
rate
:
qdgathers
[
i
].
dc_times
/
qdgathers
[
i
].
times
?
((
qdgathers
[
i
].
dc_times
/
qdgathers
[
i
].
times
).
toFixed
(
6
)
*
100
).
toFixed
(
3
)
:
0
});
}
var
none_tkls
=
this
.
state
.
none_tkls
;
var
sum
=
0
;
var
list_show
=
[];
for
(
var
i
in
none_tkls
){
sum
+=
none_tkls
[
i
][
'times'
];
let
qd
=
none_tkls
[
i
][
"qd"
];
if
(
qd
)
list_show
.
push
(<
p
>
{
qd
[
'user'
]
+
" "
+
none_tkls
[
i
][
'times'
]
}
</
p
>)
}
const
content
=
(
<
div
>
{
list_show
}
</
div
>
);
return
(
<
div
>
<
div
>
<
Row
>
<
Col
span=
"6"
>
<
div
className
=
"
box
"
style=
{
{
marginLeft
:
'0px'
}
}
>
<
h3
>
请求数
</
h3
>
<
span
>
{
this
.
state
.
tody
.
count
}
</
span
>
</
div
>
</
Col
>
<
Col
span=
"6"
>
<
div
className
=
"
box
"
style=
{
{
marginLeft
:
'0px'
}
}
>
<
h3
>
投放计划
</
h3
>
<
span
>
{
this
.
state
.
tody
.
schedule_count
}
</
span
>
</
div
>
</
Col
>
{
this
.
state
.
username
!==
'admin'
?
<
Col
span=
"6"
>
<
div
className
=
"
box
"
style=
{
{
marginLeft
:
'0px'
}
}
>
<
h3
>
导出数
</
h3
>
<
span
>
次日发布
</
span
>
</
div
>
</
Col
>
:
<
Col
span=
"6"
>
<
div
className
=
"
box
"
style=
{
{
marginLeft
:
'0px'
}
}
>
<
h3
>
无效请求
</
h3
>
<
Popover
content=
{
content
}
title=
"详情"
>
<
span
>
{
sum
}
</
span
>
</
Popover
>
</
div
>
</
Col
>
}
<
Col
span=
"6"
>
<
div
className
=
"
box
"
>
<
h3
>
淘口令数
</
h3
>
<
span
>
{
this
.
state
.
tody
.
tkl_count
}
</
span
>
</
div
>
</
Col
>
</
Row
>
</
div
>
<
RangePicker
onChange=
{
this
.
onChange
.
bind
(
this
)
}
value=
{
ranges
}
format=
{
'YYYYMMDD'
}
style=
{
{
margin
:
'10px 0px'
}
}
/>
<
Button
type=
"primary"
icon=
"export"
onClick=
{
this
.
exportData
.
bind
(
this
)
}
style=
{
{
float
:
'right'
,
margin
:
'10px 0px'
}
}
>
导出数据
...
...
config/config.default.js
View file @
328c6966
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://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",
...
...
db/mongo/tao-agent.js
View file @
328c6966
...
...
@@ -13,6 +13,10 @@ const schema = mongoose.Schema({
required
:
true
,
set
:
v
=>
hash
(
v
)
},
info
:{
type
:
String
,
unique
:
false
},
role
:
{
type
:
String
,
required
:
true
...
...
db/mongo/tao-nonetkl-log.js
0 → 100644
View file @
328c6966
const
mongoose
=
require
(
'mongoose'
);
const
{
ObjectId
}
=
mongoose
.
SchemaTypes
;
const
schema
=
mongoose
.
Schema
({
qd
:{
type
:
ObjectId
,
required
:
true
,
ref
:
'tao-agent'
},
times
:{
type
:
Number
,
required
:
true
},
date
:{
type
:
String
,
required
:
true
},
},
{
timestamps
:
true
});
schema
.
index
({
qd
:
1
});
module
.
exports
=
mongoose
.
model
(
'tao-nonetkl-log'
,
schema
);
lib/controller.js
View file @
328c6966
...
...
@@ -9,6 +9,7 @@ const Session = require('../db/mongo/session');
const
Agent
=
require
(
'../db/mongo/tao-agent'
);
const
Schedule
=
require
(
'../db/mongo/tao-schedule'
);
const
GatherData
=
require
(
'../db/mongo/tao-data'
);
const
Nonetkl
=
require
(
'../db/mongo/tao-nonetkl-log'
);
const
url
=
require
(
'url'
);
const
not_full
=
'params not full error'
;
const
not_right
=
'params not right error'
;
...
...
@@ -60,15 +61,36 @@ exports.putTbkl = async (req, res, next) => {
res
.
status
(
400
).
send
(
'already exsits error'
);
}
};
exports
.
logs
=
async
(
req
,
res
,
next
)
=>
{
let
{
start
,
end
}
=
req
.
body
;
const
condition
=
{
'$and'
:
[{
'createdAt'
:
{
'$gte'
:
moment
(
start
,
'YYYYMMDD'
).
startOf
(
'day'
).
toDate
()}},
{
'createdAt'
:
{
'$lt'
:
moment
(
end
,
'YYYYMMDD'
).
endOf
(
'day'
).
toDate
()}}]};
let
{
limit
=
100
,
skip
=
0
,
sort
=
{
'updatedAt'
:
-
1
}}
=
req
.
query
;
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
};
var
logs
=
await
Log
.
find
({},
null
,
options
).
populate
({
path
:
"schedule"
,
select
:
"links qd"
,
populate
:{
path
:
'qd'
,
select
:
'user'
}});
let
total
=
await
Log
.
count
({},
null
);
logs
=
logs
.
map
(
x
=>
{
var
d
=
x
.
toJSON
();
d
[
'updatedAt'
]
=
dateFormat
(
d
[
'updatedAt'
]);
return
d
;});
res
.
send
({
status
:
'ok'
,
result
:
logs
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
//const condition = {'$and': [{'createdAt': {'$gte': moment(start, 'YYYYMMDD').startOf('day').toDate()}}, {'createdAt': {'$lt': moment(end, 'YYYYMMDD').endOf('day').toDate()}}]};
let
sess
=
req
.
cookies
[
'sess'
];
if
(
sess
){
let
{
limit
=
100
,
skip
=
0
,
sort
=
{
'updatedAt'
:
-
1
}}
=
req
.
query
;
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
};
var
session_body
=
await
Session
.
findById
(
sess
);
if
(
session_body
){
var
user
=
session_body
.
toJSON
().
user
;
let
qs
=
{};
if
(
user
!=
'5a1e81f8c86fa7aa4b51b18b'
){
let
schedules
=
await
Schedule
.
find
({
qd
:
user
},
null
,{
limit
:
1000
});
schedules
=
schedules
.
map
(
x
=>
{
return
{
schedule
:
x
.
toJSON
().
_id
}});
console
.
dir
(
schedules
);
qs
=
{
$or
:
schedules
};
}
var
logs
=
await
Log
.
find
(
qs
,
null
,
options
).
populate
({
path
:
"schedule"
,
select
:
"links qd"
,
populate
:{
path
:
'qd'
,
select
:
'user'
}});
let
total
=
await
Log
.
count
(
qs
,
null
);
logs
=
logs
.
map
(
x
=>
{
var
d
=
x
.
toJSON
();
d
[
'updatedAt'
]
=
dateFormat
(
d
[
'updatedAt'
]);
return
d
;});
res
.
send
({
status
:
'ok'
,
result
:
logs
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
}
else
{
res
.
status
(
400
).
send
(
not_login
);
}
}
else
{
res
.
status
(
400
).
send
(
not_login
);
}
}
...
...
@@ -77,14 +99,56 @@ exports.getQdGatherData = async (req, res, next) => {
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
};
let
sess
=
req
.
cookies
[
'sess'
];
if
(
sess
){
var
none_tkls
=
[];
var
session_body
=
await
Session
.
findById
(
sess
);
if
(
session_body
){
var
user
=
session_body
.
toJSON
().
user
;
let
qs
=
(
user
==
'5a1e81f8c86fa7aa4b51b18b'
?
{}
:
{
qd
:
user
});
var
qs
=
{};
var
match_qs
=
{
date
:
moment
().
format
(
'YYYYMMDD'
)};
var
kl_qs
=
{
status
:
'use'
};
//console.log(user);
var
list
=
[];
var
none_total
=
[];
if
(
user
!=
'5a1e81f8c86fa7aa4b51b18b'
){
qs
=
{
qd
:
user
};
let
schedules
=
await
Schedule
.
find
({
qd
:
user
},
null
,{
limit
:
1000
});
schedules
=
schedules
.
map
(
x
=>
{
return
{
schedule
:
x
.
toJSON
().
_id
}});
//qs = { $or:schedules };
if
(
schedules
.
length
){
match_qs
[
'$or'
]
=
schedules
;
list
=
await
Log
.
aggregate
([
{
$match
:
match_qs
},
{
$group
:{
_id
:
"$schedule"
,
sum
:{
$sum
:
"$times"
}
}
}
])
}
kl_qs
[
'creater'
]
=
user
;
}
else
{
list
=
await
Log
.
aggregate
([
{
$match
:
match_qs
},
{
$group
:{
_id
:
"$schedule"
,
sum
:{
$sum
:
"$times"
}
}
}
]);
none_tkls
=
await
Nonetkl
.
find
({
date
:
match_qs
[
'date'
]}).
populate
(
'qd'
,
'user'
).
limit
(
1000
);
}
var
gatherDatas
=
await
GatherData
.
find
(
qs
,
null
,
options
).
populate
(
'qd'
,
'user'
);
let
total
=
await
GatherData
.
count
({},
null
);
let
tkl_count
=
await
Kouling
.
count
(
kl_qs
,
null
);
gatherDatas
=
gatherDatas
.
map
(
x
=>
{
var
d
=
x
.
toJSON
();
d
[
'date'
]
=
dateFormat
(
d
[
'date'
],
'YYYYMMDD'
);
return
d
;});
res
.
send
({
status
:
'ok'
,
result
:
gatherDatas
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
res
.
send
({
status
:
'ok'
,
result
:
gatherDatas
,
list
:
list
,
none_tkls
:
none_tkls
,
tkl_count
:
tkl_count
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
}
else
{
res
.
status
(
400
).
send
(
not_login
);
...
...
@@ -146,7 +210,7 @@ exports.createLink = async (req, res, next) => {
}
exports
.
getSchedules
=
async
(
req
,
res
,
next
)
=>
{
let
{
limit
=
100
,
skip
=
0
,
sort
=
{
'
upd
atedAt'
:
-
1
}}
=
req
.
query
;
let
{
limit
=
100
,
skip
=
0
,
sort
=
{
'
cre
atedAt'
:
-
1
}}
=
req
.
query
;
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
};
let
schedules
=
await
Schedule
.
find
({},
null
,
options
).
populate
(
'links'
,
'name title target'
).
populate
(
'qd'
,
'user'
);
var
tasks
=
[];
...
...
@@ -160,12 +224,81 @@ exports.getSchedules = async (req, res, next) => {
});
}
exports
.
getQds
=
async
(
req
,
res
,
next
)
=>
{
let
{
limit
=
100
,
skip
=
0
,
sort
=
{
'createdAt'
:
-
1
}}
=
req
.
query
;
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
};
let
qds
=
await
Agent
.
find
({},
null
,
options
);
let
total
=
await
Agent
.
count
({},
null
,
options
);
var
tasks
=
[];
var
_tasks
=
[];
qds
.
forEach
(
(
item
)
=>
{
tasks
.
push
(
Kouling
.
count
({
creater
:
item
.
_id
,
status
:
'use'
}));
_tasks
.
push
(
Schedule
.
count
({
qd
:
item
.
_id
,
status
:
'use'
}));
});
var
arrs
=
await
Promise
.
all
(
tasks
);
var
_arrs
=
await
Promise
.
all
(
_tasks
);
qds
=
qds
.
map
((
x
,
i
)
=>
{
x
=
x
.
toJSON
();
x
[
'tkl_count'
]
=
arrs
[
i
];
x
[
'schedule_count'
]
=
_arrs
[
i
];
return
x
;
});
//console.dir(_arrs);
res
.
send
({
status
:
'ok'
,
result
:
qds
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
}
exports
.
createQd
=
async
(
req
,
res
,
next
)
=>
{
let
{
user
,
info
=
'xxx'
,
password
=
'abc123'
,
role
=
'channel'
}
=
req
.
body
;
tao
.
saveAgent
({
user
,
info
,
password
,
role
},
function
(
e
,
result
){
if
(
e
)
res
.
status
(
400
),
send
(
e
);
else
res
.
send
({
status
:
'ok'
,
result
:
result
});
});
}
exports
.
updateSchedule
=
async
(
req
,
res
,
next
)
=>
{
let
{
schedule
,
status
}
=
req
.
body
;
//let schedules = await Schedule.f
let
total
=
await
Schedule
.
count
({},
null
);
res
.
send
({
status
:
'ok'
,
result
:
schedules
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
let
{
scheduleId
,
status
}
=
req
.
body
;
var
modify_result
=
{};
if
(
status
==
'disable'
){
remove_result
=
await
Kouling
.
update
({
status
:
'use'
,
schedule
:
scheduleId
},{
$set
:{
status
:
'disable'
}},{
multi
:
true
});
let
result
=
await
Schedule
.
update
({
_id
:
scheduleId
},{
$set
:{
status
:
status
}},{
multi
:
true
});
res
.
send
({
status
:
'ok'
,
schedule
:
result
,
remove_result
:
remove_result
});
}
else
{
var
schedule
=
await
Schedule
.
findById
(
scheduleId
).
populate
(
'links'
);
schedule
=
schedule
.
toJSON
();
var
links
=
schedule
.
links
;
var
qd
=
schedule
.
qd
;
var
tasks
=
[];
links
.
forEach
(
item
=>
{
var
data
=
{
title
:
item
.
title
,
target
:
item
.
target
,
pic
:
item
.
pic
,
qd
:
qd
,
link
:
item
.
_id
,
schedule
:
schedule
.
_id
}
for
(
var
i
=
0
;
i
<
5
;
i
++
){
tasks
.
push
(
createTbkl
(
data
));
}
});
var
tkls
=
await
Promise
.
all
(
tasks
);
console
.
dir
(
tkls
);
if
(
tkls
&&
tkls
.
length
){
var
ids
=
[];
for
(
var
k
in
tkls
){
ids
.
push
(
tkls
[
k
].
_id
);
}
let
result
=
await
Schedule
.
update
({
_id
:
scheduleId
},{
$set
:{
status
:
status
}},{
multi
:
true
});
//var remove_result = await Kouling.update({status:'use',schedule:schedule._id,_id:{'$nin':ids}},{$set:{status:'disable'}},{multi:true});
res
.
send
({
status
:
'ok'
,
schedule
:
result
,
new
:
tkls
});
}
else
res
.
status
(
400
).
send
(
'error'
);
}
}
exports
.
createSchedule
=
async
(
req
,
res
,
next
)
=>
{
...
...
@@ -215,6 +348,39 @@ exports.createSchedule = async (req, res, next) => {
}
}
exports
.
newTbkl
=
async
(
req
,
res
,
next
)
=>
{
let
{
id
}
=
req
.
body
;
var
schedule
=
await
Schedule
.
findById
(
id
).
populate
(
'links'
);
schedule
=
schedule
.
toJSON
();
var
links
=
schedule
.
links
;
var
qd
=
schedule
.
qd
;
var
tasks
=
[];
links
.
forEach
(
item
=>
{
var
data
=
{
title
:
item
.
title
,
target
:
item
.
target
,
pic
:
item
.
pic
,
qd
:
qd
,
link
:
item
.
_id
,
schedule
:
schedule
.
_id
}
for
(
var
i
=
0
;
i
<
5
;
i
++
){
tasks
.
push
(
createTbkl
(
data
));
}
});
var
result
=
await
Promise
.
all
(
tasks
);
if
(
result
&&
result
.
length
){
var
ids
=
[];
for
(
var
k
in
result
){
ids
.
push
(
result
[
k
].
_id
);
}
var
remove_result
=
await
Kouling
.
update
({
status
:
'use'
,
schedule
:
schedule
.
_id
,
_id
:{
'$nin'
:
ids
}},{
$set
:{
status
:
'disable'
}},{
multi
:
true
});
res
.
send
({
result
:
'ok'
,
new
:
result
,
remove_result
:
remove_result
});
}
else
res
.
send
({
result
:
'ok'
,
new
:
result
,
remove_result
:{
nModified
:
0
}});
}
var
createTbkl
=
async
(
data
)
=>
{
let
{
title
,
target
,
pic
,
qd
}
=
data
;
return
new
Promise
(
async
(
r
,
d
)
=>
{
...
...
lib/cron.js
View file @
328c6966
...
...
@@ -7,7 +7,7 @@ const tao = require('./tao');
const
_
=
require
(
'lodash'
);
const
moment
=
require
(
'moment'
);
const
controller
=
require
(
'./controller'
);
const
max
=
10000
0
;
const
max
=
10000
;
var
CronJob
=
cron
.
CronJob
;
var
job
=
new
CronJob
({
cronTime
:
'0 */2 * * * *'
,
...
...
lib/session.js
View file @
328c6966
...
...
@@ -9,7 +9,6 @@ exports.login = async (req,res,next) => {
let
{
username
,
password
}
=
req
.
body
;
console
.
dir
(
crypto
.
createHash
(
'md5'
).
update
(
password
).
digest
(
'hex'
));
let
user
=
await
agent
.
findOne
({
user
:
username
,
password
:
crypto
.
createHash
(
'md5'
).
update
(
password
).
digest
(
'hex'
)});
console
.
dir
(
user
);
if
(
user
){
let
sess
=
{
user
:
user
.
_id
};
const
_sess
=
await
new
session
(
sess
).
save
();
...
...
@@ -29,7 +28,7 @@ exports.logout = async (req,res,next) => {
if
(
!
err
){
res
.
clearCookie
(
'sess'
);
res
.
clearCookie
(
'username'
);
res
.
redirect
(
'/'
)
res
.
send
({
result
:
'ok'
}
)
}
else
{
res
.
status
(
500
).
send
(
'错误'
);
...
...
routes/index.js
View file @
328c6966
...
...
@@ -14,12 +14,16 @@ router.get('/logout',session.logout);
router
.
post
(
'/to_tbkl'
,
controller
.
createTbkl
);
//系统生成淘口令
router
.
get
(
'/tbkls'
,
controller
.
getTbkls
);
router
.
get
(
'/links'
,
controller
.
getLinks
);
router
.
get
(
'/qds'
,
controller
.
getQds
);
router
.
post
(
'/qd'
,
controller
.
createQd
);
router
.
post
(
'/newtkl'
,
controller
.
newTbkl
);
router
.
post
(
'/link'
,
controller
.
createLink
);
router
.
get
(
'/schedules'
,
controller
.
getSchedules
);
router
.
post
(
'/schedule'
,
controller
.
createSchedule
);
router
.
post
(
'/schedule_update'
,
controller
.
updateSchedule
);
router
.
get
(
'/gathers/qd'
,
controller
.
getQdGatherData
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment