package task

import (
	"log-server/global"
	"time"
)

type GameTargetComplete struct {
	Id                   uint      `json:"id"`
	TaskId               int       `json:"task_id"`
	NewComplete          int       `json:"new_complete"`
	PayComplete          int       `json:"pay_complete"`
	RetainedComplete     int       `json:"retained_complete"`
	NewTarget            int       `json:"new_target"`
	PayTarget            int       `json:"pay_target"`
	RetainedTarget       int       `json:"retained_target"`
	Amount               int       `json:"amount"`
	CreateDate           time.Time `json:"create_date"`
	UpdateTime           time.Time `json:"update_time"` // 更新时间
	GameRate             string    `json:"game_rate"`
	IsComplete           int       `json:"is_complete"`
	HandNewComplete      int       `json:"hand_new_complete"`
	HandRetainedComplete int       `json:"hand_retained_complete"`
	HandPayComplete      int       `json:"hand_pay_complete"`
	HandAmountTotal      int       `json:"hand_amount_total"`
}

func (GameTargetComplete) TableName() string {
	return "game_target_complete"
}

// 获取任务完成数据
func (s *GameTargetComplete) CompleteTaskData(date string) (mps map[int]GameTargetComplete, err error) {
	db := global.GVA_DB.Table("game_target_complete")
	db = db.Where("create_date = ?", date)
	var apiList []GameTargetComplete
	mps = map[int]GameTargetComplete{}
	err = db.Order("id desc").Find(&apiList).Error
	for _, api := range apiList {
		mps[api.TaskId] = api
	}
	return
}
