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
4bc7c8c6
authored
Feb 01, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-魔方统计-20210112'
parents
684bfd50
9eae0dd2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletions
special/activity_view_statistics/main.go
special/activity_view_statistics/main.go
View file @
4bc7c8c6
...
...
@@ -81,6 +81,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
var
viewData
model
.
ViewData
//fmt.Println(string(dataByte))
if
err
=
json
.
Unmarshal
(
dataByte
,
&
viewData
);
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
return
}
...
...
@@ -98,12 +99,13 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Find
(
whereMap
)
.
One
(
&
historyData
)
if
err
!=
nil
&&
err
!=
mgo
.
ErrNotFound
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
return
}
//mysql数据操作
var
result
model
.
ActivityViewStatistics
err
=
specialDb
.
Table
(
&
result
)
.
Where
(
"activity_id"
,
viewData
.
ActivityId
)
.
Select
()
err
=
specialDb
.
Reset
()
.
Table
(
&
result
)
.
Where
(
"activity_id"
,
viewData
.
ActivityId
)
.
Select
()
if
result
.
ActivityId
==
0
{
//先去数据库插入
activityViewStatistics
:=
model
.
ActivityViewStatistics
{
...
...
@@ -114,6 +116,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
}
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_view_statistics"
)
.
Data
(
activityViewStatistics
)
.
Insert
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
return
}
...
...
@@ -133,6 +136,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_view_statistics"
)
.
Where
(
"activity_id"
,
viewData
.
ActivityId
)
.
Data
(
activityViewStatistics
)
.
Update
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
return
}
...
...
@@ -145,6 +149,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
selector
:=
bson
.
M
{
"unique_id"
:
historyData
.
UniqueId
}
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Update
(
selector
,
&
historyData
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
}
}
else
{
...
...
@@ -158,6 +163,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
var
user
model
.
UserMain
err
=
db
.
Reset
()
.
Table
(
&
user
)
.
Where
(
"user_id"
,
viewData
.
UserId
)
.
Select
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
}
mobile
=
user
.
Mobile
...
...
@@ -166,6 +172,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
var
userActivity
model
.
UserActivity
count
,
err
:=
db
.
Reset
()
.
Table
(
&
userActivity
)
.
Where
(
"activity_id"
,
viewData
.
ActivityId
)
.
Where
(
"user_id"
,
viewData
.
UserId
)
.
Count
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
}
if
count
!=
0
{
...
...
@@ -187,6 +194,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
if
historyData
.
UniqueId
==
""
{
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Insert
(
&
historyData
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
}
}
else
{
...
...
@@ -194,6 +202,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
selector
:=
bson
.
M
{
"unique_id"
:
historyData
.
UniqueId
}
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Update
(
selector
,
&
historyData
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
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