Beispiel #1
0
// 是否有新的资源
// partnerId:合作商Id
// gameVersionI:游戏版本Id
// resourceVersionId:当前的资源版本号
// 返回值:
// 游戏资源信息列表
// 是否有新的资源
func IfHasNewResource(partnerId, gameVersionId, resourceVersionId int) ([]map[string]interface{}, bool) {
	tmp := make([]map[string]interface{}, 0)

	// 用于判断PartnerId,GameVersionId是否存在于列表中的匿名方法
	ifIdExists := func(id int, idlist []int) bool {
		var exists = false
		for _, item := range idlist {
			if item == id {
				exists = true
				break
			}
		}

		return exists
	}

	for _, resourceVersionItem := range ResourceVersionList {
		// 如果比当前版本低则跳过
		if resourceVersionItem.Id <= resourceVersionId {
			continue
		}

		// 如果PartnerId不一致则跳过
		if ifIdExists(partnerId, resourceVersionItem.PartnerIdList()) == false {
			continue
		}

		// 如果GameVersionId不一致则跳过
		if ifIdExists(gameVersionId, resourceVersionItem.GameVersionIdList()) == false {
			continue
		}

		// 如果不处于有效期间则跳过
		now := time.Now()
		startTime := timeUtil.ConverToStandardFormat(resourceVersionItem.StartTime)
		endTime := timeUtil.ConverToStandardFormat(resourceVersionItem.EndTime)
		if now.Unix() < startTime.Unix() || now.Unix() > endTime.Unix() {
			continue
		}

		// 构造数据并添加到列表中
		tmpResource := make(map[string]interface{})
		tmpResource["Id"] = resourceVersionItem.Id
		tmpResource["Url"] = resourceVersionItem.Url
		tmpResource["Size"] = resourceVersionItem.Size
		tmpResource["MD5"] = resourceVersionItem.MD5
		tmpResource["IfRestart"] = resourceVersionItem.IfRestart
		tmpResource["IfDelete"] = resourceVersionItem.IfDelete

		tmp = append(tmp, tmpResource)
	}

	return tmp, len(tmp) > 0
}
Beispiel #2
0
// 判断服务器是否维护
// 返回值
// 是否维护
func IfServerMaintain() bool {
	// 判断状态 1:正常;2:维护
	if ServerGroupObj.GroupState == 2 {
		return true
	}

	// 判断时间
	now := time.Now()
	beginTime := timeUtil.ConverToStandardFormat(ServerGroupObj.MaintainBeginTime)
	endTime := beginTime.Add(time.Duration(ServerGroupObj.MaintainMinutes) * time.Minute)
	if beginTime.Unix() <= now.Unix() && now.Unix() <= endTime.Unix() {
		return true
	}

	return false
}
Beispiel #3
0
// 获取开服日期
// 返回值:
// 开服时间对象
func GetOpenDate() (time.Time, error) {
	return timeUtil.ConverToStandardFormat(ServerGroupObj.OpenDate)
}