You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.2 KiB
101 lines
2.2 KiB
package handler |
|
|
|
import ( |
|
"server/call" |
|
"server/common" |
|
"server/db" |
|
"server/modules/web/app" |
|
"server/modules/web/values" |
|
|
|
"github.com/gin-gonic/gin" |
|
"gorm.io/gorm" |
|
) |
|
|
|
func H5Info(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
resp := values.H5Info{} |
|
con := call.GetConfigH5() |
|
if con != nil { |
|
resp.CollectReward = con.CollectReward |
|
resp.DownloadReward = con.DownloadReward |
|
} |
|
data := &common.PlayerH5Data{UID: a.UID} |
|
err := db.Mysql().Get(data) |
|
if err == gorm.ErrRecordNotFound { |
|
db.Mysql().Create(data) |
|
} |
|
resp.IsCollect = data.Collect == 2 |
|
resp.IsDownload = data.Download == 2 |
|
a.Data = resp |
|
} |
|
|
|
func H5CollectDraw(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
con := call.GetConfigH5() |
|
if con == nil || con.CollectReward <= 0 { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
data := &common.PlayerH5Data{UID: a.UID} |
|
db.Mysql().Get(data) |
|
if data.Collect == 2 { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
res, err := db.Mysql().UpdateRes(&common.PlayerH5Data{UID: a.UID, Collect: 1}, map[string]interface{}{"collect": 2}) |
|
if err != nil { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
if res == 0 { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
// call.UpdateCurrencyPro(&common.UpdateCurrency{ |
|
// CurrencyBalance: &common.CurrencyBalance{ |
|
// UID: a.UID, |
|
// Event: common.CurrencyEventH5Collect, |
|
// }, |
|
// }, true, true) |
|
} |
|
|
|
func H5DownloadDraw(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
con := call.GetConfigH5() |
|
if con == nil || con.DownloadReward <= 0 { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
data := &common.PlayerH5Data{UID: a.UID} |
|
db.Mysql().Get(data) |
|
if data.Download == 2 { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
res, err := db.Mysql().UpdateRes(&common.PlayerH5Data{UID: a.UID, Download: 1}, map[string]interface{}{"download": 2}) |
|
if err != nil { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
if res == 0 { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
|
|
// call.UpdateCurrencyPro(&common.UpdateCurrencyNotify{ |
|
// Pairs: []*common.CurrencyPair{{Type: common.CurrencyTypeBindCash, Value: con.DownloadReward}}, |
|
// CurrencyBalance: &common.CurrencyBalance{ |
|
// UID: a.UID, |
|
// Event: common.CurrencyEventH5Download, |
|
// }, |
|
// }, true, true) |
|
}
|
|
|