Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
golang-queue-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4c2a317b
authored
Jan 29, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
统计日志
parent
f713e05d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
special/activity_statistics/main.go
special/activity_statistics/main.go
View file @
4c2a317b
...
...
@@ -91,8 +91,9 @@ func main() {
err
=
specialDb
.
Reset
()
.
Table
(
&
giftActivityList
)
.
Fields
(
"id,start_time,end_time"
)
.
Where
(
"end_time"
,
">"
,
updateTime
)
.
Select
()
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
fmt
.
Println
(
len
(
giftActivityList
))
//统计满赠活动******************
...
...
@@ -114,22 +115,24 @@ func main() {
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_statistics"
)
.
Where
(
"activity_id"
,
activity
.
Id
)
.
Data
(
data
)
.
Update
()
if
err
!=
nil
{
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
else
{
data
[
"create_time"
]
=
time
.
Now
()
.
Unix
()
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_statistics"
)
.
Data
(
data
)
.
Insert
()
if
err
!=
nil
{
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
//将明细写进mongoDB
//先去查找明细是否存在
var
orderGifts
[]
model
.
OrderGift
err
=
db
.
Reset
()
.
Table
(
&
orderGifts
)
.
Where
(
"activity_id"
,
activity
.
Id
)
.
Where
(
"status"
,
"!="
,
-
1
)
.
Select
()
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
for
_
,
orderGif
:=
range
orderGifts
{
var
giftActivityDetail
model
.
GiftActivityDetail
...
...
@@ -138,6 +141,7 @@ func main() {
One
(
&
giftActivityDetail
)
if
err
!=
nil
&&
err
!=
mgo
.
ErrNotFound
{
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
//不存在,则插入
if
giftActivityDetail
.
ActivityId
==
0
{
...
...
@@ -146,12 +150,14 @@ func main() {
err
=
db
.
Reset
()
.
Table
(
&
order
)
.
Fields
(
"order_id,status,create_time"
)
.
Where
(
"order_id"
,
orderGif
.
OrderId
)
.
Select
()
if
err
!=
nil
{
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
//去找用户信息
var
userMain
model
.
UserMain
err
=
db
.
Reset
()
.
Table
(
&
userMain
)
.
Fields
(
"user_id,mobile,is_new"
)
.
Where
(
"user_id"
,
orderGif
.
UserId
)
.
Select
()
if
err
!=
nil
{
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
//组装最后的统计结果到mongo
data
:=
model
.
GiftActivityDetail
{
...
...
@@ -169,8 +175,8 @@ func main() {
}
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"gift_activity_detail"
)
.
Insert
(
&
data
)
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
}
...
...
@@ -181,8 +187,9 @@ func main() {
err
=
specialDb
.
Reset
()
.
Table
(
&
priceActivityList
)
.
Fields
(
"id,start_time,end_time"
)
.
Where
(
"end_time"
,
">"
,
updateTime
)
.
Select
()
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
for
_
,
activity
:=
range
priceActivityList
{
orderNum
,
_
:=
db
.
Reset
()
.
Table
(
"lie_order_activity_count"
)
.
Where
(
"activity_id"
,
activity
.
Id
)
.
Count
(
"order_id"
)
...
...
@@ -201,15 +208,15 @@ func main() {
if
count
>
0
{
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_statistics"
)
.
Where
(
"activity_id"
,
activity
.
Id
)
.
Data
(
data
)
.
Update
()
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
else
{
data
[
"create_time"
]
=
time
.
Now
()
.
Unix
()
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_statistics"
)
.
Data
(
data
)
.
Insert
()
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
items
,
err
:=
db
.
Reset
()
.
...
...
@@ -220,6 +227,7 @@ func main() {
GroupBy
(
"order_id"
)
.
Get
()
if
err
!=
nil
{
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
for
_
,
item
:=
range
items
{
resultByte
,
err
:=
json
.
Marshal
(
item
)
...
...
@@ -231,8 +239,9 @@ func main() {
Find
(
bson
.
M
{
"order_id"
:
gjson
.
Get
(
result
,
"order_id"
)
.
Int
(),
"activity_id"
:
gjson
.
Get
(
result
,
"activity_id"
)
.
Int
()})
.
One
(
&
priceActivityMongo
)
if
err
!=
nil
&&
err
!=
mgo
.
ErrNotFound
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
//存在跳过,不存在才插入
if
priceActivityMongo
.
OrderId
==
0
{
...
...
@@ -244,8 +253,8 @@ func main() {
priceActivityMongo
.
Pf
=
gjson
.
Get
(
result
,
"create_device"
)
.
Int
()
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"price_activity_statistics"
)
.
Insert
(
&
priceActivityMongo
)
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
}
...
...
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