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

34 lines
769 B

package call
import (
"server/common"
"server/db"
"time"
"github.com/liangdas/mqant/log"
"gorm.io/gorm"
)
type Task struct {
Uid int // uid
Value int64 // 进度值
Types []common.TaskType // 任务类型
}
func CheckTask(task Task) (taskId int) {
log.Info("checkTask task:%v", task)
now := time.Now()
for _, taskType := range task.Types {
err := db.Mysql().C().Model(&common.TaskData{}).
Where("uid = ? and task_type = ? and task_status = 0 and (end_at >= ? or end_at = -1)", task.Uid, taskType, now.Unix()).
Updates(map[string]interface{}{
"task_value": gorm.Expr("task_value + ?", task.Value),
}).Error
if err != nil {
log.Error("update task progress err, %+v:%d:%s", task, taskType, err.Error())
continue
}
}
return
}