package warorder import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" ) const modulename = "战令" type Warorder struct { modules.ModuleBase service core.IService api *apiComp configure *configureComp model *modelWarorder } func NewModule() core.IModule { return &Warorder{} } func (this *Warorder) GetType() core.M_Modules { return comm.ModuleWarorder } func (this *Warorder) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service return } func (this *Warorder) Start() (err error) { err = this.ModuleBase.Start() return } func (this *Warorder) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.model = this.RegisterComp(new(modelWarorder)).(*modelWarorder) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } // 发货 func (this *Warorder) Delivery(session comm.IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets) { var ( product map[string]int32 //商品id warorders *pb.DBWarorders info *pb.Warorder wtype int32 err error ok bool ) product = this.configure.getproduct() if _, ok = product[pid]; !ok { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.String(), Message: fmt.Sprintf("no found pid:%s", pid), } return } wtype = product[pid] if warorders, err = this.model.getUserWarorders(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } if info, ok = warorders.Warorder[wtype]; !ok { info = &pb.Warorder{ Vip: true, } warorders.Warorder[wtype] = info } info.Vip = true this.model.updateUserWarorders(session.GetUserId(), warorders) return } // 活动开启 func (this *Warorder) ActivityOpenNotice(hdlist *pb.DBHuodong) { switch hdlist.Itype { case pb.HdType_HdTypeWarorder: this.model.setopentime(2, hdlist) break case pb.HdType_SupplyWarOrder: this.model.setopentime(3, hdlist) break case pb.HdType_MoondreamWarOrder: this.model.setopentime(4, hdlist) break } } // 活动关闭 func (this *Warorder) ActivityCloseNotice(hdlist *pb.DBHuodong) { }