ice_reward.go 3.38 KB
package sdkdb

import (
	"strconv"

	"github.com/astaxie/beego/orm"
)

type IceReward struct {
	Id            string `orm:pk` //奖励id
	Title         string //奖励标题
	Content       string //奖励消息内容
	TrigType      int64  //触发类型 0,开启应用
	ActType       int64  //活动类型,0,时间段,1,永久有效
	StartTime     int64  //开始时间
	EndTime       int64  //结束时间
	UserFilter    string
	VersionFilter int64
	PlatFilter    string
	GTID          string
	TopType       string
	ValidTime     int64
	GameId        string
	GTName        string
}

func IceRewardInit() {
	// 注册模型
	orm.RegisterModel(new(IceReward))
}

func IceRewardQueryIDWithRank(gtid string, gid string, toptype string) (iceRewards []IceReward, err error) {
	o := orm.NewOrm()

	var datalist []orm.Params

	_, err = o.Raw("SELECT a.*,b.gtname as GTNAME FROM ice_reward a,ice_gametopset b where a.gtid=? and a.gameid=? and a.gtid = b.gtid and a.gameid = b.gid and  a.ISDEL=0 and b.isdel='0'", gtid, gid).Values(&datalist)

	/*if datalist != nil {
		iceReward = new(IceReward)
		iceReward.Id = datalist[0]["ID"].(string)
		iceReward.Title = datalist[0]["TITLE"].(string)
		iceReward.Content = datalist[0]["CONTENT"].(string)

		trigType, _ := strconv.Atoi(datalist[0]["TRIGTYPE"].(string))
		iceReward.TrigType = int64(trigType)

		actType, _ := strconv.Atoi(datalist[0]["ACTTYPE"].(string))
		iceReward.ActType = int64(actType)

		startTime, _ := strconv.Atoi(datalist[0]["STARTTIME"].(string))
		iceReward.StartTime = int64(startTime)

		endTime, _ := strconv.Atoi(datalist[0]["ENDTIME"].(string))
		iceReward.EndTime = int64(endTime)

		iceReward.UserFilter = datalist[0]["USERFILTER"].(string)

		versionFilter, _ := strconv.Atoi(datalist[0]["VERSIONFILTER"].(string))
		iceReward.VersionFilter = int64(versionFilter)

		iceReward.PlatFilter = datalist[0]["PLATFILTER"].(string)
		iceReward.GTID = datalist[0]["GTID"].(string)
		iceReward.TopType = datalist[0]["TOPTYPE"].(string)

		validTime, _ := strconv.Atoi(datalist[0]["VALIDTIME"].(string))
		iceReward.ValidTime = int64(validTime)

		iceReward.GameId = datalist[0]["GAMEID"].(string)
	} */

	// update time 2017年9月4日12:30:32 update by 徐振浩
	//update start
	//获取奖励具体内容
	iceReward := make([]IceReward, len(datalist))
	if datalist != nil {
		for k, v := range datalist {
			iceReward[k].Id = v["ID"].(string)
			iceReward[k].Title = v["TITLE"].(string)
			iceReward[k].Content = v["CONTENT"].(string)
			iceReward[k].GTName = v["GTNAME"].(string)
			trigType, _ := strconv.Atoi(v["TRIGTYPE"].(string))
			iceReward[k].TrigType = int64(trigType)

			actType, _ := strconv.Atoi(v["ACTTYPE"].(string))
			iceReward[k].ActType = int64(actType)

			startTime, _ := strconv.Atoi(v["STARTTIME"].(string))
			iceReward[k].StartTime = int64(startTime)

			endTime, _ := strconv.Atoi(v["ENDTIME"].(string))
			iceReward[k].EndTime = int64(endTime)

			iceReward[k].UserFilter = v["USERFILTER"].(string)

			versionFilter, _ := strconv.Atoi(v["VERSIONFILTER"].(string))
			iceReward[k].VersionFilter = int64(versionFilter)

			iceReward[k].PlatFilter = v["PLATFILTER"].(string)
			iceReward[k].GTID = v["GTID"].(string)
			iceReward[k].TopType = v["TOPTYPE"].(string)

			validTime, _ := strconv.Atoi(v["VALIDTIME"].(string))
			iceReward[k].ValidTime = int64(validTime)

			iceReward[k].GameId = v["GAMEID"].(string)
		}
	}

	//update end

	return iceReward, err
}