印度包网
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.
 
 
 

45 lines
1.4 KiB

package call
import (
"server/common"
"server/db"
"time"
"github.com/liangdas/mqant/log"
"gorm.io/gorm"
)
type Task struct {
Uid int // uid
Types []common.TaskType // 任务类型
Value int64 // 进度值
}
func CheckTask(task Task) {
log.Info("checkTask task:%v", task)
now := time.Now().Unix()
con := GetConfigTask()
uid := task.Uid
for _, v := range con {
for _, t := range task.Types {
if (t == common.TaskTypeOnceRecharge || t == common.TaskTypeInvite) && v.Type == t { // 单次充值任务 || 首次充值任务 || v.Type == common.TaskTypeFirstRecharge)
data := GetUserTaskDataByTaskID(task.Uid, v.TaskID)
if data.ID == 0 {
db.Mysql().Create(&common.TaskData{UID: uid, TaskID: v.TaskID, Time: now, Progress: v.Target})
} else if data.Progress == 0 {
db.Mysql().Update(&common.TaskData{UID: uid, TaskID: v.TaskID}, map[string]interface{}{"progress": v.Target, "time": now})
}
break
} else if (t == common.TaskTypeBet1000 || t == common.TaskTypeBet10000 || t == common.TaskTypePlayGame) && v.Type == t {
data := GetUserTaskDataByTaskID(task.Uid, v.TaskID)
if data.ID == 0 {
db.Mysql().Create(&common.TaskData{UID: uid, TaskID: v.TaskID, Time: now, Progress: task.Value})
} else {
db.Mysql().Update(&common.TaskData{UID: uid, TaskID: v.TaskID}, map[string]interface{}{"progress": gorm.Expr("progress + ?", task.Value), "time": now})
}
break
}
}
}
}