每周优惠日

This commit is contained in:
hahwu 2025-10-21 16:23:31 +08:00
parent bf5cbc9d5d
commit 7d3e299877
6 changed files with 51 additions and 4 deletions

View File

@ -334,3 +334,16 @@ func GetPetCoinShopReward(ChargeId int) []*item.Item {
}
return nil
}
func GetWeeklyDiscountStartEnd() (int64, int64) {
data, err := gamedata.GetDataByKey(CFG_CHARGE_CONST, "weekly_discount_time")
if err != nil {
return 0, 0
}
str := gamedata.GetStringValue(data, "Value")
strArr := strings.Split(str, "|")
if len(strArr) != 2 {
return 0, 0
}
return GoUtil.ParseTime(strArr[0]), GoUtil.ParseTime(strArr[1])
}

View File

@ -143,7 +143,6 @@ func (gl *GameLogic) OpenTimestampTick() {
gl.NoonFlush()
})
//gl.CreateDailyLogFile()
go func() {
for k := range gl.Mdispatr.ChanTimer {
k.Cb()

View File

@ -523,6 +523,13 @@ func ReqGmCommand_(player *Player, Command string) error {
case "resetCompensation":
compensationMod := player.PlayMod.getCompensationMod()
compensationMod.C20250910 = false
case "resetWeekly":
ChargeMod := player.PlayMod.getChargeMod()
ChargeMod.WeeklyDiscount = make(map[int]int)
player.PushClientRes(ChargeMod.BackData())
PlayroomMod := player.PlayMod.getPlayroomMod()
PlayroomMod.WeeklyDiscount = make(map[int]int)
PlayroomBackData(player)
case "resetCode":
BaseMod := player.PlayMod.getBaseMod()
BaseMod.AddCode = fmt.Sprintf("MMM-%s-%s", "156", GoUtil.UniqueStringFromInt(int(BaseMod.Uid)))

View File

@ -12,6 +12,7 @@ import (
"server/GoUtil"
activityCfg "server/conf/activity"
cardCfg "server/conf/card"
chargeCfg "server/conf/charge"
guesscolorCfg "server/conf/guessColor"
itemCfg "server/conf/item"
limitedTimeEventCfg "server/conf/limitedTimeEvent"
@ -398,6 +399,20 @@ func (p *Player) Login() {
AvatarMod.Login(PlayBaseMod.GetRegisterTime())
HandbookItem := p.PlayMod.getCardMod().Login(G_GameLogicPtr.SeverInfo.OpenTime)
p.HandleItem(HandbookItem, msg.ITEM_POP_LABEL_AllCollectRewardHB.String())
// 每周优惠特殊处理
WeeklyStartTime, WeeklyEndTime := chargeCfg.GetWeeklyDiscountStartEnd()
now := GoUtil.Now()
if now >= WeeklyStartTime && now <= WeeklyEndTime {
ChargeMod.WeeklyEndTime = WeeklyEndTime
}
if WeeklyStartTime > now {
go func() {
time.Sleep(time.Duration(WeeklyStartTime-now) * time.Second)
ChargeMod.WeeklyEndTime = WeeklyEndTime
p.PushClientRes(ChargeMod.BackData())
PlayroomBackData(p)
}()
}
}
func (p *Player) Outline() {

View File

@ -38,6 +38,7 @@ type ChargeMod struct {
LastWorkTime int64 // 上次打工时间
WishList *WishList
WeeklyDiscount map[int]int // 每周折扣购买次数
WeeklyEndTime int64
}
type WishList struct {
@ -136,6 +137,9 @@ func (c *ChargeMod) ZeroUpdate(Emit []int) {
}
c.WishList.SendList = make([]int64, 0)
c.WeeklyDiscount = make(map[int]int)
if c.IsWeeklyDiscountDay() && c.WeeklyEndTime < Now {
c.WeeklyEndTime = GoUtil.ZeroTimestamp() + 7*24*3600
}
c.InitChessShop(Emit)
}
@ -508,7 +512,7 @@ func (c *ChargeMod) IsWeeklyDiscountDay() bool {
return false
}
Weekday, _ := GoUtil.GetWeekdayAndHour()
return Weekday == Day
return Weekday == Day || c.WeeklyEndTime > GoUtil.Now()
}
func (c *ChargeMod) PetWorkBackData() *msg.LogoutPetWork {

View File

@ -15940,6 +15940,7 @@ type ResCharge struct {
AdEndTime int64 `protobuf:"varint,14,opt,name=AdEndTime,proto3" json:"AdEndTime,omitempty"` // 广告礼包结束时间
WeeklyDiscount map[int32]*WeeklyDiscountInfo `protobuf:"bytes,15,rep,name=WeeklyDiscount,proto3" json:"WeeklyDiscount,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // 每周优惠 id -> 限购次数
PetWorkRemainTime int64 `protobuf:"varint,16,opt,name=PetWorkRemainTime,proto3" json:"PetWorkRemainTime,omitempty"` // 剩余时间
WeeklyEndTime int64 `protobuf:"varint,17,opt,name=WeeklyEndTime,proto3" json:"WeeklyEndTime,omitempty"` // 每周优惠结束时间
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -16086,6 +16087,13 @@ func (x *ResCharge) GetPetWorkRemainTime() int64 {
return 0
}
func (x *ResCharge) GetWeeklyEndTime() int64 {
if x != nil {
return x.WeeklyEndTime
}
return 0
}
type LogoutPetWork struct {
state protoimpl.MessageState `protogen:"open.v1"`
WorkTime int64 `protobuf:"varint,1,opt,name=WorkTime,proto3" json:"WorkTime,omitempty"` // 工作时间
@ -27402,7 +27410,7 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"\rResDeleteMail\x12&\n" +
"\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" +
"\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x0e\n" +
"\x02Id\x18\x03 \x01(\x05R\x02Id\"\xdf\a\n" +
"\x02Id\x18\x03 \x01(\x05R\x02Id\"\x85\b\n" +
"\tResCharge\x12\x16\n" +
"\x06Charge\x18\x01 \x01(\x02R\x06Charge\x12\x14\n" +
"\x05Total\x18\x02 \x01(\x05R\x05Total\x12\x14\n" +
@ -27420,7 +27428,8 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"\vMonthCharge\x18\r \x01(\x02R\vMonthCharge\x12\x1c\n" +
"\tAdEndTime\x18\x0e \x01(\x03R\tAdEndTime\x12O\n" +
"\x0eWeeklyDiscount\x18\x0f \x03(\v2'.tutorial.ResCharge.WeeklyDiscountEntryR\x0eWeeklyDiscount\x12,\n" +
"\x11PetWorkRemainTime\x18\x10 \x01(\x03R\x11PetWorkRemainTime\x1aX\n" +
"\x11PetWorkRemainTime\x18\x10 \x01(\x03R\x11PetWorkRemainTime\x12$\n" +
"\rWeeklyEndTime\x18\x11 \x01(\x03R\rWeeklyEndTime\x1aX\n" +
"\x10SpecialShopEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\x05R\x03key\x12.\n" +
"\x05value\x18\x02 \x01(\v2\x18.tutorial.ResSpecialShopR\x05value:\x028\x01\x1aT\n" +