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
114fb871
authored
Apr 14, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
团购定时任务
parent
de4c9c78
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
40 deletions
dal/order/Order/Order.go
dal/order/OrderActionLog/OrderActionLog.go
dal/order/UserGroup/UserGroup.go
dal/order/UserGroupJoin/UserGroupJoin.go
order/cron/tuangouOrder/main.go
dal/order/Order/Order.go
View file @
114fb871
package
Order
package
Order
import
(
import
(
_
"database/sql"
_
"database/sql"
_
"fmt"
_
"fmt"
"github.com/ichunt2019/logger"
"github.com/ichunt2019/logger"
"go-queue-server/dal/db"
"go-queue-server/dal/db"
"go-queue-server/util"
_
"time"
_
"time"
)
)
func
initDb
(
dns
string
)
(
err
error
)
{
err
=
db
.
Init
(
dns
)
if
err
!=
nil
{
return
}
return
}
func
UpdateStatus
(
order_id
int
,
status_extend
int
)
(
err
error
)
{
func
UpdateStatus
(
order_id
int
,
status_extend
int
)
(
err
error
)
{
initDb
(
util
.
Configs
.
Liexin_databases
.
Dns
)
//初始化db
_
,
err1
:=
db
.
DB
.
Exec
(
"update lie_order set status_extend = ?, wms_syn = ? where order_id = ?"
,
status_extend
,
1
,
order_id
)
_
,
err1
:=
db
.
DB
.
Exec
(
"update lie_order set status_extend = ?, wms_syn = ? where order_id = ?"
,
status_extend
,
1
,
order_id
)
...
...
dal/order/OrderActionLog/OrderActionLog.go
View file @
114fb871
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"fmt"
"fmt"
"github.com/ichunt2019/logger"
"github.com/ichunt2019/logger"
"go-queue-server/dal/db"
"go-queue-server/dal/db"
"go-queue-server/util"
"log"
"log"
"time"
"time"
)
)
...
@@ -20,17 +19,8 @@ type ActionLog struct {
...
@@ -20,17 +19,8 @@ type ActionLog struct {
CreateTime
int
`db:"create_time"`
CreateTime
int
`db:"create_time"`
}
}
func
initDb
(
dns
string
)
(
err
error
)
{
err
=
db
.
Init
(
dns
)
if
err
!=
nil
{
return
}
return
}
func
AddLog
()
(
err
error
)
{
func
AddLog
()
(
err
error
)
{
initDb
(
util
.
Configs
.
Liexin_databases
.
Dns
)
//初始化db
// QueryRow()
// QueryRow()
// Query()
// Query()
...
...
dal/order/UserGroup/UserGroup.go
View file @
114fb871
...
@@ -2,11 +2,10 @@ package UserGroup
...
@@ -2,11 +2,10 @@ package UserGroup
import
(
import
(
"database/sql"
"database/sql"
_
"fmt"
"encoding/json"
_
"fmt"
"github.com/ichunt2019/logger"
"github.com/ichunt2019/logger"
"go-queue-server/dal/db"
"go-queue-server/dal/db"
"go-queue-server/util"
"encoding/json"
)
)
type
UserGroup
struct
{
type
UserGroup
struct
{
...
@@ -21,18 +20,11 @@ type UserGroup struct {
...
@@ -21,18 +20,11 @@ type UserGroup struct {
CreateTime
int
`db:"create_time"`
CreateTime
int
`db:"create_time"`
}
}
func
initDb
(
dns
string
)
(
err
error
)
{
err
=
db
.
Init
(
dns
)
if
err
!=
nil
{
return
}
return
}
// 单行查询
// 单行查询
func
QueryRow
(
order_id
int
)
[]
byte
{
func
QueryRow
(
order_id
int
)
[]
byte
{
initDb
(
util
.
Configs
.
Liexin_databases
.
Dns
)
//初始化db
//
initDb(util.Configs.Liexin_databases.Dns) //初始化db
var
userGroup
UserGroup
var
userGroup
UserGroup
...
@@ -50,7 +42,7 @@ func QueryRow(order_id int) []byte {
...
@@ -50,7 +42,7 @@ func QueryRow(order_id int) []byte {
// 更新参团状态
// 更新参团状态
func
UpdateStatus
(
order_id
int
)
(
err
error
)
{
func
UpdateStatus
(
order_id
int
)
(
err
error
)
{
initDb
(
util
.
Configs
.
Liexin_databases
.
Dns
)
//初始化db
//
initDb(util.Configs.Liexin_databases.Dns) //初始化db
_
,
err1
:=
db
.
DB
.
Exec
(
"update lie_user_group set status = ?, is_assign = ? where order_id = ?"
,
1
,
1
,
order_id
)
_
,
err1
:=
db
.
DB
.
Exec
(
"update lie_user_group set status = ?, is_assign = ? where order_id = ?"
,
1
,
1
,
order_id
)
...
...
dal/order/UserGroupJoin/UserGroupJoin.go
View file @
114fb871
...
@@ -3,7 +3,6 @@ package UserGroupJoin
...
@@ -3,7 +3,6 @@ package UserGroupJoin
import
(
import
(
"github.com/ichunt2019/logger"
"github.com/ichunt2019/logger"
"go-queue-server/dal/db"
"go-queue-server/dal/db"
"go-queue-server/util"
"time"
"time"
)
)
...
@@ -18,7 +17,6 @@ func initDb(dns string) (err error) {
...
@@ -18,7 +17,6 @@ func initDb(dns string) (err error) {
// 新增虚拟参团人员
// 新增虚拟参团人员
func
InsertGroupJoin
(
group_id
int
,
order_id
int
,
account
string
)
(
err
error
)
{
func
InsertGroupJoin
(
group_id
int
,
order_id
int
,
account
string
)
(
err
error
)
{
initDb
(
util
.
Configs
.
Liexin_databases
.
Dns
)
//初始化db
current
:=
time
.
Now
()
.
Unix
()
current
:=
time
.
Now
()
.
Unix
()
_
,
err1
:=
db
.
DB
.
Exec
(
"insert into lie_user_group_join (group_id, account, order_id, join_time) values (?, ?, ?, ?)"
,
group_id
,
account
,
order_id
,
current
)
_
,
err1
:=
db
.
DB
.
Exec
(
"insert into lie_user_group_join (group_id, account, order_id, join_time) values (?, ?, ?, ?)"
,
group_id
,
account
,
order_id
,
current
)
...
...
order/cron/tuangouOrder/main.go
View file @
114fb871
...
@@ -3,7 +3,7 @@ package main
...
@@ -3,7 +3,7 @@ package main
import
(
import
(
"encoding/json"
"encoding/json"
"flag"
"flag"
_
"fmt"
"fmt"
"github.com/ichunt2019/logger"
"github.com/ichunt2019/logger"
"go-queue-server/dal/db"
"go-queue-server/dal/db"
"go-queue-server/util"
"go-queue-server/util"
...
@@ -73,7 +73,9 @@ func main() {
...
@@ -73,7 +73,9 @@ func main() {
RedisConn
=
redis_connect
(
util
.
Configs
)
RedisConn
=
redis_connect
(
util
.
Configs
)
t1
:=
time
.
NewTimer
(
time
.
Minute
*
5
)
t1
:=
time
.
NewTimer
(
time
.
Second
*
5
)
for
{
for
{
select
{
select
{
...
@@ -110,7 +112,7 @@ func main() {
...
@@ -110,7 +112,7 @@ func main() {
}
}
//t1.Reset(time.Second * 1)
//t1.Reset(time.Second * 1)
t1
.
Reset
(
time
.
Minute
*
5
)
t1
.
Reset
(
time
.
Second
*
5
)
}
}
}
}
}
}
...
@@ -141,7 +143,7 @@ func assign() {
...
@@ -141,7 +143,7 @@ func assign() {
for
_
,
v
:=
range
tuangou_order
{
for
_
,
v
:=
range
tuangou_order
{
value
,
_
:=
v
.
([]
byte
)
value
,
_
:=
v
.
([]
byte
)
order_id
,
_
:=
strconv
.
Atoi
(
string
(
value
))
order_id
,
_
:=
strconv
.
Atoi
(
string
(
value
))
//
fmt.Println(order_id)
fmt
.
Println
(
order_id
)
// 写入到chan
// 写入到chan
select
{
select
{
...
...
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