This commit is contained in:
yangduo 2024-06-26 20:58:00 +08:00
commit 3da5f2771a
25 changed files with 304 additions and 92 deletions

View File

@ -1 +1,2 @@
[${item.name}] has been synthesized successfully. Please go to the personal assets page on the web to view it. The web address : XXXXX
[${item.name}] has been synthesized successfully. Please go to the personal assets page on the web to view it. The web address :
https://www.counterfire.games/marketplace

View File

@ -1 +1,2 @@
[{$hero.name} ${hero.quality}] has been on-chain successfully. Please go to the personal assets page on the web to view it. The web market address is XXXXX
[{$hero.name} ${hero.quality}] has been on-chain successfully. Please go to the personal assets page on the web to view it. The web market address is
http://www.counterfire.games/marketplace

View File

@ -1 +1,2 @@
[{$hero.name} ${hero.quality}] has been on-chain successfully. Please go to the personal assets page on the web to view it. The web market address is XXXXX
[{$hero.name} ${hero.quality}] has been on-chain successfully. Please go to the personal assets page on the web to view it. The web market address is
https://www.counterfire.games/marketplace

View File

@ -3,5 +3,5 @@
"port": 3306,
"user": "root",
"passwd": "keji178",
"database": "bcnft_dev"
"database": "maildb_dev_1"
}

View File

@ -1,18 +1,18 @@
[
{
"name": "hero",
"nft_name": "hero",
"nft_symbol": "nft_symbol",
"nft_description": "description",
"nft_image": "https://res2.cebggame.com/nft/home_meta/home.jpg",
"nft_external_link": "https://res2.cebggame.com/nft/home_meta/home.jpg"
"nft_name": "COUNTERFIRE | Genesis Heroes",
"nft_symbol": "Heroes",
"nft_description": "The Genesis Heroes NFT collection grants access to play-to-earn (P2E) features in the Counter Fire game. Its initial release will be through blind boxes. Upon opening these boxes, players will randomly obtain their unique hero characters, spanning across 10 professions and 2 tiers. Owners of Genesis Heroes will also enjoy lucrative token airdrop rewards.",
"nft_image": "https://res2.counterfire.games/nft/home_meta/home.jpg",
"nft_external_link": "https://res2.counterfire.games/nft/home_meta/home.jpg"
},
{
"name": "gold_bullion",
"nft_name": "gold_bullion",
"nft_symbol": "nft_symbol",
"nft_description": "description",
"nft_image": "https://res2.cebggame.com/nft/home_meta/home.jpg",
"nft_external_link": "https://res2.cebggame.com/nft/home_meta/home.jpg"
"nft_name": "COUNTERFIRE | Golds",
"nft_symbol": "golds",
"nft_description": "COUNTERFIRE | Golds",
"nft_image": "https://res2.counterfire.games/nft/home_meta/home.jpg",
"nft_external_link": "https://res2.counterfire.games/nft/home_meta/home.jpg"
}
]

View File

@ -40,6 +40,16 @@ func (this *app) Update() {
}
func (this *app) registerDataSources() {
f5.GetGoStyleDb().RegisterDataSource(
constant.MAIL_DB,
mt.Table.MailDb.GetById(0).GetHost(),
mt.Table.MailDb.GetById(0).GetPort(),
mt.Table.MailDb.GetById(0).GetUser(),
mt.Table.MailDb.GetById(0).GetPasswd(),
mt.Table.MailDb.GetById(0).GetDatabase(),
30)
f5.GetGoStyleDb().RegisterDataSource(
constant.GAME_DB,
mt.Table.GameDb.GetById(0).GetHost(),

View File

@ -0,0 +1,14 @@
package mt
import (
"f5"
"mtb"
)
type MailDb struct {
mtb.MailDb
}
type MailDbTable struct {
f5.IdMetaTable[MailDb]
}

View File

@ -7,6 +7,7 @@ import (
type table struct {
BackTaskCluster *BackTaskClusterTable
GameDb *GameDbTable
MailDb *MailDbTable
BcEventDb *BcEventDbTable
BcNftDb *BcNftDbTable
Config *ConfigTable
@ -29,6 +30,11 @@ var Table = f5.New(func(this *table) {
this.PrimKey = ""
})
this.MailDb = f5.New(func(this *MailDbTable) {
this.FileName = "../config/maildb.mysql.json"
this.PrimKey = ""
})
this.BcEventDb = f5.New(func(this *BcEventDbTable) {
this.FileName = "../config/bceventdb.mysql.json"
this.PrimKey = ""

View File

@ -24,6 +24,17 @@ type GameDb struct {
_flags2_ uint64
}
type MailDb struct {
host string
port int32
user string
passwd string
database string
_flags1_ uint64
_flags2_ uint64
}
type BcNftDb struct {
host string
port int32
@ -158,6 +169,46 @@ func (this *GameDb) HasDatabase() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *MailDb) GetHost() string {
return this.host
}
func (this *MailDb) HasHost() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *MailDb) GetPort() int32 {
return this.port
}
func (this *MailDb) HasPort() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *MailDb) GetUser() string {
return this.user
}
func (this *MailDb) HasUser() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *MailDb) GetPasswd() string {
return this.passwd
}
func (this *MailDb) HasPasswd() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *MailDb) GetDatabase() string {
return this.database
}
func (this *MailDb) HasDatabase() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *BcNftDb) GetHost() string {
return this.host
}
@ -397,6 +448,14 @@ func (this *GameDb) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
}
func (this *MailDb) 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)
}
func (this *BcNftDb) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)

View File

@ -18,6 +18,15 @@ message GameDb
optional string database = 5;
}
message MailDb
{
optional string host = 1;
optional int32 port = 2;
optional string user = 3;
optional string passwd = 4;
optional string database = 5;
}
message BcNftDb
{
optional string host = 1;

View File

@ -1,6 +1,41 @@
package service
func SendSysMail(uniKey string, to string, subject string, content string, expireTime int32,
import (
"q5"
"f5"
"main/constant"
)
func SendSysMail(uniKey string, to string, subject string, content string, sendTime int32, expireTime int32,
tag1 int32, tag2 int32) bool {
return true
var dbErr error
nowTime := f5.GetApp().GetRealSeconds()
f5.GetGoStyleDb().Upsert(
constant.MAIL_DB,
"t_sys_mail",
[][]string{
{"unikey", uniKey},
},
[][]string{
},
[][]string{
{"unikey", uniKey},
{"subject", subject},
{"content", content},
{"recipients", q5.EncodeJson([]string{
to,
})},
{"tag1", q5.ToString(tag1)},
{"tag2", q5.ToString(tag2)},
{"sendtime", q5.ToString(sendTime)},
{"expiretime", q5.ToString(expireTime)},
{"user_reg_start_time", q5.ToString(0)},
{"user_reg_end_time", q5.ToString(nowTime + 3600 * 24 * 365 * 10)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
dbErr = err
})
return dbErr == nil
}

View File

@ -9,7 +9,20 @@ import (
)
func UpdateSpecTransferStatus(dbIdx int64, status int32) bool {
return true
var dbErr error
f5.GetGoStyleDb().Update(
constant.BCEVENT_DB,
"t_721nft_spec_transfer",
[][]string {
{"idx", q5.ToString(dbIdx)},
},
[][]string {
{"status", q5.ToString(status)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
dbErr = err
})
return dbErr == nil
}
func OpenGoldBullion(accountId string, accountAddress string, netId int32, tokenId string) bool {

View File

@ -24,6 +24,10 @@ func (this* goldBullionReturn) unInit() {
func (this* goldBullionReturn) loadExpiredGoldBullion() {
f5.GetGoStyleDb().LoopLoad(
constant.GAME_DB,
"t_gold_bullion",
func () int64 {
return 60 * 5
},
func (lastIdx int64) string {
nowTime := f5.GetApp().GetRealSeconds()
expiredTime := nowTime - 3600 * 24 - 60 * 5

View File

@ -8,6 +8,7 @@ import (
"jccommon"
"main/constant"
"main/service"
"math/rand"
)
type repairNft struct {
@ -26,6 +27,10 @@ func (this* repairNft) unInit() {
func (this* repairNft) processNft() {
f5.GetGoStyleDb().LoopLoad(
constant.BCNFT_DB,
"t_nft",
func () int64 {
return 60 * 1
},
func (lastIdx int64) string {
sql := fmt.Sprintf(`
SELECT * FROM t_nft WHERE idx > %d AND item_id = 0 LIMIT 1000`,
@ -47,6 +52,10 @@ SELECT * FROM t_nft WHERE idx > %d AND item_id = 0 LIMIT 1000`,
func (this* repairNft) processOrder() {
f5.GetGoStyleDb().LoopLoad(
constant.BCNFT_DB,
"t_order",
func () int64 {
return 60 + q5.ToInt64(rand.Intn(2))
},
func (lastIdx int64) string {
sql := fmt.Sprintf(`
SELECT * FROM t_order WHERE idx > %d AND item_id = 0 LIMIT 1000`,
@ -68,6 +77,10 @@ SELECT * FROM t_order WHERE idx > %d AND item_id = 0 LIMIT 1000`,
func (this* repairNft) processSale() {
f5.GetGoStyleDb().LoopLoad(
constant.BCNFT_DB,
"t_sale",
func () int64 {
return 60 + q5.ToInt64(rand.Intn(2))
},
func (lastIdx int64) string {
sql := fmt.Sprintf(`
SELECT * FROM t_sale WHERE idx > %d AND item_id = 0 LIMIT 1000`,

View File

@ -81,6 +81,7 @@ func (this* goldBullion) internalSendMail(dbIdx int64, accountAddress string, ma
subject,
content,
q5.ToInt32(nowTime),
q5.ToInt32(nowTime),
mailCfg.Tag1,
mailCfg.Tag2)
if sendOk {

View File

@ -16,6 +16,9 @@ type hero struct {
func (this* hero) onMint(dbIdx int64, netId int32, contractAddress string, tokenId string,
from string, to string) bool {
if jccommon.IsAirDropNft(tokenId) {
return service.UpdateSpecTransferStatus(dbIdx, 1)
}
ok := this.internalSendMail(dbIdx, to, constant.MAIL_HERO_MINT, tokenId)
return ok
}
@ -66,6 +69,7 @@ func (this* hero) internalSendMail(dbIdx int64, accountAddress string, mailName
subject,
content,
q5.ToInt32(nowTime),
q5.ToInt32(nowTime),
mailCfg.Tag1,
mailCfg.Tag2)
if sendOk {

View File

@ -8,6 +8,7 @@ import (
"mt"
"jccommon"
"main/constant"
"math/rand"
)
type SpecTransfer721 struct {
@ -27,6 +28,10 @@ func (this* SpecTransfer721) UnInit() {
func (this* SpecTransfer721) process() {
f5.GetGoStyleDb().LoopLoad(
constant.BCEVENT_DB,
"t_721nft_spec_transfer",
func () int64 {
return 3 + q5.ToInt64(rand.Intn(2))
},
func (lastIdx int64) string {
nowTime := f5.GetApp().GetRealSeconds()
expiredTime := nowTime - 3600 * 24 * 7

View File

@ -76,3 +76,13 @@ const (
EVENT_MAIL_UPDATE = "mail.update"
EVENT_UPSER_GROUP_UPDATE = "user_group.update"
)
const (
IMTBL_CHANNEL = 1
GUEST_CHANNEL = 2
BC_CHANNEL = 3
)
const (
BC_POLY_POLY_METAKASK = 13
)

View File

@ -18,6 +18,7 @@ import (
type goodsDto struct {
Event interface{} `json:"event"`
Nft interface{} `json:"nft"`
InShopCart int32 `json:"in_shopcart"`
}
type MarketApi struct {
@ -410,6 +411,9 @@ WHERE idx in (%s)
}
func (this *MarketApi) Goods(c *gin.Context) {
openId := c.MustGet("open_id").(string)
cartDb := service.GetShopCartByOpenId(openId)
netId := q5.ToInt64(c.Param("net_id"))
contractAddress := c.Param("contract_address")
tokenId := c.Param("token_id")
@ -457,6 +461,15 @@ WHERE net_id=? AND contract_address=? AND token_id=? AND status=?
c.JSON(200, rspObj)
return
}
if len(nfts) <= 0 {
p := new(common.NftDto)
//p.Param1 = q5.ToInt64(ds.GetByName("idx"))
p.NetId = q5.ToInt32(netId)
p.ContractAddress = contractAddress
p.TokenId = tokenId
p.Payload = nil
q5.AppendSlice(&nfts, p)
}
GetCacheMgr().GetNfts(nfts)
{
for _, val := range nfts {
@ -464,6 +477,9 @@ WHERE net_id=? AND contract_address=? AND token_id=? AND status=?
p = new(goodsDto)
p.Event = val.Payload
p.Nft = val.NftCache.GetJsonData()
if cartDb != nil && cartDb.GetGoods(val.NetId, val.ContractAddress, val.TokenId) != nil{
p.InShopCart = 1
}
rspObj.Data = p
}
}

View File

@ -5,6 +5,8 @@ import (
"f5"
"mt"
"fmt"
"jccommon"
"strings"
"github.com/gin-gonic/gin"
)
@ -32,6 +34,15 @@ func internalJwtAuth(c *gin.Context, maybe bool) {
}
}
tmpStrings := q5.StrSplit(jwtToken, ".")
if len(tmpStrings) > 3 {
internalMetaMaskJwtAuth(c, jwtToken)
} else {
internalImmutJwtAuth(c, jwtToken)
}
}
func internalImmutJwtAuth(c *gin.Context, jwtToken string) {
params := map[string]string{
"c": "Jwt",
"a": "verify",
@ -83,7 +94,73 @@ func internalJwtAuth(c *gin.Context, maybe bool) {
c.Abort()
return
}
c.Set("open_id", jsonRspObj.Decoded.Sub)
openId := fmt.Sprintf("%d_2006_%s", jccommon.IMTBL_CHANNEL, jsonRspObj.Decoded.Sub)
c.Set("open_id", openId)
c.Next()
})
}
func internalMetaMaskJwtAuth(c *gin.Context, jwtToken string) {
params := map[string]string{
"c": "MetaMaskJwt",
"a": "verify",
}
jsonReqObj := &struct {
Data string `json:"data"`
}{
Data: jwtToken,
}
jsonRspObj := &struct {
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
Decoded struct {
Id string `json:"id"`
OpenId string `json:"openid"`
Plat int32 `json:"plat"`
Version int32 `json:"version"`
} `json:"decoded"`
}{}
rspObj := &struct {
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{}
paramsStr := q5.EncodeJson(jsonReqObj)
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Web3ServiceCluster.RandElement().GetUrl())
f5.GetHttpCliMgr().SendGoStyleJsonRspPost(
url,
params,
jsonRspObj,
q5.HTTP_HEADER_JSON,
paramsStr,
func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil ||
!rsp.JsonParseOk() {
rspObj.ErrCode = 500
rspObj.ErrMsg = "server internal error"
c.JSON(200, rspObj)
c.Abort()
return
}
rspObj.ErrCode = q5.SafeToInt32(jsonRspObj.ErrCode)
rspObj.ErrMsg = jsonRspObj.ErrMsg
if q5.SafeToInt32(rspObj.ErrCode) != 0 {
rspObj.ErrCode = 501
rspObj.ErrMsg = "jwt error"
c.JSON(200, rspObj)
c.Abort()
return
}
if jsonRspObj.Decoded.Plat != jccommon.BC_POLY_POLY_METAKASK {
rspObj.ErrCode = 501
rspObj.ErrMsg = "not summport platform"
c.JSON(200, rspObj)
c.Abort()
return
}
openId := fmt.Sprintf("%d_2006_%s",
jccommon.BC_CHANNEL,
strings.ToLower(jsonRspObj.Decoded.OpenId))
c.Set("open_id", openId)
c.Next()
})
}

View File

@ -17,5 +17,7 @@ func (this *MarketRouter) InitRouter() {
api.MarketApi.TransactionHistory)
f5.GetApp().GetGinEngine().GET("/api/market/product/category/:net_id", api.MarketApi.CategoryGoodsNum)
f5.GetApp().GetGinEngine().GET("/api/market/product/query_price", api.MarketApi.QueryPrice)
f5.GetApp().GetGinEngine().GET("/api/market/product/goods/:net_id/:contract_address/:token_id", api.MarketApi.Goods)
f5.GetApp().GetGinEngine().GET("/api/market/product/goods/:net_id/:contract_address/:token_id",
middleware.MaybeJwtAuth,
api.MarketApi.Goods)
}

View File

@ -20,7 +20,6 @@ func GetShopCartByOpenId(openId string) *common.ShopCart {
return
}
if ds.Next() {
cartDb := common.NewShopCart()
if q5.DecodeJson(ds.GetByName("data"), cartDb) == nil {
}
}

View File

@ -1,69 +0,0 @@
package model
import (
"q5"
"f5"
"main/constant"
)
type inbox struct {
}
var Inbox = new(inbox)
func (this *inbox) Mark(accountId string, mailId int64, nowTime int64, expireTime int32) error {
var result error
f5.GetGoStyleDb().Upsert(
constant.MAIL_DB,
"t_inbox",
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
},
[][]string{
{"state", q5.ToString(constant.INBOX_STATE_READ)},
{"expiretime", q5.ToString(expireTime)},
{"modifytime", q5.ToString(nowTime)},
},
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
{"state", q5.ToString(constant.INBOX_STATE_READ)},
{"expiretime", q5.ToString(expireTime)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
result = err
})
return result
}
func (this *inbox) Delete(accountId string, mailId int64, nowTime int64, expireTime int32) error {
var result error
f5.GetGoStyleDb().Upsert(
constant.MAIL_DB,
"t_inbox",
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
},
[][]string{
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
{"expiretime", q5.ToString(expireTime)},
{"modifytime", q5.ToString(nowTime)},
},
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
{"expiretime", q5.ToString(expireTime)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
result = err
})
return result
}

View File

@ -6,7 +6,7 @@ import (
type table struct {
NftServerCluster *NftServerClusterTable
NftDb *NftDbTable
//NftDb *NftDbTable
Config *ConfigTable
NftHomeMeta *NftHomeMetaTable
//Contract *ContractTable
@ -18,10 +18,11 @@ var Table = f5.New(func(this *table) {
this.PrimKey = "instance_id"
})
/*
this.NftDb = f5.New(func(this *NftDbTable) {
this.FileName = "../config/nftdb.mysql.json"
this.PrimKey = ""
})
})*/
this.Config = f5.New(func(this *ConfigTable) {
this.FileName = "../config/config.json"

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit bf49efd5a029a9e0749019c03fb4295dd89bf350
Subproject commit cc296565ec6f6a2e150ddcafcc4c194a6eb20e48