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) {
...
@@ -81,6 +81,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
var
viewData
model
.
ViewData
var
viewData
model
.
ViewData
//fmt.Println(string(dataByte))
//fmt.Println(string(dataByte))
if
err
=
json
.
Unmarshal
(
dataByte
,
&
viewData
);
err
!=
nil
{
if
err
=
json
.
Unmarshal
(
dataByte
,
&
viewData
);
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
return
return
}
}
...
@@ -98,12 +99,13 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -98,12 +99,13 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Find
(
whereMap
)
.
One
(
&
historyData
)
Find
(
whereMap
)
.
One
(
&
historyData
)
if
err
!=
nil
&&
err
!=
mgo
.
ErrNotFound
{
if
err
!=
nil
&&
err
!=
mgo
.
ErrNotFound
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
return
return
}
}
//mysql数据操作
//mysql数据操作
var
result
model
.
ActivityViewStatistics
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
{
if
result
.
ActivityId
==
0
{
//先去数据库插入
//先去数据库插入
activityViewStatistics
:=
model
.
ActivityViewStatistics
{
activityViewStatistics
:=
model
.
ActivityViewStatistics
{
...
@@ -114,6 +116,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -114,6 +116,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
}
}
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_view_statistics"
)
.
Data
(
activityViewStatistics
)
.
Insert
()
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_view_statistics"
)
.
Data
(
activityViewStatistics
)
.
Insert
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
return
return
}
}
...
@@ -133,6 +136,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -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
)
.
_
,
err
=
specialDb
.
Reset
()
.
Table
(
"lie_activity_view_statistics"
)
.
Where
(
"activity_id"
,
viewData
.
ActivityId
)
.
Data
(
activityViewStatistics
)
.
Update
()
Data
(
activityViewStatistics
)
.
Update
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
return
return
}
}
...
@@ -145,6 +149,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -145,6 +149,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
selector
:=
bson
.
M
{
"unique_id"
:
historyData
.
UniqueId
}
selector
:=
bson
.
M
{
"unique_id"
:
historyData
.
UniqueId
}
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Update
(
selector
,
&
historyData
)
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Update
(
selector
,
&
historyData
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
}
}
}
else
{
}
else
{
...
@@ -158,6 +163,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -158,6 +163,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
var
user
model
.
UserMain
var
user
model
.
UserMain
err
=
db
.
Reset
()
.
Table
(
&
user
)
.
Where
(
"user_id"
,
viewData
.
UserId
)
.
Select
()
err
=
db
.
Reset
()
.
Table
(
&
user
)
.
Where
(
"user_id"
,
viewData
.
UserId
)
.
Select
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
}
}
mobile
=
user
.
Mobile
mobile
=
user
.
Mobile
...
@@ -166,6 +172,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -166,6 +172,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
var
userActivity
model
.
UserActivity
var
userActivity
model
.
UserActivity
count
,
err
:=
db
.
Reset
()
.
Table
(
&
userActivity
)
.
Where
(
"activity_id"
,
viewData
.
ActivityId
)
.
Where
(
"user_id"
,
viewData
.
UserId
)
.
Count
()
count
,
err
:=
db
.
Reset
()
.
Table
(
&
userActivity
)
.
Where
(
"activity_id"
,
viewData
.
ActivityId
)
.
Where
(
"user_id"
,
viewData
.
UserId
)
.
Count
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
}
}
if
count
!=
0
{
if
count
!=
0
{
...
@@ -187,6 +194,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -187,6 +194,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
if
historyData
.
UniqueId
==
""
{
if
historyData
.
UniqueId
==
""
{
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Insert
(
&
historyData
)
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Insert
(
&
historyData
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
}
}
}
else
{
}
else
{
...
@@ -194,6 +202,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -194,6 +202,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
selector
:=
bson
.
M
{
"unique_id"
:
historyData
.
UniqueId
}
selector
:=
bson
.
M
{
"unique_id"
:
historyData
.
UniqueId
}
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Update
(
selector
,
&
historyData
)
err
=
mongoConn
.
DB
(
"ichunt"
)
.
C
(
"activity_view_history"
)
.
Update
(
selector
,
&
historyData
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
logger
.
Error
(
err
.
Error
())
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