From d17c81ceb56d27606ea113f674e4ea8876672c81 Mon Sep 17 00:00:00 2001 From: zhora Date: Tue, 14 Oct 2025 15:08:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/item.go | 6 ++++++ modules/web/handler/user.go | 12 ++++++++++++ modules/web/values/protocol.go | 12 ++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/call/item.go b/call/item.go index 8b8edd1..ca7ae66 100644 --- a/call/item.go +++ b/call/item.go @@ -26,6 +26,12 @@ func GetUserValidItems(uid, itemID int) []*common.PlayerItems { return list } +func GetUserValidItemsMax(uid, itemID int) common.PlayerItems { + var result common.PlayerItems + _ = db.Mysql().C().Model(&common.PlayerItems{}).Where("uid = ? and item_id = ? and `status` = ?", uid, itemID, common.ItemStatusNormal).Order("Exi1 desc").Limit(1).Find(&result).Error + return result +} + func GetUserItemByExi1(uid, itemID, exi1 int) []*common.PlayerItems { list := []*common.PlayerItems{} db.Mysql().QueryAll(fmt.Sprintf("uid = %d and item_id = %d and exi1 = %d and status = %d", uid, itemID, exi1, common.ItemStatusNormal), "", &common.PlayerItems{}, &list) diff --git a/modules/web/handler/user.go b/modules/web/handler/user.go index 438f4ac..625bc03 100644 --- a/modules/web/handler/user.go +++ b/modules/web/handler/user.go @@ -43,6 +43,12 @@ func getUserInfo(uid int, isNew bool) (resp values.UserInfoResp, err error) { resp.Activitys.DaySign = call.ShouldShowActivitySign(uid) resp.Activitys.WeekCard = call.ShouldShowActivityWeekCard(uid) resp.Activitys.LuckyShop = call.ShouldShowActivityLuckShop(uid) + if ticker := call.GetUserValidItemsMax(uid, common.ItemDiscountTicket); ticker.ID > 0 { + resp.Activitys.DiscountTicket = struct { + Amount int64 + DiscountAmount int64 + }{Amount: ticker.Exi2, DiscountAmount: ticker.Exi1} + } vip := call.GetVipCon(uid) var nextVip *common.ConfigVIP if vip != nil { @@ -133,6 +139,12 @@ func GetUserInfo(c *gin.Context) { resp.Activitys.DaySign = call.ShouldShowActivitySign(uid) resp.Activitys.WeekCard = call.ShouldShowActivityWeekCard(uid) resp.Activitys.LuckyShop = call.ShouldShowActivityLuckShop(uid) + if ticker := call.GetUserValidItemsMax(uid, common.ItemDiscountTicket); ticker.ID > 0 { + resp.Activitys.DiscountTicket = struct { + Amount int64 + DiscountAmount int64 + }{Amount: ticker.Exi2, DiscountAmount: ticker.Exi1} + } vip := call.GetVipCon(a.UID) nextVip := call.GetConfigVIPByLevel(vip.Level + 1) resp.CurrentVip.Bonus = vip.Bonus diff --git a/modules/web/values/protocol.go b/modules/web/values/protocol.go index 11fa5cb..67771db 100644 --- a/modules/web/values/protocol.go +++ b/modules/web/values/protocol.go @@ -64,10 +64,14 @@ type UserInfoResp struct { CurrentVip *OneUserInfoVip NextVip *OneUserInfoVip Activitys struct { - RechargeBack bool - DaySign bool - WeekCard bool // 是否弹出周卡 - LuckyShop bool // 是否弹出幸运商店 + RechargeBack bool + DaySign bool + WeekCard bool // 是否弹出周卡 + LuckyShop bool // 是否弹出幸运商店 + DiscountTicket struct { + Amount int64 // 优惠券额度 + DiscountAmount int64 // 优惠金额 + } // 优惠金额最大优惠券 } }