From 7afa5f69fe10ee2b4689bca89a21a9c9d3b77b30 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Tue, 22 Oct 2024 14:40:15 +0800 Subject: [PATCH] add is_superfanship_give_wechat --- app/mix/service/logic/vas_zone.go | 44 +++++++++++++++++++++++++++++-- dbstruct/vas_mongo.go | 7 ++--- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/app/mix/service/logic/vas_zone.go b/app/mix/service/logic/vas_zone.go index 4ac13812..b5b43d90 100644 --- a/app/mix/service/logic/vas_zone.go +++ b/app/mix/service/logic/vas_zone.go @@ -540,8 +540,48 @@ func (v *Vas) UnlockZoneSuperfanship(ctx *gin.Context, tx *sqlx.Tx, order *dbstr // 超粉赠送微信 zv, _ := v.store.GetZoneVasById(ctx, zid) - if zv.IsSuperfanshipGiveWechat != 1 { - return nil + if len(zv.SuperfanPriceList) <= 0 { + if zv.IsSuperfanshipGiveWechat != 1 { + return nil + } + } else { + isSuperfanshipGiveWechat := 0 + switch order.GetProductId() { + case dbstruct.ProductIdH5ZoneSuperfanshipEternal: + for _, v := range zv.SuperfanPriceList { + if v.Period == dbstruct.SuperfanshipValidPeriodEternal { + isSuperfanshipGiveWechat = v.IsSuperfanshipGiveWechat + } + } + case dbstruct.ProductIdH5ZoneSuperfanshipMonth: + for _, v := range zv.SuperfanPriceList { + if v.Period == dbstruct.SuperfanshipValidPeriodMonth { + isSuperfanshipGiveWechat = v.IsSuperfanshipGiveWechat + } + } + case dbstruct.ProductIdH5ZoneSuperfanshipSeason: + for _, v := range zv.SuperfanPriceList { + if v.Period == dbstruct.SuperfanshipValidPeriodSeason { + isSuperfanshipGiveWechat = v.IsSuperfanshipGiveWechat + } + } + case dbstruct.ProductIdH5ZoneSuperfanshipHalfYear: + for _, v := range zv.SuperfanPriceList { + if v.Period == dbstruct.SuperfanshipValidPeriodHalfYear { + isSuperfanshipGiveWechat = v.IsSuperfanshipGiveWechat + } + } + case dbstruct.ProductIdH5ZoneSuperfanshipYear: + for _, v := range zv.SuperfanPriceList { + if v.Period == dbstruct.SuperfanshipValidPeriodYear { + isSuperfanshipGiveWechat = v.IsSuperfanshipGiveWechat + } + } + } + if isSuperfanshipGiveWechat != 1 { + logger.Warn("isSuperfanshipGiveWechat, orderId: %v", order.GetID()) + return nil + } } _err = v.SuperfanUnlockContact(ctx, tx, mid, zv.Mid, orderId) if _err != nil { diff --git a/dbstruct/vas_mongo.go b/dbstruct/vas_mongo.go index d1d592ca..d45cf31f 100644 --- a/dbstruct/vas_mongo.go +++ b/dbstruct/vas_mongo.go @@ -94,9 +94,10 @@ type ZoneVas struct { } type SuperfanPriceItem struct { - Period int `json:"period" bson:"period"` - Price int64 `json:"price" bson:"price"` - Enable int `json:"enable" bson:"enable"` + Period int `json:"period" bson:"period"` + Price int64 `json:"price" bson:"price"` + Enable int `json:"enable" bson:"enable"` + IsSuperfanshipGiveWechat int `json:"is_superfanship_give_wechat" bson:"is_superfanship_give_wechat"` // 是否开启超粉空间赠送微信 0: 不赠送, 1: 赠送 } func (p ZoneVas) GetSuperfanshipDurationSecond() int64 {