Compare commits

..

1 Commits

Author SHA1 Message Date
aozhiwei
58f7ed2745 屏蔽贡献点返回 2024-09-22 14:16:15 +08:00
215 changed files with 916 additions and 7973 deletions

View File

@ -1,53 +0,0 @@
[
{
"net_id": 11155111,
"rpc_url": "https://rpc.sepolia.org",
"account_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"token_name": "USDC",
"token_address": "0xd95353ea0dd9d8a970e2b167b2c2bffef6222402"
},
{
"net_id": 11155111,
"rpc_url": "https://rpc.sepolia.org",
"account_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"token_name": "USDT",
"token_address": "0xedd5e19f46b3f8fe5ed16808f885565e2980cee0"
},
{
"net_id": 13473,
"rpc_url": "https://rpc.testnet.immutable.com",
"account_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"token_name": "USDC",
"token_address": "0x11440cE5a7d6a1e6fa1e9fd790EBa93476F0DeA0"
},
{
"net_id": 421614,
"rpc_url": "https://arbitrum-sepolia.blockpi.network/v1/rpc/public",
"account_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"token_name": "USDC",
"token_address": "0xafd1935c13eebc205998d870ef423658293e71bc"
},
{
"net_id": 421614,
"rpc_url": "https://arbitrum-sepolia.blockpi.network/v1/rpc/public",
"account_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"token_name": "USDT",
"token_address": "0x55bef0fc1423421c3ce1e070d9671e4b417db57c"
},
{
"net_id": 97,
"rpc_url": "https://bsc-testnet-rpc.publicnode.com",
"account_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"token_name": "USDC",
"token_address": "0x9895d4a938111a747c543cbe5e7479fad7306ff6"
},
{
"net_id": 97,
"rpc_url": "https://bsc-testnet-rpc.publicnode.com",
"account_address": "0x50A8e60041A206AcaA5F844a1104896224be6F39",
"token_name": "USDT",
"token_address": "0x8f34a7b59841bc87f7d80f9858490cc1412d50fb"
}
]

View File

@ -99,26 +99,6 @@
"switch_name": "ui.contribution.show",
"switch_desc": "25-贡献点是否显示"
},
{
"switch_name": "ui.activationCode",
"switch_desc": "26-激活码是否显示"
},
{
"switch_name": "circuitMatch",
"switch_desc": "27-巡回赛"
},
{
"switch_name": "ui.marketNft",
"switch_desc": "28-marketNFT是否显示"
},
{
"switch_name": "ui.officeSite",
"switch_desc": "29-官网"
},
{
"switch_name": "circuitTask",
"switch_desc": "30-巡回赛任务"
},
{
"switch_name": "only.allowed.superWhiteList",
"switch_desc": "100-只允许至尊白名单用户登录登录"

View File

@ -1 +0,0 @@
../../backtask/config/nets/

View File

@ -1 +0,0 @@
../../backtask/config/nets.json

View File

@ -1,9 +0,0 @@
{
"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

@ -1,5 +1,7 @@
{
"redirect_url": "http://internal.game2006api-test.kingsome.cn",
"max_concurrent_num": 60,
"gamesapi_url": "https://game2006sapi-test.kingsome.cn",
"redirect_url": "https://game2006api-test.kingsome.cn",
"redirect_secret_key": "~kCu8jYS)rJ5Ay_pZS_rT#&jOl)Qo0m)",
"max_concurrent_num": 10,
"request_over_time": 30
}

View File

@ -1,9 +0,0 @@
{
"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

@ -4,6 +4,5 @@
"immutable_base_url": "https://api.sandbox.immutable.com",
"hero_contract_address": "0x65570A86E5aA2B14325f8a13C70b74f7d1E2f5c9",
"immutable_api_key": "sk_imapik-test-kbe8ZWVEzySQPmdiOd8H_ac92cd",
"chain_name": "imtbl-zkevm-testnet",
"scoreboard_height": 100
"chain_name": "imtbl-zkevm-testnet"
}

View File

@ -1 +0,0 @@
../../backtask/config/nets

View File

@ -1,123 +0,0 @@
[
{
"rights": "1:5",
"require": 0,
"thisPoint": 1000,
"rank": 0,
"vip_name": "item_desc_210001",
"rate": 1,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 100
},
{
"rights": "1:10",
"require": 1000,
"thisPoint": 1000,
"rank": 1,
"vip_name": "item_desc_210001",
"rate": 1.2,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 101
},
{
"rights": "1:10|2:0.05",
"require": 2200,
"thisPoint": 2000,
"rank": 2,
"vip_name": "item_desc_210001",
"rate": 1.4,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 102
},
{
"rights": "1:15|2:0.05",
"require": 5000,
"thisPoint": 4000,
"rank": 3,
"vip_name": "item_desc_210001",
"rate": 1.6,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 103
},
{
"rights": "1:15|2:0.075|4:0.05",
"require": 11400,
"thisPoint": 8000,
"rank": 4,
"vip_name": "item_desc_210001",
"rate": 1.8,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 104
},
{
"rights": "1:20|2:0.075|4:0.05",
"require": 25800,
"thisPoint": 16000,
"rank": 5,
"vip_name": "item_desc_210001",
"rate": 2,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 105
},
{
"rights": "1:20|2:0.1|4:0.075|5:0.05",
"require": 57800,
"thisPoint": 32000,
"rank": 6,
"vip_name": "item_desc_210001",
"rate": 2.2,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 106
},
{
"rights": "1:25|2:0.1|4:0.075|5:0.05",
"require": 128200,
"thisPoint": 64000,
"rank": 7,
"vip_name": "item_desc_210001",
"rate": 2.4,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 107
},
{
"rights": "1:25|2:0.125|4:0.1|5:0.075|3:2",
"require": 281800,
"thisPoint": 128000,
"rank": 8,
"vip_name": "item_desc_210001",
"rate": 2.6,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 108
},
{
"rights": "1:30|2:0.125|4:0.1|5:0.075|3:3",
"require": 614600,
"thisPoint": 256000,
"rank": 9,
"vip_name": "item_desc_210001",
"rate": 2.8,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 109
},
{
"rights": "1:30|2:0.15|4:0.125|5:0.1|3:5|6:100",
"require": 1331400,
"thisPoint": -1,
"rank": 10,
"vip_name": "item_desc_210001",
"rate": 1,
"vip_working_tips": "item_desc_210001",
"vip_unworking_tips": "item_desc_210001",
"id": 110
}
]

View File

@ -1,6 +1,6 @@
{
"secret_key": "520d8eAbB(8cf1^#$^&!@d833a42c820432PDAFE^^)",
"gameapi_url": "https://game2006sapi-test.kingsome.cn",
"gameapi_url": "https://game2006api-test.kingsome.cn",
"gm_open": 1,
"gm_secret_key": "Pu6bxRKiS^@pUQdAC!RHMTY^srV5V^4&fqgUs1HjM*LI1sABQDQemU^Mh!55"
}

View File

@ -1,9 +0,0 @@
{
"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",
"contract_name": "BEUSDC",
"currency_decimal": 18
"currency_decimal": 6
},
{
"currency_name": "USDT",
"contract_name": "BEUSDT",
"currency_decimal": 18
"currency_decimal": 6
}
]

View File

@ -1 +0,0 @@
../../light_backtask/res/stakingVip@stakingVip.json

View File

@ -4,6 +4,5 @@
"auto_start_time": 3600,
"game_start_notify_time": 20,
"delay_delete_time": 60,
"match_real_player": 1,
"circuit_mode_interval_time": 0
"match_real_player": 1
}

View File

@ -1,9 +0,0 @@
{
"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

@ -1,5 +0,0 @@
{
"mqproxy_url": "http://127.0.0.1:3010",
"notice_url": "http://127.0.0.1:3012",
"notice_channel_id": "world_room_1"
}

View File

@ -1,7 +0,0 @@
[
{
"instance_id": 1,
"listen_port": 3013,
"http_listen_port": 3012
}
]

View File

@ -1,9 +0,0 @@
{
"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

@ -1,7 +0,0 @@
{
"gamesapi_url": "https://game2006sapi-test.kingsome.cn",
"redirect_url": "https://game2006api-test.kingsome.cn",
"redirect_secret_key": "~kCu8jYS)rJ5Ay_pZS_rT#&jOl)Qo0m)",
"max_concurrent_num": 10,
"request_over_time": 30
}

View File

@ -1,7 +0,0 @@
[
{
"instance_id": 1,
"listen_port": 3011,
"http_listen_port": 3010
}
]

View File

@ -82,7 +82,6 @@ CREATE TABLE `t_game_switch` (
`switch_name` varchar(60) NOT NULL COMMENT '功能名',
`is_open` int(11) NOT NULL DEFAULT '0' COMMENT '是否开启',
`audit_is_open` int(11) NOT NULL DEFAULT '0' COMMENT '审核模式是否开启',
`server_list` varchar(20) NOT NULL DEFAULT '' COMMENT '服务器(列表空所有服)',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
@ -136,80 +135,6 @@ CREATE TABLE `t_super_whitelist` (
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `t_whitelist`
--
DROP TABLE IF EXISTS `t_whitelist`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_whitelist` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_identity` varchar(60) NOT NULL COMMENT 'account_id or account_address or email',
`enable` int(11) NOT NULL DEFAULT '0' COMMENT '是否生效',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `user_identity` (`user_identity`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `t_blacklist`
--
DROP TABLE IF EXISTS `t_blacklist`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_blacklist` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_identity` varchar(60) NOT NULL COMMENT 'account_id or account_address or email',
`enable` int(11) NOT NULL DEFAULT '0' COMMENT '是否生效',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `user_identity` (`user_identity`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `t_internal_gameapi_host`
--
DROP TABLE IF EXISTS `t_internal_gameapi_host`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_internal_gameapi_host` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`gameapi_host` varchar(60) NOT NULL COMMENT 'gameapi_host(ip)',
`gameapi_port` int(11) NOT NULL DEFAULT '0' COMMENT 'gameapi_port',
`enable` int(11) NOT NULL DEFAULT '0' COMMENT '是否生效',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `gameapi_host` (`gameapi_host`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `t_apigate_host`
--
DROP TABLE IF EXISTS `t_apigate_host`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_apigate_host` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`apigate_host` varchar(60) NOT NULL COMMENT 'apigate_host(ip)',
`apigate_port` int(11) NOT NULL DEFAULT '0' COMMENT 'apigate_port',
`enable` int(11) NOT NULL DEFAULT '0' COMMENT '是否生效',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `apigate_host` (`apigate_host`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

View File

@ -1,180 +0,0 @@
package system
import (
"f5"
"fmt"
"main/constant"
"main/model/system"
"net/http"
"q5"
"strings"
"math/rand"
"github.com/gin-gonic/gin"
)
type ActiveCodeApi struct {
}
func (aca *ActiveCodeApi) GenCode(c *gin.Context) {
var batchid int32 = 0
var maxbatchid int32 = 0
db := f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table("t_activation_code").Select("max(batch_id)")
err := db.Error
if err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
f5.RspErr2(c, 1, err.Error())
return
}
} else {
var count int64 = 0
if db.Count(&count); count > 0 {
db.Scan(&maxbatchid)
}
}
if maxbatchid >= 0xFFF {
f5.RspErr2(c, 1, "batchid overflow")
return
}
batchid = maxbatchid + 1
count := q5.SafeToInt32(c.DefaultQuery("count", "1"))
if count < 1 {
count = 1
}
if count > 5000 {
count = 5000
}
tryCount := 0
postfix := fmt.Sprintf("%03x", batchid)
codelist := map[string]int{}
nowsecs := int32(f5.GetApp().GetRealSeconds())
batchcodeinfo := []*system.ActiveCode{}
for i := 0; i < int(count); {
if tryCount > 10000*10 {
f5.RspErr2(c, 1, "internal error")
return
}
code := aca.genCode(7) + postfix
_, exist := codelist[code]
if exist {
tryCount++
continue
}
codelist[code] = 1
i++
p := new(system.ActiveCode)
p.Batch_id = batchid
p.Code = code
p.CreateTime = nowsecs
p.ModifyTime = nowsecs
batchcodeinfo = append(batchcodeinfo, p)
}
err = f5.GetApp().GetOrmDb(constant.ACCOUNT_DB).Table("t_activation_code").Create(batchcodeinfo).Error
if err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "成功生成",
"batchid": batchid,
})
}
const strpol = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghjkmnpqrstuvwxyz"
func (this *ActiveCodeApi) genCode(n int) string {
var sb strings.Builder
k := len(strpol)
for i := 0; i < n; i++ {
c := strpol[rand.Intn(k)]
sb.WriteByte(c)
}
return sb.String()
}
func (this *ActiveCodeApi) List(c *gin.Context) {
req := struct {
BatchId int32 `json:"batch_id"`
PageDto system.PageDto `json:"page_dto"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
sql := fmt.Sprintf("SELECT * FROM t_activation_code WHERE 1=1 AND batch_id = %d", req.BatchId)
params := []string{}
result := []*system.ActiveCode{}
f5.GetGoStyleDb().PageQuery(
constant.ACCOUNT_DB,
q5.ToInt32(req.PageDto.PageSize),
q5.ToInt32(req.PageDto.Page),
sql,
params,
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
"",
func(err error, pg *f5.Pagination) {
if err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
f5.UnmarshalModelList(pg.Rows, &result)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "获取成功",
"data": result,
"total": pg.Total,
"total_page": pg.TotalPages,
"cur_page": pg.CurrentPage,
})
})
}
func (this *ActiveCodeApi) DownloadFile(c *gin.Context) {
batchid := q5.SafeToInt32(c.DefaultQuery("batchid", ""))
if batchid < 1 {
f5.RspErr2(c, 1, "batchid error")
return
}
sql := fmt.Sprintf("SELECT * FROM t_activation_code WHERE 1=1 AND batch_id = %d", batchid)
f5.GetGoStyleDb().RawQuery(
constant.ACCOUNT_DB,
sql,
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
data := []struct {
BatchId int32 `json:"batch_id"`
Code string `json:"activation_code"`
}{}
for ds.Next() {
p := q5.NewSliceElement(&data)
p.BatchId = q5.SafeToInt32(ds.GetByName("batch_id"))
p.Code = ds.GetByName("activation_code")
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
"data": data,
})
})
}

View File

@ -30,10 +30,10 @@ func (bpa *BlockPlayerApi) List(c *gin.Context) {
constant.CONF_DB,
q5.ToInt32(req.PageDto.PageSize),
q5.ToInt32(req.PageDto.Page),
"SELECT * FROM t_blacklist WHERE 1=1",
"SELECT * FROM t_blockplayer WHERE 1=1 AND deleted = 0",
[]string{},
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
" ORDER BY user_identity ",
" ORDER BY account_id ",
func(err error, pg *f5.Pagination) {
if err != nil {
c.JSON(http.StatusOK, gin.H{
@ -45,8 +45,8 @@ func (bpa *BlockPlayerApi) List(c *gin.Context) {
for pg.Rows.Next() {
p := new(system.BlockPlayer)
p.Enable = q5.SafeToInt32(pg.Rows.GetByName("enable"))
p.Identity = pg.Rows.GetByName("user_identity")
p.Blocked = q5.SafeToInt32(pg.Rows.GetByName("blocked"))
p.Account = pg.Rows.GetByName("account_id")
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
q5.AppendSlice(&result, p)
@ -64,8 +64,7 @@ func (bpa *BlockPlayerApi) List(c *gin.Context) {
func (bpa *BlockPlayerApi) Add(c *gin.Context) {
req := struct {
Identity string `binding:"required" json:"user_identity"`
Enable int32 `json:"enable"`
Account string `binding:"required" json:"account_id"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
@ -75,20 +74,34 @@ func (bpa *BlockPlayerApi) Add(c *gin.Context) {
return
}
info := new(system.BlockPlayer)
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
var count int64 = 0
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_blacklist").Where("user_identity =?", req.Identity)
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_blockplayer").Where("account_id =?", req.Account)
if err := db.Count(&count).Error; err == nil && count > 0 {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "数据存在",
})
db.Take(info)
if info.Deleted == 0 {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "数据存在",
})
} else {
info.Blocked = 1
info.Deleted = 0
info.ModifyTime = nowDaySeconds
db.Save(info)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "添加成功",
})
}
return
}
info := new(system.BlockPlayer)
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
info.Identity = req.Identity
info.Enable = req.Enable
info.Account = req.Account
info.Blocked = 1
info.CreateTime = nowDaySeconds
info.ModifyTime = nowDaySeconds
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
@ -106,8 +119,8 @@ func (bpa *BlockPlayerApi) Add(c *gin.Context) {
func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
req := struct {
Identity string `binding:"required" json:"user_identity"`
Enable int32 `json:"enable"`
Account string `binding:"required" json:"account_id"`
Blocked int32 `json:"blocked"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
@ -119,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, "user_identity = ?", req.Identity).Error; err != nil {
if err := db.Take(blockplayer, "account_id =?", req.Account).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
c.JSON(http.StatusOK, gin.H{
"code": 500,
@ -135,16 +148,15 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
}
}
if blockplayer.Enable != req.Enable {
blockplayer.Enable = req.Enable
blockplayer.ModifyTime = int32(f5.GetApp().GetRealSeconds())
if err := db.Where("user_identity = ?", req.Identity).Save(blockplayer).Error; err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
}
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
blockplayer.Blocked = req.Blocked
blockplayer.ModifyTime = nowDaySeconds
if err := db.Where("account_id = ?", req.Account).Save(blockplayer).Error; err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
@ -153,49 +165,49 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) {
}
func (bpa *BlockPlayerApi) Del(c *gin.Context) {
// req := struct {
// Identity string `binding:"required" json:"user_identity"`
// }{}
// if err := c.ShouldBindJSON(&req); err != nil {
// c.JSON(http.StatusOK, gin.H{
// "code": 1,
// "message": err.Error(),
// })
// return
// }
req := struct {
Account string `binding:"required" json:"account_id"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
return
}
// blockplayer := new(system.BlockPlayer)
// db := f5.GetApp().GetOrmDb(constant.CONF_DB)
// if err := db.Take(blockplayer, "user_identity = ?", req.Identity).Error; err != nil {
// if !f5.IsOrmErrRecordNotFound(err) {
// c.JSON(http.StatusOK, gin.H{
// "code": 500,
// "message": "sever internal error:" + err.Error(),
// })
// return
// } else {
// c.JSON(http.StatusOK, gin.H{
// "code": 2,
// "message": "无法查到记录",
// })
// return
// }
// } else {
// }
// nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
// blockplayer.Deleted = 1
// blockplayer.ModifyTime = nowDaySeconds
// if err := db.Where("user_identity = ?", req.Identity).Save(blockplayer).Error; err != nil {
// c.JSON(http.StatusOK, gin.H{
// "code": 500,
// "message": "sever internal error:" + err.Error(),
// })
// return
// }
// c.JSON(http.StatusOK, gin.H{
// "code": 0,
// "message": "",
// })
blockplayer := new(system.BlockPlayer)
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
if err := db.Take(blockplayer, "account_id =?", req.Account).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
} else {
c.JSON(http.StatusOK, gin.H{
"code": 2,
"message": "无法查到记录",
})
return
}
} else {
}
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
blockplayer.Deleted = 1
blockplayer.ModifyTime = nowDaySeconds
if err := db.Where("account_id = ?", req.Account).Save(blockplayer).Error; err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
})
}
func (bpa *BlockPlayerApi) UploadExcel(c *gin.Context) {
@ -230,8 +242,8 @@ func (bpa *BlockPlayerApi) UploadExcel(c *gin.Context) {
continue
}
member := new(system.BlockPlayer)
member.Identity = row[0]
member.Enable = 1
member.Account = row[0]
member.Blocked = 1
member.CreateTime = nowDaySeconds
member.ModifyTime = nowDaySeconds
blockplayers = append(blockplayers, member)

View File

@ -13,6 +13,4 @@ type ApiGroup struct {
GameSwitchApi
BlockPlayerApi
WhiteListApi
ActiveCodeApi
WorkerToolApi
}

View File

@ -1,15 +1,12 @@
package system
import (
"encoding/json"
"f5"
"fmt"
"main/constant"
"main/model/system"
"main/mt"
"net/http"
"q5"
"sort"
"github.com/gin-gonic/gin"
)
@ -56,8 +53,7 @@ func (this *GameSwitchApi) List(c *gin.Context) {
page := c.DefaultQuery("page", "")
result := []struct {
system.GameSwitch
Servers []int32 `json:"serverList"`
Remark string `json:"remark"`
Remark string `json:"remark"`
}{}
f5.GetGoStyleDb().PageQuery(
constant.CONF_DB,
@ -85,8 +81,6 @@ func (this *GameSwitchApi) List(c *gin.Context) {
if exist {
p.Remark = desc
}
p.Servers = make([]int32, 0)
json.Unmarshal([]byte(pg.Rows.GetByName("server_list")), &p.Servers)
p.AuditOpen = q5.SafeToInt32(pg.Rows.GetByName("audit_is_open"))
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
@ -146,7 +140,6 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
req := struct {
Name string `binding:"required" json:"switch_name"`
Open *int32 `binding:"required" json:"is_open"`
Servers []int `json:"serverList"`
AuditOpen *int32 `binding:"required" json:"audit_is_open"`
Remark string `json:"remark"`
}{}
@ -157,10 +150,7 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
})
return
}
gswitch := new(struct {
system.GameSwitch
Servers string `gorm:"column:server_list" json:"serverList"`
})
gswitch := new(system.GameSwitch)
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
if err := db.Take(gswitch, "switch_name = ?", req.Name).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
@ -178,11 +168,8 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
}
}
sort.Ints(req.Servers)
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
gswitch.Opened = *req.Open
serverbytes, _ := json.Marshal(req.Servers)
gswitch.Servers = string(serverbytes)
gswitch.AuditOpen = *req.AuditOpen
gswitch.ModifyTime = nowDaySeconds
if err := db.Where("switch_name = ?", req.Name).Save(gswitch).Error; err != nil {
@ -196,8 +183,6 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
"code": 0,
"message": "",
})
this.refreshAct(func(f5.HttpCliResponse) {})
}
func (this *GameSwitchApi) Del(c *gin.Context) {
@ -243,32 +228,3 @@ func (this *GameSwitchApi) Del(c *gin.Context) {
"message": "",
})
}
func (this *GameSwitchApi) Refresh(c *gin.Context) {
this.refreshAct(func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil {
f5.RspErr2(c, 500, rsp.GetErr().Error())
return
}
rspJson := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
CP int32 `json:"contributionPoint"`
}{}
if q5.DecodeJson(rsp.GetRawData(), &rspJson) != nil {
f5.RspErr2(c, 500, "server internal error")
return
}
f5.RspErr2(c, rspJson.ErrCode, rspJson.ErrMsg)
})
}
func (this *GameSwitchApi) refreshAct(cb func(f5.HttpCliResponse)) {
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.RandElement().GetGameapiUrl()+"/webapp/index.php",
map[string]string{
"c": "OutAppTools",
"a": "refreshServerSwitch",
},
cb)
}

View File

@ -3,8 +3,6 @@ package system
import (
"f5"
"fmt"
"main/mt"
"main/service"
"main/constant"
"main/model/system"
@ -127,68 +125,3 @@ func (this *NFTApi) NFTQuery(c *gin.Context) {
return p
})
}
func (this *NFTApi) BalanceQuery(c *gin.Context) {
type BalanceQueryForm struct {
Account string `json:"account_address"`
}
reqJson := BalanceQueryForm{}
if !checkparam(&reqJson, c) {
return
}
selfaccount := false
if reqJson.Account != "" {
mt.Table.Chain.Traverse(func(item *mt.Chain) bool {
if item.GetAccountAddress() == reqJson.Account {
selfaccount = true
return false
}
return true
})
}
type retitem struct {
Account string `json:"account_address"`
TokenName string `json:"token_name"`
ChainBalance string `json:"chain_balance"`
Recharge int64 `json:"recharge"`
NetId int32 `json:"net_id"`
TokenAddress string `json:"-"`
}
result := []retitem{}
mt.Table.Chain.Traverse(func(item *mt.Chain) bool {
account := item.GetAccountAddress()
if selfaccount && account != reqJson.Account {
return true
}
if reqJson.Account != "" && !selfaccount {
account = reqJson.Account
}
p := q5.NewSliceElement(&result)
p.Account = account
p.NetId = item.GetNetId()
p.TokenName = item.GetTokenName()
p.TokenAddress = item.GetTokenAddress()
key := fmt.Sprintf("%d$%s", item.GetNetId(), item.GetTokenAddress())
if selfaccount || reqJson.Account == "" {
p.ChainBalance, p.Recharge = service.Balance.GetGlobalBalance(key)
} else {
p.ChainBalance, p.Recharge = service.Balance.GetAccoutBalance(key, account)
}
return true
})
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
"data": result,
})
}

View File

@ -3,10 +3,8 @@ package system
import (
"f5"
"fmt"
"jccommon"
"main/constant"
"main/model/system"
"main/mt"
"net/http"
"q5"
"strings"
@ -65,7 +63,11 @@ func (pai *PlayerApi) Info(c *gin.Context) {
})
if len(accountids) == 0 {
f5.RspErr2(c, 0, "")
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
})
return
}
@ -77,7 +79,10 @@ func (pai *PlayerApi) Info(c *gin.Context) {
filterstr += ")"
} else {
f5.RspErr2(c, 1, "input one of playername, account_id, address, email")
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "input one of playername, account_id, address, email",
})
return
}
sql := fmt.Sprintf(`SELECT * FROM t_user WHERE idx > %d AND %s `, cursor, filterstr)
@ -131,11 +136,6 @@ func (pai *PlayerApi) BagQuery(c *gin.Context) {
return
}
if len(reqJson.Account_id) > 0xFF {
f5.RspErr2(c, 1, "输入过长")
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)
@ -153,82 +153,13 @@ func (pai *PlayerApi) HeroesQuery(c *gin.Context) {
}
reqJson := HeroesQueryForm{}
if !checkparam(&reqJson, c) || reqJson.Account_id == "" {
return
}
if len(reqJson.Account_id) > 0xFF {
f5.RspErr2(c, 1, "输入过长")
if !checkparam(&reqJson, c) {
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
filterstr := "account_id = '" + reqJson.Account_id + "' "
{
sql := fmt.Sprintf(`SELECT address FROM t_immutable_account WHERE idx > 1 AND account_id = '%s'`, reqJson.Account_id)
address := ""
f5.GetGoStyleDb().RawQuery(
constant.ACCOUNT_DB,
sql,
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
return
}
if ds.Next() {
address = ds.GetByIndex(0)
}
})
if address != "" {
lockaddrlist := []string{}
mt.Table.Contract.Traverse(func(mtc *mt.Contract) bool {
if mtc.GetName() == jccommon.CONTRACT_NAME_NFTLock {
lockaddrlist = append(lockaddrlist, strings.ToLower(mtc.GetAddress()))
}
return true
})
sql = fmt.Sprintf(`SELECT token_id FROM t_nft WHERE idx > 1 AND token_type IN (1, 12) AND (owner_address = '%s'`, address)
if len(lockaddrlist) > 0 {
sql += fmt.Sprintf(" OR (last_lock_address = '%s' AND owner_address IN (", address)
for _, addr := range lockaddrlist {
sql += "'" + addr + "',"
}
sql = sql[:len(sql)-1]
sql += "))"
}
sql += ")"
f5.GetSysLog().Debug("tokenid sql:%s", sql)
tokenidlist := []string{}
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
return
}
for ds.Next() {
tokenidlist = append(tokenidlist, ds.GetByIndex(0))
}
})
if len(tokenidlist) > 0 {
tokenfilterstr := "OR token_id IN ("
for _, v := range tokenidlist {
tokenfilterstr += v + ","
}
tokenfilterstr = tokenfilterstr[:len(tokenfilterstr)-1]
tokenfilterstr += ")"
filterstr += tokenfilterstr
}
}
}
sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND (%s)`, cursor, filterstr)
f5.GetSysLog().Debug("hero sql:%s", sql)
filterstr := " account_id = '" + reqJson.Account_id + "' "
sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr)
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
p := new(system.Hero)
@ -254,7 +185,10 @@ func (pai *PlayerApi) GoldBullionQuery(c *gin.Context) {
} else if reqJson.Open_address != "" {
filterstr = " open_address = '" + reqJson.Open_address + "'"
} else {
f5.RspErr2(c, 1, "input one of token_id, open_address")
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "input one of token_id, open_address",
})
return
}
@ -314,7 +248,10 @@ func (pai *PlayerApi) GameMallQuery(c *gin.Context) {
} else if reqJson.Seller_address != "" {
filterstr = " seller_address = '" + reqJson.Seller_address + "'"
} else {
f5.RspErr2(c, 1, "input one of order_id, seller, seller_address")
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "input one of order_id, seller, seller_address",
})
return
}
@ -327,181 +264,3 @@ func (pai *PlayerApi) GameMallQuery(c *gin.Context) {
return p
})
}
func (pai *PlayerApi) InappOrderQuery(c *gin.Context) {
type InappOrderQueryForm struct {
Order_id string `json:"order_id"`
SP_Order_id string `json:"sp_order_id"`
Account_id string `json:"account_id"`
}
reqJson := InappOrderQueryForm{}
if !checkparam(&reqJson, c) {
return
}
filterstr := ""
if reqJson.Order_id != "" {
filterstr = " order_id = '" + reqJson.Order_id + "'"
} else if reqJson.SP_Order_id != "" {
filterstr = " sp_order_id = '" + reqJson.SP_Order_id + "'"
} else if reqJson.Account_id != "" {
filterstr = " account_id = '" + reqJson.Account_id + "'"
} else {
f5.RspErr2(c, 1, "input one of order_id, app store order_id, account_id")
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
sql := fmt.Sprintf(`SELECT * FROM t_inapp_order WHERE idx > %d AND %s `, cursor, filterstr)
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
p := new(struct {
Idx int64 `gorm:"column:idx" json:"idx"`
Order_id string `gorm:"column:order_id" json:"order_id"`
SP_Order_id string `gorm:"column:sp_order_id" json:"sp_order_id"`
Platform int `gorm:"column:platform" json:"platform"`
Account_id string `gorm:"column:account_id" json:"account_id"`
Goods_id int `gorm:"column:goods_id" json:"goods_id"`
Price float64 `gorm:"column:price" json:"price"`
Status int `gorm:"column:status" json:"status"`
Createtime int `gorm:"column:createtime" json:"createtime"`
Modifytime int `gorm:"column:modifytime" json:"modifytime"`
})
f5.UnmarshalModel(ds, 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 {
f5.RspErr2(c, 1, "输入过长")
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
})
}
func (pai *PlayerApi) VipBindQuery(c *gin.Context) {
type VipBindQueryForm struct {
Identity string `binding:"required" json:"identity"`
}
reqJson := VipBindQueryForm{}
if !checkparam(&reqJson, c) {
return
}
if len(reqJson.Identity) > 0xFF {
f5.RspErr2(c, 1, "输入过长")
return
}
rsp := []struct {
Account string `gorm:"column:account_address" json:"account_address"`
Passport string `gorm:"column:passport_address" json:"passport_address"`
Email string `gorm:"column:lower_case_email" json:"lower_case_email"`
}{}
sql := `SELECT * FROM t_vip_bind WHERE idx > 0 AND (account_address = ? OR passport_address = ?)`
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
[]string{
reqJson.Identity,
reqJson.Identity,
},
func(err error, ds *f5.DataSet) {
if err != nil {
f5.RspErr2(c, 500, "server internal error")
return
}
for ds.Next() {
p := q5.NewSliceElement(&rsp)
f5.UnmarshalModel(ds, p)
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
"data": rsp,
})
})
}
func (pai *PlayerApi) VipUserQuery(c *gin.Context) {
type VipUserQueryForm struct {
Account string `binding:"required" json:"account_address"`
}
reqJson := VipUserQueryForm{}
if !checkparam(&reqJson, c) {
return
}
if len(reqJson.Account) > 0xFF {
f5.RspErr2(c, 1, "输入过长")
return
}
rsp := []struct {
Account string `gorm:"column:account_address" json:"account_address"`
Level int64 `gorm:"column:vip_lv" json:"vip_lv"`
Balance string `gorm:"column:escec_balance" json:"escec_balance"`
Stacking string `gorm:"column:escec_stacking" json:"escec_stacking"`
Convert string `gorm:"column:escec_convert" json:"escec_convert"`
Total string `gorm:"column:escec_total" json:"escec_total"`
StackingLast int64 `gorm:"column:stacking_last_src_idx" json:"stacking_last_src_idx"`
TransferLast int64 `gorm:"column:escec_transfer_last_src_idx" json:"escec_transfer_last_src_idx"`
DepositLast int64 `gorm:"column:vester_deposit_last_src_idx" json:"vester_deposit_last_src_idx"`
WithdrawLast int64 `gorm:"column:vester_withdraw_last_src_idx" json:"vester_withdraw_last_src_idx"`
}{}
sql := `SELECT * FROM t_vip_user WHERE idx > 0 AND account_address = ?`
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
[]string{
reqJson.Account,
},
func(err error, ds *f5.DataSet) {
if err != nil {
f5.RspErr2(c, 500, "server internal error")
return
}
for ds.Next() {
p := q5.NewSliceElement(&rsp)
f5.UnmarshalModel(ds, p)
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
"data": rsp,
})
})
}

View File

@ -16,6 +16,7 @@ type WhiteListApi struct {
func (bpa *WhiteListApi) List(c *gin.Context) {
req := struct {
Type string `json:"type"`
PageDto system.PageDto `json:"page_dto"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
@ -25,8 +26,12 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
})
return
}
sql := "SELECT * FROM t_whitelist WHERE 1=1"
params := []string{}
sql := "SELECT * FROM t_whitelist WHERE 1=1 AND deleted = 0"
params := []string{}
if req.Type != "" {
sql += " AND type = ?"
params = append(params, req.Type)
}
result := []*system.WhiteListItem{}
f5.GetGoStyleDb().PageQuery(
constant.CONF_DB,
@ -35,7 +40,7 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
sql,
params,
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
" ORDER BY user_identity ",
" ORDER BY account_id ",
func(err error, pg *f5.Pagination) {
if err != nil {
c.JSON(http.StatusOK, gin.H{
@ -47,8 +52,8 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
for pg.Rows.Next() {
p := new(system.WhiteListItem)
p.Enable = q5.SafeToInt32(pg.Rows.GetByName("enable"))
p.Identity = pg.Rows.GetByName("user_identity")
p.Type = pg.Rows.GetByName("type")
p.Account = pg.Rows.GetByName("account_id")
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
q5.AppendSlice(&result, p)
@ -66,8 +71,8 @@ func (bpa *WhiteListApi) List(c *gin.Context) {
func (bpa *WhiteListApi) Add(c *gin.Context) {
req := struct {
Identity string `binding:"required" json:"user_identity"`
Enable int32 `json:"enable"`
Account string `binding:"required" json:"account_id"`
Type string `binding:"required" json:"type"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
@ -81,17 +86,29 @@ func (bpa *WhiteListApi) Add(c *gin.Context) {
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
var count int64 = 0
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_whitelist").Where("user_identity = ?", req.Identity)
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table("t_whitelist").Where("account_id = ? AND type = ?", req.Account, req.Type)
if err := db.Count(&count).Error; err == nil && count > 0 {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "数据存在",
})
db.Take(info)
if info.Deleted == 0 {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "数据存在",
})
} else {
info.Deleted = 0
info.ModifyTime = nowDaySeconds
db.Save(info)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "添加成功",
})
}
return
}
info.Identity = req.Identity
info.Enable = req.Enable
info.Account = req.Account
info.Type = req.Type
info.CreateTime = nowDaySeconds
info.ModifyTime = nowDaySeconds
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
@ -108,58 +125,9 @@ func (bpa *WhiteListApi) Add(c *gin.Context) {
}
func (bpa *WhiteListApi) Edit(c *gin.Context) {
req := struct {
Identity string `binding:"required" json:"user_identity"`
Enable int32 `json:"enable"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
return
}
whiteListItem := new(system.WhiteListItem)
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
if err := db.Take(whiteListItem, "user_identity =?", req.Identity).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
} else {
c.JSON(http.StatusOK, gin.H{
"code": 2,
"message": "无法查到记录",
})
return
}
}
if whiteListItem.Enable != req.Enable {
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
whiteListItem.Enable = req.Enable
whiteListItem.ModifyTime = nowDaySeconds
if err := db.Where("user_identity = ?", req.Identity).Save(whiteListItem).Error; err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
}
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
})
}
func (bpa *WhiteListApi) Del(c *gin.Context) {
// req := struct {
// Account string `binding:"required" json:"user_identity"`
// Type string `json:"type"`
// Account string `binding:"required" json:"account_id"`
// Type string `json:"type"`
// }{}
// if err := c.ShouldBindJSON(&req); err != nil {
// c.JSON(http.StatusOK, gin.H{
@ -169,13 +137,9 @@ func (bpa *WhiteListApi) Del(c *gin.Context) {
// return
// }
// whiteListItem := new(system.WhiteListItem)
// db := f5.GetApp().GetOrmDb(constant.CONF_DB).Where("user_identity = ?", req.Account)
// if req.Type != "" {
// db = db.Where("type = ?", req.Type)
// }
// if err := db.Take(whiteListItem).Error; err != nil {
// whitelistitem := new(system.WhiteListItem)
// db := f5.GetApp().GetOrmDb(constant.CONF_DB)
// if err := db.Take(whitelistitem, "account_id =?", req.Account).Error; err != nil {
// if !f5.IsOrmErrRecordNotFound(err) {
// c.JSON(http.StatusOK, gin.H{
// "code": 500,
@ -187,23 +151,14 @@ func (bpa *WhiteListApi) Del(c *gin.Context) {
// "code": 2,
// "message": "无法查到记录",
// })
// return
// }
// } else {
// if whiteListItem.Deleted == 1 {
// c.JSON(http.StatusOK, gin.H{
// "code": 2,
// "message": "无法查到记录",
// })
// return
// }
// }
// nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
// whiteListItem.Deleted = 1
// whiteListItem.ModifyTime = nowDaySeconds
// if err := db.Save(whiteListItem).Error; err != nil {
// nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
// whiteListItem.Blocked = req.Blocked
// whiteListItem.ModifyTime = nowDaySeconds
// if err := db.Where("account_id = ?", req.Account).Save(whiteListItem).Error; err != nil {
// c.JSON(http.StatusOK, gin.H{
// "code": 500,
// "message": "sever internal error:" + err.Error(),
@ -216,6 +171,66 @@ func (bpa *WhiteListApi) Del(c *gin.Context) {
// })
}
func (bpa *WhiteListApi) Del(c *gin.Context) {
req := struct {
Account string `binding:"required" json:"account_id"`
Type string `json:"type"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
return
}
whiteListItem := new(system.WhiteListItem)
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Where("account_id = ?", req.Account)
if req.Type != "" {
db = db.Where("type = ?", req.Type)
}
if err := db.Take(whiteListItem).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
} else {
c.JSON(http.StatusOK, gin.H{
"code": 2,
"message": "无法查到记录",
})
return
}
} else {
if whiteListItem.Deleted == 1 {
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
})
return
}
}
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
whiteListItem.Deleted = 1
whiteListItem.ModifyTime = nowDaySeconds
if err := db.Save(whiteListItem).Error; err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 500,
"message": "sever internal error:" + err.Error(),
})
return
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
})
}
func (bpa *WhiteListApi) UploadExcel(c *gin.Context) {
file, _, err := c.Request.FormFile("file")
if err != nil {
@ -248,8 +263,9 @@ func (bpa *WhiteListApi) UploadExcel(c *gin.Context) {
continue
}
member := new(system.WhiteListItem)
member.Identity = row[0]
member.Enable = 1
member.Account = row[0]
member.Type = row[1]
member.Deleted = 0
member.CreateTime = nowDaySeconds
member.ModifyTime = nowDaySeconds
whitelist = append(whitelist, member)

View File

@ -1,299 +0,0 @@
package system
import (
"f5"
"fmt"
"main/constant"
"main/model/system"
"net"
"net/http"
"q5"
"time"
"github.com/gin-gonic/gin"
)
type WorkerToolApi struct {
}
func (bpa *WorkerToolApi) ListGameApi(c *gin.Context) {
req := struct {
PageDto system.PageDto `json:"page_dto"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
sql := "SELECT * FROM t_internal_gameapi_host WHERE 1=1"
params := []string{}
result := []*system.GameApiHostItem{}
f5.GetGoStyleDb().PageQuery(
constant.CONF_DB,
q5.ToInt32(req.PageDto.PageSize),
q5.ToInt32(req.PageDto.Page),
sql,
params,
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
"",
func(err error, pg *f5.Pagination) {
if err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
for pg.Rows.Next() {
p := new(system.GameApiHostItem)
f5.UnmarshalModel(pg.Rows, p)
q5.AppendSlice(&result, p)
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "获取成功",
"data": result,
"total": pg.Total,
"total_page": pg.TotalPages,
"cur_page": pg.CurrentPage,
})
})
}
func (bpa *WorkerToolApi) AddGameApi(c *gin.Context) {
req := struct {
Host string `binding:"required" json:"gameapi_host"`
Port int32 `binding:"required" json:"gameapi_port"`
Enable int32 `json:"enable"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
if !bpa.testHostport(c, req.Host, req.Port) {
return
}
info := new(system.GameApiHostItem)
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
var count int64 = 0
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table(info.TableName()).Where("gameapi_host = ?", req.Host)
if err := db.Count(&count).Error; err != nil {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
} else if count > 0 {
f5.RspErr2(c, 2, "host(ip)已存在")
return
}
info.Host = req.Host
info.Port = req.Port
info.Enable = req.Enable
info.CreateTime = nowDaySeconds
info.ModifyTime = nowDaySeconds
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
f5.RspErr2(c, 0, "添加成功")
}
func (bpa *WorkerToolApi) EditGameApi(c *gin.Context) {
req := struct {
Idx int64 `binding:"required" json:"idx"`
Host string `binding:"required" json:"gameapi_host"`
Port int32 `binding:"required" json:"gameapi_port"`
Enable int32 `json:"enable"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
if !bpa.testHostport(c, req.Host, req.Port) {
return
}
item := new(system.GameApiHostItem)
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table(item.TableName())
if err := db.Take(item, "idx = ?", req.Idx).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
} else {
f5.RspErr2(c, 2, "无法查到记录")
return
}
}
var count int64 = 0
db = f5.GetApp().GetOrmDb(constant.CONF_DB).Table(item.TableName()).Where("gameapi_host = ?", req.Host).Where("idx != ?", req.Idx)
if err := db.Count(&count).Error; err != nil {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
} else if count > 0 {
f5.RspErr2(c, 2, "host(ip)已存在")
return
}
if item.Host != req.Host ||
item.Port != req.Port ||
item.Enable != req.Enable {
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
item.Host = req.Host
item.Port = req.Port
item.Enable = req.Enable
item.ModifyTime = nowDaySeconds
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Table(item.TableName()).Where("idx = ?", req.Idx).Omit("idx", "createtime").Save(item).Error; err != nil {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
}
}
f5.RspErr2(c, 0, "")
}
func (bpa *WorkerToolApi) ListApiGate(c *gin.Context) {
req := struct {
PageDto system.PageDto `json:"page_dto"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
sql := "SELECT * FROM t_apigate_host WHERE 1=1"
params := []string{}
result := []*system.ApiGateHostItem{}
f5.GetGoStyleDb().PageQuery(
constant.CONF_DB,
q5.ToInt32(req.PageDto.PageSize),
q5.ToInt32(req.PageDto.Page),
sql,
params,
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
"",
func(err error, pg *f5.Pagination) {
if err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
for pg.Rows.Next() {
p := new(system.ApiGateHostItem)
f5.UnmarshalModel(pg.Rows, p)
q5.AppendSlice(&result, p)
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "获取成功",
"data": result,
"total": pg.Total,
"total_page": pg.TotalPages,
"cur_page": pg.CurrentPage,
})
})
}
func (bpa *WorkerToolApi) AddApiGate(c *gin.Context) {
req := struct {
Host string `binding:"required" json:"apigate_host"`
Port int32 `binding:"required" json:"apigate_port"`
Enable int32 `json:"enable"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
if !bpa.testHostport(c, req.Host, req.Port) {
return
}
info := new(system.ApiGateHostItem)
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
var count int64 = 0
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table(info.TableName()).Where("apigate_host = ?", req.Host)
if err := db.Count(&count).Error; err != nil {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
} else if count > 0 {
f5.RspErr2(c, 2, "host(ip)已存在")
return
}
info.Host = req.Host
info.Port = req.Port
info.Enable = req.Enable
info.CreateTime = nowDaySeconds
info.ModifyTime = nowDaySeconds
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(info).Error; err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
f5.RspErr2(c, 0, "添加成功")
}
func (bpa *WorkerToolApi) EditApiGate(c *gin.Context) {
req := struct {
Idx int64 `binding:"required" json:"idx"`
Host string `binding:"required" json:"apigate_host"`
Port int32 `binding:"required" json:"apigate_port"`
Enable int32 `json:"enable"`
}{}
if err := c.ShouldBindJSON(&req); err != nil {
f5.RspErr2(c, 1, err.Error())
return
}
if !bpa.testHostport(c, req.Host, req.Port) {
return
}
item := new(system.ApiGateHostItem)
db := f5.GetApp().GetOrmDb(constant.CONF_DB).Table(item.TableName())
if err := db.Take(item, "idx = ?", req.Idx).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
} else {
f5.RspErr2(c, 2, "无法查到记录")
return
}
}
var count int64 = 0
db = f5.GetApp().GetOrmDb(constant.CONF_DB).Table(item.TableName()).Where("apigate_host = ?", req.Host).Where("idx != ?", req.Idx)
if err := db.Count(&count).Error; err != nil {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
} else if count > 0 {
f5.RspErr2(c, 2, "host(ip)已存在")
return
}
if item.Host != req.Host ||
item.Port != req.Port ||
item.Enable != req.Enable {
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
item.Host = req.Host
item.Port = req.Port
item.Enable = req.Enable
item.ModifyTime = nowDaySeconds
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Table(item.TableName()).Where("idx = ?", req.Idx).Omit("idx", "createtime").Save(item).Error; err != nil {
f5.RspErr2(c, 500, "sever internal error:"+err.Error())
return
}
}
f5.RspErr2(c, 0, "")
}
func (bpa *WorkerToolApi) testHostport(c *gin.Context, host string, port int32) bool {
addrAndPort := fmt.Sprintf("%s:%d", host, port)
conn, err := net.DialTimeout("tcp", addrAndPort, time.Second)
if err != nil {
f5.RspErr2(c, 2, "host(ip) port 连不上")
return false
} else {
conn.Close()
return true
}
}

View File

@ -18,7 +18,6 @@ const (
APP_MODULE_IDX = iota
ROUTER_MODULE_IDX
SESSION_MGR_MODULE_IDX
SERVICE_MGR_MODULE_IDX
MAX_MODULE_IDX
)

View File

@ -1,17 +1,16 @@
package global
import (
"fmt"
"main/common"
"main/constant"
"q5"
"fmt"
"main/constant"
"main/common"
)
var modules [constant.MAX_MODULE_IDX]q5.Module
var initOrders = []int32 {
constant.ROUTER_MODULE_IDX,
constant.SESSION_MGR_MODULE_IDX,
constant.SERVICE_MGR_MODULE_IDX,
}
var app common.App
@ -40,10 +39,6 @@ func RegModule(idx int32, m q5.Module) {
{
sessionMgr = m.(common.SessionMgr)
}
case constant.SERVICE_MGR_MODULE_IDX:
{
}
default:
{
panic("unknow module")

View File

@ -18,65 +18,41 @@ require (
)
require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/bytedance/sonic v1.10.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/ethereum/go-ethereum v1.13.15 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.4 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gomodule/redigo v1.8.3 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.3 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 // indirect
github.com/xuri/nfp v0.0.0-20230919160717-d98342af3f05 // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.5.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
replace q5 => ../../third_party/q5

View File

@ -1,11 +1,3 @@
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc=
@ -16,33 +8,15 @@ github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA=
github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.13.15 h1:U7sSGYGo4SPjP6iNIifNoyIAiNjrmQkz6EwQG+/EZWo=
github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
@ -58,15 +32,9 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG
github.com/gomodule/redigo v1.8.3 h1:HR0kYDX2RJZvAup8CsiJwxB4dTCSC0AaUq6S4SiLwUc=
github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
@ -81,9 +49,6 @@ github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@ -100,8 +65,6 @@ github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@ -114,12 +77,6 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
@ -135,29 +92,16 @@ golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
@ -173,5 +117,3 @@ gorm.io/gorm v1.25.4 h1:iyNd8fNAe8W9dvtlgeRI5zSVZPsq3OpcTu37cYcpCmw=
gorm.io/gorm v1.25.4/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=

View File

@ -1,12 +1,12 @@
package middleware
import (
"adminserver/constant"
"bytes"
"encoding/json"
"f5"
"io"
"main/common"
"main/constant"
"strings"
"github.com/gin-gonic/gin"

View File

@ -1,12 +0,0 @@
package system
type ActiveCode struct {
Code string `gorm:"column:activation_code" json:"activation_code"`
Batch_id int32 `gorm:"column:batch_id" json:"batch_id"`
CreateTime int32 `gorm:"column:createtime" json:"-"`
ModifyTime int32 `gorm:"column:modifytime" json:"-"`
}
func (ac *ActiveCode) TableName() string {
return "t_activation_code"
}

View File

@ -1,12 +1,13 @@
package system
type BlockPlayer struct {
Identity string `gorm:"column:user_identity" json:"user_identity"`
Enable int32 `gorm:"column:enable" json:"enable"`
Account string `gorm:"column:account_id" json:"account_id"`
Blocked int32 `gorm:"column:blocked" json:"blocked"`
Deleted int32 `gorm:"column:deleted" json:"deleted"`
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
}
func (BlockPlayer) TableName() string {
return "t_blacklist"
return "t_blockplayer"
}

View File

@ -1,31 +0,0 @@
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

@ -1,8 +1,9 @@
package system
type WhiteListItem struct {
Identity string `gorm:"column:user_identity" json:"user_identity"`
Enable int32 `gorm:"column:enable" json:"enable"`
Account string `gorm:"column:account_id" json:"account_id"`
Type string `gorm:"column:type" json:"type"`
Deleted int32 `gorm:"column:deleted" json:"deleted"`
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
}
@ -12,7 +13,10 @@ func (WhiteListItem) TableName() string {
}
type SuperWhiteListItem struct {
WhiteListItem
Identity string `gorm:"column:user_identity" json:"user_identity"`
Enable int32 `gorm:"column:enable" json:"enable"`
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
}
func (SuperWhiteListItem) TableName() string {

View File

@ -1,27 +0,0 @@
package system
type GameApiHostItem struct {
Idx int64 `gorm:"column:idx" json:"idx"`
Host string `gorm:"column:gameapi_host" json:"gameapi_host"`
Port int32 `gorm:"column:gameapi_port" json:"gameapi_port"`
Enable int32 `gorm:"column:enable" json:"enable"`
CreateTime int32 `gorm:"column:createtime" json:"-"`
ModifyTime int32 `gorm:"column:modifytime" json:"-"`
}
func (GameApiHostItem) TableName() string {
return "t_internal_gameapi_host"
}
type ApiGateHostItem struct {
Idx int64 `gorm:"column:idx" json:"idx"`
Host string `gorm:"column:apigate_host" json:"apigate_host"`
Port int32 `gorm:"column:apigate_port" json:"apigate_port"`
Enable int32 `gorm:"column:enable" json:"enable"`
CreateTime int32 `gorm:"column:createtime" json:"-"`
ModifyTime int32 `gorm:"column:modifytime" json:"-"`
}
func (ApiGateHostItem) TableName() string {
return "t_apigate_host"
}

View File

@ -1,14 +0,0 @@
package mt
import (
"f5"
"main/mtb"
)
type Chain struct {
mtb.Erc20
}
type ChainTable struct {
f5.RawMetaTable[Chain]
}

View File

@ -1,112 +0,0 @@
package mt
import (
"encoding/json"
"f5"
"fmt"
"q5"
"strings"
)
type Contract struct {
name string
address string
}
type ContractTable struct {
netIdNameHash *q5.ConcurrentMap[string, *Contract]
netIdAddressHash *q5.ConcurrentMap[string, *Contract]
}
func (this *Contract) GetName() string {
return this.name
}
func (this *Contract) GetAddress() string {
return this.address
}
func (this *ContractTable) IsNoLoad() bool {
return false
}
func (this *ContractTable) Load() {
this.netIdNameHash = new(q5.ConcurrentMap[string, *Contract])
this.netIdAddressHash = new(q5.ConcurrentMap[string, *Contract])
nets := []interface{}{}
{
if jsonStr, err := f5.ReadJsonFile("../config/nets.json"); err == nil {
if err := json.Unmarshal([]byte(jsonStr), &nets); err != nil {
panic(fmt.Sprintf("load metafile json decode error %s %s", "nets.json", err))
}
} else {
panic(fmt.Sprintf("load metafile error %s %s", "nets.json", err))
}
}
{
for _, val := range nets {
netId := q5.SafeToInt32(val)
fileName := fmt.Sprintf("../config/nets/%d/contract.json", netId)
if jsonStr, err := f5.ReadJsonFile(fileName); err == nil {
contracts := []struct {
Name string `json:"name"`
Address string `json:"address"`
}{}
if err := json.Unmarshal([]byte(jsonStr), &contracts); err != nil {
panic(fmt.Sprintf("load metafile json decode error %s %s", "contract.json", err))
}
for _, val2 := range contracts {
p := new(Contract)
p.name = q5.SafeToString(val2.Name)
p.address = strings.ToLower(q5.SafeToString(val2.Address))
{
key := fmt.Sprintf("%d_%s", netId, p.name)
this.netIdNameHash.Store(key, p)
}
{
key := fmt.Sprintf("%d_%s", netId, p.address)
this.netIdAddressHash.Store(key, p)
}
}
} else {
panic(fmt.Sprintf("load metafile error %s %s", "contract.json", err))
}
}
}
}
func (this *ContractTable) PreInit1() {
}
func (this *ContractTable) ElementsInit(int) {
}
func (this *ContractTable) PostInit1() {
}
func (this *ContractTable) GetByNetIdName(netId int32, name string) *Contract {
key := fmt.Sprintf("%d_%s", netId, name)
if v, ok := this.netIdNameHash.Load(key); ok {
return *v
} else {
return nil
}
}
func (this *ContractTable) GetByNetIdAddress(netId int32, address string) *Contract {
key := fmt.Sprintf("%d_%s", netId, address)
if v, ok := this.netIdAddressHash.Load(key); ok {
return *v
} else {
return nil
}
}
func (this *ContractTable) Traverse(cb func(*Contract) bool) {
this.netIdNameHash.Range(func(k string, v *Contract) bool {
return cb(v)
})
}

View File

@ -17,8 +17,6 @@ type table struct {
Permission *PermissionTable
ConfDb *ConfDbTable
Item *ItemTable
Contract *ContractTable
Chain *ChainTable
}
var Table = f5.New(func(this *table) {
@ -73,14 +71,8 @@ var Table = f5.New(func(this *table) {
this.Permission = new(PermissionTable)
this.Contract = new(ContractTable)
this.Item = f5.New(func(this *ItemTable) {
this.FileName = "../res/item@item.json"
this.PrimKey = "id"
})
this.Chain = f5.New(func(this *ChainTable) {
this.FileName = "../config/erc20.json"
})
})

View File

@ -128,17 +128,6 @@ type Item struct {
_flags2_ uint64
}
type Erc20 struct {
token_name string
net_id int32
rpc_url string
account_address string
token_address string
_flags1_ uint64
_flags2_ uint64
}
func (this *AdminCluster) GetInstanceId() int32 {
return this.instance_id
}
@ -603,46 +592,6 @@ func (this *Item) HasSubType() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Erc20) GetTokenName() string {
return this.token_name
}
func (this *Erc20) HasTokenName() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Erc20) GetNetId() int32 {
return this.net_id
}
func (this *Erc20) HasNetId() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Erc20) GetRpcUrl() string {
return this.rpc_url
}
func (this *Erc20) HasRpcUrl() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Erc20) GetAccountAddress() string {
return this.account_address
}
func (this *Erc20) HasAccountAddress() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Erc20) GetTokenAddress() string {
return this.token_address
}
func (this *Erc20) HasTokenAddress() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *AdminCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
@ -734,11 +683,3 @@ func (this *Item) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.type_, "type", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.sub_type, "sub_type", &this._flags1_, 4, kv)
}
func (this *Erc20) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.token_name, "token_name", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.net_id, "net_id", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.rpc_url, "rpc_url", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.account_address, "account_address", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.token_address, "token_address", &this._flags1_, 5, kv)
}

View File

@ -0,0 +1,3 @@
syntax = "proto2";
package cs;
option go_package = ".;cs";

View File

@ -0,0 +1,3 @@
syntax = "proto2";
package cs;
option go_package = ".;cs";

View File

@ -103,12 +103,3 @@ message Item
optional int32 type = 3;
optional int32 sub_type = 4;
}
message Erc20
{
optional string token_name = 1;
optional int32 net_id = 2;
optional string rpc_url = 3;
optional string account_address = 4;
optional string token_address = 5;
}

View File

@ -0,0 +1,3 @@
syntax = "proto2";
package ss;
option go_package = ".;ss";

View File

@ -0,0 +1,4 @@
syntax = "proto2";
package ss;
option go_package = ".;ss";

View File

@ -29,8 +29,6 @@ func (this *routerMgr) Init() {
this.system.InitGameSwitchRouter(priGroup)
this.system.InitBlockPlayerRouter(priGroup)
this.system.InitWhiteListRouter(priGroup)
this.system.InitActiveCodeRouter(priGroup)
this.system.InitWorkerToolRouter(priGroup)
f5.GetSysLog().Info("routerMgr.init")
}

View File

@ -1,21 +0,0 @@
package system
import (
v1 "main/api/v1"
"main/middleware"
"github.com/gin-gonic/gin"
)
type ActiveCodeRoute struct {
}
func (this *ActiveCodeRoute) InitActiveCodeRouter(priRouter *gin.RouterGroup) {
group := priRouter.Group("active_code")
api := v1.ApiGroupApp.SystemApiGroup.ActiveCodeApi
{
group.GET("gen", middleware.Permission("api/v1/active_code/gen", api.GenCode))
group.POST("list", middleware.Permission("api/v1/active_code/list", api.List))
group.GET("download", middleware.Permission("api/v1/active_code/download", api.DownloadFile))
}
}

View File

@ -16,7 +16,7 @@ func (this *BlockPlayerRoute) InitBlockPlayerRouter(priRouter *gin.RouterGroup)
{
group.POST("add", middleware.Permission("api/v1/block_player/add", api.Add))
group.POST("edit", middleware.Permission("api/v1/block_player/edit", api.Edit))
// group.POST("del", middleware.Permission("api/v1/block_player/del", api.Del))
group.POST("del", middleware.Permission("api/v1/block_player/del", api.Del))
group.POST("list", middleware.Permission("api/v1/block_player/list", api.List))
group.POST("uploadExcel", middleware.Permission("api/v1/block_player/uploadExcel", api.UploadExcel))
}

View File

@ -13,6 +13,4 @@ type RouterGroup struct {
GameSwitchRoute
BlockPlayerRoute
WhiteListRoute
ActiveCodeRoute
WorkerToolRoute
}

View File

@ -18,7 +18,6 @@ func (this *GameSwitchRoute) InitGameSwitchRouter(priRouter *gin.RouterGroup) {
//group.POST("add", middleware.Permission("api/v1/game_switch/add", api.Add))
group.POST("edit", middleware.Permission("api/v1/game_switch/edit", api.Edit))
//group.POST("del", middleware.Permission("api/v1/game_switch/del", api.Del))
group.GET("list", middleware.Permission("api/v1/game_switch/list", api.List))
group.GET("refresh", middleware.Permission("api/v1/game_switch/refresh", api.Refresh))
group.GET("list", middleware.Permission("api/v1/game_switch/list", api.List))
}
}

View File

@ -16,6 +16,5 @@ func (nr *NFTRouter) InitNFTRouter(priRouter *gin.RouterGroup) {
group.POST("orderquery", middleware.Permission("api/v1/nft/orderquery", api.OrderQuery))
group.POST("salequery", middleware.Permission("api/v1/nft/salequery", api.SaleQuery))
group.POST("nftquery", middleware.Permission("api/v1/nft/nftquery", api.NFTQuery))
group.POST("balancequery", middleware.Permission("api/v1/nft/balancequery", api.BalanceQuery))
}
}

View File

@ -19,9 +19,5 @@ 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("inapporderquery", middleware.Permission("api/v1/player/inapporderquery", api.InappOrderQuery))
group.POST("rechargequery", middleware.Permission("api/v1/player/rechargequery", api.RechargeQuery))
group.POST("vipbindquery", middleware.Permission("api/v1/player/vipbindquery", api.VipBindQuery))
group.POST("vipuserquery", middleware.Permission("api/v1/player/vipuserquery", api.VipUserQuery))
}
}

View File

@ -15,8 +15,8 @@ func (this *WhiteListRoute) InitWhiteListRouter(priRouter *gin.RouterGroup) {
api := v1.ApiGroupApp.SystemApiGroup.WhiteListApi
{
group.POST("add", middleware.Permission("api/v1/white_list/add", api.Add))
group.POST("edit", middleware.Permission("api/v1/white_list/edit", api.Edit))
// group.POST("del", middleware.Permission("api/v1/white_list/del", api.Del))
//group.POST("edit", middleware.Permission("api/v1/white_list/edit", api.Edit))
group.POST("del", middleware.Permission("api/v1/white_list/del", api.Del))
group.POST("list", middleware.Permission("api/v1/white_list/list", api.List))
group.POST("uploadExcel", middleware.Permission("api/v1/white_list/uploadExcel", api.UploadExcel))
}

View File

@ -1,28 +0,0 @@
package system
import (
v1 "main/api/v1"
"main/middleware"
"github.com/gin-gonic/gin"
)
type WorkerToolRoute struct {
}
func (this *WorkerToolRoute) InitWorkerToolRouter(priRouter *gin.RouterGroup) {
group := priRouter.Group("gameapihost")
api := v1.ApiGroupApp.SystemApiGroup.WorkerToolApi
{
group.POST("add", middleware.Permission("api/v1/gameapihost/add", api.AddGameApi))
group.POST("edit", middleware.Permission("api/v1/gameapihost/edit", api.EditGameApi))
group.POST("list", middleware.Permission("api/v1/gameapihost/list", api.ListGameApi))
}
{
supergroup := priRouter.Group("apigate")
supergroup.POST("add", middleware.Permission("api/v1/apigate/add", api.AddApiGate))
supergroup.POST("list", middleware.Permission("api/v1/apigate/list", api.ListApiGate))
supergroup.POST("edit", middleware.Permission("api/v1/apigate/edit", api.EditApiGate))
}
}

View File

@ -1,195 +0,0 @@
package service
import (
"f5"
"fmt"
"main/constant"
"main/mt"
"q5"
"strings"
"sync"
"time"
)
type baseinfo struct {
recharge int64
balance string
}
type addressBalance struct {
gcTime int64
infoList q5.ConcurrentMap[string, *baseinfo] // <netid$toke_addr, baseinfo>
}
type chainbalance struct {
gcTime int64
infoList q5.ConcurrentMap[string, *baseinfo] // <netid$toke_addr, baseinfo>
addressBalanceList q5.ConcurrentMap[string, *addressBalance] // <account, addressBalance>
}
func (this *chainbalance) init() {
this.infoList = q5.ConcurrentMap[string, *baseinfo]{}
this.addressBalanceList = q5.ConcurrentMap[string, *addressBalance]{}
this.GetGlobalBalance("")
go this.checkBalanceList()
}
func (this *chainbalance) unInit() {
}
func (this *chainbalance) GetAccoutBalance(netidtoken string, acc string) (string, int64) {
info, exist := this.addressBalanceList.Load(acc)
if !exist {
tmpinfo := new(addressBalance)
this.addressBalanceList.Store(acc, tmpinfo)
info = &tmpinfo
}
if nowseconds := f5.GetApp().GetRealSeconds(); (*info).gcTime+60 < nowseconds {
(*info).gcTime = nowseconds
this.getChainBalance(acc)
}
v, exist := (*info).infoList.Load(netidtoken)
if exist {
return (*v).balance, (*v).recharge
}
return "", 0
}
func (this *chainbalance) GetGlobalBalance(netidtoken string) (string, int64) {
if nowseconds := f5.GetApp().GetRealSeconds(); this.gcTime+60 < nowseconds {
this.gcTime = nowseconds
go this.getChainBalance("")
}
v, exist := this.infoList.Load(netidtoken)
if exist {
return (*v).balance, (*v).recharge
}
return "", 0
}
func (this *chainbalance) getChainBalance(acc string) {
url := mt.Table.Web3ServiceCluster.RandElement().GetUrl() + "/webapp/index.php"
var wg sync.WaitGroup
mt.Table.Chain.Traverse(func(item *mt.Chain) bool {
var info *baseinfo
key := fmt.Sprintf("%d$%s", item.GetNetId(), item.GetTokenAddress())
if acc == "" {
tmp, exist := this.infoList.Load(key)
if !exist {
info = new(baseinfo)
this.infoList.Store(key, info)
tmp = &info
} else {
info = *tmp
}
} else {
accinfo, exist := this.addressBalanceList.Load(acc)
if !exist {
tmp := new(addressBalance)
this.addressBalanceList.Store(acc, tmp)
accinfo = &tmp
info = new(baseinfo)
tmp.infoList.Store(key, info)
} else {
keyinfo, exist := (*accinfo).infoList.Load(key)
if !exist {
info = new(baseinfo)
(*accinfo).infoList.Store(key, info)
} else {
info = *keyinfo
}
}
}
{
sql := fmt.Sprintf(`SELECT sum(diamond) FROM t_recharge_order WHERE idx > 0 AND pay_status = 1 AND net_id = %d AND currency_name = '%s'`, item.GetNetId(), strings.ToLower(item.GetTokenAddress()))
if acc != "" {
sql = fmt.Sprintf(`%s AND account_address = '%s'`, sql, strings.ToLower(acc))
}
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
return
}
if ds.Next() {
info.recharge = q5.SafeToInt64(ds.GetByIndex(0)) / 100
}
})
}
rpcurl := item.GetRpcUrl()
doquery := func(account string, tokeaddr string, balance *string) {
f5.GetHttpCliMgr().SendGoStyleRequest(
url,
map[string]string{
"c": "Erc20",
"a": "getBalance",
"rpc_url": rpcurl,
"account_address": account,
"token_address": tokeaddr,
},
func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil {
return
}
rspJson := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Balance string `json:"balance"`
}{}
if q5.DecodeJson(rsp.GetRawData(), &rspJson) != nil {
return
}
*balance = rspJson.Balance
})
wg.Done()
}
queryAcc := item.GetAccountAddress()
if acc != "" {
queryAcc = acc
}
wg.Add(1)
go doquery(queryAcc, item.GetTokenAddress(), &info.balance)
return true
})
wg.Wait()
}
func (this *chainbalance) checkBalanceList() {
fmt.Println("checkBalanceList start")
for {
if time.Now().UTC().Hour() == 0 && time.Now().UTC().Minute() == 0 {
nowseconds := f5.GetApp().GetRealSeconds()
deletelist := []string{}
this.addressBalanceList.Range(func(key string, value *addressBalance) bool {
if value.gcTime+86400 < nowseconds {
deletelist = append(deletelist, key)
}
return true
})
for _, account := range deletelist {
this.addressBalanceList.Delete(account)
}
f5.GetSysLog().Info("delete chainbalance address cache count:%d", len(deletelist))
}
time.Sleep((time.Second * 60))
}
}

View File

@ -1,13 +0,0 @@
package service
import (
"main/constant"
"main/global"
)
var Balance = new(chainbalance)
var _serviceMgr = new(serviceMgr)
func init() {
global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr)
}

View File

@ -1,12 +0,0 @@
package service
type serviceMgr struct {
}
func (this *serviceMgr) Init() {
Balance.init()
}
func (this *serviceMgr) UnInit() {
Balance.unInit()
}

View File

@ -3,7 +3,6 @@ package app
import (
"f5"
//. "main/global"
"main/constant"
"main/mt"
)
@ -13,11 +12,11 @@ type app struct {
}
func (this *app) GetPkgName() string {
return "apigate"
return "gamesapi"
}
func (this *app) GetHttpListenPort() int32 {
return mt.Table.ApigateCluster.GetHttpListenPort()
return mt.Table.GamesapiCluster.GetHttpListenPort()
}
func (this *app) Run(initCb func(), unInitCb func()) {
@ -40,18 +39,29 @@ func (this *app) Update() {
}
func (this *app) registerDataSources() {
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(),
/* 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(),
1,
mt.Table.ConfDb.GetById(0).GetMaxOpenConns(),
mt.Table.ConfDb.GetById(0).GetMaxIdleConns())
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
mt.Table.MailDb.GetById(0).GetMaxIdleConns())
f5.GetJsStyleDb().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(),
1,
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
mt.Table.MailDb.GetById(0).GetMaxIdleConns()) */
}
func (this *app) HasTask() bool {
return false
return false //GetMailMgr().HasTask()
}

View File

@ -1,9 +1,5 @@
package constant
const (
CONF_DB = "confdb"
)
const (
APP_MODULE_IDX = iota
ROUTER_MODULE_IDX

View File

@ -4,9 +4,10 @@ import (
"bytes"
"errors"
"f5"
"io"
"io/ioutil"
"jccommon"
"main/service"
"main/mt"
"net/http"
net_url "net/url"
"q5"
@ -16,45 +17,31 @@ import (
"github.com/google/uuid"
)
/*
转发规则
如果c是OutApp开头则不需要对account_id和session_id参数校验
其他的需要校验
OutApp不需要限制并发数!!!
Callback 也不需要
*/
func CaForward(c *gin.Context) {
accountId := c.DefaultQuery("account_id", "")
sessionId := c.DefaultQuery("session_id", "")
cmd:=c.DefaultQuery("c", "")
var needlimit bool = !strings.HasPrefix(cmd, "OutApp") && !strings.HasPrefix(cmd, "Callback")
if needlimit && !jccommon.IsValidSessionId(accountId, sessionId) {
if !jccommon.IsValidSessionId(accountId, sessionId) {
f5.RspErr(c, 500, "invalid session_id")
c.Abort()
service.SApiForward.IncInvalidSessionTimes()
return
}
if needlimit {
cLock := service.SApiForward.AcquireLock(accountId)
if cLock == nil {
f5.RspErr(c, 500, "system busy")
c.Abort()
return
}
defer service.SApiForward.ReleaseLock(cLock)
cLock := service.SApiForward.AcquireLock(accountId)
if cLock == nil {
f5.RspErr(c, 500, "system busy")
c.Abort()
return
}
defer service.SApiForward.ReleaseLock(cLock)
service.SApiForward.IncTotalTimes()
beginTick := q5.GetTickCount()
defer func() {
costTime := q5.GetTickCount() - beginTick
service.SApiForward.UpdateCostTime(costTime)
}()
downStreamUrl, downStreamHost := service.SApiForward.GetDownStreamHost()
newUrl := downStreamUrl + c.Request.URL.Path[5:]
newUrl := mt.Table.Config.GetById(0).GetRedirectUrl() + c.Request.URL.Path[5:]
if !q5.StrContains(newUrl, "?") {
newUrl = newUrl + "?"
}
@ -77,6 +64,7 @@ func CaForward(c *gin.Context) {
case "GET":
{
service.SApiForward.IncGetTimes()
u.Set("__sign", service.SApiForward.Sign(params, nonce, nowTime, ""))
newUrl += u.Encode()
httpRequest, createErr = http.NewRequest("GET", newUrl, nil)
if !f5.IsOnlineEnv() {
@ -87,6 +75,7 @@ func CaForward(c *gin.Context) {
{
service.SApiForward.IncPostTimes()
if postData, err := c.GetRawData(); err == nil {
u.Set("__sign", service.SApiForward.Sign(params, nonce, nowTime, string(postData)))
newUrl += u.Encode()
httpRequest, createErr = http.NewRequest("POST", newUrl, bytes.NewBuffer(postData))
contentType := c.GetHeader("Content-Type")
@ -116,13 +105,10 @@ func CaForward(c *gin.Context) {
f5.GetSysLog().Info("CaForward create request url:%s error:%s", newUrl, createErr)
return
}
if downStreamHost != "" {
httpRequest.Host = downStreamHost
}
client := &http.Client{}
if resp, err := client.Do(httpRequest); err == nil {
defer resp.Body.Close()
if bytes, err := io.ReadAll(resp.Body); err == nil {
if bytes, err := ioutil.ReadAll(resp.Body); err == nil {
service.SApiForward.IncOkTimes()
c.String(200, string(bytes))
c.Abort()

View File

@ -1,34 +0,0 @@
package mt
import (
"f5"
"main/mtb"
)
type ApigateCluster struct {
mtb.ApigateCluster
}
type ApigateClusterTable struct {
f5.IdMetaTable[ApigateCluster]
selfConf *ApigateCluster
}
func (this *ApigateCluster) Init1() {
}
func (this *ApigateClusterTable) GetListenPort() int32 {
return this.selfConf.GetListenPort()
}
func (this *ApigateClusterTable) GetHttpListenPort() int32 {
return this.selfConf.GetHttpListenPort()
}
func (this *ApigateClusterTable) PostInit1() {
this.selfConf = this.GetById(int64(f5.GetApp().GetInstanceId()))
if this.selfConf == nil {
panic("apigate集群无法读取本服配置")
}
}

View File

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

View File

@ -3,12 +3,10 @@ package mt
import (
"f5"
"main/mtb"
"net/url"
)
type Config struct {
mtb.Config
redirectHost string
}
type ConfigTable struct {
@ -16,29 +14,25 @@ type ConfigTable struct {
selfConf *Config
}
func (this *Config) Init1() {
u, err := url.Parse(this.GetRedirectUrl())
if err != nil {
panic(err)
}
this.redirectHost = u.Host
func (this *ConfigTable) GetGameSApiUrl() string {
return this.selfConf.GetGamesapiUrl()
}
func (this *ConfigTable) GetSecretKey() string {
return this.selfConf.GetSecretKey()
}
func (this *ConfigTable) GetMaxConcurrentNum() int32 {
return this.selfConf.GetMaxConcurrentNum()
}
func (this *ConfigTable) GetRedirectUrl() string {
return this.selfConf.GetRedirectUrl()
}
func (this *ConfigTable) GetRedirectHost() string{
return this.selfConf.redirectHost
func (this *ConfigTable) GetRedirectSecretKey() string {
return this.selfConf.GetRedirectSecretKey()
}
func (this *ConfigTable) PostInit1() {
this.selfConf = this.GetById(int64(0))
if this.selfConf == nil {
panic("apigate config无法读取本服配置")
panic("gamesapi config无法读取本服配置")
}
}

View File

@ -0,0 +1,34 @@
package mt
import (
"f5"
"main/mtb"
)
type GamesapiCluster struct {
mtb.GamesapiCluster
}
type GamesapiClusterTable struct {
f5.IdMetaTable[GamesapiCluster]
selfConf *GamesapiCluster
}
func (this *GamesapiCluster) Init1() {
}
func (this *GamesapiClusterTable) GetListenPort() int32 {
return this.selfConf.GetListenPort()
}
func (this *GamesapiClusterTable) GetHttpListenPort() int32 {
return this.selfConf.GetHttpListenPort()
}
func (this *GamesapiClusterTable) PostInit1() {
this.selfConf = this.GetById(int64(f5.GetApp().GetInstanceId()))
if this.selfConf == nil {
panic("gamesapi集群无法读取本服配置")
}
}

View File

@ -5,14 +5,13 @@ import (
)
type table struct {
ApigateCluster *ApigateClusterTable
Config *ConfigTable
ConfDb *ConfDbTable
GamesapiCluster *GamesapiClusterTable
Config *ConfigTable
}
var Table = f5.New(func(this *table) {
this.ApigateCluster = f5.New(func(this *ApigateClusterTable) {
this.FileName = "../config/apigate.cluster.json"
this.GamesapiCluster = f5.New(func(this *GamesapiClusterTable) {
this.FileName = "../config/gamesapi.cluster.json"
this.PrimKey = "instance_id"
})
@ -20,9 +19,4 @@ var Table = f5.New(func(this *table) {
this.FileName = "../config/config.json"
this.PrimKey = ""
})
this.ConfDb = f5.New(func(this *ConfDbTable) {
this.FileName = "../config/confdb.mysql.json"
this.PrimKey = ""
})
})

View File

@ -4,7 +4,7 @@ import (
"f5"
)
type ApigateCluster struct {
type GamesapiCluster struct {
instance_id int32
listen_port int32
http_listen_port int32
@ -14,57 +14,81 @@ type ApigateCluster struct {
}
type Config struct {
gamesapi_url string
secret_key string
gm_open int32
gm_secret_key string
redirect_url string
max_concurrent_num int32
request_over_time int32
redirect_secret_key string
_flags1_ 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
}
func (this *ApigateCluster) GetInstanceId() int32 {
func (this *GamesapiCluster) GetInstanceId() int32 {
return this.instance_id
}
func (this *ApigateCluster) HasInstanceId() bool {
func (this *GamesapiCluster) HasInstanceId() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *ApigateCluster) GetListenPort() int32 {
func (this *GamesapiCluster) GetListenPort() int32 {
return this.listen_port
}
func (this *ApigateCluster) HasListenPort() bool {
func (this *GamesapiCluster) HasListenPort() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *ApigateCluster) GetHttpListenPort() int32 {
func (this *GamesapiCluster) GetHttpListenPort() int32 {
return this.http_listen_port
}
func (this *ApigateCluster) HasHttpListenPort() bool {
func (this *GamesapiCluster) HasHttpListenPort() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Config) GetGamesapiUrl() string {
return this.gamesapi_url
}
func (this *Config) HasGamesapiUrl() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Config) GetSecretKey() string {
return this.secret_key
}
func (this *Config) HasSecretKey() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Config) GetGmOpen() int32 {
return this.gm_open
}
func (this *Config) HasGmOpen() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Config) GetGmSecretKey() string {
return this.gm_secret_key
}
func (this *Config) HasGmSecretKey() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Config) GetRedirectUrl() string {
return this.redirect_url
}
func (this *Config) HasRedirectUrl() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *Config) GetMaxConcurrentNum() int32 {
@ -72,7 +96,7 @@ func (this *Config) GetMaxConcurrentNum() int32 {
}
func (this *Config) HasMaxConcurrentNum() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
return (this._flags1_ & (uint64(1) << 6)) > 0
}
func (this *Config) GetRequestOverTime() int32 {
@ -80,84 +104,31 @@ func (this *Config) GetRequestOverTime() int32 {
}
func (this *Config) HasRequestOverTime() bool {
return (this._flags1_ & (uint64(1) << 3)) > 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) GetRedirectSecretKey() string {
return this.redirect_secret_key
}
func (this *ApigateCluster) LoadFromKv(kv map[string]interface{}) {
func (this *Config) HasRedirectSecretKey() bool {
return (this._flags1_ & (uint64(1) << 8)) > 0
}
func (this *GamesapiCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.listen_port, "listen_port", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.http_listen_port, "http_listen_port", &this._flags1_, 3, kv)
}
func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.redirect_url, "redirect_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.max_concurrent_num, "max_concurrent_num", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.request_over_time, "request_over_time", &this._flags1_, 3, 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)
f5.ReadMetaTableField(&this.gamesapi_url, "gamesapi_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.secret_key, "secret_key", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.gm_open, "gm_open", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.gm_secret_key, "gm_secret_key", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.redirect_url, "redirect_url", &this._flags1_, 5, kv)
f5.ReadMetaTableField(&this.max_concurrent_num, "max_concurrent_num", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.request_over_time, "request_over_time", &this._flags1_, 7, kv)
f5.ReadMetaTableField(&this.redirect_secret_key, "redirect_secret_key", &this._flags1_, 8, kv)
}

View File

@ -2,7 +2,7 @@ package mt;
option go_package = ".;mt";
message ApigateCluster
message GamesapiCluster
{
optional int32 instance_id = 1;
optional int32 listen_port = 2;
@ -11,18 +11,12 @@ message ApigateCluster
message Config
{
optional string redirect_url = 1;
optional int32 max_concurrent_num = 2;
optional int32 request_over_time = 3;
}
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;
optional string gamesapi_url = 1;
optional string secret_key = 2;
optional int32 gm_open = 3;
optional string gm_secret_key = 4;
optional string redirect_url = 5;
optional int32 max_concurrent_num = 6;
optional int32 request_over_time = 7;
optional string redirect_secret_key = 8;
}

View File

@ -2,25 +2,15 @@ package service
import (
"f5"
"fmt"
"main/constant"
"main/mt"
"math/rand"
"q5"
"sync"
"sync/atomic"
"time"
)
type downStreamHost struct {
Host string `json:"host"`
Port int32 `json:"port"`
Url string `json:"url"`
}
type sApiForward struct {
userCache []*SApiForwardLockCache
downStreams []downStreamHost
insessTimes int32
total int32
getTimes int32
@ -45,7 +35,6 @@ type SApiForwardLock struct {
}
func (this *sApiForward) init() {
q5.NewSlice(&this.downStreams, 0, 20)
q5.NewSlice(&this.userCache, 1024, 1024)
for i := 0; i < len(this.userCache); i++ {
p := new(SApiForwardLockCache)
@ -53,11 +42,6 @@ func (this *sApiForward) init() {
p.userHash = &map[string]*SApiForwardLock{}
this.userCache[i] = p
}
this.LoadDownStreams()
go func() {
time.Sleep(time.Second * 60 * 10)
this.LoadDownStreams()
}()
}
func (this *sApiForward) unInit() {
@ -144,6 +128,18 @@ func (this *sApiForward) getOrCreate(c *SApiForwardLockCache, accountId string)
}
}
func (this *sApiForward) Sign(params []*[]string, nonce string, timeStamp int64, postData string) string {
signData := ""
q5.Sort(params, func(a *[]string, b *[]string) bool {
return (*a)[0] < (*b)[0]
})
for _, v := range params {
signData += (*v)[0] + "=" + (*v)[1] + "&"
}
signData += nonce + q5.ToString(timeStamp) + postData + mt.Table.Config.GetRedirectSecretKey()
return q5.Md5Str(signData)
}
func (this *sApiForward) outputMonitorLog() {
logtimes := 0
for {
@ -178,41 +174,3 @@ func (this *sApiForward) outputMonitorLog() {
time.Sleep(time.Second * 10)
}
}
func (this *sApiForward) LoadDownStreams() error {
err, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.CONF_DB,
"t_apigate_host",
[][]string{})
if err == nil {
downStreams := []downStreamHost{}
q5.NewSlice(&downStreams, 0, 20)
for ds.Next() {
host := ds.GetByName("apigate_host")
port := q5.ToInt32(ds.GetByName("apigate_port"))
enable := q5.ToInt32(ds.GetByName("enable"))
if enable != 0 {
downSteam := q5.NewSliceElement(&downStreams)
downSteam.Host = host
downSteam.Port = port
downSteam.Url = fmt.Sprintf("http://%s:%d", downSteam.Host, downSteam.Port)
}
}
this.downStreams = downStreams
f5.GetSysLog().Info("LoadDownstreams ok %s", q5.EncodeJson(&downStreams))
} else {
f5.GetSysLog().Info("LoadDownstreams err %s", err)
}
return err
}
func (this *sApiForward) GetDownStreamHost() (string, string) {
downStreams := this.downStreams
if len(downStreams) <= 0 {
return mt.Table.Config.GetRedirectUrl(), ""
}
downStream := downStreams[rand.Intn(len(downStreams))]
return downStream.Url, mt.Table.Config.GetRedirectHost()
}

View File

@ -103,6 +103,8 @@ func (this *recharge) markOk(idx int64, deliveryAccountId string) error {
func (this *recharge) returnContribution(netId int32, shortOrderId int64,
userIdentity string, returnContribution float64, payTime int32) error {
return nil
/*
var resultErr error
nowTime := f5.GetApp().GetRealSeconds()
f5.GetGoStyleDb().Upsert(
@ -126,4 +128,5 @@ func (this *recharge) returnContribution(netId int32, shortOrderId int64,
resultErr = err
})
return resultErr
*/
}

View File

@ -2,7 +2,7 @@ package app
import (
"f5"
"main/constant"
//. "main/global"
"main/mt"
)
@ -39,18 +39,29 @@ func (this *app) Update() {
}
func (this *app) registerDataSources() {
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(),
/* 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(),
1,
mt.Table.ConfDb.GetById(0).GetMaxOpenConns(),
mt.Table.ConfDb.GetById(0).GetMaxIdleConns())
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
mt.Table.MailDb.GetById(0).GetMaxIdleConns())
f5.GetJsStyleDb().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(),
1,
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
mt.Table.MailDb.GetById(0).GetMaxIdleConns()) */
}
func (this *app) HasTask() bool {
return false
return false //GetMailMgr().HasTask()
}

View File

@ -1,9 +1,5 @@
package constant
const (
CONF_DB = "confdb"
)
const (
APP_MODULE_IDX = iota
ROUTER_MODULE_IDX

View File

@ -7,6 +7,7 @@ import (
"io/ioutil"
"jccommon"
"main/service"
"main/mt"
"net/http"
net_url "net/url"
"q5"
@ -40,8 +41,7 @@ func CaForward(c *gin.Context) {
costTime := q5.GetTickCount() - beginTick
service.SApiForward.UpdateCostTime(costTime)
}()
downStreamUrl, downStreamHost := service.SApiForward.GetDownStreamHost()
newUrl := downStreamUrl + c.Request.URL.Path[5:]
newUrl := mt.Table.Config.GetById(0).GetRedirectUrl() + c.Request.URL.Path[5:]
if !q5.StrContains(newUrl, "?") {
newUrl = newUrl + "?"
}
@ -105,9 +105,6 @@ func CaForward(c *gin.Context) {
f5.GetSysLog().Info("CaForward create request url:%s error:%s", newUrl, createErr)
return
}
if downStreamHost != "" {
httpRequest.Host = downStreamHost
}
client := &http.Client{}
if resp, err := client.Do(httpRequest); err == nil {
defer resp.Body.Close()

View File

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

View File

@ -3,12 +3,10 @@ package mt
import (
"f5"
"main/mtb"
"net/url"
)
type Config struct {
mtb.Config
redirectHost string
}
type ConfigTable struct {
@ -16,38 +14,22 @@ type ConfigTable struct {
selfConf *Config
}
func (this *Config) Init1() {
u, err := url.Parse(this.GetRedirectUrl())
if err != nil {
panic(err)
}
this.redirectHost = u.Host
}
func (this *ConfigTable) GetGameSApiUrl() string {
return this.selfConf.GetGamesapiUrl()
}
func (this *ConfigTable) GetRedirectUrl() string {
return this.selfConf.GetRedirectUrl()
}
func (this *ConfigTable) GetRedirectHost() string {
return this.selfConf.redirectHost
}
func (this *ConfigTable) GetSecretKey() string {
return this.selfConf.GetSecretKey()
}
func (this *ConfigTable) GetRedirectSecretKey() string {
return this.selfConf.GetRedirectSecretKey()
}
func (this *ConfigTable) GetMaxConcurrentNum() int32 {
return this.selfConf.GetMaxConcurrentNum()
}
func (this *ConfigTable) GetRedirectSecretKey() string {
return this.selfConf.GetRedirectSecretKey()
}
func (this *ConfigTable) PostInit1() {
this.selfConf = this.GetById(int64(0))
if this.selfConf == nil {

View File

@ -7,7 +7,6 @@ import (
type table struct {
GamesapiCluster *GamesapiClusterTable
Config *ConfigTable
ConfDb *ConfDbTable
}
var Table = f5.New(func(this *table) {
@ -20,10 +19,4 @@ var Table = f5.New(func(this *table) {
this.FileName = "../config/config.json"
this.PrimKey = ""
})
this.ConfDb = f5.New(func(this *ConfDbTable) {
this.FileName = "../config/confdb.mysql.json"
this.PrimKey = ""
})
})

View File

@ -27,19 +27,6 @@ type Config 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
}
func (this *GamesapiCluster) GetInstanceId() int32 {
return this.instance_id
}
@ -128,62 +115,6 @@ func (this *Config) HasRedirectSecretKey() bool {
return (this._flags1_ & (uint64(1) << 8)) > 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 *GamesapiCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
@ -201,13 +132,3 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.request_over_time, "request_over_time", &this._flags1_, 7, kv)
f5.ReadMetaTableField(&this.redirect_secret_key, "redirect_secret_key", &this._flags1_, 8, 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)
}

View File

@ -20,14 +20,3 @@ message Config
optional int32 request_over_time = 7;
optional string redirect_secret_key = 8;
}
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;
}

View File

@ -2,25 +2,15 @@ package service
import (
"f5"
"fmt"
"main/constant"
"main/mt"
"math/rand"
"q5"
"sync"
"sync/atomic"
"time"
)
type downStreamHost struct {
Host string `json:"host"`
Port int32 `json:"port"`
Url string `json:"url"`
}
type sApiForward struct {
userCache []*SApiForwardLockCache
downStreams []downStreamHost
insessTimes int32
total int32
getTimes int32
@ -45,7 +35,6 @@ type SApiForwardLock struct {
}
func (this *sApiForward) init() {
q5.NewSlice(&this.downStreams, 0, 20)
q5.NewSlice(&this.userCache, 1024, 1024)
for i := 0; i < len(this.userCache); i++ {
p := new(SApiForwardLockCache)
@ -53,11 +42,6 @@ func (this *sApiForward) init() {
p.userHash = &map[string]*SApiForwardLock{}
this.userCache[i] = p
}
this.LoadDownStreams()
go func() {
time.Sleep(time.Second * 60 * 10)
this.LoadDownStreams()
}()
}
func (this *sApiForward) unInit() {
@ -190,41 +174,3 @@ func (this *sApiForward) outputMonitorLog() {
time.Sleep(time.Second * 10)
}
}
func (this *sApiForward) LoadDownStreams() error {
err, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.CONF_DB,
"t_internal_gameapi_host",
[][]string{})
if err == nil {
downStreams := []downStreamHost{}
q5.NewSlice(&downStreams, 0, 20)
for ds.Next() {
host := ds.GetByName("gameapi_host")
port := q5.ToInt32(ds.GetByName("gameapi_port"))
enable := q5.ToInt32(ds.GetByName("enable"))
if enable != 0 {
downSteam := q5.NewSliceElement(&downStreams)
downSteam.Host = host
downSteam.Port = port
downSteam.Url = fmt.Sprintf("http://%s:%d", downSteam.Host, downSteam.Port)
}
}
if len(downStreams) > 0 {
this.downStreams = downStreams
}
f5.GetSysLog().Info("LoadDownstreams ok %s", q5.EncodeJson(&downStreams))
} else {
f5.GetSysLog().Info("LoadDownstreams err %s", err)
}
return err
}
func (this *sApiForward) GetDownStreamHost() (string, string) {
downStreams := this.downStreams
if len(downStreams) <= 0 {
return mt.Table.Config.GetRedirectUrl(), ""
}
downStream := downStreams[rand.Intn(len(downStreams))]
return downStream.Url, mt.Table.Config.GetRedirectHost()
}

View File

@ -14,7 +14,7 @@ var Friend = new (friend)
func (this *friend) Force(accountId1 string, accountId2 string, nowTime int64,
cb func (error, int64, int64)) {
f5.GetJsStyleDb().UpsertEx(
f5.GetJsStyleDb().Upsert(
constant.FRIEND_DB,
"t_friend_relationship",
[][]string{
@ -33,14 +33,7 @@ func (this *friend) Force(accountId1 string, accountId2 string, nowTime int64,
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
cb(err, lastInsertId, rowsAffected)
this.updateAddFriendTask(accountId1, nowTime)
this.updateAddFriendTask(accountId2, nowTime)
},
func (ds *f5.DataSet) bool {
return true
})
cb)
}
func (this *friend) DeleteSoft(accountId1 string, accountId2 string,
@ -58,26 +51,3 @@ func (this *friend) DeleteSoft(accountId1 string, accountId2 string,
},
cb)
}
func (this *friend) updateAddFriendTask(accountId string, nowTime int64) {
f5.GetJsStyleDb().Upsert(
constant.GAME_DB,
"t_rookie_task_value",
[][]string{
{"account_id", accountId},
{"task_type", "16"},
},
[][]string{
{"!value", "value + 1"},
{"modifytime", q5.ToString(nowTime)},
},
[][]string{
{"account_id", accountId},
{"task_type", "16"},
{"value", "1"},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
})
}

View File

@ -1,9 +1,5 @@
package jccommon
const (
MAX_PACKET_LEN = 1024 * 64
)
const (
NFT_TYPE_CFHERO = 1
NFT_TYPE_GOLD_BULLION = 11
@ -38,16 +34,12 @@ const (
CONTRACT_NAME_FounderTag = "FounderTag"
CONTRACT_NAME_NFTLock = "NFTLock"
CONTRACT_NAME_GameItemMall = "GameItemMall"
CONTRACT_NAME_StakedEsCecRouter = "stakedEsCecRouter"
CONTRACT_NAME_EsCec = "esCEC"
CONTRACT_NAME_Vester = "vester"
)
const (
MAIL_TAG1_CUSTOM = 10
MAIL_TAG1_HERO = 100
MAIL_TAG1_GOLD_BULLION = 101
MAIL_TAG1_OLD_USER = 102
)
const (
@ -61,8 +53,6 @@ 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 (
@ -115,7 +105,6 @@ const (
const (
MAP_MODE_BOUNTY = 301
MAP_MODE_CIRCUIT = 7
)
const (

View File

@ -108,38 +108,6 @@ type UserStackingPo struct {
Contracts []*ContractStackingPo `json:"contracts"`
}
type ContractStakeAndUnstakeCecPo struct {
Account string `json:"account"`
Token string `json:"token"`
Amount string `json:"amount"`
}
type Erc20TransferPo struct {
From string `json:"from"`
To string `json:"to"`
Value string `json:"value"`
}
type BlockDataPo struct {
TimeStamp int32 `json:"timestamp"`
}
type VesterClaimPo struct {
Receiverstring string `json:"receiver"`
Amount string `json:"amount"`
}
type VesterDepositPo struct {
Account string `json:"account"`
Amount string `json:"amount"`
}
type VesterWithdrawPo struct {
Account string `json:"account"`
ClaimedAmount string `json:"claimedAmount"`
Balance string `json:"balance"`
}
type NftIdentity struct {
NetId int32
ContractAddress string
@ -173,23 +141,8 @@ func NewContractStackingPo() *ContractStackingPo {
return p
}
func NewContractStakeAndUnstakeCecPo() *ContractStakeAndUnstakeCecPo {
p := new(ContractStakeAndUnstakeCecPo)
return p
}
func NewUserStackingPo() *UserStackingPo {
p := new(UserStackingPo)
p.Contracts = []*ContractStackingPo{}
return p
}
func NewErc20TransferPo() *Erc20TransferPo {
p := new(Erc20TransferPo)
return p
}
func NewBlockDataPo() *BlockDataPo {
p := new(BlockDataPo)
return p
}

View File

@ -1,21 +1,20 @@
package jccommon
import (
"q5"
"strconv"
)
func GetGoldBullionGoldNum(itemId int32) int32 {
switch itemId {
case V_ITEM_GOLD_BULLION_1K: {
return 1000
}
return 1000
}
case V_ITEM_GOLD_BULLION_1W: {
return 10000 * 1
}
return 10000 * 1
}
default: {
return 0
}
return 0
}
}
}
@ -68,15 +67,15 @@ func CalcContributionScore(nfts []*NftStacking) float64 {
for _, v := range nfts {
switch v.TokenType {
case NFT_TYPE_CFHERO, NFT_TYPE_CFHERO_NORMAL: {
baseScore += GetHeroStackingScore(v.Quality)
if v.TokenType == NFT_TYPE_CFHERO {
rate += 0.05
}
baseScore += GetHeroStackingScore(v.Quality)
if v.TokenType == NFT_TYPE_CFHERO {
rate += 0.05
}
}
case NFT_TYPE_FOUNDER_TAG: {
baseScore += GetFounderTagStackingScore(v.Quality)
rate += 0.1
}
baseScore += GetFounderTagStackingScore(v.Quality)
rate += 0.1
}
}
}
if rate > 1 {
@ -86,34 +85,8 @@ func CalcContributionScore(nfts []*NftStacking) float64 {
return score
}
func ExtractChannel(accountId string) string {
strs := q5.StrSplit(accountId, "_")
return strs[0]
}
func IsValidSessionId(accountId string, sessionId string) bool {
return true
// if accountId == "" || sessionId == "" {
// return false
// }
// strs := q5.StrSplit(sessionId, "_")
// if len(strs) < 4 {
// return false
// }
// if f5.IsOnlineEnv() {
// channel := ExtractChannel(accountId)
// if channel == "6000" {
// return false
// }
// }
// session_createtime := strs[0]
// account_regtime := strs[1]
// md51 := strs[2]
// // md52:=strs[3]
// return q5.Md5Str(accountId + "f3a6a9a5-217a-4079-ab99-b5d69b8212be" + account_regtime + session_createtime) == md51
}
func GenTransId(funcId int8, time int32, seqId int32, params []int64) (string, error) {

View File

@ -35,7 +35,4 @@ const (
USER_ADD_GOLD_REASON_USE = 2
)
const VESTER_DEPOSIT_EVENT_NAME = "Deposit"
const VESTER_WITHDRAW_EVENT_NAME = "Withdraw"
const BASE_SCORE = 2800

View File

@ -1,14 +0,0 @@
package mt
import (
"f5"
"main/mtb"
)
type StakingVip struct {
mtb.StakingVip
}
type StakingVipTable struct {
f5.IdMetaTable[StakingVip]
}

View File

@ -19,7 +19,6 @@ type table struct {
HashRateCommon *HashRateCommonTable
Contract *ContractTable
BcCurrency *BcCurrencyTable
StakingVip *StakingVipTable
}
var Table = f5.New(func(this *table) {
@ -87,9 +86,4 @@ var Table = f5.New(func(this *table) {
this.PrimKey = "name"
})
this.StakingVip = f5.New(func(this *StakingVipTable) {
this.FileName = "../res/stakingVip@stakingVip.json"
this.PrimKey = "rank"
})
})

View File

@ -84,7 +84,6 @@ type Config struct {
immutable_base_url string
chain_name string
immutable_api_key string
scoreboard_height int32
_flags1_ uint64
_flags2_ uint64
@ -138,21 +137,6 @@ type HashRateCommon struct {
_flags2_ uint64
}
type StakingVip struct {
rights string
require int64
thisPoint int64
rank int32
vip_name string
rate float64
vip_working_tips string
vip_unworking_tips string
id int32
_flags1_ uint64
_flags2_ uint64
}
func (this *BackTaskCluster) GetInstanceId() int32 {
return this.instance_id
}
@ -497,14 +481,6 @@ func (this *Config) HasImmutableApiKey() bool {
return (this._flags1_ & (uint64(1) << 6)) > 0
}
func (this *Config) GetScoreboardHeight() int32 {
return this.scoreboard_height
}
func (this *Config) HasScoreboardHeight() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0
}
func (this *Item) GetName() string {
return this.name
}
@ -649,78 +625,6 @@ func (this *HashRateCommon) HasCecPool() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *StakingVip) GetRights() string {
return this.rights
}
func (this *StakingVip) HasRights() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *StakingVip) GetRequire() int64 {
return this.require
}
func (this *StakingVip) HasRequire() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *StakingVip) GetThisPoint() int64 {
return this.thisPoint
}
func (this *StakingVip) HasThisPoint() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *StakingVip) GetRank() int32 {
return this.rank
}
func (this *StakingVip) HasRank() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *StakingVip) GetVipName() string {
return this.vip_name
}
func (this *StakingVip) HasVipName() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *StakingVip) GetRate() float64 {
return this.rate
}
func (this *StakingVip) HasRate() bool {
return (this._flags1_ & (uint64(1) << 6)) > 0
}
func (this *StakingVip) GetVipWorkingTips() string {
return this.vip_working_tips
}
func (this *StakingVip) HasVipWorkingTips() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0
}
func (this *StakingVip) GetVipUnworkingTips() string {
return this.vip_unworking_tips
}
func (this *StakingVip) HasVipUnworkingTips() bool {
return (this._flags1_ & (uint64(1) << 8)) > 0
}
func (this *StakingVip) GetId() int32 {
return this.id
}
func (this *StakingVip) HasId() bool {
return (this._flags1_ & (uint64(1) << 9)) > 0
}
func (this *BackTaskCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
@ -784,7 +688,6 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.immutable_base_url, "immutable_base_url", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.chain_name, "chain_name", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.immutable_api_key, "immutable_api_key", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.scoreboard_height, "scoreboard_height", &this._flags1_, 7, kv)
}
func (this *Item) LoadFromKv(kv map[string]interface{}) {
@ -819,15 +722,3 @@ func (this *HashRateCommon) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.end_time, "end_time", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.cec_pool, "cec_pool", &this._flags1_, 4, kv)
}
func (this *StakingVip) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.rights, "rights", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.require, "require", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.thisPoint, "thisPoint", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.rank, "rank", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.vip_name, "vip_name", &this._flags1_, 5, kv)
f5.ReadMetaTableField(&this.rate, "rate", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.vip_working_tips, "vip_working_tips", &this._flags1_, 7, kv)
f5.ReadMetaTableField(&this.vip_unworking_tips, "vip_unworking_tips", &this._flags1_, 8, kv)
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 9, kv)
}

View File

@ -71,7 +71,6 @@ message Config
optional string immutable_base_url = 3;
optional string chain_name = 4;
optional string immutable_api_key = 6;
optional int32 scoreboard_height = 7;
}
message Item
@ -110,17 +109,4 @@ message HashRateCommon
optional string start_time = 2;
optional string end_time = 3;
optional int32 cec_pool = 4;
}
message StakingVip
{
optional string rights = 1;
optional int64 require = 2;
optional int64 thisPoint = 3;
optional int32 rank = 4;
optional string vip_name = 5;
optional double rate = 6;
optional string vip_working_tips = 7;
optional string vip_unworking_tips = 8;
optional int32 id = 9;
}

View File

@ -6,7 +6,6 @@ import (
)
var BcCurrency = new(bcCurrency)
var Vip = new(vip)
var _serviceMgr = new(serviceMgr)
func init() {

View File

@ -5,7 +5,6 @@ type serviceMgr struct {
func (this *serviceMgr) Init() {
BcCurrency.init()
Vip.init()
}
func (this *serviceMgr) UnInit() {

View File

@ -1,340 +0,0 @@
package service
import (
"f5"
"main/constant"
"main/mt"
"math/big"
"q5"
"strings"
"sync"
)
type vip struct {
lock sync.Mutex
}
type vesterDepositWithdrawPo struct {
idx int64
eventName string
chainTimestamp int32
accountAddress string
depositAmount string
withdrawClamiedAmount string
withdrawBalance string
}
func (this *vip) init() () {
}
func (this *vip) Add(accountAddress string, val string, idx int64, valField string, idxField string) bool {
this.lock.Lock()
defer this.lock.Unlock()
extKv := [][]string{}
lvParams := map[string]string{}
accountAddress = strings.ToLower(accountAddress)
err, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.BCNFT_DB,
"t_vip_user",
[][]string {
{"account_address", accountAddress},
})
if err != nil {
return false
}
nowTime := f5.GetApp().GetRealSeconds()
updateKv := [][]string {
{idxField, q5.ToString(idx)},
{"modifytime", q5.ToString(nowTime)},
}
insertKv := [][]string {
{"account_address", accountAddress},
{valField, val},
{idxField, q5.ToString(idx)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
}
updateKv = append(updateKv, extKv...)
insertKv = append(insertKv, extKv...)
if ds.Next() {
if q5.ToInt64(ds.GetByName(idxField)) >= idx {
return true
}
bnOldVal, _ := new(big.Int).SetString(ds.GetByName(valField), 10)
bnVal, _ := new(big.Int).SetString(val, 10)
if bnOldVal == nil {
bnOldVal = new(big.Int)
}
bnNewVal := bnOldVal.Add(bnOldVal, bnVal)
updateKv = append(updateKv, [][]string{{valField, bnNewVal.String()}}...)
lvParams["escec_balance"] = ds.GetByName("escec_balance")
lvParams["escec_stacking"] = ds.GetByName("escec_stacking")
lvParams["escec_convert"] = ds.GetByName("escec_convert")
lvParams["last_convert_time"] = ds.GetByName("last_convert_time")
lvParams[valField] = bnNewVal.String()
newlv := this.calcVipLv(lvParams)
updateKv = append(updateKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewUpdate(
constant.BCNFT_DB,
"t_vip_user",
[][]string {
{"account_address", accountAddress},
},
updateKv)
if err1 != nil {
return false
}
} else {
lvParams[valField] = val
newlv := this.calcVipLv(lvParams)
insertKv = append(insertKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewInsert(
constant.BCNFT_DB,
"t_vip_user",
insertKv)
if err1 != nil {
return false
}
}
return true
}
func (this *vip) Replace(accountAddress string, val string, idx int64, valField string, idxField string,
extKv [][]string) bool {
this.lock.Lock()
defer this.lock.Unlock()
accountAddress = strings.ToLower(accountAddress)
err, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.BCNFT_DB,
"t_vip_user",
[][]string {
{"account_address", accountAddress},
})
if err != nil {
return false
}
lvParams := map[string]string{}
replaceFields:= func() {
lvParams[valField] = val
for _, sli := range extKv {
if len(sli) > 1 {
lvParams[sli[0]] = sli[1]
}
}
}
nowTime := f5.GetApp().GetRealSeconds()
updateKv := [][]string {
{valField, val},
{idxField, q5.ToString(idx)},
{"modifytime", q5.ToString(nowTime)},
}
insertKv := [][]string {
{"account_address", accountAddress},
{valField, val},
{idxField, q5.ToString(idx)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
}
updateKv = append(updateKv, extKv...)
insertKv = append(insertKv, extKv...)
if ds.Next() {
if q5.ToInt64(ds.GetByName(idxField)) >= idx {
return true
}
lvParams["escec_balance"] = ds.GetByName("escec_balance")
lvParams["escec_stacking"] = ds.GetByName("escec_stacking")
lvParams["escec_convert"] = ds.GetByName("escec_convert")
lvParams["last_convert_time"] = ds.GetByName("last_convert_time")
replaceFields()
newlv := this.calcVipLv(lvParams)
updateKv = append(updateKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewUpdate(
constant.BCNFT_DB,
"t_vip_user",
[][]string {
{"account_address", accountAddress},
},
updateKv)
if err1 != nil {
return false
}
} else {
replaceFields()
newlv := this.calcVipLv(lvParams)
insertKv = append(insertKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewInsert(
constant.BCNFT_DB,
"t_vip_user",
insertKv)
if err1 != nil {
return false
}
}
return true
}
/*
Deposit amount his_amount 衰减,最后的存覆盖之前的
Withdraw 所有
按时间排序处理事件的先后顺序
通过Vester.sol的remainingEsToken方法获取, 如果要本地计算的话, 那就取每次Deposit事件的时间和amount, 加上先前的转换的余额, 再按total * (now - deposit_time) / (365 * 24 * 3600)
*/
func (this *vip) RecalcEsCecConvert(accountAddress string) error {
accountAddress = strings.ToLower(accountAddress)
err , ds := f5.GetGoStyleDb().NewOrmSelect(
constant.BCEVENT_DB,
"t_vester_deposit_withdraw",
[][]string {
{"account_address", accountAddress},
})
if err != nil {
return err
}
matchDeposits := []*vesterDepositWithdrawPo{}
var lastWithdraw *vesterDepositWithdrawPo
{
allDeposits := []*vesterDepositWithdrawPo{}
for ds.Next() {
p := new(vesterDepositWithdrawPo)
p.idx = q5.ToInt64(ds.GetByName("idx"))
p.eventName = ds.GetByName("event_name")
p.chainTimestamp = q5.ToInt32(ds.GetByName("chain_timestamp"))
p.accountAddress = ds.GetByName("account_address")
p.depositAmount = ds.GetByName("deposit_amount")
p.withdrawClamiedAmount = ds.GetByName("withdraw_clamied_amount")
p.withdrawBalance = ds.GetByName("withdraw_balance")
if p.eventName == constant.VESTER_DEPOSIT_EVENT_NAME {
q5.AppendSlice(&allDeposits, p)
} else if p.eventName == constant.VESTER_WITHDRAW_EVENT_NAME {
if lastWithdraw == nil || lastWithdraw.chainTimestamp < p.chainTimestamp {
lastWithdraw = p
}
}
}
for _, val := range allDeposits {
if lastWithdraw == nil || val.chainTimestamp > lastWithdraw.chainTimestamp {
q5.AppendSlice(&matchDeposits, val)
}
}
}
q5.Sort(matchDeposits, func (a *vesterDepositWithdrawPo, b *vesterDepositWithdrawPo) bool {
return a.chainTimestamp < b.chainTimestamp
})
var lastDeposit *vesterDepositWithdrawPo
nowTime := q5.ToInt32(f5.GetApp().GetRealSeconds())
bnTotal := new(big.Int)
for _, val := range matchDeposits {
if lastDeposit != nil {
if nowTime > lastDeposit.chainTimestamp {
bnPassTime := new(big.Int).SetInt64(int64(nowTime - lastDeposit.chainTimestamp))
bnTotalTime := new(big.Int).SetInt64(int64(365 * 24 * 3600))
bnTmp := bnTotal.Mul(bnTotal, bnPassTime)
bnInterest := bnTmp.Div(bnTmp, bnTotalTime)
bnTotal = bnTotal.Sub(bnTotal, bnInterest)
}
}
bnAmount, _ := new(big.Int).SetString(val.depositAmount, 10)
bnTotal = bnAmount.Add(bnAmount, bnTotal)
lastDeposit = val
}
var maxIdx int64
if lastDeposit != nil &&
lastDeposit.idx > maxIdx {
maxIdx = lastDeposit.idx
}
if lastWithdraw != nil &&
lastWithdraw.idx > maxIdx {
maxIdx = lastWithdraw.idx
}
if lastDeposit != nil {
this.Replace(accountAddress, bnTotal.String(), maxIdx, "escec_convert", "deposit_withdraw_last_src_idx",
[][]string {
{"last_convert_time", q5.ToString(lastDeposit.chainTimestamp)},
})
} else if lastWithdraw != nil {
this.Replace(accountAddress, "0", maxIdx, "escec_convert", "deposit_withdraw_last_src_idx",
[][]string {
{"last_convert_time", q5.ToString(lastWithdraw.chainTimestamp)},
})
}
return nil
}
func (this *vip) calcVipLv(params map[string]string) (lv int64) {
balancestr := params["escec_balance"]
if balancestr == "" {
balancestr = "0"
}
escec_balance, ok := new(big.Int).SetString(balancestr, 10)
if !ok {
escec_balance = new(big.Int).SetInt64(0)
}
stackingstr := params["escec_stacking"]
if stackingstr == "" {
stackingstr = "0"
}
escec_stacking, ok := new(big.Int).SetString(stackingstr, 10)
if !ok {
escec_stacking = new(big.Int).SetInt64(0)
}
curExec := new(big.Int).Add(escec_balance, escec_stacking)
convertstr := params["escec_convert"]
if convertstr == "" {
convertstr = "0"
}
escec_convert, ok := new(big.Int).SetString(convertstr, 10)
if !ok {
escec_convert = new(big.Int).SetInt64(0)
}
last_convert_time := q5.SafeToInt64(params["last_convert_time"])
nowsecs := f5.GetApp().GetRealSeconds()
diff := nowsecs - last_convert_time
if diff < 0 {
diff = 0
}
elapse := new(big.Int).SetInt64(diff)
depositExec := new(big.Int).Mul(escec_convert, elapse)
depositExec = depositExec.Div(depositExec, new(big.Int).SetInt64(365*24*3600))
if depositExec.Cmp(escec_convert) < 0 {
depositExec = new(big.Int).Sub(escec_convert, depositExec)
} else {
depositExec.SetInt64(0)
}
curExec = curExec.Add(curExec, depositExec)
convercurExec := new(big.Int).Div(curExec, new(big.Int).SetInt64(1000*1000*1000*1000*1000*1000)).Int64()
lv = 0
for {
cfg := mt.Table.StakingVip.GetById(lv)
nextlvcfg := mt.Table.StakingVip.GetById(lv + 1)
if cfg != nil && nextlvcfg != nil {
if cfg.GetRequire() <= convercurExec && nextlvcfg.GetRequire() > convercurExec {
return lv
}
} else {
break
}
lv++
}
return
}

View File

@ -1,121 +0,0 @@
package task
import (
"q5"
"f5"
"jccommon"
"main/mt"
"main/constant"
"main/service"
"strings"
"fmt"
)
type esCecTransfer struct {
}
func (this *esCecTransfer) init() {
mt.Table.Contract.Traverse(func (ele *mt.Contract) bool {
if ele.GetName() == jccommon.CONTRACT_NAME_EsCec {
go this.process(ele.GetNetId(), ele.GetAddress())
}
return true
})
}
func (this *esCecTransfer) unInit() {
}
func (this *esCecTransfer) process(netId int32, contractAddress string) {
key := fmt.Sprintf("esCecTransfer.lastIdx.%d.%s", netId, contractAddress)
if dbLastIdxStr, err := jccommon.GetDbParam(constant.BCEVENT_DB, key); err == nil {
f5.GetGoStyleDb().IncrementLoad(
constant.BCEVENT_DB,
"esCecTransfer." + q5.ToString(netId) + "." + contractAddress,
"t_blockchain_event",
q5.ToInt64(dbLastIdxStr),
func (lastIdx int64, maxIdx int64) (string, []string) {
sql := fmt.Sprintf(`
SELECT * FROM t_blockchain_event
WHERE idx > %d AND idx <= %d AND net_id = %d AND contract_address = ? AND event_name IN (?)
ORDER BY idx LIMIT 1000
`,
lastIdx,
maxIdx,
netId)
params := []string{
contractAddress,
"Transfer",
}
return sql, params
},
func (newLastIdx int64) {
jccommon.SaveDbParam(constant.BCEVENT_DB, key, q5.ToString(newLastIdx))
},
this.saveToDb)
} else {
panic(fmt.Sprintf("esCecTransfer.Transfer getDBParam error %s", err))
}
}
func (this* esCecTransfer) saveToDb(ds *f5.DataSet) bool {
ro := jccommon.NewErc20TransferPo()
bo := jccommon.NewBlockDataPo()
if err := q5.DecodeJson(ds.GetByName("return_values"), ro); err != nil {
f5.GetSysLog().Warning("esCecTransfer.parser.return_values error:%s", err)
return false
}
if err := q5.DecodeJson(ds.GetByName("block_data"), bo); err != nil {
f5.GetSysLog().Warning("esCecTransfer.parser.block_data error:%s", err)
return false
}
idx := q5.ToInt64(ds.GetByName("idx"))
if !q5.IsWeb3ZeroAddress(ro.To) {
if !service.Vip.Add(ro.To, ro.Value, idx, "escec_balance", "escec_transfer_last_src_idx") {
return false
}
}
if !q5.IsWeb3ZeroAddress(ro.From) {
if !service.Vip.Add(ro.From, "-" + ro.Value, idx, "escec_balance", "escec_transfer_last_src_idx") {
return false
}
}
txhash := ds.GetByName("txhash")
logIndex := ds.GetByName("log_index")
netId := ds.GetByName("net_id")
eventName := ds.GetByName("event_name")
contractAddress := ds.GetByName("contract_address")
createTime := ds.GetByName("createtime")
modifyTime := ds.GetByName("modifytime")
if err, _, _ := f5.GetGoStyleDb().NewUpsert(
constant.BCEVENT_DB,
"t_escec_transfer",
[][]string{
{"txhash", txhash},
{"log_index", logIndex},
{"net_id", netId},
{"contract_address", contractAddress},
},
[][]string{
},
[][]string{
{"txhash", txhash},
{"log_index", logIndex},
{"net_id", netId},
{"contract_address", strings.ToLower(contractAddress)},
{"src_idx", q5.ToString(idx)},
{"event_name", eventName},
{"chain_timestamp", q5.ToString(bo.TimeStamp)},
{"from_address", strings.ToLower(ro.From)},
{"to_address", strings.ToLower(ro.To)},
{"value", ro.Value},
{"createtime", createTime},
{"modifytime", modifyTime},
}); err != nil {
return false
}
return true
}

View File

@ -1,95 +0,0 @@
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

@ -1,99 +0,0 @@
package task
import (
"encoding/json"
"f5"
"main/constant"
"main/mt"
"q5"
"time"
)
type rankchart struct {
}
type rankitem struct {
Idx int64 `json:"idx"`
Account string `json:"account_id"`
Name string `json:"name"`
Head int32 `json:"head_id"`
HeadFrame int32 `json:"head_frame"`
Score int32 `json:"score"`
Rank int32 `json:"rank"`
}
func (r *rankchart) init() {
// go r.processLoop()
}
func (r *rankchart) unInit() {
}
func (r *rankchart) processLoop() {
for {
height := mt.Table.Config.GetById(0).GetScoreboardHeight()
r.processScoreRank(height)
time.Sleep(time.Minute)
}
}
func (r *rankchart) processScoreRank(height int32) {
sql := `SELECT idx, account_id, name, head_id, head_frame, score, score_modifytime FROM t_user WHERE idx > 0`
order := " ORDER BY score DESC, score_modifytime ASC, idx ASC "
const perpage = int32(512)
pageno := int32(1)
item := new(rankitem)
for {
datalist := []string{}
var queryerr error
lastpage := false
f5.GetGoStyleDb().PageQuery(
constant.GAME_DB,
perpage,
pageno,
sql,
[]string{},
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
order,
func(err error, p *f5.Pagination) {
if err != nil {
queryerr = err
return
}
if p.CurrentPage == p.TotalPages {
lastpage = true
}
for p.Rows.Next() {
item.Rank = int32(p.Rows.NumOfReaded()) + (pageno-1)*(perpage)
if height > 0 && item.Rank > height {
lastpage = true
return
}
item.Idx = q5.SafeToInt64(p.Rows.GetByName("idx"))
item.Account = p.Rows.GetByName("account_id")
item.Name = p.Rows.GetByName("name")
item.Head = q5.SafeToInt32(p.Rows.GetByName("head_id"))
item.HeadFrame = q5.SafeToInt32(p.Rows.GetByName("head_frame"))
item.Score = q5.SafeToInt32(p.Rows.GetByName("score"))
rankdata, _ := json.Marshal(item)
datalist = append(datalist, string(rankdata))
}
})
if len(datalist) > 0 {
// push to redis
// fmt.Println(datalist)
}
if queryerr != nil || lastpage {
break
}
pageno++
}
}

Some files were not shown because too many files have changed in this diff Show More