86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
package addrecharge
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
/*
|
|
累计充值
|
|
*/
|
|
type AddRecharge struct {
|
|
modules.ModuleBase
|
|
service core.IService
|
|
api *apiComp
|
|
configure *configureComp
|
|
modelRecharge *ModelRecharge
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &AddRecharge{}
|
|
}
|
|
|
|
func (this *AddRecharge) GetType() core.M_Modules {
|
|
return comm.ModuleAddrecharge
|
|
}
|
|
|
|
func (this *AddRecharge) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
if err = this.ModuleBase.Init(service, module, options); err != nil {
|
|
return
|
|
}
|
|
this.service = service
|
|
return
|
|
}
|
|
|
|
func (this *AddRecharge) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (this *AddRecharge) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelRecharge = this.RegisterComp(new(ModelRecharge)).(*ModelRecharge)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
// 活动开启
|
|
func (this *AddRecharge) ActivityOpenNotice(hdlist *pb.DBHuodong) {
|
|
switch hdlist.Itype {
|
|
case pb.HdType_AddUpRecharge:
|
|
this.modelRecharge.setopen()
|
|
break
|
|
}
|
|
}
|
|
|
|
// 活动关闭
|
|
func (this *AddRecharge) ActivityCloseNotice(hdlist *pb.DBHuodong) {
|
|
|
|
}
|
|
|
|
// 充值金额
|
|
func (this *AddRecharge) RechargeIntegral(session comm.IUserSession, integral int32) {
|
|
var (
|
|
open bool
|
|
info *pb.DBAddRecharge
|
|
err error
|
|
)
|
|
open = this.modelRecharge.getopen()
|
|
if !open {
|
|
return
|
|
}
|
|
if info, err = this.modelRecharge.getUserDTasks(session.GetUserId()); err != nil {
|
|
this.Errorln(err)
|
|
return
|
|
}
|
|
info.Integral += integral
|
|
this.modelRecharge.Change(session.GetUserId(), map[string]interface{}{
|
|
"integral": info.Integral,
|
|
})
|
|
}
|