|
|
|
|
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)
|
|
|
|
|
call.CheckTask(call.Task{Uid: a.UID, Value: 0, Types: []common.TaskType{common.TaskTypeDownload}})
|
|
|
|
|
}
|