This commit is contained in:
shoopea 2019-10-11 14:58:18 +08:00
parent 3f186e1734
commit 546af872f0

26
job.go
View File

@ -894,18 +894,19 @@ func jobGDeposit(j Job) {
func jobVaultStatus(j Job) {
var (
p JobPayloadVaultStatus
userID64, currentUserID64 int64
itemID64, deposit, withdraw int64
p JobPayloadVaultStatus
userID64, currentUserID64 int64
itemID64, deposit, withdraw int64
itemList, depositList, withdrawList []int64
idList []int64
)
err := setJobStart(j.ID64)
logOnError(err, "jobVaultStatus : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobVaultStatus : Unmarshal payload")
stmt := `SELECT x.user_id
,x.item_id
,(SELECT COALESCE(SUM(omv.quantity), 0)
@ -929,16 +930,20 @@ func jobVaultStatus(j Job) {
AND omv.user_id in (?` + strings.Repeat(",?", len(p.UserListID64)-1) + `)
AND omv.item_type_id in (?` + strings.Repeat(",?", len(p.ItemTypeListID64)-1) + `)) x
ORDER BY x.user_id ASC;`
rows, err := db.Query(stmt, p.DepositChatID64, p.UserListID64..., p.ItemTypeListID64...)
idList = nil
idList = append(idList, p.UserListID64...)
idList = append(idList, p.ItemTypeListID64...)
rows, err := db.Query(stmt, p.DepositChatID64, idList...)
logOnError(err, "jobVaultStatus : Get rows")
if err != nil {
err = setJobDone(j.ID64)
logOnError(err, "jobVaultStatus : setJobDone")
return
return
}
currentUserID64 = 0
for rows.Next() {
err = rows.Scan(&userID64, &itemID64, &deposit, &withdraw)
@ -951,7 +956,7 @@ func jobVaultStatus(j Job) {
depositList = nil
withdrawList = nil
}
itemList = append(itemList, itemID64)
depositList = append(depositList, deposit)
withdrawList = append(withdrawList, withdraw)
@ -962,7 +967,6 @@ func jobVaultStatus(j Job) {
err = rows.Err()
logOnError(err, "jobVaultStatus : query end")
rows.Close()
err = setJobDone(j.ID64)
logOnError(err, "jobVaultStatus : setJobDone")