diff --git a/modules/shopcenter/api_Info.go b/modules/shopcenter/api_Info.go index d6c8c55c4..b7628a39d 100644 --- a/modules/shopcenter/api_Info.go +++ b/modules/shopcenter/api_Info.go @@ -16,8 +16,9 @@ func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.ShopCenterInfo func (this *apiComp) Info(session comm.IUserSession, req *pb.ShopCenterInfoReq) (errdata *pb.ErrorData) { var ( info *pb.DBShopCenter - conf *cfg.GameShopCenterControlData + confs []*cfg.GameShopCenterControlData activitys map[pb.HdType]*pb.DBHuodong + activity *pb.DBShopCenterItem ok bool err error ) @@ -33,30 +34,34 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ShopCenterInfoReq) } return } + if confs, err = this.module.configure.getGameShopCenterControls(); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: err.Error(), + } + return + } - for _, v := range info.Item { - if conf, err = this.module.configure.getGameShopCenterControl(v.Id); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ConfigNoFound, - Title: pb.ErrorCode_ConfigNoFound.ToString(), - Message: err.Error(), + for _, v := range confs { + if activity, ok = info.Item[v.Id]; !ok { + if v.On == 0 { + info.Item[v.Id] = &pb.DBShopCenterItem{Id: v.Id, Open: true, Record: make(map[int32]bool)} + } else { + info.Item[v.Id] = &pb.DBShopCenterItem{Id: v.Id, Open: false, Record: make(map[int32]bool)} } - return + activity = info.Item[v.Id] } - if conf.Type == 1 || conf.Type == 2 || conf.Type == 5 || conf.Type == 6 || conf.Type == 7 { - v.Open = true + if _, ok = activitys[pb.HdType_XSFundPhysical]; ok && v.Type == 3 { + activity.Open = true continue } - if _, ok = activitys[pb.HdType_XSFundPhysical]; ok && conf.Type == 3 { - v.Open = true + if _, ok = activitys[pb.HdType_XSFundRecruit]; ok && v.Type == 4 { + activity.Open = true continue } - if _, ok = activitys[pb.HdType_XSFundRecruit]; ok && conf.Type == 4 { - v.Open = true - continue - } - if _, ok = activitys[pb.HdType_XSFundRecruit]; ok && conf.Type == 5 { - v.Open = true + if _, ok = activitys[pb.HdType_XSFundRecruit]; ok && v.Type == 5 { + activity.Open = true continue } } diff --git a/modules/shopcenter/modelShop.go b/modules/shopcenter/modelShop.go index 7a8e07fca..250b8ec74 100644 --- a/modules/shopcenter/modelShop.go +++ b/modules/shopcenter/modelShop.go @@ -6,7 +6,6 @@ import ( "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/modules" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" "sync" "go.mongodb.org/mongo-driver/bson/primitive" @@ -50,33 +49,17 @@ func (this *ModelShop) getactivity() map[pb.HdType]*pb.DBHuodong { // 获取用户全部的埋点数据 func (this *ModelShop) getUserShopCenter(uid string) (results *pb.DBShopCenter, err error) { - var ( - confs []*cfg.GameShopCenterControlData - ) - results = &pb.DBShopCenter{} if err = this.Get(uid, results); err != nil && err != mgo.MongodbNil { this.module.Errorln(err) return } if err == mgo.MongodbNil { - if confs, err = this.module.configure.getGameShopCenterControls(); err != nil { - return - } results = &pb.DBShopCenter{ Id: primitive.NewObjectID().Hex(), Uid: uid, Item: make(map[int32]*pb.DBShopCenterItem), } - for _, v := range confs { - if v.On == 0 { - results.Item[v.Id] = &pb.DBShopCenterItem{ - Id: v.Id, - Open: true, - Record: make(map[int32]bool), - } - } - } err = this.Add(uid, results) } return