go_dreamfactory/modules/pay/configure.go
2023-11-22 16:10:54 +08:00

168 lines
4.3 KiB
Go

package pay
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
game_recharge = "game_recharge.json"
game_rechargediamond = "game_rechargediamond.json"
game_paypackage = "game_paypackage.json"
game_paygiftpack = "game_paygiftpack.json"
)
// /背包配置管理组件
type configureComp struct {
modules.MCompConfigure
module *Pay
}
// 组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Pay)
this.LoadConfigure(game_recharge, cfg.NewGameRecharge)
this.LoadConfigure(game_rechargediamond, cfg.NewGameRechargeDiamond)
this.LoadConfigure(game_paypackage, cfg.NewGamePayPackage)
this.LoadConfigure(game_paygiftpack, cfg.NewGamePayGiftpack)
return
}
// 获取手动加入频道 任务限制
func (this *configureComp) getGameRecharge(id string) (result *cfg.GameRechargeData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_recharge); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if result, ok = v.(*cfg.GameRecharge).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_recharge, id)
this.module.Errorln(err)
return
}
}
return
}
// 获取手动加入频道 任务限制
func (this *configureComp) getPayPackageDatas(ptype int32) (result []*cfg.GamePayPackageData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_paypackage); err != nil {
this.module.Errorln(err)
return
} else {
result = make([]*cfg.GamePayPackageData, 0)
for _, v := range v.(*cfg.GamePayPackage).GetDataList() {
if v.Type == ptype {
result = append(result, v)
}
}
}
return
}
// 获取手动加入频道 任务限制
func (this *configureComp) getPayPackageData(id int32) (result *cfg.GamePayPackageData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_paypackage); err != nil {
this.module.Errorln(err)
return
} else {
if result, ok = v.(*cfg.GamePayPackage).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_paypackage, id)
this.module.Errorln(err)
return
}
}
return
}
// 获取手动加入频道 任务限制
func (this *configureComp) getPayPackageDataByPid(pid int32) (result *cfg.GamePayPackageData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_paypackage); err != nil {
this.module.Errorln(err)
return
} else {
for _, v := range v.(*cfg.GamePayPackage).GetDataMap() {
if v.Id == pid {
result = v
return
}
}
}
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_paypackage, pid)
return
}
// 获取手动加入频道 任务限制
func (this *configureComp) getPayGiftpackeData(id int32) (result *cfg.GamePayGiftpackData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_paygiftpack); err != nil {
this.module.Errorln(err)
return
} else {
if result, ok = v.(*cfg.GamePayGiftpack).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_paygiftpack, id)
this.module.Errorln(err)
return
}
}
return
}
// 獲取
func (this *configureComp) getPayGiftpackDataByPid(pid int32) (result *cfg.GamePayGiftpackData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_paygiftpack); err != nil {
this.module.Errorln(err)
return
} else {
for _, v := range v.(*cfg.GamePayGiftpack).GetDataMap() {
if v.Id == pid {
result = v
return
}
}
}
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_paygiftpack, pid)
return
}
// 獲取
func (this *configureComp) getGameRechargeDiamond(pid int32) (conf *cfg.GameRechargeDiamondData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_rechargediamond); err != nil {
this.module.Errorln(err)
return
} else {
if conf, ok = v.(*cfg.GameRechargeDiamond).GetDataMap()[pid]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_rechargediamond, pid)
this.module.Errorln(err)
return
}
}
return
}