package model import ( "encoding/json" "github.com/codinl/go-logger" ) //go:generate goqueryset -in config.go // gen:qs type Config struct { Model Name string `gorm:"unique_index;not null"` Value string `gorm:"size:65535;not null"` } func (m *Config) TableName() string { return "config" } type PayConfig struct { MemberFee uint32 `json:"member_fee"` DepositFee uint32 `json:"deposit_fee"` NotifyUrl string `json:"notify_url"` } const ( ConfigNamePay = "pay_config" // 支付配置 ) func PayConfigInfo() (*PayConfig, error) { payConfig := new(PayConfig) var configAllocation Config err := NewConfigQuerySet(DB).NameEq(ConfigNamePay).One(&configAllocation) if err != nil { logger.Error("err:", err) return payConfig, err } err = json.Unmarshal([]byte(configAllocation.Value), payConfig) if err != nil { logger.Error("err:", err) return payConfig, err } return payConfig, nil } // //type ConfigInterface interface { // Encode() string //} // //type CheckConfig struct { // Check uint8 `json:"check"` //} // //func (c *CheckConfig) Encode() string { // configBytes, err := json.Marshal(c) // if err != nil { // return "" // } // return string(configBytes) //} // //type AutoChargeMobileConfig struct { // IsOpen uint8 `json:"is_open"` //} // //func (c *AutoChargeMobileConfig) Encode() string { // configBytes, err := json.Marshal(c) // if err != nil { // return "" // } // return string(configBytes) //} // //type StepConfig struct { // InitStep uint32 `json:"init_step"` // InviteStepAward uint32 `json:"invite_step_award"` // StepDayLimit uint32 `json:"step_day_limit"` // StepToVmRate float64 `json:"step_to_vm_rate"` // InviteAwardRate float64 `json:"invite_award_rate"` // InviteAwardRateLimit float64 `json:"invite_award_rate_limit"` // SuperMemberRm uint32 `json:"super_member_rm"` //} // //func (c *StepConfig) Encode() string { // configBytes, err := json.Marshal(c) // if err != nil { // return "" // } // return string(configBytes) //} // ////type FBConfig struct { //// AssistanceValidityTerm uint32 `json:"assistance_validity_term"` // 邀请倒计时 //// Postage uint32 `json:"postage"` // 邮费 //// AssistanceFee uint32 `json:"assistance_fee"` // 每人拆红包 //// OrderAssistanceFee uint32 `json:"order_assistance_fee"` // 订单邀请拆红包 //// ActivityExpire string `json:"activity_expire"` // 活动过期时间 ////} //// ////type FOConfig struct { //// ActivityExpire string `json:"activity_expire"` // 活动过期时间 ////} //// ////func (c *FBConfig) Encode() string { //// configBytes, err := json.Marshal(c) //// if err != nil { //// return "" //// } //// return string(configBytes) ////} // //type InviteLotteryConfig struct { // Name string `json:"name"` // 名字 // Image string `json:"image"` // 图片 // DrawTime uint32 `json:"draw_time"` // 开奖的分钟数 // SponsorId uint32 `json:"sponsor_id"` // 赞助商ID // NeedNum uint32 `json:"need_num"` // 需要的邀请数 // IsShow uint8 `json:"is_show"` // 上下架 //} // //func (c *InviteLotteryConfig) Encode() string { // configBytes, err := json.Marshal(c) // if err != nil { // return "" // } // return string(configBytes) //} // ////type TargetUserConfig struct { //// List map[uint32]bool `json:"list"` ////} //// ////func (c *TargetUserConfig) Encode() string { //// configBytes, err := json.Marshal(c) //// if err != nil { //// return "" //// } //// return string(configBytes) ////}