Commit 114fb871 by 孙龙

团购定时任务

parent de4c9c78
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)
......
...@@ -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()
......
...@@ -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)
......
...@@ -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)
......
...@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment