上传活动统一接口

This commit is contained in:
liwei 2023-07-31 17:38:03 +08:00
parent 3d2c87b003
commit ef949f0107
9 changed files with 54 additions and 46 deletions

View File

@ -960,5 +960,5 @@ const (
const ( const (
HdTypeWarorder = 1 // 圣桃战令类型 HdTypeWarorder = 1 // 圣桃战令类型
HdTypePay = 2 // 限时类型 HdTypePay = 2 // 圣桃充值礼包
) )

View File

@ -53,7 +53,6 @@ func (this *Activity) Start() (err error) {
var module core.IModule var module core.IModule
if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil { if module, err = this.service.GetModule(comm.ModuleWarorder); err == nil {
if m, ok := module.(comm.IWarorder); ok { if m, ok := module.(comm.IWarorder); ok {
m.OpenWarorder(2, rst.Stime)
m.ActivityNotice(rst) m.ActivityNotice(rst)
} }
} }
@ -63,7 +62,6 @@ func (this *Activity) Start() (err error) {
var module core.IModule var module core.IModule
if module, err = this.service.GetModule(comm.ModulePay); err == nil { if module, err = this.service.GetModule(comm.ModulePay); err == nil {
if m, ok := module.(comm.IPay); ok { if m, ok := module.(comm.IPay); ok {
m.OpenActivity(1, rst.Stime)
m.ActivityNotice(rst) m.ActivityNotice(rst)
} }
} }

View File

@ -22,7 +22,7 @@ func (this *apiComp) GetActivity(session comm.IUserSession, req *pb.PayGetActivi
activitys *pb.DBActivityGiftbag activitys *pb.DBActivityGiftbag
info *pb.ActivityGiftbagItem info *pb.ActivityGiftbagItem
conf *cfg.GamePayGiftpackData conf *cfg.GamePayGiftpackData
otime int64 activity *pb.DBHuodong
err error err error
ok bool ok bool
) )
@ -38,7 +38,7 @@ func (this *apiComp) GetActivity(session comm.IUserSession, req *pb.PayGetActivi
return return
} }
if otime, ok = this.module.modelActivity.getopentime(req.Atype); !ok { if activity, ok = this.module.modelActivity.getopentime(req.Atype); !ok {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_WarorderNoOpen, Code: pb.ErrorCode_WarorderNoOpen,
Title: pb.ErrorCode_WarorderNoOpen.ToString(), Title: pb.ErrorCode_WarorderNoOpen.ToString(),
@ -54,8 +54,8 @@ func (this *apiComp) GetActivity(session comm.IUserSession, req *pb.PayGetActivi
activitys.Activitys[req.Atype] = info activitys.Activitys[req.Atype] = info
} }
if info.Opentime != otime { if info.Opentime != activity.Stime {
info.Opentime = otime info.Opentime = activity.Stime
for _, v := range info.Items { for _, v := range info.Items {
if conf, err = this.module.configure.getPayGiftpackeData(v.Id); err != nil { if conf, err = this.module.configure.getPayGiftpackeData(v.Id); err != nil {

View File

@ -21,7 +21,7 @@ type modelActivityComp struct {
modules.MCompModel modules.MCompModel
module *Pay module *Pay
lock sync.RWMutex 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 this.TableName = comm.TableActivityGiftbag
//创建uid索引 //创建uid索引
this.lock.Lock() this.lock.Lock()
this.opentime = make(map[int32]int64) this.opentime = make(map[int32]*pb.DBHuodong)
this.lock.Unlock() this.lock.Unlock()
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
}) })
return 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() this.lock.RLock()
otime, open = this.opentime[wtype] activity, open = this.opentime[wtype]
this.lock.RUnlock() this.lock.RUnlock()
return return
} }
func (this *modelActivityComp) setopentime(wtype int32, opentime int64) { func (this *modelActivityComp) setopentime(wtype int32, activity *pb.DBHuodong) {
this.lock.RLock() this.lock.RLock()
this.opentime[wtype] = opentime this.opentime[wtype] = activity
this.lock.RUnlock() this.lock.RUnlock()
return return
} }

View File

@ -271,11 +271,10 @@ func (this *Pay) ModulePayDelivery(session comm.IUserSession, Productid string,
return return
} }
// 开启活动礼包
func (this *Pay) OpenActivity(atype int32, opentime int64) {
this.modelActivity.setopentime(atype, opentime)
}
func (this *Pay) ActivityNotice(hdlist *pb.DBHuodong) { func (this *Pay) ActivityNotice(hdlist *pb.DBHuodong) {
switch hdlist.Itype {
case comm.HdTypePay:
this.modelActivity.setopentime(1, hdlist)
break
}
} }

View File

@ -17,7 +17,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e
var ( var (
warorders *pb.DBWarorders warorders *pb.DBWarorders
info *pb.Warorder info *pb.Warorder
otime int64 activity *pb.DBHuodong
err error err error
ok bool ok bool
) )
@ -33,7 +33,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e
return return
} }
if otime, ok = this.module.modelWarorder.getopentime(req.Rtype); !ok { if activity, ok = this.module.modelWarorder.getopentime(req.Rtype); !ok {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_WarorderNoOpen, Code: pb.ErrorCode_WarorderNoOpen,
Title: pb.ErrorCode_WarorderNoOpen.ToString(), 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 warorders.Items[req.Rtype] = info
} }
if info.Opentime != otime { if info.Opentime != activity.Stime {
info.Opentime = otime info.Opentime = activity.Stime
info.Endtime = activity.Etime
info.Freeprogress = 0 info.Freeprogress = 0
info.Payprogress = 0 info.Payprogress = 0
if err = this.module.modelWarorder.updateUserWarorders(session.GetUserId(), warorders); err != nil { if err = this.module.modelWarorder.updateUserWarorders(session.GetUserId(), warorders); err != nil {

View File

@ -18,7 +18,7 @@ type modelWarorder struct {
modules.MCompModel modules.MCompModel
module *Warorder module *Warorder
lock sync.RWMutex 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) { 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.TableName = comm.TableWarorder
this.module = module.(*Warorder) this.module = module.(*Warorder)
this.lock.Lock() this.lock.Lock()
this.opentime = make(map[int32]int64) this.opentime = make(map[int32]*pb.DBHuodong)
this.lock.Unlock() this.lock.Unlock()
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, 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 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() this.lock.RLock()
otime, open = this.opentime[wtype] activity, open = this.opentime[wtype]
this.lock.RUnlock() this.lock.RUnlock()
return return
} }
func (this *modelWarorder) setopentime(wtype int32, opentime int64) { func (this *modelWarorder) setopentime(wtype int32, activity *pb.DBHuodong) {
this.lock.RLock() this.lock.RLock()
this.opentime[wtype] = opentime this.opentime[wtype] = activity
this.lock.RUnlock() this.lock.RUnlock()
return return
} }

View File

@ -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) { func (this *Warorder) ActivityNotice(hdlist *pb.DBHuodong) {
switch hdlist.Itype {
case comm.HdTypeWarorder:
this.modelWarorder.setopentime(2, hdlist)
break
}
} }

View File

@ -91,9 +91,10 @@ type Warorder struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Opentime int64 `protobuf:"varint,1,opt,name=opentime,proto3" json:"opentime"` Opentime int64 `protobuf:"varint,1,opt,name=opentime,proto3" json:"opentime"`
Freeprogress int32 `protobuf:"varint,2,opt,name=freeprogress,proto3" json:"freeprogress"` //已领取天数 Endtime int64 `protobuf:"varint,2,opt,name=endtime,proto3" json:"endtime"`
Payprogress int32 `protobuf:"varint,3,opt,name=payprogress,proto3" json:"payprogress"` Freeprogress int32 `protobuf:"varint,3,opt,name=freeprogress,proto3" json:"freeprogress"` //已领取天数
Vip bool `protobuf:"varint,4,opt,name=vip,proto3" json:"vip"` 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() { func (x *Warorder) Reset() {
@ -135,6 +136,13 @@ func (x *Warorder) GetOpentime() int64 {
return 0 return 0
} }
func (x *Warorder) GetEndtime() int64 {
if x != nil {
return x.Endtime
}
return 0
}
func (x *Warorder) GetFreeprogress() int32 { func (x *Warorder) GetFreeprogress() int32 {
if x != nil { if x != nil {
return x.Freeprogress 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, 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, 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, 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, 0x38, 0x01, 0x22, 0x98, 0x01, 0x0a, 0x08, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12,
0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x52, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x72, 0x03, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65,
0x65, 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x6e,
0x52, 0x0c, 0x66, 0x72, 0x65, 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x72, 0x65, 0x65, 0x70, 0x72, 0x6f,
0x0a, 0x0b, 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x66, 0x72, 0x65,
0x01, 0x28, 0x05, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x61, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x76, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b,
0x69, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x76,
0x6f, 0x33, 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 ( var (