Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CnChunfeng
/
crm_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
b0188ed3
authored
Sep 28, 2021
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整获取用户下单数
parent
16d40b61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
cmd/task/user_order_count/main.go
cmd/task/user_order_count/main.go
View file @
b0188ed3
...
...
@@ -30,11 +30,14 @@ func main() {
logger
.
InitLogger
(
"file"
,
logConfig
)
logger
.
Init
()
var
current_time
=
time
.
Now
()
.
Unix
()
// 獲取前一天零點
t
:=
time
.
Now
()
tm
:=
time
.
Date
(
t
.
Year
(),
t
.
Month
(),
t
.
Day
(),
0
,
0
,
0
,
0
,
t
.
Location
())
yesterday_time
:=
tm
.
AddDate
(
0
,
0
,
-
1
)
.
Unix
()
db
:=
dao
.
GetLiexinDb
()
row
,
err
:=
db
.
Queryx
(
"SELECT user_id, FROM_UNIXTIME(create_time,
\"
%Y%m%d
\"
) AS date, COUNT(*) AS count FROM `lie_order` "
+
"WHERE user_id > 0 AND is_type = 0 AND create_time > ? GROUP BY user_id, date ORDER BY create_time"
,
current
_time
)
"WHERE user_id > 0 AND is_type = 0 AND create_time > ? GROUP BY user_id, date ORDER BY create_time"
,
yesterday
_time
)
defer
db
.
Close
()
if
err
!=
nil
{
...
...
@@ -46,11 +49,6 @@ func main() {
crm_db
:=
dao
.
GetDb
()
defer
crm_db
.
Close
()
if
!
row
.
Next
()
{
fmt
.
Println
(
"未获取到用户下单数"
)
return
}
for
row
.
Next
()
{
var
user_order_count
model
.
UserOrderCount
row
.
StructScan
(
&
user_order_count
)
...
...
@@ -62,6 +60,7 @@ func main() {
continue
}
var
current_time
=
time
.
Now
()
.
Unix
()
_
,
err
:=
crm_db
.
Exec
(
"insert into lie_user_order_count (user_id, date, count, create_time) values (?, ?, ?, ?)"
,
user_order_count
.
User_Id
,
user_order_count
.
Date
,
user_order_count
.
Count
,
current_time
)
...
...
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