diff --git a/modules/shop/api_getlist.go b/modules/shop/api_getlist.go index 8ff52f86c..3ed7fee17 100644 --- a/modules/shop/api_getlist.go +++ b/modules/shop/api_getlist.go @@ -83,14 +83,14 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) if req.IsManualRefresh && shopconf.Rnum > 0 { //可以手动刷新 isrefresh := false if refresh > 0 { // - if time.Unix(shopData.RefreshtimegoldShop, 0).Day() < configure.Now().Day() { - shopData.RefreshtimegoldShop = configure.Now().Unix() - shopData.RefreshnumgoldShop = 0 + if time.Unix(int64(sdata.RefreshNumResetTime), 0).Day() < configure.Now().Day() { + sdata.RefreshNumResetTime = configure.Now().Unix() + sdata.ManualRefreshNum = 0 + sdata.Leftfreerefreshnum = refresh } - if shopData.RefreshnumgoldShop < refresh { + if sdata.Leftfreerefreshnum > 0 { isrefresh = true - shopData.RefreshnumgoldShop++ - + sdata.Leftfreerefreshnum-- } } if !isrefresh { @@ -108,6 +108,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) if errdata = this.module.ConsumeRes(session, shopconf.Rneed, true); errdata != nil { return } + sdata.ManualRefreshNum++ } var _items []*cfg.GameShopitemData @@ -122,9 +123,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) } items = append(items, randomGoods(_items)) } - // sdata.LastRefreshTime = configure.Now().Unix() - sdata.ManualRefreshNum++ - sdata.Leftfreerefreshnum = refresh - shopData.RefreshnumgoldShop + sdata.Items = make([]*pb.UserShopGood, len(items)) sdata.Preview = make(map[int32]*pb.UserShopDataEx) for i, v := range items { @@ -172,7 +171,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) goods = transGoods(items, sdata) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype105, 1) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype105, 1)) - this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{"refreshnumgoldShop": shopData.RefreshnumgoldShop, "refreshtimegoldShop": shopData.RefreshtimegoldShop, "shops": shopData.Shops}) + this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{"shops": shopData.Shops}) } else if !req.IsManualRefresh { isrefresh := configure.Now().After((time.Unix(sdata.LastRefreshTime, 0))) if isrefresh { diff --git a/pb/shop_db.pb.go b/pb/shop_db.pb.go index b22d72676..5611ae5d5 100644 --- a/pb/shop_db.pb.go +++ b/pb/shop_db.pb.go @@ -88,11 +88,12 @@ type UserShopData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - LastRefreshTime int64 `protobuf:"varint,1,opt,name=LastRefreshTime,proto3" json:"LastRefreshTime"` //最后一次刷新时间 - ManualRefreshNum int32 `protobuf:"varint,2,opt,name=ManualRefreshNum,proto3" json:"ManualRefreshNum"` //手动刷新次数 - Items []*UserShopGood `protobuf:"bytes,3,rep,name=Items,proto3" json:"Items"` //商品列表 - Preview map[int32]*UserShopDataEx `protobuf:"bytes,5,rep,name=preview,proto3" json:"preview" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //预览数据 - Leftfreerefreshnum int32 `protobuf:"varint,6,opt,name=leftfreerefreshnum,proto3" json:"leftfreerefreshnum"` //剩余免费刷新次数 + LastRefreshTime int64 `protobuf:"varint,1,opt,name=LastRefreshTime,proto3" json:"LastRefreshTime"` //最后一次刷新时间 + ManualRefreshNum int32 `protobuf:"varint,2,opt,name=ManualRefreshNum,proto3" json:"ManualRefreshNum"` //手动刷新次数 + Items []*UserShopGood `protobuf:"bytes,3,rep,name=Items,proto3" json:"Items"` //商品列表 + Preview map[int32]*UserShopDataEx `protobuf:"bytes,5,rep,name=preview,proto3" json:"preview" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //预览数据 + Leftfreerefreshnum int32 `protobuf:"varint,6,opt,name=leftfreerefreshnum,proto3" json:"leftfreerefreshnum"` //剩余免费刷新次数 + RefreshNumResetTime int64 `protobuf:"varint,7,opt,name=RefreshNumResetTime,proto3" json:"RefreshNumResetTime"` //重置刷新次数 } func (x *UserShopData) Reset() { @@ -162,6 +163,13 @@ func (x *UserShopData) GetLeftfreerefreshnum() int32 { return 0 } +func (x *UserShopData) GetRefreshNumResetTime() int64 { + if x != nil { + return x.RefreshNumResetTime + } + return 0 +} + type UserShopDataEx struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -222,11 +230,9 @@ type DBShop struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //装备id - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //装备id - RefreshnumgoldShop int32 `protobuf:"varint,3,opt,name=refreshnumgoldShop,proto3" json:"refreshnumgoldShop" bson:"refreshnumgoldShop"` //刷新金币商店次数 - RefreshtimegoldShop int64 `protobuf:"varint,4,opt,name=refreshtimegoldShop,proto3" json:"refreshtimegoldShop" bson:"refreshtimegoldShop"` //刷新金币商店的时间 - Shops map[int32]*UserShopData `protobuf:"bytes,5,rep,name=shops,proto3" json:"shops" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //商店数据 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //装备id + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //装备id + Shops map[int32]*UserShopData `protobuf:"bytes,5,rep,name=shops,proto3" json:"shops" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //商店数据 } func (x *DBShop) Reset() { @@ -275,20 +281,6 @@ func (x *DBShop) GetUid() string { return "" } -func (x *DBShop) GetRefreshnumgoldShop() int32 { - if x != nil { - return x.RefreshnumgoldShop - } - return 0 -} - -func (x *DBShop) GetRefreshtimegoldShop() int64 { - if x != nil { - return x.RefreshtimegoldShop - } - return 0 -} - func (x *DBShop) GetShops() map[int32]*UserShopData { if x != nil { return x.Shops @@ -307,7 +299,7 @@ var file_shop_shop_db_proto_rawDesc = []byte{ 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x67, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x75, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x62, - 0x75, 0x79, 0x22, 0xbc, 0x02, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x70, 0x44, + 0x75, 0x79, 0x22, 0xee, 0x02, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x70, 0x44, 0x61, 0x74, 0x61, 0x12, 0x28, 0x0a, 0x0f, 0x4c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x4c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, @@ -322,26 +314,23 @@ var file_shop_shop_db_proto_rawDesc = []byte{ 0x76, 0x69, 0x65, 0x77, 0x12, 0x2e, 0x0a, 0x12, 0x6c, 0x65, 0x66, 0x74, 0x66, 0x72, 0x65, 0x65, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x6e, 0x75, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x6c, 0x65, 0x66, 0x74, 0x66, 0x72, 0x65, 0x65, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, - 0x68, 0x6e, 0x75, 0x6d, 0x1a, 0x4b, 0x0a, 0x0c, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x70, - 0x44, 0x61, 0x74, 0x61, 0x45, 0x78, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x22, 0x5e, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x70, 0x44, 0x61, 0x74, - 0x61, 0x45, 0x78, 0x12, 0x2b, 0x0a, 0x09, 0x65, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45, 0x71, 0x75, 0x69, - 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x65, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, - 0x12, 0x1f, 0x0a, 0x04, 0x4e, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x04, 0x4e, 0x65, 0x65, - 0x64, 0x22, 0xff, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x53, 0x68, 0x6f, 0x70, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, - 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2e, - 0x0a, 0x12, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x6e, 0x75, 0x6d, 0x67, 0x6f, 0x6c, 0x64, - 0x53, 0x68, 0x6f, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x72, 0x65, 0x66, 0x72, - 0x65, 0x73, 0x68, 0x6e, 0x75, 0x6d, 0x67, 0x6f, 0x6c, 0x64, 0x53, 0x68, 0x6f, 0x70, 0x12, 0x30, - 0x0a, 0x13, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x74, 0x69, 0x6d, 0x65, 0x67, 0x6f, 0x6c, - 0x64, 0x53, 0x68, 0x6f, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x13, 0x72, 0x65, 0x66, - 0x72, 0x65, 0x73, 0x68, 0x74, 0x69, 0x6d, 0x65, 0x67, 0x6f, 0x6c, 0x64, 0x53, 0x68, 0x6f, 0x70, + 0x68, 0x6e, 0x75, 0x6d, 0x12, 0x30, 0x0a, 0x13, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4e, + 0x75, 0x6d, 0x52, 0x65, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x13, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x73, + 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x1a, 0x4b, 0x0a, 0x0c, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, + 0x77, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, + 0x6f, 0x70, 0x44, 0x61, 0x74, 0x61, 0x45, 0x78, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x22, 0x5e, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x70, 0x44, + 0x61, 0x74, 0x61, 0x45, 0x78, 0x12, 0x2b, 0x0a, 0x09, 0x65, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x5f, 0x45, 0x71, + 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x65, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x4e, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x04, 0x4e, + 0x65, 0x65, 0x64, 0x22, 0x9d, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x53, 0x68, 0x6f, 0x70, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x05, 0x73, 0x68, 0x6f, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x44, 0x42, 0x53, 0x68, 0x6f, 0x70, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x73, 0x68, 0x6f, 0x70, 0x73, 0x1a, 0x47, 0x0a, 0x0a, 0x53, 0x68,