This commit is contained in:
shoopea 2020-06-28 14:58:26 +02:00
parent 27ebd8260c
commit 7730b0c897
2 changed files with 39 additions and 4 deletions

21
item.go
View File

@ -448,3 +448,24 @@ func loadObjItem() error {
return nil
}
func getObjItemVal(objID64 int, quality string) float64 {
var val float64
item, err := getObjItem(objID64)
if err != nil {
return 0
}
if !item.Auction {
return 0
}
row := db.QueryRow(`SELECT avg(omaa.price)
FROM obj_msg_auction_announce omaa
WHERE omaa.item_id = ?
AND omaa.quality = ?`, objID64, quality)
err = row.Scan(&val)
if err != nil {
logOnError(err, "getObjItemVal : row.Scan")
return 0
}
return val
}

22
job.go
View File

@ -2606,9 +2606,10 @@ func jobCheckVaultLimit(j Job) {
func jobVaultVal(j Job) {
var (
p JobPayloadVaultVal
p2 JobPayloadGetVault
b []byte
p JobPayloadVaultVal
p2 JobPayloadGetVault
b []byte
other, part, rec float64
)
err := setJobStart(j.ID64)
@ -2646,9 +2647,22 @@ func jobVaultVal(j Job) {
err = json.Unmarshal(b, &p2)
logOnError(err, "jobVaultVal : Unmarshal(p2)")
for _, v := range p2.Vault {
item, _ := getObjItem(v.ItemID64)
switch item.ItemTypeID {
case cacheObjSubType[`item_part`]:
part += getObjItemVal(v.ItemID64, v.Quality)
case cacheObjSubType[`item_rec`]:
rec += getObjItemVal(v.ItemID64, v.Quality)
case cacheObjSubType[`item_other`]:
other += getObjItemVal(v.ItemID64, v.Quality)
default:
}
}
c := TGCommand{
Type: commandReplyMsg,
Text: "out",
Text: fmt.Sprintf("Value :\n- Parts: %f\n- Recipes: %f\n- Other: %f", part, rec, other),
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
ParseMode: cmdParseModeHTML,