This commit is contained in:
shoopea 2019-05-11 13:41:05 +08:00
parent b6444c33ab
commit 21354ef97b
3 changed files with 23 additions and 4 deletions

2
def.go
View File

@ -16,7 +16,7 @@ type ChatWarsMessage struct {
}
type ChatWarsMessageAuctionAnnounce struct {
MsgID64 int64 `json:"msg_id"`
ObjID64 int64 `json:"obj_id"`
LotID int32 `json:"lot_id"`
Item string `json:"item"`
Cond string `json:"cond"`

23
sql.go
View File

@ -1278,6 +1278,21 @@ func getObjSubTypeId(objId int64) (int64, error) {
return objSubTypeId, nil
}
func setObjSubTypeId(objId int64, objSubTypeID64 int64) error {
var objSubTypeId int64
stmt, err := db.Prepare(`UPDATE obj o SET o.obj_sub_type_id = ? WHERE o.id = ?l`)
logOnError(err, "setObjSubTypeId : prepare update")
if err != nil {
return err
}
defer stmt.Close()
err = stmt.Exec(objSubTypeID64, objId)
logOnError(err, "setObjSubTypeId : exec update")
return err
}
func insertMsgReport(objId int64, war_date int32, atk int32, def int32, exp int32, gold int32, stock int32, crit bool, stamina bool) error {
objSubTypeId, err := getObjSubTypeId(objId)
if err != nil {
@ -1328,10 +1343,14 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
}
defer stmt.Close()
_, err = stmt.Exec(m.MsgID64, m.LotID, m.Item, m.Cond, m.Quality, m.Seller, m.Buyer, m.Price, m.Status, m.End)
_, err = stmt.Exec(m.ObjID64, m.LotID, m.Item, m.Cond, m.Quality, m.Seller, m.Buyer, m.Price, m.Status, m.End)
if err != nil {
return err
}
err = setObjSubTypeId(m.ObjID64, objSubTypeMessageAuctionAnnounce)
logOnError(err, "insertMsgAuctionAnnounce : setObjSubTypeId")
return nil
}
@ -1392,7 +1411,7 @@ func setJobDone(jobId int64) error {
}
func setJobStart(jobId int64) error {
stmt, err := db.Prepare(`UPDATE obj_job j SET j.ended = ? WHERE j.obj_id = ?;`)
stmt, err := db.Prepare(`UPDATE obj_job j SET j.started = ? WHERE j.obj_id = ?;`)
logOnError(err, "setJobStart : prepare update obj_job")
if err != nil {
return err

View File

@ -101,7 +101,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId)
case objSubTypeMessageAuctionAnnounce:
cwm := ChatWarsMessageAuctionAnnounce{
MsgID64: objId,
ObjID64: objId,
}
l, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Lot}"), 10, 32)
cwm.LotID = int32(l)