Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dt_analysis
Project
Project
Details
Activity
Releases
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
haoyanbin
dt_analysis
Commits
3e8a66eb
Commit
3e8a66eb
authored
Sep 10, 2023
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
fbe19fe5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
38 deletions
+46
-38
survey.go
api/mobile/survey.go
+33
-30
survey.go
model/request/survey.go
+2
-2
survey.go
model/survey.go
+1
-0
survey.go
service/survey.go
+10
-6
No files found.
api/mobile/survey.go
View file @
3e8a66eb
...
@@ -15,6 +15,11 @@ import (
...
@@ -15,6 +15,11 @@ import (
"time"
"time"
)
)
var
Moc
=
map
[
int
]
string
{
1
:
"直接留资"
,
2
:
"转介绍留资"
,
}
func
GetSurveyUserList
(
c
*
gin
.
Context
)
{
func
GetSurveyUserList
(
c
*
gin
.
Context
)
{
var
req
request
.
GetSurveyUserListReq
var
req
request
.
GetSurveyUserListReq
_
=
c
.
ShouldBindJSON
(
&
req
)
_
=
c
.
ShouldBindJSON
(
&
req
)
...
@@ -92,8 +97,8 @@ func CreateSurveyLog(c *gin.Context) {
...
@@ -92,8 +97,8 @@ func CreateSurveyLog(c *gin.Context) {
var
req
model
.
SurveyLog
var
req
model
.
SurveyLog
_
=
c
.
ShouldBindJSON
(
&
req
)
_
=
c
.
ShouldBindJSON
(
&
req
)
//
ipData, _ := service.GetIpaddr(c.ClientIP())
ipData
,
_
:=
service
.
GetIpaddr
(
c
.
ClientIP
())
ipData
,
_
:=
service
.
GetIpaddr
(
"125.34.219.138"
)
//
ipData, _ := service.GetIpaddr("125.34.219.138")
//fmt.Println(ipData)
//fmt.Println(ipData)
req
.
Country
=
ipData
.
Country
req
.
Country
=
ipData
.
Country
...
@@ -102,6 +107,7 @@ func CreateSurveyLog(c *gin.Context) {
...
@@ -102,6 +107,7 @@ func CreateSurveyLog(c *gin.Context) {
req
.
City
=
ipData
.
City
req
.
City
=
ipData
.
City
req
.
CreateTime
=
utils
.
NowTime
()
req
.
CreateTime
=
utils
.
NowTime
()
req
.
Ip
=
c
.
ClientIP
()
if
err
:=
service
.
CreateSurveyLog
(
req
);
err
!=
nil
{
if
err
:=
service
.
CreateSurveyLog
(
req
);
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"创建失败!"
,
zap
.
Any
(
"err"
,
err
))
global
.
GVA_LOG
.
Error
(
"创建失败!"
,
zap
.
Any
(
"err"
,
err
))
response
.
FailWithMessage
(
"创建失败"
,
c
)
response
.
FailWithMessage
(
"创建失败"
,
c
)
...
@@ -163,10 +169,7 @@ func ExportSurveyUserExcel(c *gin.Context) {
...
@@ -163,10 +169,7 @@ func ExportSurveyUserExcel(c *gin.Context) {
optionData
+=
v2
.
OptionValue
+
" * "
+
strconv
.
Itoa
(
v2
.
OptionNum
)
+
"; "
optionData
+=
v2
.
OptionValue
+
" * "
+
strconv
.
Itoa
(
v2
.
OptionNum
)
+
"; "
}
}
isReference
:=
"转介绍留资"
isReference
:=
"直接留资"
if
v
.
Contacts
==
v
.
WorkerMobile
{
isReference
=
"直接留资"
}
moc
:=
""
moc
:=
""
if
v
.
MocId
==
1
{
if
v
.
MocId
==
1
{
...
@@ -217,19 +220,6 @@ func ExportMocDataExcel(c *gin.Context) {
...
@@ -217,19 +220,6 @@ func ExportMocDataExcel(c *gin.Context) {
var
req
request
.
GetSurveyUserListReq
var
req
request
.
GetSurveyUserListReq
_
=
c
.
ShouldBindQuery
(
&
req
)
_
=
c
.
ShouldBindQuery
(
&
req
)
req
.
Status
=
1
//req.IsReference = 1
req
.
MocId
=
1
surveyCount
:=
service
.
GetSurveyUserCount
(
req
)
//留资数量
logCountReq
:=
request
.
GetSurveyLogListReq
{
SlPage
:
10
,
MocId
:
req
.
MocId
,
}
logCount
:=
service
.
GetSurveyLogCount
(
logCountReq
)
//点击量
fmt
.
Println
(
logCount
)
fileName
:=
"数据统计"
+
time
.
Now
()
.
Format
(
"20060102"
)
fileName
:=
"数据统计"
+
time
.
Now
()
.
Format
(
"20060102"
)
f
:=
excelize
.
NewFile
()
f
:=
excelize
.
NewFile
()
// Create a new sheet.
// Create a new sheet.
...
@@ -247,18 +237,31 @@ func ExportMocDataExcel(c *gin.Context) {
...
@@ -247,18 +237,31 @@ func ExportMocDataExcel(c *gin.Context) {
f
.
SetCellValue
(
fileName
,
"J1"
,
"留资率"
)
f
.
SetCellValue
(
fileName
,
"J1"
,
"留资率"
)
f
.
SetCellValue
(
fileName
,
"K1"
,
"获客单价"
)
f
.
SetCellValue
(
fileName
,
"K1"
,
"获客单价"
)
f
.
SetCellValue
(
fileName
,
"A2"
,
time
.
Now
()
.
Format
(
"2006/01/02"
))
for
k
,
v
:=
range
Moc
{
f
.
SetCellValue
(
fileName
,
"B2"
,
"直接留资"
)
req
.
MocId
=
k
f
.
SetCellValue
(
fileName
,
"C2"
,
"短信"
)
req
.
Status
=
1
f
.
SetCellValue
(
fileName
,
"D2"
,
""
)
surveyCount
:=
service
.
GetSurveyUserCount
(
req
)
//留资数量
f
.
SetCellValue
(
fileName
,
"E2"
,
""
)
f
.
SetCellValue
(
fileName
,
"F2"
,
""
)
f
.
SetCellValue
(
fileName
,
"G2"
,
logCount
[
0
]
.
Cid
)
f
.
SetCellValue
(
fileName
,
"H2"
,
""
)
f
.
SetCellValue
(
fileName
,
"I2"
,
surveyCount
)
f
.
SetCellValue
(
fileName
,
"J2"
,
""
)
f
.
SetCellValue
(
fileName
,
"K2"
,
""
)
logCountReq
:=
request
.
GetSurveyLogListReq
{
SlPage
:
10
,
MocId
:
k
,
Groupby
:
" user_id "
,
}
logCount
:=
service
.
GetSurveyLogCount
(
logCountReq
)
//点击量
a
:=
strconv
.
Itoa
(
k
+
1
)
f
.
SetCellValue
(
fileName
,
"A"
+
a
,
time
.
Now
()
.
Format
(
"2006/01/02"
))
f
.
SetCellValue
(
fileName
,
"B"
+
a
,
v
)
f
.
SetCellValue
(
fileName
,
"C"
+
a
,
"短信"
)
f
.
SetCellValue
(
fileName
,
"D"
+
a
,
""
)
f
.
SetCellValue
(
fileName
,
"E"
+
a
,
""
)
f
.
SetCellValue
(
fileName
,
"F"
+
a
,
""
)
f
.
SetCellValue
(
fileName
,
"G"
+
a
,
logCount
[
k
])
f
.
SetCellValue
(
fileName
,
"H"
+
a
,
""
)
f
.
SetCellValue
(
fileName
,
"I"
+
a
,
surveyCount
)
f
.
SetCellValue
(
fileName
,
"J"
+
a
,
""
)
f
.
SetCellValue
(
fileName
,
"K"
+
a
,
""
)
}
// Set active sheet of the workbook.
// Set active sheet of the workbook.
f
.
SetActiveSheet
(
index
)
f
.
SetActiveSheet
(
index
)
// Save xlsx file by the given path.
// Save xlsx file by the given path.
...
...
model/request/survey.go
View file @
3e8a66eb
...
@@ -83,6 +83,6 @@ type GetSurveyLogList struct {
...
@@ -83,6 +83,6 @@ type GetSurveyLogList struct {
}
}
type
SlData
struct
{
type
SlData
struct
{
Cid
int
`json:"cid"`
Cid
int
`json:"cid"`
Page
int
`json:"page
"`
MocId
int
`json:"moc_id
"`
}
}
model/survey.go
View file @
3e8a66eb
...
@@ -35,6 +35,7 @@ type SurveyLog struct {
...
@@ -35,6 +35,7 @@ type SurveyLog struct {
MocId
int
`gorm:"type:int(255)" json:"moc_id"`
MocId
int
`gorm:"type:int(255)" json:"moc_id"`
Page
int
`gorm:"type:int(255)" json:"page"`
Page
int
`gorm:"type:int(255)" json:"page"`
CreateTime
string
`gorm:"type:string(255)" json:"create_time"`
CreateTime
string
`gorm:"type:string(255)" json:"create_time"`
Ip
string
`gorm:"type:string(255)" json:"ip"`
Country
string
`gorm:"type:string(255)" json:"country"`
Country
string
`gorm:"type:string(255)" json:"country"`
Area
string
`gorm:"type:string(255)" json:"area"`
Area
string
`gorm:"type:string(255)" json:"area"`
Region
string
`gorm:"type:string(255)" json:"region"`
Region
string
`gorm:"type:string(255)" json:"region"`
...
...
service/survey.go
View file @
3e8a66eb
...
@@ -265,14 +265,14 @@ func GetSurveyUserCount(req request.GetSurveyUserListReq) int64 {
...
@@ -265,14 +265,14 @@ func GetSurveyUserCount(req request.GetSurveyUserListReq) int64 {
}
}
// 点击量
// 点击量
func
GetSurveyLogCount
(
req
request
.
GetSurveyLogListReq
)
[]
request
.
SlData
{
func
GetSurveyLogCount
(
req
request
.
GetSurveyLogListReq
)
map
[
int
]
int
{
list
:=
make
([]
request
.
SlData
,
0
)
list
:=
make
([]
request
.
SlData
,
0
)
table
:=
"
survey_log as sl "
+
table
:=
"
(select moc_id, user_id, page from survey_log group by ip)sl "
"
left join customer_user as cu on sl.user_id=cu.id "
//table := " survey_log as sl
left join customer_user as cu on sl.user_id=cu.id "
field
:=
" count(sl.
id) as cid, sl.page
"
field
:=
" count(sl.
page) as cid, sl.moc_id
"
conditions
:=
""
conditions
:=
""
...
@@ -305,12 +305,16 @@ func GetSurveyLogCount(req request.GetSurveyLogListReq) []request.SlData {
...
@@ -305,12 +305,16 @@ func GetSurveyLogCount(req request.GetSurveyLogListReq) []request.SlData {
" WHERE 1>0 "
+
conditions
" WHERE 1>0 "
+
conditions
if
req
.
Groupby
!=
""
{
if
req
.
Groupby
!=
""
{
sqlStr2
+=
" GROUP BY
"
+
req
.
Groupby
sqlStr2
+=
" GROUP BY
sl.moc_id"
}
}
global
.
GVA_DB
.
Raw
(
sqlStr2
)
.
Scan
(
&
list
)
global
.
GVA_DB
.
Raw
(
sqlStr2
)
.
Scan
(
&
list
)
if
global
.
GVA_DB
.
Error
!=
nil
{
if
global
.
GVA_DB
.
Error
!=
nil
{
return
nil
return
nil
}
}
return
list
reply
:=
make
(
map
[
int
]
int
,
0
)
for
_
,
v
:=
range
list
{
reply
[
v
.
MocId
]
=
v
.
Cid
}
return
reply
}
}
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