diff --git a/bin/marketserver/config/confdb.mysql.json b/bin/marketserver/config/confdb.mysql.json new file mode 100644 index 00000000..c3477c54 --- /dev/null +++ b/bin/marketserver/config/confdb.mysql.json @@ -0,0 +1,9 @@ +{ + "host": "mysql-test.kingsome.cn", + "port": 3306, + "user": "root", + "passwd": "keji178", + "database": "confdb_dev_1", + "max_open_conns": 1, + "max_idle_conns": 1 +} diff --git a/bin/marketserver/config/currencys/97/currency.json b/bin/marketserver/config/currencys/97/currency.json index 00ec2ea5..2cdb2bb2 100644 --- a/bin/marketserver/config/currencys/97/currency.json +++ b/bin/marketserver/config/currencys/97/currency.json @@ -2,11 +2,11 @@ { "currency_name": "USDC", "contract_name": "BEUSDC", - "currency_decimal": 6 + "currency_decimal": 18 }, { "currency_name": "USDT", "contract_name": "BEUSDT", - "currency_decimal": 6 + "currency_decimal": 18 } ] diff --git a/server/adminserver/api/v1/system/block_player.go b/server/adminserver/api/v1/system/block_player.go index 789a8879..f1b1d9cd 100644 --- a/server/adminserver/api/v1/system/block_player.go +++ b/server/adminserver/api/v1/system/block_player.go @@ -132,7 +132,7 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) { blockplayer := new(system.BlockPlayer) db := f5.GetApp().GetOrmDb(constant.CONF_DB) - if err := db.Take(blockplayer, "account_id =?", req.Account).Error; err != nil { + if err := db.Take(blockplayer, "account_id = ? AND deleted = 0", req.Account).Error; err != nil { if !f5.IsOrmErrRecordNotFound(err) { c.JSON(http.StatusOK, gin.H{ "code": 500, @@ -178,7 +178,7 @@ func (bpa *BlockPlayerApi) Del(c *gin.Context) { blockplayer := new(system.BlockPlayer) db := f5.GetApp().GetOrmDb(constant.CONF_DB) - if err := db.Take(blockplayer, "account_id =?", req.Account).Error; err != nil { + if err := db.Take(blockplayer, "account_id = ? AND deleted = 0", req.Account).Error; err != nil { if !f5.IsOrmErrRecordNotFound(err) { c.JSON(http.StatusOK, gin.H{ "code": 500, diff --git a/server/adminserver/api/v1/system/player.go b/server/adminserver/api/v1/system/player.go index 70004ebe..67e954c9 100644 --- a/server/adminserver/api/v1/system/player.go +++ b/server/adminserver/api/v1/system/player.go @@ -136,6 +136,14 @@ func (pai *PlayerApi) BagQuery(c *gin.Context) { return } + if len(reqJson.Account_id) > 0xFF { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": "输入过长", + }) + return + } + cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) filterstr := " account_id = '" + reqJson.Account_id + "' " sql := fmt.Sprintf(`SELECT * FROM t_bag WHERE idx > %d AND %s `, cursor, filterstr) @@ -157,6 +165,14 @@ func (pai *PlayerApi) HeroesQuery(c *gin.Context) { return } + if len(reqJson.Account_id) > 0xFF { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": "输入过长", + }) + return + } + cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) filterstr := " account_id = '" + reqJson.Account_id + "' " sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr) @@ -264,3 +280,36 @@ func (pai *PlayerApi) GameMallQuery(c *gin.Context) { return p }) } + +func (pai *PlayerApi) RechargeQuery(c *gin.Context) { + type RechargeQueryForm struct { + Identity string `binding:"required" json:"identity"` + } + + reqJson := RechargeQueryForm{} + if !checkparam(&reqJson, c) { + return + } + + if len(reqJson.Identity) > 0xFF { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": "输入过长", + }) + return + } + + cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) + filterstr := + " (receiver_account_id = '" + reqJson.Identity + + "' OR account_address = '" + reqJson.Identity + + "' OR passport_address = '" + reqJson.Identity + + "' OR lower_case_email = '" + reqJson.Identity + "')" + sql := fmt.Sprintf(`SELECT * FROM t_recharge_order WHERE idx > %d AND %s `, cursor, filterstr) + + query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { + p := new(system.RechargeOrder) + f5.UnmarshalModel(ds, p) + return p + }) +} diff --git a/server/adminserver/api/v1/system/whitelist.go b/server/adminserver/api/v1/system/whitelist.go index 890a08ee..b45fa2f1 100644 --- a/server/adminserver/api/v1/system/whitelist.go +++ b/server/adminserver/api/v1/system/whitelist.go @@ -207,8 +207,8 @@ func (bpa *WhiteListApi) Del(c *gin.Context) { } else { if whiteListItem.Deleted == 1 { c.JSON(http.StatusOK, gin.H{ - "code": 0, - "message": "", + "code": 2, + "message": "无法查到记录", }) return diff --git a/server/adminserver/model/system/rechargeorder.go b/server/adminserver/model/system/rechargeorder.go new file mode 100644 index 00000000..adcb6267 --- /dev/null +++ b/server/adminserver/model/system/rechargeorder.go @@ -0,0 +1,31 @@ +package system + +type RechargeOrder struct { + Idx int64 `gorm:"column:idx" json:"idx"` + Order_id string `gorm:"column:order_id;comment:订单id" json:"order_id"` + Short_Order_id string `gorm:"column:short_order_id;comment:短订单id" json:"short_order_id"` + Account_address string `gorm:"column:account_address;comment:钱包地址" json:"account_address"` + Passport_address string `gorm:"column:passport_address;comment:passport地址" json:"passport_address"` + Currency_address string `gorm:"column:currency_address;comment:货币地址" json:"currency_address"` + Currency_name string `gorm:"column:currency_name;comment:货币名称" json:"currency_name"` + Item_id int `gorm:"column:item_id;comment:item_id" json:"item_id"` + Item_num int64 `gorm:"column:item_num;comment:item_num" json:"item_num"` + Price string `gorm:"column:price;comment:price" json:"price"` + Createtime int `gorm:"column:createtime;comment:创建时间" json:"createtime"` + Modifytime int `gorm:"column:modifytime;comment:修改时间" json:"modifytime"` + Diamond float64 `gorm:"column:diamond;comment:diamond" json:"diamond"` + Pay_status int `gorm:"column:pay_status;comment:0:支付中 1:支付成功" json:"pay_status"` + Pay_time int `gorm:"column:pay_time;comment:支付成功时间" json:"pay_time"` + Delivery_status int `gorm:"column:delivery_status;comment:0:未发货 1:发货成功" json:"delivery_status"` + Delivery_time int `gorm:"column:delivery_time;comment:发货成功时间" json:"delivery_time"` + Receiver_account_id string `gorm:"column:receiver_account_id;comment:收货人account_id" json:"receiver_account_id"` + Net_id int64 `gorm:"column:net_id;comment:net_id" json:"net_id"` + Txhash string `gorm:"column:txhash;comment:txhash" json:"txhash"` + Lower_case_email string `gorm:"column:lower_case_email;comment:lower_case_email" json:"lower_case_email"` + Present_diamond float64 `gorm:"column:present_diamond;comment:充值赠送钻石" json:"present_diamond"` + Return_contribution float64 `gorm:"column:return_contribution;comment:return_contribution" json:"return_contribution"` +} + +func (this *RechargeOrder) TableName() string { + return "t_recharge_rder" +} diff --git a/server/adminserver/router/system/sys_player.go b/server/adminserver/router/system/sys_player.go index aa5f74bc..8ec419ef 100644 --- a/server/adminserver/router/system/sys_player.go +++ b/server/adminserver/router/system/sys_player.go @@ -19,5 +19,6 @@ func (pr *PlayerRouter) InitPlayerRouter(priRouter *gin.RouterGroup) { group.POST("goldbullionquery", middleware.Permission("api/v1/player/goldbullionquery", api.GoldBullionQuery)) group.POST("ticketconsumequery", middleware.Permission("api/v1/player/ticketconsumequery", api.TicketConsumeQuery)) group.POST("gamemallquery", middleware.Permission("api/v1/player/gamemallquery", api.GameMallQuery)) + group.POST("rechargequery", middleware.Permission("api/v1/player/rechargequery", api.RechargeQuery)) } } diff --git a/server/jccommon/constant.go b/server/jccommon/constant.go index 4f762121..f11725e9 100644 --- a/server/jccommon/constant.go +++ b/server/jccommon/constant.go @@ -40,6 +40,7 @@ const ( MAIL_TAG1_CUSTOM = 10 MAIL_TAG1_HERO = 100 MAIL_TAG1_GOLD_BULLION = 101 + MAIL_TAG1_OLD_USER = 102 ) const ( @@ -53,6 +54,8 @@ const ( MAIL_TAG2_GOLD_BULLION_LOCK = 2 MAIL_TAG2_GOLD_BULLION_UNLOCK = 3 MAIL_TAG2_GOLD_BULLION_RETURN = 4 + + MAIL_TAG2_OLD_USER = 1 ) const ( diff --git a/server/light_backtask/task/olduser.go b/server/light_backtask/task/olduser.go new file mode 100644 index 00000000..056ae223 --- /dev/null +++ b/server/light_backtask/task/olduser.go @@ -0,0 +1,95 @@ +package task + +import ( + "q5" + "f5" + "main/constant" + "encoding/json" + "fmt" + "jccommon" +) + +type oldUser struct { + +} + +func (this *oldUser) init() { + oldUsers := []struct { + Idx int32 `json:"idx"` + AccountId string `json:"account_id"` + Diamond int32 `json:"diamond"` + }{} + { + if jsonStr, err := f5.ReadJsonFile("/home/kingsome/pub/game2006web3/server/web3tools/1.json"); err == nil { + if err := json.Unmarshal([]byte(jsonStr), &oldUsers); err != nil { + panic(fmt.Sprintf("load oldUser json decode error %s %s", "nets.json", err)) + } + } else { + panic(fmt.Sprintf("load oldUser error %s %s", "nets.json", err)) + } + } + type AttachmentDto struct { + ItemId int32 `json:"itemid"` + ItemNum int32 `json:"itemnum"` + } + //fmt.Println("%s", oldUsers) + for _, user := range oldUsers { + if user.Idx <= 0 { + panic("") + } + if user.AccountId == "" { + panic("") + } + if user.Diamond <= 0 { + panic("") + } + mailId := q5.ToString(f5.GetApp().NewLockNodeUuid()) + unikey := "oldUser.return.20240823:" + user.AccountId + subject := "Claim Your Diamonds" + content := "Thanks for participating in P2E S1! The gold you earned in Gold Mode has been converted to diamonds at a 1:1 ratio. Click “Claim” to receive your rewards now." + nowTime := f5.GetApp().GetRealSeconds() + sendTime := f5.GetApp().GetRealSeconds() + expireTime := nowTime + 3600 * 24 * 15 + userRegEndTime := nowTime + 3600 * 24 * 365 + f5.GetGoStyleDb().Upsert( + constant.BCNFT_DB, + "t_mail", + [][]string{ + {"unikey", unikey}, + }, + [][]string{ + }, + [][]string{ + {"mail_id", mailId}, + {"mail_type", q5.ToString(jccommon.MAIL_TYPE_GROUP)}, + {"unikey", unikey}, + {"subject", subject}, + {"content", content}, + {"recipients", q5.EncodeJson([]string{ + user.AccountId, + })}, + {"attachments", q5.EncodeJson([]AttachmentDto{ + AttachmentDto{ + ItemId : 10014, + ItemNum : user.Diamond}, + })}, + {"sendtime", q5.ToString(sendTime)}, + {"user_reg_start_time", q5.ToString(0)}, + {"user_reg_end_time", q5.ToString(userRegEndTime)}, + {"tag1", q5.ToString(jccommon.MAIL_TAG1_OLD_USER)}, + {"tag2", q5.ToString(jccommon.MAIL_TAG2_OLD_USER)}, + {"expiretime", q5.ToString(expireTime)}, + {"createtime", q5.ToString(nowTime)}, + {"modifytime", q5.ToString(nowTime)}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + if err != nil { + panic("") + } + }) + } +} + +func (this *oldUser) unInit() { + +} diff --git a/server/light_backtask/task/taskmgr.go b/server/light_backtask/task/taskmgr.go index 42cb72d1..aa00ce33 100644 --- a/server/light_backtask/task/taskmgr.go +++ b/server/light_backtask/task/taskmgr.go @@ -9,7 +9,7 @@ type taskMgr struct { sysMail repairOrder refreshMeta - contribution + //contribution chainActivity recharge } @@ -20,7 +20,7 @@ func (this *taskMgr) Init() { this.sysMail.init() this.repairOrder.init() //this.refreshMeta.init() - this.contribution.init() + //this.contribution.init() this.chainActivity.init() this.recharge.init() } @@ -28,7 +28,7 @@ func (this *taskMgr) Init() { func (this *taskMgr) UnInit() { this.recharge.unInit() this.chainActivity.unInit() - this.contribution.unInit() + //this.contribution.unInit() //this.refreshMeta.unInit() this.repairOrder.unInit() this.sysMail.unInit() diff --git a/server/mailserver/mail/mailmgr.go b/server/mailserver/mail/mailmgr.go index 45d3ad5f..492c6e64 100644 --- a/server/mailserver/mail/mailmgr.go +++ b/server/mailserver/mail/mailmgr.go @@ -134,6 +134,7 @@ func (this *mailMgr) CaGetMailList(c *gin.Context) { this.traversePlayerMail( hum, func (m *mail) bool { + f5.GetSysLog().Info("getMailList mail_id:%s", m.mailId) if m.IsValid(hum) { if hum.IsReadable(m) { mailDto := new(common.MailDto) diff --git a/server/mailserver/player/player.go b/server/mailserver/player/player.go index 508d8226..7e03f2d3 100644 --- a/server/mailserver/player/player.go +++ b/server/mailserver/player/player.go @@ -240,6 +240,7 @@ func (this *player) load() { p.state = q5.ToInt32(ds.GetByName("state")) p.expireTime = q5.ToInt32(ds.GetByName("expiretime")) this.inboxHash[p.mailId] = p + f5.GetSysLog().Info("load mail mail_id:%s", p.mailId) } this.loaded = true }) diff --git a/server/marketserver/api/v1/activity/contribution.go b/server/marketserver/api/v1/activity/contribution.go index 8c7c7c37..d78f8560 100644 --- a/server/marketserver/api/v1/activity/contribution.go +++ b/server/marketserver/api/v1/activity/contribution.go @@ -17,10 +17,7 @@ type ContriApi struct { func (cta *ContriApi) HistoryQuery(c *gin.Context) { account := strings.ToLower(c.Param("account_address")) if account == "" { - c.JSON(200, gin.H{ - "errcode": 1, - "errmsg": "", - }) + f5.RspErr(c, 2, "empty account") return } @@ -63,24 +60,26 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) { { loweremail, accountid := service.Contribution.GetEmailAccountId(account) - sql := `SELECT * FROM t_contribution_history WHERE idx > 0 AND account_id = ?` - f5.GetGoStyleDb().RawQuery( - constant.GAME_DB, - sql, - []string{accountid}, - func(err error, ds *f5.DataSet) { - if err != nil { - return - } + if accountid != "" { + sql = `SELECT * FROM t_contribution_history WHERE idx > 0 AND account_id = ?` + f5.GetGoStyleDb().RawQuery( + constant.GAME_DB, + sql, + []string{accountid}, + func(err error, ds *f5.DataSet) { + if err != nil { + return + } - for ds.Next() { - p := new(info) - p.Type = 2 - p.Time = q5.SafeToInt32(ds.GetByName("createtime")) - p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("contribution"))) - q5.AppendSlice(&rspObj.Rows, p) - } - }) + for ds.Next() { + p := new(info) + p.Type = 2 + p.Time = q5.SafeToInt32(ds.GetByName("createtime")) + p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("contribution"))) + q5.AppendSlice(&rspObj.Rows, p) + } + }) + } sql = `SELECT * FROM t_recharge_return_contribution WHERE idx > 0 AND user_identity IN (?` @@ -121,10 +120,7 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) { func (cta *ContriApi) CECQuery(c *gin.Context) { account := strings.ToLower(c.Param("account_address")) if account == "" { - c.JSON(200, gin.H{ - "errcode": 1, - "errmsg": "", - }) + f5.RspErr(c, 2, "empty account") return } @@ -140,8 +136,8 @@ func (cta *ContriApi) CECQuery(c *gin.Context) { } `json:"info"` }{} - totalgcp, _ := service.Contribution.GetGlobalContribution(false) mycp, _ := service.Contribution.GetAddressContribution(account, false) + totalgcp, _ := service.Contribution.GetGlobalContribution(false) rspObj.CP = fmt.Sprintf("%.2f", mycp) rspObj.Info.MyCP = rspObj.CP rspObj.Info.GCP = fmt.Sprintf("%.2f", totalgcp) diff --git a/server/marketserver/api/v1/activity/stacking.go b/server/marketserver/api/v1/activity/stacking.go index a78a3376..24d28888 100644 --- a/server/marketserver/api/v1/activity/stacking.go +++ b/server/marketserver/api/v1/activity/stacking.go @@ -132,6 +132,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { Date int32 `json:"date"` Amount string `json:"amount"` Type int32 `json:"type"` + From string `json:"from"` } rspObj := struct { ErrCode int32 `json:"errcode"` @@ -140,7 +141,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { }{} { - sql := `SELECT * FROM t_diamond_consume_product WHERE account_id = ? OR passport_address = ? ORDER BY createtime DESC` + sql := `SELECT * FROM t_diamond_consume_product WHERE idx > 0 AND (account_id = ? OR passport_address = ?)` params := []string{ accountAddress, accountAddress, @@ -161,13 +162,14 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { obj.Date = q5.SafeToInt32(ds.GetByName("createtime")) obj.Amount = ds.GetByName("amount") obj.Type = 1 + obj.From = accountAddress rspObj.Rows = append(rspObj.Rows, obj) } }) } { - sql := `SELECT pay_time, diamond + present_diamond FROM t_recharge_order WHERE passport_address = ? AND pay_status = 1 ORDER BY createtime DESC` + sql := `SELECT pay_time, diamond + present_diamond, account_address FROM t_recharge_order WHERE idx > 0 AND passport_address = ? AND pay_status = 1` params := []string{ accountAddress, } @@ -186,6 +188,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { obj.Date = q5.SafeToInt32(ds.GetByName("pay_time")) obj.Amount = ds.GetByIndex(1) + obj.From = ds.GetByIndex(2) obj.Type = 0 rspObj.Rows = append(rspObj.Rows, obj) } diff --git a/server/marketserver/api/v1/enter.go b/server/marketserver/api/v1/enter.go index 47db03d5..272c7207 100644 --- a/server/marketserver/api/v1/enter.go +++ b/server/marketserver/api/v1/enter.go @@ -4,6 +4,7 @@ import ( "main/api/v1/activity" "main/api/v1/asset" "main/api/v1/event" + "main/api/v1/game_switch" "main/api/v1/gold_bullion" "main/api/v1/hero" "main/api/v1/ingame" @@ -26,6 +27,7 @@ type ApiGroup struct { ActivityApiGroup activity.ApiGroup EventApiGroup event.ApiGroup RechargeApiGroup recharge.ApiGroup + SwitchApiGroup game_switch.ApiGroup } var ApiGroupApp = new(ApiGroup) diff --git a/server/marketserver/api/v1/game_switch/enter.go b/server/marketserver/api/v1/game_switch/enter.go new file mode 100644 index 00000000..0cac7f13 --- /dev/null +++ b/server/marketserver/api/v1/game_switch/enter.go @@ -0,0 +1,5 @@ +package game_switch + +type ApiGroup struct { + GameSwitchApi +} diff --git a/server/marketserver/api/v1/game_switch/gswitch.go b/server/marketserver/api/v1/game_switch/gswitch.go new file mode 100644 index 00000000..31c6a0ee --- /dev/null +++ b/server/marketserver/api/v1/game_switch/gswitch.go @@ -0,0 +1,23 @@ +package game_switch + +import ( + "main/service" + "net/http" + + "github.com/gin-gonic/gin" +) + +type GameSwitchApi struct { + data map[string]int32 + time int64 +} + +func (this *GameSwitchApi) List(c *gin.Context) { + + c.JSON(http.StatusOK, gin.H{ + "code": 0, + "message": "获取成功", + "contributionPoint": "", + "data": service.GameSwitches.GetSwitchList(), + }) +} diff --git a/server/marketserver/api/v1/ingame/ingame.go b/server/marketserver/api/v1/ingame/ingame.go index 90ffd446..0c2cf05b 100644 --- a/server/marketserver/api/v1/ingame/ingame.go +++ b/server/marketserver/api/v1/ingame/ingame.go @@ -1,33 +1,34 @@ package ingame import ( - "q5" "f5" - "main/mt" "main/common" "main/constant" . "main/global" + "main/mt" + "marketserver/service" + "q5" + "github.com/gin-gonic/gin" ) type InGameApi struct { - } func (this *InGameApi) HeroList(c *gin.Context) { reqJson := struct { PageSize interface{} `json:"page_size"` - Cursor interface{} `json:"cursor"` - Search struct { + Cursor interface{} `json:"cursor"` + Search struct { Name string `json:"name"` } `json:"search"` Filter struct { - ItemIds []interface{} `json:"item_ids"` + ItemIds []interface{} `json:"item_ids"` HeroRanks []interface{} `json:"hero_ranks"` } `json:"filter"` Sort struct { - Fields [] struct { - Name string `json:"name"` + Fields []struct { + Name string `json:"name"` Type interface{} `json:"type"` } `json:"fields"` } `json:"sort"` @@ -45,10 +46,10 @@ func (this *InGameApi) HeroList(c *gin.Context) { } rspObj := struct { - ErrCode int32 `json:"errcode"` - ErrMsg string `json:"errmsg"` - Page common.StreamPagination `json:"page"` - Rows [] interface{} `json:"rows"` + ErrCode int32 `json:"errcode"` + ErrMsg string `json:"errmsg"` + Page common.StreamPagination `json:"page"` + Rows []interface{} `json:"rows"` }{} q5.NewSlice(&rspObj.Rows, 0, 10) @@ -56,26 +57,31 @@ func (this *InGameApi) HeroList(c *gin.Context) { heroList, q5.SafeToInt32(reqJson.PageSize), q5.SafeToInt64(reqJson.Cursor), - func (kv interface{}) bool { + func(kv interface{}) bool { return true }, - func (a interface{}, b interface{}) bool { + func(a interface{}, b interface{}) bool { return true }, - func (p *f5.StreamPagination) { + func(p *f5.StreamPagination) { rspObj.Page.FillPage(p) }, - func (kv interface{}) { + func(kv interface{}) { q5.AppendSlice(&rspObj.Rows, kv) }) c.JSON(200, rspObj) } func (this *InGameApi) HeroMint(c *gin.Context) { + if service.GameSwitches.CheckSwitch(constant.GAME_SWITCH_HERO_MINT) == 0 { + f5.RspErr(c, 404, "unavailable request") + return + } + reqJson := struct { - NetId interface{} `json:"net_id"` - To string `json:"to"` - HeroUniIds []string `json:"hero_uniids"` + NetId interface{} `json:"net_id"` + To string `json:"to"` + HeroUniIds []string `json:"hero_uniids"` }{} if err := c.ShouldBindJSON(&reqJson); err != nil { f5.RspErr(c, 401, "params parse error") @@ -99,29 +105,28 @@ func (this *InGameApi) HeroMint(c *gin.Context) { {"account_id", accountId}, {"idx", uniid}, }, - func (err error, ds *f5.DataSet) { + func(err error, ds *f5.DataSet) { if err != nil { f5.RspErr(c, 500, "server internal error") return } if ds.Next() { params := map[string]string{ - "c": "OutAppMint", - "a": "mintHero", - "account_id": accountId, + "c": "OutAppMint", + "a": "mintHero", + "account_id": accountId, "account_address": accountAddress, - "to_address": reqJson.To, - "uniid": uniid, + "to_address": reqJson.To, + "uniid": uniid, } rspObj := &struct { - ErrCode interface{} `json:"errcode"` - ErrMsg string `json:"errmsg"` - TransId string `json:"trans_id"` + ErrCode interface{} `json:"errcode"` + ErrMsg string `json:"errmsg"` + TransId string `json:"trans_id"` TransReq interface{} `json:"trans_req"` - }{ - } + }{} f5.GetHttpCliMgr().SendGoStyleRequest( - mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", + mt.Table.Config.GetGameApiUrl()+"/webapp/index.php", params, func(rsp f5.HttpCliResponse) { if rsp.GetErr() != nil { @@ -146,10 +151,15 @@ func (this *InGameApi) HeroMint(c *gin.Context) { } func (this *InGameApi) newHeroMint(c *gin.Context) { + if service.GameSwitches.CheckSwitch(constant.GAME_SWITCH_HERO_MINT) == 0 { + f5.RspErr(c, 404, "unavailable request") + return + } + reqJson := struct { - NetId interface{} `json:"net_id"` - To string `json:"to"` - HeroUniIds []string `json:"hero_uniids"` + NetId interface{} `json:"net_id"` + To string `json:"to"` + HeroUniIds []string `json:"hero_uniids"` }{} if err := c.ShouldBindJSON(&reqJson); err != nil { f5.RspErr(c, 401, "params parse error") @@ -173,29 +183,28 @@ func (this *InGameApi) newHeroMint(c *gin.Context) { {"account_id", accountId}, {"idx", uniid}, }, - func (err error, ds *f5.DataSet) { + func(err error, ds *f5.DataSet) { if err != nil { f5.RspErr(c, 500, "server internal error") return } if ds.Next() { params := map[string]string{ - "c": "OutAppMint", - "a": "mintHero", - "account_id": accountId, + "c": "OutAppMint", + "a": "mintHero", + "account_id": accountId, "account_address": accountAddress, - "to_address": reqJson.To, - "uniid": uniid, + "to_address": reqJson.To, + "uniid": uniid, } rspObj := &struct { - ErrCode interface{} `json:"errcode"` - ErrMsg string `json:"errmsg"` - TransId string `json:"trans_id"` + ErrCode interface{} `json:"errcode"` + ErrMsg string `json:"errmsg"` + TransId string `json:"trans_id"` TransReq interface{} `json:"trans_req"` - }{ - } + }{} f5.GetHttpCliMgr().SendGoStyleRequest( - mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", + mt.Table.Config.GetGameApiUrl()+"/webapp/index.php", params, func(rsp f5.HttpCliResponse) { if rsp.GetErr() != nil { diff --git a/server/marketserver/api/v1/nft/nft.go b/server/marketserver/api/v1/nft/nft.go index dfc3aea6..c8b6a435 100644 --- a/server/marketserver/api/v1/nft/nft.go +++ b/server/marketserver/api/v1/nft/nft.go @@ -6,6 +6,7 @@ import ( "main/mt" "jccommon" "main/constant" + "main/service" "strings" "github.com/gin-gonic/gin" ) @@ -67,6 +68,13 @@ func (this *NftApi) Unlock(c *gin.Context) { f5.RspErr(c, 500, "nft not found") return } + if ok, err := service.User.InBlackList(accountAddress); err != nil { + f5.RspErr(c, 500, "server internal error") + return + } else if ok { + f5.RspErr(c, 501, "illegal user") + return + } params := map[string]string{ "c": "BcService", "a": "nftUnlock", diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index 43da1fd6..17ec91ff 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -13,6 +13,7 @@ import ( "q5" "strings" + "math/big" "github.com/gin-gonic/gin" ) @@ -36,7 +37,7 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) { } if contribution, err := service.Contribution.GetAddressContribution(accountAddress, true); err != nil { - f5.RspErr(c, 2, "server internal error") + f5.RspErr(c, 2, err.Error()) return } else { rspObj.Contribution = q5.ToString(contribution) @@ -165,11 +166,25 @@ func (this *RechargeApi) internalBuy(c *gin.Context, } } srcPrice := q5.ToInt64(goodsMeta.GetPrice()) * q5.ToInt64(goodsNum) - price := q5.PowInt64(10, currencyMeta.GetCurrencyDecimal()) * srcPrice - if price <= 0 || price < q5.ToInt64(goodsMeta.GetPrice()) { + bnPrice := big.NewInt(0) + { + var i, e = big.NewInt(10), big.NewInt(currencyMeta.GetCurrencyDecimal()) + i.Exp(i, e, nil) + bnPrice = i.Mul(i, big.NewInt(srcPrice)) + } + f5.GetSysLog().Info("recharge net_id:%d currency_name:%s decimal:%d srcPrice:%d bnPrice:%s", + netId, currencyMeta.GetCurrencyName(), currencyMeta.GetCurrencyDecimal(), srcPrice, bnPrice.String()); + if bnPrice.Cmp(big.NewInt(0)) < 0 || bnPrice.Cmp(big.NewInt(srcPrice)) < 0 { f5.RspErr(c, 3, "server internal error") return } + if ok, err := service.User.InBlackList(accountAddress); err != nil { + f5.RspErr(c, 500, "server internal error") + return + } else if ok { + f5.RspErr(c, 501, "illegal user") + return + } params := map[string]string{ "c": "BcService", "a": "recharge", @@ -177,7 +192,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context, "order_id": orderId, "account_address": accountAddress, "passport_address": passportAddress, - "amount": q5.ToString(price), + "amount": bnPrice.String(), "currency_name": currencyContractMeta.GetName(), "currency_address": currencyContractMeta.GetAddress(), } @@ -216,7 +231,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context, currencyContractMeta.GetAddress(), goodsMeta.GetId(), itemNum, - price, + bnPrice.String(), srcPrice, diamond, presentDiamond, diff --git a/server/marketserver/api/v1/user/user.go b/server/marketserver/api/v1/user/user.go index c73085ae..524b2997 100644 --- a/server/marketserver/api/v1/user/user.go +++ b/server/marketserver/api/v1/user/user.go @@ -26,7 +26,11 @@ func (this *UserApi) Info(c *gin.Context) { Diamond string `json:"diamond"` }{} rspObj.Email = c.MustGet("email").(string) - contributionPoint, _ := service.Contribution.GetAddressContribution(accountAddress, false) + contributionPoint, err := service.Contribution.GetAddressContribution(accountAddress, false) + if err != nil { + f5.RspErr(c, 2, err.Error()) + return + } var gold float64 var diamond float64 { @@ -114,7 +118,7 @@ func (this *UserApi) Info(c *gin.Context) { if err != nil { return } - for ds.Next() { + if ds.Next() { diamond += q5.ToFloat64(ds.GetByIndex(0)) } }) diff --git a/server/marketserver/app/app.go b/server/marketserver/app/app.go index 575be92d..70152d4d 100644 --- a/server/marketserver/app/app.go +++ b/server/marketserver/app/app.go @@ -97,6 +97,17 @@ func (this *app) registerDataSources() { 1, mt.Table.AccountDb.GetById(0).GetMaxOpenConns(), mt.Table.AccountDb.GetById(0).GetMaxIdleConns()) + + f5.GetGoStyleDb().RegisterDataSource( + constant.CONF_DB, + mt.Table.ConfDb.GetById(0).GetHost(), + mt.Table.ConfDb.GetById(0).GetPort(), + mt.Table.ConfDb.GetById(0).GetUser(), + mt.Table.ConfDb.GetById(0).GetPasswd(), + mt.Table.ConfDb.GetById(0).GetDatabase(), + 1, + mt.Table.ConfDb.GetById(0).GetMaxOpenConns(), + mt.Table.ConfDb.GetById(0).GetMaxIdleConns()) } func (this *app) HasTask() bool { diff --git a/server/marketserver/constant/constant.go b/server/marketserver/constant/constant.go index 13006a48..1c2704ed 100644 --- a/server/marketserver/constant/constant.go +++ b/server/marketserver/constant/constant.go @@ -5,6 +5,7 @@ const ( BCNFT_DB = "bcnftdb" BCEVENT_DB = "bceventdb" GAME_DB = "gamedb" + CONF_DB = "confdb" ) const ( @@ -24,4 +25,9 @@ const ( RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 100 RECHARGE_CURRENCY_MAX_DECIMAL = 6 RECHARGE_CURRENCY_MAX_BUY_NUM = 9999 + BNB_RECHARGE_CURRENCY_MAX_DECIMAL = 18 +) + +const ( + GAME_SWITCH_HERO_MINT = "heroMint" ) diff --git a/server/marketserver/mt/ConfDb.go b/server/marketserver/mt/ConfDb.go new file mode 100644 index 00000000..ab948bf7 --- /dev/null +++ b/server/marketserver/mt/ConfDb.go @@ -0,0 +1,15 @@ +package mt + +import ( + "f5" + "main/mtb" +) + +type ConfDb struct { + mtb.ConfDb +} + +type ConfDbTable struct { + f5.IdMetaTable[ConfDb] + selfConf *ConfDb +} diff --git a/server/marketserver/mt/Currency.go b/server/marketserver/mt/Currency.go index 650dd1ec..bb2647e7 100644 --- a/server/marketserver/mt/Currency.go +++ b/server/marketserver/mt/Currency.go @@ -43,14 +43,21 @@ func (this *Currency) GetContract() *Contract { return this.contract } -func (this *Currency) check() { +func (this *Currency) check(netId int32) { if this.GetCurrencyDecimal() <= 0 { panic("Currency currency_decimal <= 0") return } - if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL { - panic("Currency exchange_rate > uplimit") - return + if netId == 56 || netId == 97 { + if this.GetCurrencyDecimal() != constant.BNB_RECHARGE_CURRENCY_MAX_DECIMAL { + panic("Currency exchange_rate > uplimit") + return + } + } else { + if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL { + panic("Currency exchange_rate > uplimit") + return + } } } @@ -109,7 +116,7 @@ func (this *CurrencyTable) Load() { for _, currencyCfg := range currencysCfg { p := new(Currency) p.init(currencyCfg.CurrencyName, currencyCfg.ContractName, currencyCfg.CurrencyDecimal) - p.check() + p.check(netId) currencysMeta := this.GetByNetId(netId) if currencysMeta == nil { currencysMeta = new(q5.ConcurrentMap[string, *Currency]) diff --git a/server/marketserver/mt/export.go b/server/marketserver/mt/export.go index 1fc05347..dc7673b3 100644 --- a/server/marketserver/mt/export.go +++ b/server/marketserver/mt/export.go @@ -18,6 +18,7 @@ type table struct { Recharge *RechargeTable Currency *CurrencyTable AccountDb *AccountDbTable + ConfDb *ConfDbTable } var Table = f5.New(func(this *table) { @@ -46,6 +47,11 @@ var Table = f5.New(func(this *table) { this.PrimKey = "" }) + this.ConfDb = f5.New(func(this *ConfDbTable) { + this.FileName = "../config/confdb.mysql.json" + this.PrimKey = "" + }) + this.Config = f5.New(func(this *ConfigTable) { this.FileName = "../config/config.json" this.PrimKey = "" diff --git a/server/marketserver/mtb/mtb.auto_gen.go b/server/marketserver/mtb/mtb.auto_gen.go index 34282aa4..15c16c16 100644 --- a/server/marketserver/mtb/mtb.auto_gen.go +++ b/server/marketserver/mtb/mtb.auto_gen.go @@ -65,6 +65,19 @@ type GameDb struct { _flags2_ uint64 } +type ConfDb struct { + host string + port int32 + user string + passwd string + database string + max_open_conns int32 + max_idle_conns int32 + + _flags1_ uint64 + _flags2_ uint64 +} + type Config struct { gameapi_url string jwks_uri string @@ -374,6 +387,62 @@ func (this *GameDb) HasMaxIdleConns() bool { return (this._flags1_ & (uint64(1) << 7)) > 0 } +func (this *ConfDb) GetHost() string { + return this.host +} + +func (this *ConfDb) HasHost() bool { + return (this._flags1_ & (uint64(1) << 1)) > 0 +} + +func (this *ConfDb) GetPort() int32 { + return this.port +} + +func (this *ConfDb) HasPort() bool { + return (this._flags1_ & (uint64(1) << 2)) > 0 +} + +func (this *ConfDb) GetUser() string { + return this.user +} + +func (this *ConfDb) HasUser() bool { + return (this._flags1_ & (uint64(1) << 3)) > 0 +} + +func (this *ConfDb) GetPasswd() string { + return this.passwd +} + +func (this *ConfDb) HasPasswd() bool { + return (this._flags1_ & (uint64(1) << 4)) > 0 +} + +func (this *ConfDb) GetDatabase() string { + return this.database +} + +func (this *ConfDb) HasDatabase() bool { + return (this._flags1_ & (uint64(1) << 5)) > 0 +} + +func (this *ConfDb) GetMaxOpenConns() int32 { + return this.max_open_conns +} + +func (this *ConfDb) HasMaxOpenConns() bool { + return (this._flags1_ & (uint64(1) << 6)) > 0 +} + +func (this *ConfDb) GetMaxIdleConns() int32 { + return this.max_idle_conns +} + +func (this *ConfDb) HasMaxIdleConns() bool { + return (this._flags1_ & (uint64(1) << 7)) > 0 +} + func (this *Config) GetGameapiUrl() string { return this.gameapi_url } @@ -573,6 +642,16 @@ func (this *GameDb) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv) } +func (this *ConfDb) LoadFromKv(kv map[string]interface{}) { + f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv) + f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv) + f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv) + f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv) + f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv) + f5.ReadMetaTableField(&this.max_open_conns, "max_open_conns", &this._flags1_, 6, kv) + f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv) +} + func (this *Config) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv) f5.ReadMetaTableField(&this.jwks_uri, "jwks_uri", &this._flags1_, 2, kv) diff --git a/server/marketserver/proto/mt.proto b/server/marketserver/proto/mt.proto index 03428950..565ac8cd 100644 --- a/server/marketserver/proto/mt.proto +++ b/server/marketserver/proto/mt.proto @@ -53,6 +53,17 @@ message GameDb optional int32 max_idle_conns = 7; } +message ConfDb +{ + optional string host = 1; + optional int32 port = 2; + optional string user = 3; + optional string passwd = 4; + optional string database = 5; + optional int32 max_open_conns = 6; + optional int32 max_idle_conns = 7; +} + message Config { optional string gameapi_url = 1; diff --git a/server/marketserver/router/game_switch/enter.go b/server/marketserver/router/game_switch/enter.go new file mode 100644 index 00000000..1871e5c2 --- /dev/null +++ b/server/marketserver/router/game_switch/enter.go @@ -0,0 +1,5 @@ +package game_switch + +type RouterGroup struct { + GameSwitchRouter +} diff --git a/server/marketserver/router/game_switch/game_switch.go b/server/marketserver/router/game_switch/game_switch.go new file mode 100644 index 00000000..9811f62c --- /dev/null +++ b/server/marketserver/router/game_switch/game_switch.go @@ -0,0 +1,13 @@ +package game_switch + +import ( + "f5" + v1 "main/api/v1" +) + +type GameSwitchRouter struct{} + +func (this *GameSwitchRouter) InitRouter() { + api := v1.ApiGroupApp.SwitchApiGroup + f5.GetApp().GetGinEngine().GET("/api/server_switch", api.GameSwitchApi.List) +} diff --git a/server/marketserver/router/routermgr.go b/server/marketserver/router/routermgr.go index f5a45371..61ee28cb 100644 --- a/server/marketserver/router/routermgr.go +++ b/server/marketserver/router/routermgr.go @@ -6,6 +6,7 @@ import ( "main/router/activity" "main/router/asset" "main/router/event" + "main/router/game_switch" "main/router/gold_bullion" "main/router/hero" "main/router/ingame" @@ -28,6 +29,7 @@ type routerMgr struct { activity activity.RouterGroup event event.RouterGroup recharge recharge.RouterGroup + gameswitch game_switch.RouterGroup } func (this *routerMgr) Init() { @@ -45,6 +47,7 @@ func (this *routerMgr) Init() { this.activity.ContributionRouter.InitRouter() this.event.EventRouter.InitRouter() this.recharge.RechargeRouter.InitRouter() + this.gameswitch.GameSwitchRouter.InitRouter() f5.GetSysLog().Info("routerMgr.init") diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index ea604040..7c2b6913 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -9,19 +9,24 @@ import ( ) type accountContribution struct { - history float64 - loadhistory bool - contribution float64 - rechargeContri float64 - gcTime int64 - loweremail string - accountid string + history float64 + stakingContri float64 + gamecontribution float64 + rechargeContri float64 + gcTime int64 + loweremail string + accountid string +} + +func (ac *accountContribution) sum() float64 { + return ac.history + ac.stakingContri + ac.gamecontribution + ac.rechargeContri } type contribution struct { - historyContribution float64 - globalContribution float64 - gcTime int64 + historyContribution float64 + rechargeContribution float64 + gameContribution float64 + gcTime int64 accountContributionlist q5.ConcurrentMap[string, *accountContribution] emailContributionlist q5.ConcurrentMap[string, *accountContribution] @@ -30,6 +35,7 @@ type contribution struct { func (this *contribution) init() { this.accountContributionlist = q5.ConcurrentMap[string, *accountContribution]{} this.emailContributionlist = q5.ConcurrentMap[string, *accountContribution]{} + this.GetGlobalContribution(true) go this.checkContributionList() } @@ -37,10 +43,14 @@ func (this *contribution) unInit() { } +func (c *contribution) sum() float64 { + return c.historyContribution + c.rechargeContribution + c.gameContribution +} + func (this *contribution) GetEmailContributionAccountid(email string) (float64, string, error) { info, exist := this.emailContributionlist.Load(email) if exist { - return (*info).contribution, (*info).accountid, nil + return (*info).sum(), (*info).accountid, nil } accountid := "" @@ -84,15 +94,22 @@ func (this *contribution) GetEmailAccountId(accountAddress string) (string, stri } func (this *contribution) GetAddressContribution(accountAddress string, onlyrecharge bool) (float64, error) { + if accountAddress == "" { + return 0, fmt.Errorf("empty account") + } accinfo, exist := this.accountContributionlist.Load(accountAddress) var beforcontribution float64 = 0 + if exist { + beforcontribution = (*accinfo).sum() + } + if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds { if !exist { info := new(accountContribution) this.accountContributionlist.Store(accountAddress, info) accinfo = &info } - beforcontribution = (*accinfo).contribution + beforcontribution = (*accinfo).sum() if (*accinfo).loweremail == "" { sql := `SELECT account_id FROM t_user WHERE idx > 0 AND address = ?` @@ -126,9 +143,13 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } }) } + + if (*accinfo).loweremail != "" { + this.emailContributionlist.Store((*accinfo).loweremail, *accinfo) + } } - if !(*accinfo).loadhistory { + { sql := `SELECT contribution FROM t_contribution WHERE idx > 0 and account_address = ?` f5.GetGoStyleDb().RawQuery( constant.BCNFT_DB, @@ -155,12 +176,9 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } if ds.Next() { - tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) - (*accinfo).history += tmp + (*accinfo).stakingContri, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) - - (*accinfo).loadhistory = true } if (*accinfo).accountid != "" { @@ -175,7 +193,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } if ds.Next() { - (*accinfo).contribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) + (*accinfo).gamecontribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) } @@ -199,21 +217,15 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } if ds.Next() { - tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) - (*accinfo).contribution += tmp - (*accinfo).rechargeContri = tmp + (*accinfo).rechargeContri, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) } - (*accinfo).contribution += (*accinfo).history (*accinfo).gcTime = nowseconds - if (*accinfo).loweremail != "" { - this.emailContributionlist.Store((*accinfo).loweremail, *accinfo) - } } - if beforcontribution != (*accinfo).contribution { + if beforcontribution > 0.000001 && (*accinfo).sum() > beforcontribution+0.000001 { this.GetGlobalContribution(true) } @@ -221,7 +233,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech return (*accinfo).rechargeContri, nil } - return (*accinfo).contribution, nil + return (*accinfo).sum(), nil } func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { @@ -270,7 +282,7 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { } if ds.Next() { - this.globalContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) + this.gameContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) sql = `SELECT SUM(return_contribution) FROM t_recharge_return_contribution WHERE idx > 0` @@ -284,22 +296,20 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { } if ds.Next() { - tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) - this.globalContribution += tmp + this.rechargeContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) - this.globalContribution += this.historyContribution this.gcTime = nowseconds } - return this.globalContribution, nil + return this.sum(), nil } func (this *contribution) checkContributionList() { fmt.Println("checkContributionList start") for { - if time.Now().UTC().Hour() == 0 { + if time.Now().UTC().Hour() == 0 && time.Now().UTC().Minute() == 0 { nowseconds := f5.GetApp().GetRealSeconds() deletelist := []string{} this.accountContributionlist.Range(func(key string, value *accountContribution) bool { @@ -316,7 +326,16 @@ func (this *contribution) checkContributionList() { } this.accountContributionlist.Delete(account) } + f5.GetSysLog().Info("delete contribution address cache count:%d", len(deletelist)) } - time.Sleep((time.Second * 1800)) + + f5.GetSysLog().Info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") + f5.GetSysLog().Info("contribution cache total:%.2f, recharge:%.2f, ingame:%.2f, history:%.2f", + this.sum(), + this.rechargeContribution, + this.gameContribution, + this.historyContribution) + f5.GetSysLog().Info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + time.Sleep((time.Second * 60)) } } diff --git a/server/marketserver/service/export.go b/server/marketserver/service/export.go index 517ec780..ff5606f2 100644 --- a/server/marketserver/service/export.go +++ b/server/marketserver/service/export.go @@ -7,6 +7,8 @@ import ( var Contribution = new(contribution) var _serviceMgr = new(serviceMgr) +var GameSwitches = new(gameSwitch) +var User = new(user) func init() { global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr) diff --git a/server/marketserver/service/gameswitch.go b/server/marketserver/service/gameswitch.go new file mode 100644 index 00000000..0281ba4c --- /dev/null +++ b/server/marketserver/service/gameswitch.go @@ -0,0 +1,45 @@ +package service + +import ( + "f5" + "marketserver/constant" + "q5" +) + +type gameSwitch struct { + data map[string]int32 + time int64 +} + +func (this *gameSwitch) GetSwitchList() map[string]int32 { + now := f5.GetApp().GetRealSeconds() + if now > this.time+30 { + this.data = map[string]int32{} + this.time = now + + f5.GetGoStyleDb().RawQuery( + constant.CONF_DB, + "SELECT * FROM t_game_switch WHERE 1=1", + []string{}, + func(err error, ds *f5.DataSet) { + if err != nil { + return + } + + for ds.Next() { + this.data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open")) + } + }) + } + + return this.data +} + +func (this *gameSwitch) CheckSwitch(gs string) int32 { + v, exist := this.data[gs] + if exist { + return v + } + + return 0 +} diff --git a/server/marketserver/service/recharge.go b/server/marketserver/service/recharge.go index 65043737..428f7dae 100644 --- a/server/marketserver/service/recharge.go +++ b/server/marketserver/service/recharge.go @@ -10,7 +10,7 @@ import ( func AddRechargeOrder(orderId string, shortOrderId string, netId int32, accountAddress string, passportAddress string, currencyAddress string, currencyName string, itemId int32, itemNum int32, - price int64, srcPrice int64, diamond int64, presentDiamond int64, email string) bool { + price string, srcPrice int64, diamond int64, presentDiamond int64, email string) bool { ok := false nowTime := f5.GetApp().GetRealSeconds() fields := [][]string{ @@ -23,7 +23,7 @@ func AddRechargeOrder(orderId string, shortOrderId string, {"currency_address", currencyAddress}, {"item_id", q5.ToString(itemId)}, {"item_num", q5.ToString(itemNum)}, - {"price", q5.ToString(price)}, + {"price", price}, {"diamond", q5.ToString(diamond)}, {"present_diamond", q5.ToString(presentDiamond)}, {"return_contribution", q5.ToString(srcPrice * 1)}, diff --git a/server/marketserver/service/servicemgr.go b/server/marketserver/service/servicemgr.go index 14997cfe..4e9d8baa 100644 --- a/server/marketserver/service/servicemgr.go +++ b/server/marketserver/service/servicemgr.go @@ -5,8 +5,10 @@ type serviceMgr struct { func (this *serviceMgr) Init() { Contribution.init() + User.init() } func (this *serviceMgr) UnInit() { Contribution.unInit() + User.unInit() } diff --git a/server/marketserver/service/user.go b/server/marketserver/service/user.go new file mode 100644 index 00000000..4992acb7 --- /dev/null +++ b/server/marketserver/service/user.go @@ -0,0 +1,40 @@ +package service + +import ( + "f5" + "main/constant" + "q5" +) + +//"strings" + +type user struct { +} + +func (this *user) init() { +} + +func (this *user) unInit() { +} + +func (this *user) InBlackList(userIdentity string) (bool, error) { + if userIdentity == "" { + return true, nil + } + + var queryerr error + blocked := false + f5.GetGoStyleDb().RawQuery( + constant.CONF_DB, + "SELECT * FROM t_blockplayer WHERE 1=1 AND account_id = ?", + []string{userIdentity}, + func(err error, ds *f5.DataSet) { + if err != nil { + queryerr = err + return + } + + blocked = ds.Next() && q5.SafeToInt32(ds.GetByName("blocked")) != 0 && q5.SafeToInt32(ds.GetByName("deleted")) == 0 + }) + return blocked, queryerr +}