From 27ef585eb0823412efcf8002487ecdbe32c2d084 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Mon, 22 Apr 2024 21:58:05 +0800 Subject: [PATCH] fix --- dbstruct/vas_mysql.go | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/dbstruct/vas_mysql.go b/dbstruct/vas_mysql.go index 32c05e12..85f9ab50 100644 --- a/dbstruct/vas_mysql.go +++ b/dbstruct/vas_mysql.go @@ -941,6 +941,14 @@ const ( ZoneUnlockTypeCollaborator = 5 // 协作者直接解锁 ) +var ValidZoneUnlockType = map[int32]bool{ + ZoneUnlockTypeFree: true, + ZoneUnlockTypePay: true, + ZoneUnlockTypeReachConsume: true, + ZoneUnlockTypeThirdPartner: true, + ZoneUnlockTypeCollaborator: true, +} + type ZoneUnlock struct { Id *int64 `json:"id" db:"id"` Mid *int64 `json:"mid" db:"mid"` // 用户mid @@ -966,21 +974,24 @@ type ZoneUnlock struct { } func (p *ZoneUnlock) IsUnlockAdmission() bool { - if p.GetAdmissionUntil() == -1 || p.GetAdmissionUntil() >= time.Now().Unix() { + if ValidZoneUnlockType[p.GetAdmissionUnlockType()] && + (p.GetAdmissionUntil() == -1 || p.GetAdmissionUntil() >= time.Now().Unix()) { return true } return false } func (p *ZoneUnlock) IsUnlockIronfanship() bool { - if p.IsUnlockAdmission() && (p.GetIronfanshipUntil() == -1 || p.GetIronfanshipUntil() >= time.Now().Unix()) { + if ValidZoneUnlockType[p.GetIronfanshipUnlockType()] && p.IsUnlockAdmission() && + (p.GetIronfanshipUntil() == -1 || p.GetIronfanshipUntil() >= time.Now().Unix()) { return true } return false } func (p *ZoneUnlock) IsUnlockSuperfanship() bool { - if p.IsUnlockAdmission() && (p.GetSuperfanshipUntil() == -1 || p.GetSuperfanshipUntil() >= time.Now().Unix()) { + if ValidZoneUnlockType[p.GetSuperfanshipUnlockType()] && p.IsUnlockAdmission() && + (p.GetSuperfanshipUntil() == -1 || p.GetSuperfanshipUntil() >= time.Now().Unix()) { return true } return false @@ -1035,6 +1046,13 @@ func (p *ZoneUnlock) GetAdmissionOrderId() string { return "" } +func (p *ZoneUnlock) GetAdmissionUnlockType() int32 { + if p != nil && p.AdmissionUnlockType != nil { + return *p.AdmissionUnlockType + } + return 0 +} + func (p *ZoneUnlock) GetIronfanshipCt() int64 { if p != nil && p.IronfanshipCt != nil { return *p.IronfanshipCt @@ -1056,6 +1074,13 @@ func (p *ZoneUnlock) GetIronfanshipOrderId() string { return "" } +func (p *ZoneUnlock) GetIronfanshipUnlockType() int32 { + if p != nil && p.IronfanshipUnlockType != nil { + return *p.IronfanshipUnlockType + } + return 0 +} + func (p *ZoneUnlock) GetSuperfanshipCt() int64 { if p != nil && p.SuperfanshipCt != nil { return *p.SuperfanshipCt @@ -1077,6 +1102,13 @@ func (p *ZoneUnlock) GetSuperfanshipOrderId() string { return "" } +func (p *ZoneUnlock) GetSuperfanshipUnlockType() int32 { + if p != nil && p.SuperfanshipUnlockType != nil { + return *p.SuperfanshipUnlockType + } + return 0 +} + // 空间消费详情 type ZoneConsumeHis struct { Id *int64 `json:"id" db:"id"`