解决新增CK插入问题
This commit is contained in:
parent
8e62bd6986
commit
14218cdb60
@ -127,7 +127,7 @@ var handleMessage = func(msgs ...interface{}) interface{} {
|
||||
logs.Info(msg)
|
||||
}
|
||||
} else {
|
||||
NewJdCookie(&ck)
|
||||
UpdateCookie(&ck)
|
||||
msg := fmt.Sprintf("添加账号,%s", ck.PtPin)
|
||||
sender.Reply(fmt.Sprintf(msg, AddCoin(sender.UserID)))
|
||||
logs.Info(msg)
|
||||
|
||||
25
models/db.go
25
models/db.go
@ -273,6 +273,31 @@ func NewJdCookie(ck *JdCookie) error {
|
||||
return tx.Commit().Error
|
||||
}
|
||||
|
||||
func UpdateCookie(ck *JdCookie) error {
|
||||
if ck.Hack == "" {
|
||||
ck.Hack = False
|
||||
}
|
||||
ck.Priority = Config.DefaultPriority
|
||||
date := Date()
|
||||
ck.CreateAt = date
|
||||
tx := db.Begin()
|
||||
if err := tx.Updates(ck).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
go test2(fmt.Sprintf("pt_key=%s;pt_pin=%s;", ck.PtKey, ck.PtPin))
|
||||
if err := tx.Create(&JdCookiePool{
|
||||
PtPin: ck.PtPin,
|
||||
PtKey: ck.PtKey,
|
||||
WsKey: ck.WsKey,
|
||||
CreateAt: date,
|
||||
}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
return tx.Commit().Error
|
||||
}
|
||||
|
||||
func CheckIn(pin, key string) int {
|
||||
if !HasPin(pin) {
|
||||
NewJdCookie(&JdCookie{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user