解决新增CK插入问题

This commit is contained in:
ZJY 2021-09-05 08:29:22 +08:00
parent 8e62bd6986
commit 14218cdb60
2 changed files with 26 additions and 1 deletions

View File

@ -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)

View File

@ -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{