This commit is contained in:
aozhiwei 2024-08-27 14:08:39 +08:00
commit 4ad76b5aec
37 changed files with 650 additions and 131 deletions

View File

@ -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
}

View File

@ -2,11 +2,11 @@
{ {
"currency_name": "USDC", "currency_name": "USDC",
"contract_name": "BEUSDC", "contract_name": "BEUSDC",
"currency_decimal": 6 "currency_decimal": 18
}, },
{ {
"currency_name": "USDT", "currency_name": "USDT",
"contract_name": "BEUSDT", "contract_name": "BEUSDT",
"currency_decimal": 6 "currency_decimal": 18
} }
] ]

View File

@ -132,7 +132,7 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
blockplayer := new(system.BlockPlayer) blockplayer := new(system.BlockPlayer)
db := f5.GetApp().GetOrmDb(constant.CONF_DB) 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) { if !f5.IsOrmErrRecordNotFound(err) {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"code": 500, "code": 500,
@ -178,7 +178,7 @@ func (bpa *BlockPlayerApi) Del(c *gin.Context) {
blockplayer := new(system.BlockPlayer) blockplayer := new(system.BlockPlayer)
db := f5.GetApp().GetOrmDb(constant.CONF_DB) 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) { if !f5.IsOrmErrRecordNotFound(err) {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"code": 500, "code": 500,

View File

@ -136,6 +136,14 @@ func (pai *PlayerApi) BagQuery(c *gin.Context) {
return return
} }
if len(reqJson.Account_id) > 0xFF {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "输入过长",
})
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
filterstr := " account_id = '" + reqJson.Account_id + "' " filterstr := " account_id = '" + reqJson.Account_id + "' "
sql := fmt.Sprintf(`SELECT * FROM t_bag WHERE idx > %d AND %s `, cursor, filterstr) 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 return
} }
if len(reqJson.Account_id) > 0xFF {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "输入过长",
})
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
filterstr := " account_id = '" + reqJson.Account_id + "' " filterstr := " account_id = '" + reqJson.Account_id + "' "
sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr) 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 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
})
}

View File

@ -207,8 +207,8 @@ func (bpa *WhiteListApi) Del(c *gin.Context) {
} else { } else {
if whiteListItem.Deleted == 1 { if whiteListItem.Deleted == 1 {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"code": 0, "code": 2,
"message": "", "message": "无法查到记录",
}) })
return return

View File

@ -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"
}

View File

@ -19,5 +19,6 @@ func (pr *PlayerRouter) InitPlayerRouter(priRouter *gin.RouterGroup) {
group.POST("goldbullionquery", middleware.Permission("api/v1/player/goldbullionquery", api.GoldBullionQuery)) group.POST("goldbullionquery", middleware.Permission("api/v1/player/goldbullionquery", api.GoldBullionQuery))
group.POST("ticketconsumequery", middleware.Permission("api/v1/player/ticketconsumequery", api.TicketConsumeQuery)) group.POST("ticketconsumequery", middleware.Permission("api/v1/player/ticketconsumequery", api.TicketConsumeQuery))
group.POST("gamemallquery", middleware.Permission("api/v1/player/gamemallquery", api.GameMallQuery)) group.POST("gamemallquery", middleware.Permission("api/v1/player/gamemallquery", api.GameMallQuery))
group.POST("rechargequery", middleware.Permission("api/v1/player/rechargequery", api.RechargeQuery))
} }
} }

View File

@ -40,6 +40,7 @@ const (
MAIL_TAG1_CUSTOM = 10 MAIL_TAG1_CUSTOM = 10
MAIL_TAG1_HERO = 100 MAIL_TAG1_HERO = 100
MAIL_TAG1_GOLD_BULLION = 101 MAIL_TAG1_GOLD_BULLION = 101
MAIL_TAG1_OLD_USER = 102
) )
const ( const (
@ -53,6 +54,8 @@ const (
MAIL_TAG2_GOLD_BULLION_LOCK = 2 MAIL_TAG2_GOLD_BULLION_LOCK = 2
MAIL_TAG2_GOLD_BULLION_UNLOCK = 3 MAIL_TAG2_GOLD_BULLION_UNLOCK = 3
MAIL_TAG2_GOLD_BULLION_RETURN = 4 MAIL_TAG2_GOLD_BULLION_RETURN = 4
MAIL_TAG2_OLD_USER = 1
) )
const ( const (

View File

@ -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() {
}

View File

@ -9,7 +9,7 @@ type taskMgr struct {
sysMail sysMail
repairOrder repairOrder
refreshMeta refreshMeta
contribution //contribution
chainActivity chainActivity
recharge recharge
} }
@ -20,7 +20,7 @@ func (this *taskMgr) Init() {
this.sysMail.init() this.sysMail.init()
this.repairOrder.init() this.repairOrder.init()
//this.refreshMeta.init() //this.refreshMeta.init()
this.contribution.init() //this.contribution.init()
this.chainActivity.init() this.chainActivity.init()
this.recharge.init() this.recharge.init()
} }
@ -28,7 +28,7 @@ func (this *taskMgr) Init() {
func (this *taskMgr) UnInit() { func (this *taskMgr) UnInit() {
this.recharge.unInit() this.recharge.unInit()
this.chainActivity.unInit() this.chainActivity.unInit()
this.contribution.unInit() //this.contribution.unInit()
//this.refreshMeta.unInit() //this.refreshMeta.unInit()
this.repairOrder.unInit() this.repairOrder.unInit()
this.sysMail.unInit() this.sysMail.unInit()

View File

@ -134,6 +134,7 @@ func (this *mailMgr) CaGetMailList(c *gin.Context) {
this.traversePlayerMail( this.traversePlayerMail(
hum, hum,
func (m *mail) bool { func (m *mail) bool {
f5.GetSysLog().Info("getMailList mail_id:%s", m.mailId)
if m.IsValid(hum) { if m.IsValid(hum) {
if hum.IsReadable(m) { if hum.IsReadable(m) {
mailDto := new(common.MailDto) mailDto := new(common.MailDto)

View File

@ -240,6 +240,7 @@ func (this *player) load() {
p.state = q5.ToInt32(ds.GetByName("state")) p.state = q5.ToInt32(ds.GetByName("state"))
p.expireTime = q5.ToInt32(ds.GetByName("expiretime")) p.expireTime = q5.ToInt32(ds.GetByName("expiretime"))
this.inboxHash[p.mailId] = p this.inboxHash[p.mailId] = p
f5.GetSysLog().Info("load mail mail_id:%s", p.mailId)
} }
this.loaded = true this.loaded = true
}) })

View File

@ -17,10 +17,7 @@ type ContriApi struct {
func (cta *ContriApi) HistoryQuery(c *gin.Context) { func (cta *ContriApi) HistoryQuery(c *gin.Context) {
account := strings.ToLower(c.Param("account_address")) account := strings.ToLower(c.Param("account_address"))
if account == "" { if account == "" {
c.JSON(200, gin.H{ f5.RspErr(c, 2, "empty account")
"errcode": 1,
"errmsg": "",
})
return return
} }
@ -63,7 +60,8 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
{ {
loweremail, accountid := service.Contribution.GetEmailAccountId(account) loweremail, accountid := service.Contribution.GetEmailAccountId(account)
sql := `SELECT * FROM t_contribution_history WHERE idx > 0 AND account_id = ?` if accountid != "" {
sql = `SELECT * FROM t_contribution_history WHERE idx > 0 AND account_id = ?`
f5.GetGoStyleDb().RawQuery( f5.GetGoStyleDb().RawQuery(
constant.GAME_DB, constant.GAME_DB,
sql, sql,
@ -81,6 +79,7 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
q5.AppendSlice(&rspObj.Rows, p) q5.AppendSlice(&rspObj.Rows, p)
} }
}) })
}
sql = `SELECT * FROM t_recharge_return_contribution WHERE idx > 0 AND user_identity IN (?` 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) { func (cta *ContriApi) CECQuery(c *gin.Context) {
account := strings.ToLower(c.Param("account_address")) account := strings.ToLower(c.Param("account_address"))
if account == "" { if account == "" {
c.JSON(200, gin.H{ f5.RspErr(c, 2, "empty account")
"errcode": 1,
"errmsg": "",
})
return return
} }
@ -140,8 +136,8 @@ func (cta *ContriApi) CECQuery(c *gin.Context) {
} `json:"info"` } `json:"info"`
}{} }{}
totalgcp, _ := service.Contribution.GetGlobalContribution(false)
mycp, _ := service.Contribution.GetAddressContribution(account, false) mycp, _ := service.Contribution.GetAddressContribution(account, false)
totalgcp, _ := service.Contribution.GetGlobalContribution(false)
rspObj.CP = fmt.Sprintf("%.2f", mycp) rspObj.CP = fmt.Sprintf("%.2f", mycp)
rspObj.Info.MyCP = rspObj.CP rspObj.Info.MyCP = rspObj.CP
rspObj.Info.GCP = fmt.Sprintf("%.2f", totalgcp) rspObj.Info.GCP = fmt.Sprintf("%.2f", totalgcp)

View File

@ -132,6 +132,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) {
Date int32 `json:"date"` Date int32 `json:"date"`
Amount string `json:"amount"` Amount string `json:"amount"`
Type int32 `json:"type"` Type int32 `json:"type"`
From string `json:"from"`
} }
rspObj := struct { rspObj := struct {
ErrCode int32 `json:"errcode"` 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{ params := []string{
accountAddress, accountAddress,
accountAddress, accountAddress,
@ -161,13 +162,14 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) {
obj.Date = q5.SafeToInt32(ds.GetByName("createtime")) obj.Date = q5.SafeToInt32(ds.GetByName("createtime"))
obj.Amount = ds.GetByName("amount") obj.Amount = ds.GetByName("amount")
obj.Type = 1 obj.Type = 1
obj.From = accountAddress
rspObj.Rows = append(rspObj.Rows, obj) 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{ params := []string{
accountAddress, accountAddress,
} }
@ -186,6 +188,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) {
obj.Date = q5.SafeToInt32(ds.GetByName("pay_time")) obj.Date = q5.SafeToInt32(ds.GetByName("pay_time"))
obj.Amount = ds.GetByIndex(1) obj.Amount = ds.GetByIndex(1)
obj.From = ds.GetByIndex(2)
obj.Type = 0 obj.Type = 0
rspObj.Rows = append(rspObj.Rows, obj) rspObj.Rows = append(rspObj.Rows, obj)
} }

View File

@ -4,6 +4,7 @@ import (
"main/api/v1/activity" "main/api/v1/activity"
"main/api/v1/asset" "main/api/v1/asset"
"main/api/v1/event" "main/api/v1/event"
"main/api/v1/game_switch"
"main/api/v1/gold_bullion" "main/api/v1/gold_bullion"
"main/api/v1/hero" "main/api/v1/hero"
"main/api/v1/ingame" "main/api/v1/ingame"
@ -26,6 +27,7 @@ type ApiGroup struct {
ActivityApiGroup activity.ApiGroup ActivityApiGroup activity.ApiGroup
EventApiGroup event.ApiGroup EventApiGroup event.ApiGroup
RechargeApiGroup recharge.ApiGroup RechargeApiGroup recharge.ApiGroup
SwitchApiGroup game_switch.ApiGroup
} }
var ApiGroupApp = new(ApiGroup) var ApiGroupApp = new(ApiGroup)

View File

@ -0,0 +1,5 @@
package game_switch
type ApiGroup struct {
GameSwitchApi
}

View File

@ -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(),
})
}

View File

@ -1,17 +1,18 @@
package ingame package ingame
import ( import (
"q5"
"f5" "f5"
"main/mt"
"main/common" "main/common"
"main/constant" "main/constant"
. "main/global" . "main/global"
"main/mt"
"marketserver/service"
"q5"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
type InGameApi struct { type InGameApi struct {
} }
func (this *InGameApi) HeroList(c *gin.Context) { func (this *InGameApi) HeroList(c *gin.Context) {
@ -26,7 +27,7 @@ func (this *InGameApi) HeroList(c *gin.Context) {
HeroRanks []interface{} `json:"hero_ranks"` HeroRanks []interface{} `json:"hero_ranks"`
} `json:"filter"` } `json:"filter"`
Sort struct { Sort struct {
Fields [] struct { Fields []struct {
Name string `json:"name"` Name string `json:"name"`
Type interface{} `json:"type"` Type interface{} `json:"type"`
} `json:"fields"` } `json:"fields"`
@ -48,7 +49,7 @@ func (this *InGameApi) HeroList(c *gin.Context) {
ErrCode int32 `json:"errcode"` ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"` ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"` Page common.StreamPagination `json:"page"`
Rows [] interface{} `json:"rows"` Rows []interface{} `json:"rows"`
}{} }{}
q5.NewSlice(&rspObj.Rows, 0, 10) q5.NewSlice(&rspObj.Rows, 0, 10)
@ -56,22 +57,27 @@ func (this *InGameApi) HeroList(c *gin.Context) {
heroList, heroList,
q5.SafeToInt32(reqJson.PageSize), q5.SafeToInt32(reqJson.PageSize),
q5.SafeToInt64(reqJson.Cursor), q5.SafeToInt64(reqJson.Cursor),
func (kv interface{}) bool { func(kv interface{}) bool {
return true return true
}, },
func (a interface{}, b interface{}) bool { func(a interface{}, b interface{}) bool {
return true return true
}, },
func (p *f5.StreamPagination) { func(p *f5.StreamPagination) {
rspObj.Page.FillPage(p) rspObj.Page.FillPage(p)
}, },
func (kv interface{}) { func(kv interface{}) {
q5.AppendSlice(&rspObj.Rows, kv) q5.AppendSlice(&rspObj.Rows, kv)
}) })
c.JSON(200, rspObj) c.JSON(200, rspObj)
} }
func (this *InGameApi) HeroMint(c *gin.Context) { 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 { reqJson := struct {
NetId interface{} `json:"net_id"` NetId interface{} `json:"net_id"`
To string `json:"to"` To string `json:"to"`
@ -99,7 +105,7 @@ func (this *InGameApi) HeroMint(c *gin.Context) {
{"account_id", accountId}, {"account_id", accountId},
{"idx", uniid}, {"idx", uniid},
}, },
func (err error, ds *f5.DataSet) { func(err error, ds *f5.DataSet) {
if err != nil { if err != nil {
f5.RspErr(c, 500, "server internal error") f5.RspErr(c, 500, "server internal error")
return return
@ -118,10 +124,9 @@ func (this *InGameApi) HeroMint(c *gin.Context) {
ErrMsg string `json:"errmsg"` ErrMsg string `json:"errmsg"`
TransId string `json:"trans_id"` TransId string `json:"trans_id"`
TransReq interface{} `json:"trans_req"` TransReq interface{} `json:"trans_req"`
}{ }{}
}
f5.GetHttpCliMgr().SendGoStyleRequest( f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", mt.Table.Config.GetGameApiUrl()+"/webapp/index.php",
params, params,
func(rsp f5.HttpCliResponse) { func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil { if rsp.GetErr() != nil {
@ -146,6 +151,11 @@ func (this *InGameApi) HeroMint(c *gin.Context) {
} }
func (this *InGameApi) newHeroMint(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 { reqJson := struct {
NetId interface{} `json:"net_id"` NetId interface{} `json:"net_id"`
To string `json:"to"` To string `json:"to"`
@ -173,7 +183,7 @@ func (this *InGameApi) newHeroMint(c *gin.Context) {
{"account_id", accountId}, {"account_id", accountId},
{"idx", uniid}, {"idx", uniid},
}, },
func (err error, ds *f5.DataSet) { func(err error, ds *f5.DataSet) {
if err != nil { if err != nil {
f5.RspErr(c, 500, "server internal error") f5.RspErr(c, 500, "server internal error")
return return
@ -192,10 +202,9 @@ func (this *InGameApi) newHeroMint(c *gin.Context) {
ErrMsg string `json:"errmsg"` ErrMsg string `json:"errmsg"`
TransId string `json:"trans_id"` TransId string `json:"trans_id"`
TransReq interface{} `json:"trans_req"` TransReq interface{} `json:"trans_req"`
}{ }{}
}
f5.GetHttpCliMgr().SendGoStyleRequest( f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", mt.Table.Config.GetGameApiUrl()+"/webapp/index.php",
params, params,
func(rsp f5.HttpCliResponse) { func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil { if rsp.GetErr() != nil {

View File

@ -6,6 +6,7 @@ import (
"main/mt" "main/mt"
"jccommon" "jccommon"
"main/constant" "main/constant"
"main/service"
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -67,6 +68,13 @@ func (this *NftApi) Unlock(c *gin.Context) {
f5.RspErr(c, 500, "nft not found") f5.RspErr(c, 500, "nft not found")
return 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{ params := map[string]string{
"c": "BcService", "c": "BcService",
"a": "nftUnlock", "a": "nftUnlock",

View File

@ -13,6 +13,7 @@ import (
"q5" "q5"
"strings" "strings"
"math/big"
"github.com/gin-gonic/gin" "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 { if contribution, err := service.Contribution.GetAddressContribution(accountAddress, true); err != nil {
f5.RspErr(c, 2, "server internal error") f5.RspErr(c, 2, err.Error())
return return
} else { } else {
rspObj.Contribution = q5.ToString(contribution) rspObj.Contribution = q5.ToString(contribution)
@ -165,11 +166,25 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
} }
} }
srcPrice := q5.ToInt64(goodsMeta.GetPrice()) * q5.ToInt64(goodsNum) srcPrice := q5.ToInt64(goodsMeta.GetPrice()) * q5.ToInt64(goodsNum)
price := q5.PowInt64(10, currencyMeta.GetCurrencyDecimal()) * srcPrice bnPrice := big.NewInt(0)
if price <= 0 || price < q5.ToInt64(goodsMeta.GetPrice()) { {
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") f5.RspErr(c, 3, "server internal error")
return 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{ params := map[string]string{
"c": "BcService", "c": "BcService",
"a": "recharge", "a": "recharge",
@ -177,7 +192,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
"order_id": orderId, "order_id": orderId,
"account_address": accountAddress, "account_address": accountAddress,
"passport_address": passportAddress, "passport_address": passportAddress,
"amount": q5.ToString(price), "amount": bnPrice.String(),
"currency_name": currencyContractMeta.GetName(), "currency_name": currencyContractMeta.GetName(),
"currency_address": currencyContractMeta.GetAddress(), "currency_address": currencyContractMeta.GetAddress(),
} }
@ -216,7 +231,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context,
currencyContractMeta.GetAddress(), currencyContractMeta.GetAddress(),
goodsMeta.GetId(), goodsMeta.GetId(),
itemNum, itemNum,
price, bnPrice.String(),
srcPrice, srcPrice,
diamond, diamond,
presentDiamond, presentDiamond,

View File

@ -26,7 +26,11 @@ func (this *UserApi) Info(c *gin.Context) {
Diamond string `json:"diamond"` Diamond string `json:"diamond"`
}{} }{}
rspObj.Email = c.MustGet("email").(string) 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 gold float64
var diamond float64 var diamond float64
{ {
@ -114,7 +118,7 @@ func (this *UserApi) Info(c *gin.Context) {
if err != nil { if err != nil {
return return
} }
for ds.Next() { if ds.Next() {
diamond += q5.ToFloat64(ds.GetByIndex(0)) diamond += q5.ToFloat64(ds.GetByIndex(0))
} }
}) })

View File

@ -97,6 +97,17 @@ func (this *app) registerDataSources() {
1, 1,
mt.Table.AccountDb.GetById(0).GetMaxOpenConns(), mt.Table.AccountDb.GetById(0).GetMaxOpenConns(),
mt.Table.AccountDb.GetById(0).GetMaxIdleConns()) 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 { func (this *app) HasTask() bool {

View File

@ -5,6 +5,7 @@ const (
BCNFT_DB = "bcnftdb" BCNFT_DB = "bcnftdb"
BCEVENT_DB = "bceventdb" BCEVENT_DB = "bceventdb"
GAME_DB = "gamedb" GAME_DB = "gamedb"
CONF_DB = "confdb"
) )
const ( const (
@ -24,4 +25,9 @@ const (
RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 100 RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 100
RECHARGE_CURRENCY_MAX_DECIMAL = 6 RECHARGE_CURRENCY_MAX_DECIMAL = 6
RECHARGE_CURRENCY_MAX_BUY_NUM = 9999 RECHARGE_CURRENCY_MAX_BUY_NUM = 9999
BNB_RECHARGE_CURRENCY_MAX_DECIMAL = 18
)
const (
GAME_SWITCH_HERO_MINT = "heroMint"
) )

View File

@ -0,0 +1,15 @@
package mt
import (
"f5"
"main/mtb"
)
type ConfDb struct {
mtb.ConfDb
}
type ConfDbTable struct {
f5.IdMetaTable[ConfDb]
selfConf *ConfDb
}

View File

@ -43,15 +43,22 @@ func (this *Currency) GetContract() *Contract {
return this.contract return this.contract
} }
func (this *Currency) check() { func (this *Currency) check(netId int32) {
if this.GetCurrencyDecimal() <= 0 { if this.GetCurrencyDecimal() <= 0 {
panic("Currency currency_decimal <= 0") panic("Currency currency_decimal <= 0")
return 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 { if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL {
panic("Currency exchange_rate > uplimit") panic("Currency exchange_rate > uplimit")
return return
} }
}
} }
func (this *CurrencyTable) GetByNetId(netId int32) *q5.ConcurrentMap[string, *Currency] { func (this *CurrencyTable) GetByNetId(netId int32) *q5.ConcurrentMap[string, *Currency] {
@ -109,7 +116,7 @@ func (this *CurrencyTable) Load() {
for _, currencyCfg := range currencysCfg { for _, currencyCfg := range currencysCfg {
p := new(Currency) p := new(Currency)
p.init(currencyCfg.CurrencyName, currencyCfg.ContractName, currencyCfg.CurrencyDecimal) p.init(currencyCfg.CurrencyName, currencyCfg.ContractName, currencyCfg.CurrencyDecimal)
p.check() p.check(netId)
currencysMeta := this.GetByNetId(netId) currencysMeta := this.GetByNetId(netId)
if currencysMeta == nil { if currencysMeta == nil {
currencysMeta = new(q5.ConcurrentMap[string, *Currency]) currencysMeta = new(q5.ConcurrentMap[string, *Currency])

View File

@ -18,6 +18,7 @@ type table struct {
Recharge *RechargeTable Recharge *RechargeTable
Currency *CurrencyTable Currency *CurrencyTable
AccountDb *AccountDbTable AccountDb *AccountDbTable
ConfDb *ConfDbTable
} }
var Table = f5.New(func(this *table) { var Table = f5.New(func(this *table) {
@ -46,6 +47,11 @@ var Table = f5.New(func(this *table) {
this.PrimKey = "" 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.Config = f5.New(func(this *ConfigTable) {
this.FileName = "../config/config.json" this.FileName = "../config/config.json"
this.PrimKey = "" this.PrimKey = ""

View File

@ -65,6 +65,19 @@ type GameDb struct {
_flags2_ uint64 _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 { type Config struct {
gameapi_url string gameapi_url string
jwks_uri string jwks_uri string
@ -374,6 +387,62 @@ func (this *GameDb) HasMaxIdleConns() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0 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 { func (this *Config) GetGameapiUrl() string {
return this.gameapi_url 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) 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{}) { func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv) f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.jwks_uri, "jwks_uri", &this._flags1_, 2, kv) f5.ReadMetaTableField(&this.jwks_uri, "jwks_uri", &this._flags1_, 2, kv)

View File

@ -53,6 +53,17 @@ message GameDb
optional int32 max_idle_conns = 7; 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 message Config
{ {
optional string gameapi_url = 1; optional string gameapi_url = 1;

View File

@ -0,0 +1,5 @@
package game_switch
type RouterGroup struct {
GameSwitchRouter
}

View File

@ -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)
}

View File

@ -6,6 +6,7 @@ import (
"main/router/activity" "main/router/activity"
"main/router/asset" "main/router/asset"
"main/router/event" "main/router/event"
"main/router/game_switch"
"main/router/gold_bullion" "main/router/gold_bullion"
"main/router/hero" "main/router/hero"
"main/router/ingame" "main/router/ingame"
@ -28,6 +29,7 @@ type routerMgr struct {
activity activity.RouterGroup activity activity.RouterGroup
event event.RouterGroup event event.RouterGroup
recharge recharge.RouterGroup recharge recharge.RouterGroup
gameswitch game_switch.RouterGroup
} }
func (this *routerMgr) Init() { func (this *routerMgr) Init() {
@ -45,6 +47,7 @@ func (this *routerMgr) Init() {
this.activity.ContributionRouter.InitRouter() this.activity.ContributionRouter.InitRouter()
this.event.EventRouter.InitRouter() this.event.EventRouter.InitRouter()
this.recharge.RechargeRouter.InitRouter() this.recharge.RechargeRouter.InitRouter()
this.gameswitch.GameSwitchRouter.InitRouter()
f5.GetSysLog().Info("routerMgr.init") f5.GetSysLog().Info("routerMgr.init")

View File

@ -10,17 +10,22 @@ import (
type accountContribution struct { type accountContribution struct {
history float64 history float64
loadhistory bool stakingContri float64
contribution float64 gamecontribution float64
rechargeContri float64 rechargeContri float64
gcTime int64 gcTime int64
loweremail string loweremail string
accountid string accountid string
} }
func (ac *accountContribution) sum() float64 {
return ac.history + ac.stakingContri + ac.gamecontribution + ac.rechargeContri
}
type contribution struct { type contribution struct {
historyContribution float64 historyContribution float64
globalContribution float64 rechargeContribution float64
gameContribution float64
gcTime int64 gcTime int64
accountContributionlist q5.ConcurrentMap[string, *accountContribution] accountContributionlist q5.ConcurrentMap[string, *accountContribution]
@ -30,6 +35,7 @@ type contribution struct {
func (this *contribution) init() { func (this *contribution) init() {
this.accountContributionlist = q5.ConcurrentMap[string, *accountContribution]{} this.accountContributionlist = q5.ConcurrentMap[string, *accountContribution]{}
this.emailContributionlist = q5.ConcurrentMap[string, *accountContribution]{} this.emailContributionlist = q5.ConcurrentMap[string, *accountContribution]{}
this.GetGlobalContribution(true)
go this.checkContributionList() 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) { func (this *contribution) GetEmailContributionAccountid(email string) (float64, string, error) {
info, exist := this.emailContributionlist.Load(email) info, exist := this.emailContributionlist.Load(email)
if exist { if exist {
return (*info).contribution, (*info).accountid, nil return (*info).sum(), (*info).accountid, nil
} }
accountid := "" accountid := ""
@ -84,15 +94,22 @@ func (this *contribution) GetEmailAccountId(accountAddress string) (string, stri
} }
func (this *contribution) GetAddressContribution(accountAddress string, onlyrecharge bool) (float64, error) { func (this *contribution) GetAddressContribution(accountAddress string, onlyrecharge bool) (float64, error) {
if accountAddress == "" {
return 0, fmt.Errorf("empty account")
}
accinfo, exist := this.accountContributionlist.Load(accountAddress) accinfo, exist := this.accountContributionlist.Load(accountAddress)
var beforcontribution float64 = 0 var beforcontribution float64 = 0
if exist {
beforcontribution = (*accinfo).sum()
}
if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds { if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds {
if !exist { if !exist {
info := new(accountContribution) info := new(accountContribution)
this.accountContributionlist.Store(accountAddress, info) this.accountContributionlist.Store(accountAddress, info)
accinfo = &info accinfo = &info
} }
beforcontribution = (*accinfo).contribution beforcontribution = (*accinfo).sum()
if (*accinfo).loweremail == "" { if (*accinfo).loweremail == "" {
sql := `SELECT account_id FROM t_user WHERE idx > 0 AND address = ?` 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 = ?` sql := `SELECT contribution FROM t_contribution WHERE idx > 0 and account_address = ?`
f5.GetGoStyleDb().RawQuery( f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB, constant.BCNFT_DB,
@ -155,12 +176,9 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
} }
if ds.Next() { if ds.Next() {
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) (*accinfo).stakingContri, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
(*accinfo).history += tmp
} }
}) })
(*accinfo).loadhistory = true
} }
if (*accinfo).accountid != "" { if (*accinfo).accountid != "" {
@ -175,7 +193,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
} }
if ds.Next() { 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() { if ds.Next() {
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) (*accinfo).rechargeContri, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
(*accinfo).contribution += tmp
(*accinfo).rechargeContri = tmp
} }
}) })
} }
(*accinfo).contribution += (*accinfo).history
(*accinfo).gcTime = nowseconds (*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) this.GetGlobalContribution(true)
} }
@ -221,7 +233,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
return (*accinfo).rechargeContri, nil return (*accinfo).rechargeContri, nil
} }
return (*accinfo).contribution, nil return (*accinfo).sum(), nil
} }
func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
@ -270,7 +282,7 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
} }
if ds.Next() { 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` 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() { if ds.Next() {
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) this.rechargeContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
this.globalContribution += tmp
} }
}) })
this.globalContribution += this.historyContribution
this.gcTime = nowseconds this.gcTime = nowseconds
} }
return this.globalContribution, nil return this.sum(), nil
} }
func (this *contribution) checkContributionList() { func (this *contribution) checkContributionList() {
fmt.Println("checkContributionList start") fmt.Println("checkContributionList start")
for { for {
if time.Now().UTC().Hour() == 0 { if time.Now().UTC().Hour() == 0 && time.Now().UTC().Minute() == 0 {
nowseconds := f5.GetApp().GetRealSeconds() nowseconds := f5.GetApp().GetRealSeconds()
deletelist := []string{} deletelist := []string{}
this.accountContributionlist.Range(func(key string, value *accountContribution) bool { this.accountContributionlist.Range(func(key string, value *accountContribution) bool {
@ -316,7 +326,16 @@ func (this *contribution) checkContributionList() {
} }
this.accountContributionlist.Delete(account) 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))
} }
} }

View File

@ -7,6 +7,8 @@ import (
var Contribution = new(contribution) var Contribution = new(contribution)
var _serviceMgr = new(serviceMgr) var _serviceMgr = new(serviceMgr)
var GameSwitches = new(gameSwitch)
var User = new(user)
func init() { func init() {
global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr) global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr)

View File

@ -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
}

View File

@ -10,7 +10,7 @@ import (
func AddRechargeOrder(orderId string, shortOrderId string, func AddRechargeOrder(orderId string, shortOrderId string,
netId int32, accountAddress string, passportAddress string, netId int32, accountAddress string, passportAddress string,
currencyAddress string, currencyName string, itemId int32, itemNum int32, 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 ok := false
nowTime := f5.GetApp().GetRealSeconds() nowTime := f5.GetApp().GetRealSeconds()
fields := [][]string{ fields := [][]string{
@ -23,7 +23,7 @@ func AddRechargeOrder(orderId string, shortOrderId string,
{"currency_address", currencyAddress}, {"currency_address", currencyAddress},
{"item_id", q5.ToString(itemId)}, {"item_id", q5.ToString(itemId)},
{"item_num", q5.ToString(itemNum)}, {"item_num", q5.ToString(itemNum)},
{"price", q5.ToString(price)}, {"price", price},
{"diamond", q5.ToString(diamond)}, {"diamond", q5.ToString(diamond)},
{"present_diamond", q5.ToString(presentDiamond)}, {"present_diamond", q5.ToString(presentDiamond)},
{"return_contribution", q5.ToString(srcPrice * 1)}, {"return_contribution", q5.ToString(srcPrice * 1)},

View File

@ -5,8 +5,10 @@ type serviceMgr struct {
func (this *serviceMgr) Init() { func (this *serviceMgr) Init() {
Contribution.init() Contribution.init()
User.init()
} }
func (this *serviceMgr) UnInit() { func (this *serviceMgr) UnInit() {
Contribution.unInit() Contribution.unInit()
User.unInit()
} }

View File

@ -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
}