diff --git a/comm/const.go b/comm/const.go index e29997c76..459119794 100644 --- a/comm/const.go +++ b/comm/const.go @@ -960,5 +960,5 @@ const ( const ( HdTypeWarorder = 1 // 圣桃战令类型 - HdTypePay = 2 // 限时类型 + HdTypePay = 2 // 圣桃充值礼包 ) diff --git a/modules/activity/module.go b/modules/activity/module.go index 43c984744..8136d65d0 100644 --- a/modules/activity/module.go +++ b/modules/activity/module.go @@ -53,7 +53,6 @@ func (this *Activity) Start() (err error) { var module core.IModule if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil { if m, ok := module.(comm.IWarorder); ok { - m.OpenWarorder(2, rst.Stime) m.ActivityNotice(rst) } } @@ -63,7 +62,6 @@ func (this *Activity) Start() (err error) { var module core.IModule if module, err = this.service.GetModule(comm.ModulePay); err == nil { if m, ok := module.(comm.IPay); ok { - m.OpenActivity(1, rst.Stime) m.ActivityNotice(rst) } } diff --git a/modules/pay/api_getactivity.go b/modules/pay/api_getactivity.go index a19b3bce4..b190fa3fb 100644 --- a/modules/pay/api_getactivity.go +++ b/modules/pay/api_getactivity.go @@ -22,7 +22,7 @@ func (this *apiComp) GetActivity(session comm.IUserSession, req *pb.PayGetActivi activitys *pb.DBActivityGiftbag info *pb.ActivityGiftbagItem conf *cfg.GamePayGiftpackData - otime int64 + activity *pb.DBHuodong err error ok bool ) @@ -38,7 +38,7 @@ func (this *apiComp) GetActivity(session comm.IUserSession, req *pb.PayGetActivi return } - if otime, ok = this.module.modelActivity.getopentime(req.Atype); !ok { + if activity, ok = this.module.modelActivity.getopentime(req.Atype); !ok { errdata = &pb.ErrorData{ Code: pb.ErrorCode_WarorderNoOpen, Title: pb.ErrorCode_WarorderNoOpen.ToString(), @@ -54,8 +54,8 @@ func (this *apiComp) GetActivity(session comm.IUserSession, req *pb.PayGetActivi activitys.Activitys[req.Atype] = info } - if info.Opentime != otime { - info.Opentime = otime + if info.Opentime != activity.Stime { + info.Opentime = activity.Stime for _, v := range info.Items { if conf, err = this.module.configure.getPayGiftpackeData(v.Id); err != nil { diff --git a/modules/pay/modelActivity.go b/modules/pay/modelActivity.go index 70153f630..1dabe2f39 100644 --- a/modules/pay/modelActivity.go +++ b/modules/pay/modelActivity.go @@ -21,7 +21,7 @@ type modelActivityComp struct { modules.MCompModel module *Pay lock sync.RWMutex - opentime map[int32]int64 + opentime map[int32]*pb.DBHuodong } // 组件初始化接口 @@ -31,23 +31,23 @@ func (this *modelActivityComp) Init(service core.IService, module core.IModule, this.TableName = comm.TableActivityGiftbag //创建uid索引 this.lock.Lock() - this.opentime = make(map[int32]int64) + this.opentime = make(map[int32]*pb.DBHuodong) this.lock.Unlock() this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, }) return } -func (this *modelActivityComp) getopentime(wtype int32) (otime int64, open bool) { +func (this *modelActivityComp) getopentime(wtype int32) (activity *pb.DBHuodong, open bool) { this.lock.RLock() - otime, open = this.opentime[wtype] + activity, open = this.opentime[wtype] this.lock.RUnlock() return } -func (this *modelActivityComp) setopentime(wtype int32, opentime int64) { +func (this *modelActivityComp) setopentime(wtype int32, activity *pb.DBHuodong) { this.lock.RLock() - this.opentime[wtype] = opentime + this.opentime[wtype] = activity this.lock.RUnlock() return } diff --git a/modules/pay/module.go b/modules/pay/module.go index 2bcdae1fa..3fbaf002e 100644 --- a/modules/pay/module.go +++ b/modules/pay/module.go @@ -271,11 +271,10 @@ func (this *Pay) ModulePayDelivery(session comm.IUserSession, Productid string, return } -// 开启活动礼包 -func (this *Pay) OpenActivity(atype int32, opentime int64) { - this.modelActivity.setopentime(atype, opentime) -} - func (this *Pay) ActivityNotice(hdlist *pb.DBHuodong) { - + switch hdlist.Itype { + case comm.HdTypePay: + this.modelActivity.setopentime(1, hdlist) + break + } } diff --git a/modules/warorder/api_info.go b/modules/warorder/api_info.go index 605dfd837..e7fc23acf 100644 --- a/modules/warorder/api_info.go +++ b/modules/warorder/api_info.go @@ -17,7 +17,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e var ( warorders *pb.DBWarorders info *pb.Warorder - otime int64 + activity *pb.DBHuodong err error ok bool ) @@ -33,7 +33,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e return } - if otime, ok = this.module.modelWarorder.getopentime(req.Rtype); !ok { + if activity, ok = this.module.modelWarorder.getopentime(req.Rtype); !ok { errdata = &pb.ErrorData{ Code: pb.ErrorCode_WarorderNoOpen, Title: pb.ErrorCode_WarorderNoOpen.ToString(), @@ -47,8 +47,9 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e warorders.Items[req.Rtype] = info } - if info.Opentime != otime { - info.Opentime = otime + if info.Opentime != activity.Stime { + info.Opentime = activity.Stime + info.Endtime = activity.Etime info.Freeprogress = 0 info.Payprogress = 0 if err = this.module.modelWarorder.updateUserWarorders(session.GetUserId(), warorders); err != nil { diff --git a/modules/warorder/modelWarorder.go b/modules/warorder/modelWarorder.go index 69ea747a2..4e32678f8 100644 --- a/modules/warorder/modelWarorder.go +++ b/modules/warorder/modelWarorder.go @@ -18,7 +18,7 @@ type modelWarorder struct { modules.MCompModel module *Warorder lock sync.RWMutex - opentime map[int32]int64 + opentime map[int32]*pb.DBHuodong } func (this *modelWarorder) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { @@ -26,7 +26,7 @@ func (this *modelWarorder) Init(service core.IService, module core.IModule, comp this.TableName = comm.TableWarorder this.module = module.(*Warorder) this.lock.Lock() - this.opentime = make(map[int32]int64) + this.opentime = make(map[int32]*pb.DBHuodong) this.lock.Unlock() this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, @@ -34,16 +34,16 @@ func (this *modelWarorder) Init(service core.IService, module core.IModule, comp return } -func (this *modelWarorder) getopentime(wtype int32) (otime int64, open bool) { +func (this *modelWarorder) getopentime(wtype int32) (activity *pb.DBHuodong, open bool) { this.lock.RLock() - otime, open = this.opentime[wtype] + activity, open = this.opentime[wtype] this.lock.RUnlock() return } -func (this *modelWarorder) setopentime(wtype int32, opentime int64) { +func (this *modelWarorder) setopentime(wtype int32, activity *pb.DBHuodong) { this.lock.RLock() - this.opentime[wtype] = opentime + this.opentime[wtype] = activity this.lock.RUnlock() return } diff --git a/modules/warorder/module.go b/modules/warorder/module.go index a9735ab4d..23789db4d 100644 --- a/modules/warorder/module.go +++ b/modules/warorder/module.go @@ -87,9 +87,10 @@ func (this *Warorder) Delivery(session comm.IUserSession, pid string) (errdata * } // 开启战令 -func (this *Warorder) OpenWarorder(wtype int32, opentime int64) { - this.modelWarorder.setopentime(wtype, opentime) -} func (this *Warorder) ActivityNotice(hdlist *pb.DBHuodong) { - + switch hdlist.Itype { + case comm.HdTypeWarorder: + this.modelWarorder.setopentime(2, hdlist) + break + } } diff --git a/pb/warorder_db.pb.go b/pb/warorder_db.pb.go index 92fabb466..b006b8e78 100644 --- a/pb/warorder_db.pb.go +++ b/pb/warorder_db.pb.go @@ -91,9 +91,10 @@ type Warorder struct { unknownFields protoimpl.UnknownFields Opentime int64 `protobuf:"varint,1,opt,name=opentime,proto3" json:"opentime"` - Freeprogress int32 `protobuf:"varint,2,opt,name=freeprogress,proto3" json:"freeprogress"` //已领取天数 - Payprogress int32 `protobuf:"varint,3,opt,name=payprogress,proto3" json:"payprogress"` - Vip bool `protobuf:"varint,4,opt,name=vip,proto3" json:"vip"` + Endtime int64 `protobuf:"varint,2,opt,name=endtime,proto3" json:"endtime"` + Freeprogress int32 `protobuf:"varint,3,opt,name=freeprogress,proto3" json:"freeprogress"` //已领取天数 + Payprogress int32 `protobuf:"varint,4,opt,name=payprogress,proto3" json:"payprogress"` + Vip bool `protobuf:"varint,5,opt,name=vip,proto3" json:"vip"` } func (x *Warorder) Reset() { @@ -135,6 +136,13 @@ func (x *Warorder) GetOpentime() int64 { return 0 } +func (x *Warorder) GetEndtime() int64 { + if x != nil { + return x.Endtime + } + return 0 +} + func (x *Warorder) GetFreeprogress() int32 { if x != nil { return x.Freeprogress @@ -171,16 +179,17 @@ var file_warorder_warorder_db_proto_rawDesc = []byte{ 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x22, 0x7e, 0x0a, 0x08, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x1a, - 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x72, - 0x65, 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0c, 0x66, 0x72, 0x65, 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, - 0x0a, 0x0b, 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x10, 0x0a, 0x03, 0x76, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, - 0x69, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x38, 0x01, 0x22, 0x98, 0x01, 0x0a, 0x08, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12, + 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, + 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x6e, + 0x64, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x72, 0x65, 0x65, 0x70, 0x72, 0x6f, + 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x66, 0x72, 0x65, + 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x61, 0x79, + 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, + 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x76, + 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, 0x69, 0x70, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (