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

35 lines
769 B

1 year ago
package call
import (
"server/common"
"server/db"
"time"
"github.com/liangdas/mqant/log"
"gorm.io/gorm"
)
type Task struct {
2 weeks ago
Uid int // uid
Value int64 // 进度值
1 year ago
Types []common.TaskType // 任务类型
}
func CheckTask(task Task) (taskId int) {
1 year ago
log.Info("checkTask task:%v", task)
2 weeks ago
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
1 year ago
}
}
return
1 year ago
}