Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a50abf5c4 | |||
| cbdce12462 | |||
|
|
27aff930c7 | ||
|
|
5f3a40a50e | ||
|
|
22ac6c1fed | ||
|
|
8c40855c4e | ||
|
|
c4c8bea3c1 |
@ -1,17 +0,0 @@
|
||||
module Framework
|
||||
|
||||
go 1.22.2
|
||||
|
||||
replace goutil => ../goutil
|
||||
|
||||
require (
|
||||
github.com/Shopify/sarama v1.29.1
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/jinzhu/gorm v1.9.12
|
||||
github.com/rabbitmq/amqp091-go v1.8.1
|
||||
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.230
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vms v1.0.230
|
||||
goutil v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
@ -1,46 +0,0 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"goutil/logUtilPlus"
|
||||
)
|
||||
|
||||
// AddUser 添加用户
|
||||
// AddUser 添加新的用户到数据库中。
|
||||
// 参数 User: 包含用户信息的对象。
|
||||
// 返回值: 插入操作影响的行数和可能发生的错误。
|
||||
func AddUser(User *User) (int64, error) {
|
||||
|
||||
//处理一些验证
|
||||
|
||||
// 写入到数据库
|
||||
result := connection.GetUserDB().Create(&User) // 通过数据的指针来创建
|
||||
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("添加用户失败 错误信息:", result.Error.Error())
|
||||
}
|
||||
return User.ID, nil
|
||||
}
|
||||
|
||||
// GetUserByID 根据用户ID获取用户信息
|
||||
func GetUserByID(UserID int64) (*User, error) {
|
||||
var User User
|
||||
|
||||
//缓存判断等一些设置
|
||||
|
||||
result := connection.GetUserDB().First(&User, UserID)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
return &User, nil
|
||||
}
|
||||
|
||||
// 用户登录
|
||||
func Login(account string, password string) (*User, error) {
|
||||
var User User
|
||||
result := connection.GetUserDB().Where("account = ? AND password = ?", account, password).First(&User)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
return &User, nil
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package user
|
||||
@ -1,36 +0,0 @@
|
||||
module logincenter
|
||||
|
||||
go 1.22.10
|
||||
|
||||
replace (
|
||||
common => ../common
|
||||
framework => ../framework
|
||||
goutil => ../goutil
|
||||
)
|
||||
|
||||
require common v0.0.0-00010101000000-000000000000
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/gomodule/redigo v1.8.9 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||
)
|
||||
Binary file not shown.
@ -1,31 +0,0 @@
|
||||
package connection
|
||||
|
||||
var (
|
||||
// 存放实体结构
|
||||
dbModelMap = make([]interface{}, 0)
|
||||
)
|
||||
|
||||
// RegisterDBModel 注册数据库模型到全局变量dbModelMap中。
|
||||
// 这个函数接受一个interface{}类型的参数dbModel,表示数据库模型。
|
||||
// 函数的目的是将传入的数据库模型添加到全局变量dbModelMap中,
|
||||
// 以便在其他地方可以访问和使用这些数据库模型。
|
||||
func RegisterDBModel(dbModel interface{}) {
|
||||
// 将dbModel的地址添加到dbModelMap中。
|
||||
// 这里使用地址是因为数据库模型可能比较大,通过引用存储可以提高效率。
|
||||
dbModelMap = append(dbModelMap, &dbModel)
|
||||
}
|
||||
|
||||
// BuildDB 用于遍历dbModelMap中的所有数据库模型,并检查每个模型对应的表是否存在于数据库中。
|
||||
// 如果表不存在,则自动迁移(创建)该表。这样可以确保数据库模式与程序中的模型保持同步。
|
||||
func BuildDB() {
|
||||
// 遍历dbModelMap中的每个元素
|
||||
for _, dbModel := range dbModelMap {
|
||||
|
||||
// 检查数据库中是否存在与dbModel对应的表
|
||||
tableExists := GetAdminDB().Migrator().HasTable(dbModel)
|
||||
if !tableExists {
|
||||
// 如果表不存在,则进行自动迁移
|
||||
GetAdminDB().AutoMigrate(dbModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,188 +0,0 @@
|
||||
package configYaml
|
||||
|
||||
import (
|
||||
"goutil/logUtilPlus"
|
||||
"goutil/mysqlUtil"
|
||||
"goutil/redisUtil"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DbConfig
|
||||
//
|
||||
// @description: mysql配置对象
|
||||
type DbConfig struct {
|
||||
|
||||
// 管理员数据库链接字符串
|
||||
adminConfig *mysqlUtil.DBConfig
|
||||
|
||||
// 用户数据库链接字符串
|
||||
userConfig *mysqlUtil.DBConfig
|
||||
|
||||
// 游戏模型数据库链接字符串
|
||||
gameModelConfig *mysqlUtil.DBConfig
|
||||
|
||||
// 游戏数据库链接字符串
|
||||
gameConfig *mysqlUtil.DBConfig
|
||||
|
||||
// 游戏数据库链接字符串
|
||||
playerConfig *mysqlUtil.DBConfig
|
||||
|
||||
// redis配置对象
|
||||
redisConfig *redisUtil.RedisConfig
|
||||
}
|
||||
|
||||
var (
|
||||
// 数据库配置对象
|
||||
dbConfigObj *DbConfig
|
||||
)
|
||||
|
||||
// GetAdminConfig
|
||||
// @description: 获取admin库配置
|
||||
// parameter:
|
||||
//
|
||||
// @receiver config:config
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*mysqlUtil.DBConfig:admin库配置
|
||||
func (config *DbConfig) GetAdminConfig() *mysqlUtil.DBConfig {
|
||||
return config.adminConfig
|
||||
}
|
||||
|
||||
// GetUserConfig
|
||||
// @description: 获取user库配置
|
||||
// parameter:
|
||||
//
|
||||
// @receiver config:config
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*mysqlUtil.DBConfig:user库配置
|
||||
func (config *DbConfig) GetUserConfig() *mysqlUtil.DBConfig {
|
||||
return config.adminConfig
|
||||
}
|
||||
|
||||
// GetGameModelConfig
|
||||
// @description: 获取model库配置
|
||||
// parameter:
|
||||
//
|
||||
// @receiver config:config
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*mysqlUtil.DBConfig:model库配置
|
||||
func (config *DbConfig) GetGameModelConfig() *mysqlUtil.DBConfig {
|
||||
return config.gameModelConfig
|
||||
}
|
||||
|
||||
// GetGameConfig
|
||||
// @description: 获取Game库配置
|
||||
// parameter:
|
||||
//
|
||||
// @receiver config:config
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*mysqlUtil.DBConfig:Game库配置
|
||||
func (config *DbConfig) GetGameConfig() *mysqlUtil.DBConfig {
|
||||
return config.gameConfig
|
||||
}
|
||||
|
||||
// GetPlayerConfig
|
||||
// @description: 获取玩家库配置
|
||||
// parameter:
|
||||
//
|
||||
// @receiver config:config
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*mysqlUtil.DBConfig:玩家库配置
|
||||
func (config *DbConfig) GetPlayerConfig() *mysqlUtil.DBConfig {
|
||||
return config.playerConfig
|
||||
}
|
||||
|
||||
// GetRedisConfig
|
||||
// @description: 获取redis配置对象
|
||||
// parameter:
|
||||
//
|
||||
// @receiver config:config
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*redisUtil.RedisConfig:redis配置
|
||||
func (config *DbConfig) GetRedisConfig() *redisUtil.RedisConfig {
|
||||
return config.redisConfig
|
||||
}
|
||||
|
||||
// newMysqlConfig
|
||||
//
|
||||
// @description: 创建新的Mysql配置对象
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @_gameModelConfig:
|
||||
// @_gameConfig:
|
||||
// @_playerConfig:
|
||||
// @_redisConfig:
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*DbConfig:
|
||||
func newMysqlConfig(_adminConfig *mysqlUtil.DBConfig, _userConfig *mysqlUtil.DBConfig, _gameModelConfig *mysqlUtil.DBConfig,
|
||||
_gameConfig *mysqlUtil.DBConfig,
|
||||
_playerConfig *mysqlUtil.DBConfig,
|
||||
_redisConfig *redisUtil.RedisConfig) *DbConfig {
|
||||
return &DbConfig{
|
||||
adminConfig: _adminConfig,
|
||||
userConfig: _userConfig,
|
||||
gameModelConfig: _gameModelConfig,
|
||||
gameConfig: _gameConfig,
|
||||
redisConfig: _redisConfig,
|
||||
playerConfig: _playerConfig,
|
||||
}
|
||||
}
|
||||
|
||||
// initDbConfig
|
||||
//
|
||||
// @description: 初始化数据库配置
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @configObj: 数据库配置
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @error: 错误数据
|
||||
func initDbConfig() error {
|
||||
|
||||
logUtilPlus.DebugLog("开始加载DbConfig")
|
||||
|
||||
redisConfig := ConfigYaml.Root.DbConfig.RedisConfig
|
||||
|
||||
//if redisConfig == nil {
|
||||
// logUtilPlus.DebugLog("redis配置为空")
|
||||
// return nil
|
||||
//}
|
||||
|
||||
// 初始化mysql配置对象
|
||||
dbConfigObj = newMysqlConfig(
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.AdminDB.ConnectionString, ConfigYaml.Root.DbConfig.AdminDB.MaxOpenConns, ConfigYaml.Root.DbConfig.AdminDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.UserDB.ConnectionString, ConfigYaml.Root.DbConfig.UserDB.MaxOpenConns, ConfigYaml.Root.DbConfig.UserDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.GameModel.ConnectionString, ConfigYaml.Root.DbConfig.GameModel.MaxOpenConns, ConfigYaml.Root.DbConfig.GameModel.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.GameDB.ConnectionString, ConfigYaml.Root.DbConfig.GameDB.MaxOpenConns, ConfigYaml.Root.DbConfig.GameDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.PlayerDB.ConnectionString, ConfigYaml.Root.DbConfig.PlayerDB.MaxOpenConns, ConfigYaml.Root.DbConfig.PlayerDB.MaxIdleConns),
|
||||
redisUtil.NewRedisConfig2(redisConfig.ConnectionString, redisConfig.Password, redisConfig.Database, redisConfig.MaxActive, redisConfig.MaxIdle, time.Duration(redisConfig.IdleTimeout)*time.Second, time.Duration(redisConfig.DialConnectTimeout)*time.Second))
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDbConfig
|
||||
//
|
||||
// @description: 获取mysql配置
|
||||
//
|
||||
// parameter:
|
||||
// return:
|
||||
//
|
||||
// @*DbConfig: mysql配置对象
|
||||
func GetDbConfig() *DbConfig {
|
||||
return dbConfigObj
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
module common
|
||||
|
||||
go 1.22.2
|
||||
|
||||
replace (
|
||||
framework => ../../framework
|
||||
goutil => ../../goutil
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
gorm.io/driver/mysql v1.5.7
|
||||
gorm.io/gorm v1.25.12
|
||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/gomodule/redigo v1.8.9 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/stretchr/testify v1.8.0 // indirect
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
)
|
||||
@ -1,43 +0,0 @@
|
||||
<root>
|
||||
<!-- 是否是调试模式 -->
|
||||
<DEBUG>true</DEBUG>
|
||||
<!-- web服务监听地址和端口 -->
|
||||
<WerbServerAddress>192.168.50.85:10051</WerbServerAddress>
|
||||
<!-- es地址 -->
|
||||
<EsUrls>http://10.252.0.70:18099</EsUrls>
|
||||
<!-- 数据库配置 -->
|
||||
<DbConfig>
|
||||
<AdminDB>
|
||||
<!-- 最大处于开启状态的连接数 -->
|
||||
<MaxOpenConns>0</MaxOpenConns>
|
||||
<!-- 最大处于空闲状态的连接数 -->
|
||||
<MaxIdleConns>0</MaxIdleConns>
|
||||
<!-- 数据库连接字符串 -->
|
||||
<ConnectionString><![CDATA[root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true]]></ConnectionString>
|
||||
</AdminDB>
|
||||
<UserDB>
|
||||
<!-- 最大处于开启状态的连接数 -->
|
||||
<MaxOpenConns>0</MaxOpenConns>
|
||||
<!-- 最大处于空闲状态的连接数 -->
|
||||
<MaxIdleConns>0</MaxIdleConns>
|
||||
<!-- 数据库连接字符串 -->
|
||||
<ConnectionString><![CDATA[root:Qq5201530300@tcp(192.168.50.110:3306)/user?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true]]></ConnectionString>
|
||||
</UserDB>
|
||||
<RedisConfig>
|
||||
<!-- 数据库连接字符串 -->
|
||||
<ConnectionString>192.168.50.110:6379</ConnectionString>
|
||||
<!-- 密码,如果要设置用户Id,则密码设置为:"UserId:Password" -->
|
||||
<Password></Password>
|
||||
<!-- 数据库序号 -->
|
||||
<Database>5</Database>
|
||||
<!-- 最大活跃连接数 -->
|
||||
<MaxActive>500</MaxActive>
|
||||
<!-- 最大空闲的连接数 -->
|
||||
<MaxIdle>200</MaxIdle>
|
||||
<!-- 连接空闲超时时间,单位:秒 -->
|
||||
<IdleTimeout>300</IdleTimeout>
|
||||
<!-- 连接超时时间,单位:秒 -->
|
||||
<DialConnectTimeout>10</DialConnectTimeout>
|
||||
</RedisConfig>
|
||||
</DbConfig>
|
||||
</root>
|
||||
@ -1,38 +0,0 @@
|
||||
module admincenter
|
||||
|
||||
go 1.22.10
|
||||
|
||||
replace (
|
||||
common => ../common
|
||||
framework => ../framework
|
||||
goutil => ../goutil
|
||||
)
|
||||
|
||||
require (
|
||||
common v0.0.0-00010101000000-000000000000
|
||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/gomodule/redigo v1.8.9 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
)
|
||||
@ -1,25 +0,0 @@
|
||||
module goutil
|
||||
|
||||
go 1.22.2
|
||||
|
||||
require (
|
||||
github.com/bkaradzic/go-lz4 v1.0.0
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4
|
||||
github.com/fatih/color v1.15.0
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/gomodule/redigo v1.8.9
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.26.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
|
||||
)
|
||||
BIN
.svn/wc.db
BIN
.svn/wc.db
Binary file not shown.
@ -1,4 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@ -4,7 +4,18 @@
|
||||
<option name="autoReloadType" value="ALL" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="2037df1b-9ccc-4caa-9145-2d6722712612" name="更改" comment="" />
|
||||
<list default="true" id="2037df1b-9ccc-4caa-9145-2d6722712612" name="更改" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/admincenter/internal/admin/api.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/internal/admin/api.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/common/httpServer/apiHandler.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/httpServer/apiHandler.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/common/httpServer/reflect.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/httpServer/reflect.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/common/httpServer/serverMux.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/httpServer/serverMux.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/common/rabbitmq/config.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/rabbitmq/config.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/common/webServer/responseObject.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webServer/responseObject.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/dbcenter/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/dbcenter/main.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/paycenter/internal/pay/api.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/internal/pay/api.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/center/paycenter/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/main.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@ -23,47 +34,80 @@
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="file://$USER_HOME$/go/pkg/mod/github.com/wechatpay-apiv3/wechatpay-go@v0.2.20/services/payments/jsapi/api_jsapi_request_payment.go" root0="SKIP_INSPECTION" />
|
||||
<setting file="file://$USER_HOME$/go/pkg/mod/github.com/wechatpay-apiv3/wechatpay-go@v0.2.20/services/payments/native/models.go" root0="SKIP_INSPECTION" />
|
||||
<setting file="file://$USER_HOME$/go/pkg/mod/github.com/go-pay/gopay@v1.5.108/alipay/v3/constant.go" root0="SKIP_INSPECTION" />
|
||||
<setting file="file://$USER_HOME$/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.4.windows-amd64/src/log/log.go" root0="SKIP_INSPECTION" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 3
|
||||
}</component>
|
||||
<component name="ProjectId" id="2qn73uMaWLMYCjjMpyatMYepw4t" />
|
||||
<component name="ProjectLevelVcsManager">
|
||||
<ConfirmationsSetting value="1" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"DefaultGoTemplateProperty": "Go File",
|
||||
"Docker.admincenter.redis: Compose 部署.executor": "Run",
|
||||
"Docker.center/admincenter/Dockerfile builder.executor": "Run",
|
||||
"Go 构建.go build admincenter.executor": "Debug",
|
||||
"Go 构建.go build logincenter.executor": "Debug",
|
||||
"Go 构建.go build usercenter.executor": "Debug",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
||||
"RunOnceActivity.go.migrated.go.modules.settings": "true",
|
||||
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"go.import.settings.migrated": "true",
|
||||
"go.sdk.automatically.set": "true",
|
||||
"last_opened_file_path": "D:/workspace/e2023/goProject/trunk",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"DefaultGoTemplateProperty": "Go File",
|
||||
"Docker.admincenter.redis: Compose 部署.executor": "Run",
|
||||
"Docker.admincenter/Dockerfile.executor": "Run",
|
||||
"Docker.center/admincenter/Dockerfile builder.executor": "Run",
|
||||
"Go 构建.go build admincenter.executor": "Run",
|
||||
"Go 构建.go build dbcenter.executor": "Run",
|
||||
"Go 构建.go build logincenter.executor": "Debug",
|
||||
"Go 构建.go build paycenter.executor": "Run",
|
||||
"Go 构建.go build usercenter.executor": "Run",
|
||||
"Go 测试.common/connection 中的 TestGetDBName.executor": "Run",
|
||||
"Go 测试.dbcenter 中的 Test000.executor": "Debug",
|
||||
"Go 测试.dbcenter 中的 Test001 (1).executor": "Debug",
|
||||
"Go 测试.dbcenter 中的 Test001.executor": "Run",
|
||||
"Go 测试.dbcenter 中的 Test002 (1).executor": "Run",
|
||||
"Go 测试.dbcenter 中的 Test002.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
||||
"RunOnceActivity.go.migrated.go.modules.settings": "true",
|
||||
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"go.import.settings.migrated": "true",
|
||||
"go.sdk.automatically.set": "true",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"last_opened_file_path": "D:/workspace/e2023/goProject/trunk",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"run.configurations.included.in.services": "true",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"DatabaseDriversLRU": [
|
||||
"mysql_aurora"
|
||||
]
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\logincenter\internal\game" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\logincenter" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\paycenter\internal\cert" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\usercenter\internal\wxuser2" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\dbcenter\internal" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\dbcenter" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\game\common" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\paycenter\internal\alipay" />
|
||||
<recent name="D:\workspace\e2023\goProject\trunk\center\paycenter\internal\wxpay" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Go 构建.go build usercenter">
|
||||
<component name="RunDashboard">
|
||||
<option name="configurationTypes">
|
||||
<set>
|
||||
<option value="GoApplicationRunConfiguration" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Go 构建.go build admincenter">
|
||||
<configuration name="go build admincenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||
<module name="trunk" />
|
||||
<working_directory value="$PROJECT_DIR$/center/admincenter" />
|
||||
@ -73,13 +117,31 @@
|
||||
<filePath value="$PROJECT_DIR$/center/admincenter/main.go" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="go build usercenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true">
|
||||
<configuration name="go build dbcenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||
<module name="trunk" />
|
||||
<working_directory value="$PROJECT_DIR$/center/dbcenter" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="dbcenter" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<filePath value="$PROJECT_DIR$/center/dbcenter/main.go" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="go build paycenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||
<module name="trunk" />
|
||||
<working_directory value="$PROJECT_DIR$/center/paycenter" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="paycenter" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<filePath value="$PROJECT_DIR$/center/paycenter/main.go" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="go build usercenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||
<module name="trunk" />
|
||||
<working_directory value="$PROJECT_DIR$/center/usercenter" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="logincenter" />
|
||||
<package value="usercenter" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<filePath value="$PROJECT_DIR$/center/logincenter/main.go" />
|
||||
<filePath value="$PROJECT_DIR$/center/usercenter/main.go" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration default="true" type="docker-deploy" factoryName="docker-compose.yml" temporary="true">
|
||||
@ -94,24 +156,9 @@
|
||||
</deployment>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="admincenter.redis: Compose 部署" type="docker-deploy" factoryName="docker-compose.yml" temporary="true" server-name="Docker">
|
||||
<deployment type="docker-compose.yml">
|
||||
<settings>
|
||||
<option name="services">
|
||||
<list>
|
||||
<option value="redis" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="sourceFilePath" value="center/admincenter/docker-compose.yml" />
|
||||
</settings>
|
||||
</deployment>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="center/admincenter/Dockerfile builder" type="docker-deploy" factoryName="dockerfile" temporary="true" server-name="Docker">
|
||||
<configuration name="admincenter/Dockerfile" type="docker-deploy" factoryName="dockerfile" temporary="true" server-name="Docker">
|
||||
<deployment type="dockerfile">
|
||||
<settings>
|
||||
<option name="imageTag" value="golang1.20_builder" />
|
||||
<option name="buildCliOptions" value="--target builder" />
|
||||
<option name="sourceFilePath" value="center/admincenter/Dockerfile" />
|
||||
</settings>
|
||||
</deployment>
|
||||
@ -119,18 +166,19 @@
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Go 构建.go build usercenter" />
|
||||
<item itemvalue="Go 构建.go build admincenter" />
|
||||
<item itemvalue="Docker.admincenter.redis: Compose 部署" />
|
||||
<item itemvalue="Docker.center/admincenter/Dockerfile builder" />
|
||||
<item itemvalue="Go 构建.go build paycenter" />
|
||||
<item itemvalue="Go 构建.go build usercenter" />
|
||||
<item itemvalue="Go 构建.go build dbcenter" />
|
||||
<item itemvalue="Docker.admincenter/Dockerfile" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-gosdk-5df93f7ad4aa-df9ad98b711f-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-242.22855.85" />
|
||||
<option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-GO-242.22855.85" />
|
||||
<option value="bundled-gosdk-d297c17c1fbd-85c80fddc9a6-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-243.23654.166" />
|
||||
<option value="bundled-js-predefined-d6986cc7102b-822845ee3bb5-JavaScript-GO-243.23654.166" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
@ -149,11 +197,6 @@
|
||||
<line>68</line>
|
||||
<option name="timeStamp" value="8" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/center/usercenter/internal/user/logic.go</url>
|
||||
<line>104</line>
|
||||
<option name="timeStamp" value="23" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
|
||||
BIN
trunk/center/admincenter/adminServer
Normal file
BIN
trunk/center/admincenter/adminServer
Normal file
Binary file not shown.
@ -9,8 +9,21 @@ root:
|
||||
# Elasticsearch 地址
|
||||
es_urls: "http://10.252.0.70:18099"
|
||||
|
||||
# RabbitMQ 配置
|
||||
rabbitmq_address: "amqp://admin:admin@192.168.50.85:5672/"
|
||||
|
||||
# mq队列名称
|
||||
mq_queue_name: "admin_center"
|
||||
|
||||
# 是否通过mq执行sql
|
||||
sql_use_mq: true
|
||||
|
||||
# 数据库配置
|
||||
db_config:
|
||||
|
||||
# 实时更新数据库数量{玩家库/用户库}
|
||||
db_num: [0]
|
||||
|
||||
admin_db:
|
||||
# 最大处于开启状态的连接数
|
||||
max_open_conns: 0
|
||||
|
||||
@ -5,7 +5,7 @@ services:
|
||||
container_name: mysql-admin
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: 123456
|
||||
MYSQL_DATABASE: admin,user
|
||||
MYSQL_DATABASE: admin,pay
|
||||
volumes:
|
||||
- /my/own/datadir:/var/lib/mysql
|
||||
ports:
|
||||
|
||||
@ -29,10 +29,11 @@ require (
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/streadway/amqp v1.1.0 // indirect
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
)
|
||||
|
||||
@ -53,6 +53,8 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
||||
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
@ -80,8 +82,9 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
|
||||
@ -7,6 +7,8 @@ import (
|
||||
func init() {
|
||||
//注册数据库
|
||||
connection.RegisterDBModel(&Admin{})
|
||||
connection.RegisterDBModel(&RecordAveragePlayTimes{})
|
||||
connection.RegisterDBModel(&RecordAverageWatchADNum{})
|
||||
}
|
||||
|
||||
type Admin struct {
|
||||
@ -29,6 +31,75 @@ type Admin struct {
|
||||
Describe string `gorm:"column:describe;comment:备注" json:"describe"`
|
||||
}
|
||||
|
||||
// 登录相关的记录
|
||||
type RecordLoginOfWxUser struct {
|
||||
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
||||
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
|
||||
RecordDate int64 `gorm:"column:recorddate;comment:记录日期" json:"recorddate"` //只记录当天0点的时间戳,方便查询某一日的数据
|
||||
LoginInTime int64 `gorm:"column:loginintime;comment:登录时间" json:"loginintime"`
|
||||
LoginOutTime int64 `gorm:"column:loginouttime;comment:登出时间" json:"loginouttime"`
|
||||
PlayTimes int64 `gorm:"column:playtimes;comment:游玩时长" json:"playtimes"`
|
||||
//用于统计当日的总上线人数 0=否,1=是
|
||||
IsFirstLogin int32 `gorm:"column:isfirstlogin;comment:是否首次登录" json:"isfirstlogin"`
|
||||
}
|
||||
|
||||
// 看广告相关记录
|
||||
// 记录日期便于按天统计
|
||||
type RecordWatchADOfWxUser struct {
|
||||
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||
RecordDate int64 `gorm:"column:recorddate;comment:记录日期" json:"recorddate"` //只记录当天0点的时间戳,方便查询某一日的数据
|
||||
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
||||
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
|
||||
WatchADNum int32 `gorm:"column:watchadnum;comment:看广告次数" json:"watchadnum"`
|
||||
}
|
||||
|
||||
// 历史平均看广告次数的记录
|
||||
// 再次查询的时候就不用计算了
|
||||
type RecordAverageWatchADNum struct {
|
||||
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||
RecordDate int64 `gorm:"column:recorddate;comment:记录日期" json:"recorddate"` //只记录当天0点的时间戳,方便查询某一日的数据
|
||||
SeverId int32 `gorm:"column:severid;comment:区服ID" json:"severid"`
|
||||
AverageWatchADNum float32 `gorm:"column:averageplaytimes;comment:平均看广告次数" json:"averageplaytimes"`
|
||||
PlayerNum int64 `gorm:"column:playernum;comment:当日看广告人数人数" json:"playernum"`
|
||||
}
|
||||
|
||||
// 历史平均在线时长的记录
|
||||
// 再次查询的时候就不用计算了
|
||||
type RecordAveragePlayTimes struct {
|
||||
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||
RecordDate int64 `gorm:"column:recorddate;comment:记录日期" json:"recorddate"` //只记录当天0点的时间戳,方便查询某一日的数据
|
||||
SeverId int32 `gorm:"column:severid;comment:区服ID" json:"severid"`
|
||||
AveragePlayTimes int64 `gorm:"column:averageplaytimes;comment:平均在线时长" json:"averageplaytimes"`
|
||||
PlayerNum int64 `gorm:"column:playernum;comment:当日上线人数" json:"playernum"`
|
||||
}
|
||||
|
||||
// 记录当前为止的开服数
|
||||
type WxUserSeverList struct {
|
||||
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
|
||||
}
|
||||
|
||||
func (Admin) TableName() string {
|
||||
return "admin"
|
||||
}
|
||||
|
||||
func (RecordAveragePlayTimes) TableName() string {
|
||||
return "recordaverageplaytimes"
|
||||
}
|
||||
|
||||
func (RecordAverageWatchADNum) TableName() string {
|
||||
return "recordaveragewatchadnum"
|
||||
}
|
||||
|
||||
func (WxUserSeverList) TableName() string {
|
||||
return "wxuserseverlist"
|
||||
}
|
||||
|
||||
func (RecordWatchADOfWxUser) TableName() string {
|
||||
return "recordwatchadofwxuser"
|
||||
}
|
||||
|
||||
func (RecordLoginOfWxUser) TableName() string {
|
||||
return "recordloginofwxuser"
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"common/mytime"
|
||||
"common/remark"
|
||||
"common/resultStatus"
|
||||
"common/webServer"
|
||||
@ -201,3 +202,214 @@ func (a *AdminApi) Login(account string, password string) (responseObj *webServe
|
||||
responseObj.SetData(resultMap)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取某一天玩家的平均在线时长
|
||||
func init() {
|
||||
moduleName := "AdminApi"
|
||||
methodName := "GetAveragePlaytimes"
|
||||
skipVerifyTokenPage := true
|
||||
methodDesc := "获取某一天玩家的平均在线时长"
|
||||
methodAuthor := "youjinlan"
|
||||
methodMendor := ""
|
||||
methodDate := "2025-01-21 16:00:00"
|
||||
methodInParam := []string{"int64 startTime, int64 endTime"}
|
||||
methodOutParam := `
|
||||
{
|
||||
"Code '类型:int'": "响应结果的状态值",
|
||||
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||
"Data '类型:interface{}'": "响应结果的数据"
|
||||
{
|
||||
"AveragePlaytimesForEachSever '类型:map[int32]map[int64]int64'": "各个服在该时间段内的各天平均在线时长",
|
||||
}
|
||||
}`
|
||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||
}
|
||||
|
||||
func (a *AdminApi) GetAveragePlaytimes(startTime, endTime int64) (responseObj *webServer.ResponseObject) {
|
||||
responseObj = webServer.GetInitResponseObj()
|
||||
//验证参数
|
||||
nowTime := time.Now().Unix()
|
||||
nowZero := mytime.ZeroTime(nowTime, 0)
|
||||
if startTime == 0 || endTime == 0 {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
if startTime > nowTime {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
startZero := mytime.ZeroTime(startTime, 0)
|
||||
endZero := mytime.ZeroTime(endTime, 0)
|
||||
if endZero > nowZero {
|
||||
endZero = nowZero
|
||||
}
|
||||
//GetAveragePlaytimes()
|
||||
totalMap := make(map[int32]map[int64]int64)
|
||||
userSeverList, _ := GetUserSeverList()
|
||||
date := startZero
|
||||
for _, severlist := range userSeverList {
|
||||
dateMap := make(map[int64]int64)
|
||||
for {
|
||||
var averagePlaytimes int64
|
||||
if date != mytime.ZeroTime(nowTime, 0) {
|
||||
averagePlaytimes, _, _ = GetRecordAveragePlayTimes(date, severlist.SeverId)
|
||||
if averagePlaytimes == 0 {
|
||||
playtimes := GetUserTotalPlayTimes(date, severlist.SeverId)
|
||||
count := GetUserTotalPlayerNum(date, severlist.SeverId)
|
||||
if playtimes == 0 || count == 0 {
|
||||
averagePlaytimes = 0
|
||||
} else {
|
||||
averagePlaytimes = playtimes / count
|
||||
}
|
||||
//把今日之前的数据添加到数据库,因为数据不会再变化了,下次查询就不用计算了
|
||||
recordAveragePlayTimes := &RecordAveragePlayTimes{}
|
||||
recordAveragePlayTimes.AveragePlayTimes = averagePlaytimes
|
||||
recordAveragePlayTimes.PlayerNum = count
|
||||
recordAveragePlayTimes.SeverId = severlist.SeverId
|
||||
recordAveragePlayTimes.RecordDate = date
|
||||
AddRecordAveragePlayTimes(recordAveragePlayTimes)
|
||||
}
|
||||
} else {
|
||||
playtimes := GetUserTotalPlayTimes(date, severlist.SeverId)
|
||||
count := GetUserTotalPlayerNum(date, severlist.SeverId)
|
||||
if playtimes == 0 || count == 0 {
|
||||
averagePlaytimes = 0
|
||||
} else {
|
||||
averagePlaytimes = playtimes / count
|
||||
}
|
||||
}
|
||||
dateMap[date] = averagePlaytimes
|
||||
if date+86400 > endZero {
|
||||
date = startZero
|
||||
break
|
||||
}
|
||||
date = date + 86400
|
||||
}
|
||||
totalMap[severlist.SeverId] = dateMap
|
||||
}
|
||||
resultMap := make(map[string]any)
|
||||
resultMap["AveragePlaytimesForEachSever"] = totalMap
|
||||
responseObj.SetData(resultMap)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取某一天玩家的平均看广告次数
|
||||
func init() {
|
||||
moduleName := "AdminApi"
|
||||
methodName := "GetAverageWatchADNum"
|
||||
skipVerifyTokenPage := true
|
||||
methodDesc := "获取某一天玩家的平均看广告次数"
|
||||
methodAuthor := "youjinlan"
|
||||
methodMendor := ""
|
||||
methodDate := "2025-01-24 15:00:00"
|
||||
methodInParam := []string{"int64 startTime, int64 endTime"}
|
||||
methodOutParam := `
|
||||
{
|
||||
"Code '类型:int'": "响应结果的状态值",
|
||||
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||
"Data '类型:interface{}'": "响应结果的数据"
|
||||
{
|
||||
"AverageWatchADNumForEachSever '类型:map[int32]map[int64]int32'": "各个服在该时间段内的各天平均看广告次数",
|
||||
}
|
||||
}`
|
||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||
}
|
||||
|
||||
func (a *AdminApi) GetAverageWatchADNum(startTime, endTime int64) (responseObj *webServer.ResponseObject) {
|
||||
responseObj = webServer.GetInitResponseObj()
|
||||
//验证参数
|
||||
nowTime := time.Now().Unix()
|
||||
nowZero := mytime.ZeroTime(nowTime, 0)
|
||||
if startTime == 0 || endTime == 0 {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
if startTime > nowTime {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
startZero := mytime.ZeroTime(startTime, 0)
|
||||
endZero := mytime.ZeroTime(endTime, 0)
|
||||
if endZero > nowZero {
|
||||
endZero = nowZero
|
||||
}
|
||||
//GetAveragePlaytimes()
|
||||
totalMap := make(map[int32]map[int64]float32)
|
||||
userSeverList, _ := GetUserSeverList()
|
||||
date := startZero
|
||||
for _, severlist := range userSeverList {
|
||||
dateMap := make(map[int64]float32)
|
||||
for {
|
||||
if date != mytime.ZeroTime(nowTime, 0) {
|
||||
avgWatchADNum, _, _ := GetRecordAverageWatchADNum(date, severlist.SeverId)
|
||||
if avgWatchADNum == 0 {
|
||||
avgWatchADNum = GetUserAvgWatchADNum(date, severlist.SeverId)
|
||||
count := GetUserWatchADPlayerNum(date, severlist.SeverId)
|
||||
//把今日之前的数据添加到数据库,因为数据不会再变化了,下次查询就不用计算了
|
||||
recordAverageWatchADNum := &RecordAverageWatchADNum{}
|
||||
recordAverageWatchADNum.AverageWatchADNum = avgWatchADNum
|
||||
recordAverageWatchADNum.PlayerNum = count
|
||||
recordAverageWatchADNum.SeverId = severlist.SeverId
|
||||
recordAverageWatchADNum.RecordDate = date
|
||||
AddRecordAverageWatchADNum(recordAverageWatchADNum)
|
||||
}
|
||||
} else {
|
||||
avgWatchADNum := GetUserAvgWatchADNum(date, severlist.SeverId)
|
||||
dateMap[date] = avgWatchADNum
|
||||
if date+86400 > endZero {
|
||||
date = startZero
|
||||
break
|
||||
}
|
||||
date = date + 86400
|
||||
}
|
||||
}
|
||||
totalMap[severlist.SeverId] = dateMap
|
||||
}
|
||||
resultMap := make(map[string]any)
|
||||
resultMap["AverageWatchADNumForEachSever"] = totalMap
|
||||
responseObj.SetData(resultMap)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取某个玩家的生命周期
|
||||
func init() {
|
||||
moduleName := "AdminApi"
|
||||
methodName := "GetPlayerLiveNum"
|
||||
skipVerifyTokenPage := true
|
||||
methodDesc := "获取某个玩家的生命周期"
|
||||
methodAuthor := "youjinlan"
|
||||
methodMendor := ""
|
||||
methodDate := "2025-01-24 17:00:00"
|
||||
methodInParam := []string{"int64 uid"}
|
||||
methodOutParam := `
|
||||
{
|
||||
"Code '类型:int'": "响应结果的状态值",
|
||||
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||
"Data '类型:interface{}'": "响应结果的数据"
|
||||
{
|
||||
"LiveNum '类型:int32'": "玩家的生命周期(玩了多少天)",
|
||||
}
|
||||
}`
|
||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||
}
|
||||
|
||||
func (a *AdminApi) GetPlayerLiveNum(uid int64) (responseObj *webServer.ResponseObject) {
|
||||
responseObj = webServer.GetInitResponseObj()
|
||||
if uid == 0 {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
var userRecord *RecordLoginOfWxUser
|
||||
if userRecord, _ = GetUserFirstRecord(uid); userRecord == nil {
|
||||
responseObj.SetResultStatus(resultStatus.PlayerNotExist)
|
||||
return
|
||||
}
|
||||
firstDate := userRecord.RecordDate
|
||||
userRecord, _ = GetUserLastRecord(uid)
|
||||
lastDate := userRecord.RecordDate
|
||||
resultMap := make(map[string]any)
|
||||
liveNum := mytime.DiffDays(lastDate, firstDate)
|
||||
resultMap["LiveNum"] = liveNum
|
||||
responseObj.SetData(resultMap)
|
||||
return
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ func AddAdmin(admin *Admin) (int64, error) {
|
||||
//处理一些验证
|
||||
|
||||
// 写入到数据库
|
||||
result := connection.GetAdminDB().Create(&admin) // 通过数据的指针来创建
|
||||
result := connection.Create(connection.GetAdminDB(), &admin, 0) // 通过数据的指针来创建
|
||||
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("添加管理员失败 错误信息:", result.Error.Error())
|
||||
@ -41,3 +41,103 @@ func Login(account string, password string) (*Admin, error) {
|
||||
}
|
||||
return &admin, nil
|
||||
}
|
||||
|
||||
// 查询玩家首次登录登出记录
|
||||
func GetUserFirstRecord(uid int64) (*RecordLoginOfWxUser, error) {
|
||||
var userRecord *RecordLoginOfWxUser
|
||||
result := connection.GetUserDB().Where("uid = ?", uid).First(&userRecord)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
return userRecord, nil
|
||||
}
|
||||
|
||||
// 查询玩家最新登录登出记录
|
||||
func GetUserLastRecord(uid int64) (*RecordLoginOfWxUser, error) {
|
||||
var userRecord *RecordLoginOfWxUser
|
||||
result := connection.GetUserDB().Where("uid = ?", uid).Last(&userRecord)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
return userRecord, nil
|
||||
}
|
||||
|
||||
// 计算某日某服的玩家在线总时长
|
||||
func GetUserTotalPlayTimes(date int64, severId int32) int64 {
|
||||
var totalPlayTime int64
|
||||
connection.GetUserDB().Table("recordloginofwxuser").Where("recorddate = ? AND severid = ?", date, severId).Select("SUM(playtimes)").Scan(&totalPlayTime)
|
||||
return totalPlayTime
|
||||
}
|
||||
|
||||
// 计算某日某服的玩家上线总人数
|
||||
func GetUserTotalPlayerNum(date int64, severId int32) int64 {
|
||||
var count int64
|
||||
connection.GetUserDB().Table("recordloginofwxuser").Where("recorddate = ? AND severid = ? AND isfirstlogin = ?", date, severId, 1).Count(&count)
|
||||
return count
|
||||
}
|
||||
|
||||
// 获取区服列表
|
||||
func GetUserSeverList() ([]*WxUserSeverList, error) {
|
||||
var userSeverList []*WxUserSeverList
|
||||
result := connection.GetUserDB().Find(&userSeverList)
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("查询用户区服列表失败 错误信息:%s", result.Error.Error())
|
||||
return nil, result.Error
|
||||
}
|
||||
return userSeverList, nil
|
||||
}
|
||||
|
||||
// 添加玩家的平均在线时长数据到数据库
|
||||
func AddRecordAveragePlayTimes(recordAveragePlayTimes *RecordAveragePlayTimes) (int64, error) {
|
||||
connection.CheckTableExists(connection.GetAdminDB(), &RecordAveragePlayTimes{})
|
||||
result := connection.GetAdminDB().Create(&recordAveragePlayTimes) // 通过数据的指针来创建
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("添加平均在线时长记录失败 错误信息:%s", result.Error)
|
||||
}
|
||||
return recordAveragePlayTimes.ID, nil
|
||||
}
|
||||
|
||||
// 获取某日某服的玩家平均在线时长记录和总上线人数
|
||||
func GetRecordAveragePlayTimes(date int64, severId int32) (int64, int64, error) {
|
||||
var recordAveragePlayTimes *RecordAveragePlayTimes
|
||||
result := connection.GetAdminDB().Where("recorddate = ? AND severid = ?", date, severId).First(&recordAveragePlayTimes)
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("查询平均在线时长记录失败 错误信息:%s", result.Error)
|
||||
return 0, 0, result.Error
|
||||
}
|
||||
return recordAveragePlayTimes.AveragePlayTimes, recordAveragePlayTimes.PlayerNum, nil
|
||||
}
|
||||
|
||||
// 计算某日某服的玩家平均看广告次数
|
||||
func GetUserAvgWatchADNum(date int64, severId int32) float32 {
|
||||
var avgWatchADNum float32
|
||||
connection.GetUserDB().Table("recordwatchadofwxuser").Where("recorddate = ? AND severid = ?", date, severId).Select("AVG(watchadnum)").Scan(&avgWatchADNum)
|
||||
return avgWatchADNum
|
||||
}
|
||||
|
||||
// 计算某日某服玩家的看广告总人数
|
||||
func GetUserWatchADPlayerNum(date int64, severId int32) int64 {
|
||||
var count int64
|
||||
connection.GetUserDB().Table("recordwatchadofwxuser").Where("recorddate = ? AND severid = ?", date, severId).Count(&count)
|
||||
return count
|
||||
}
|
||||
|
||||
// 添加玩家的平均看广告次数到数据库
|
||||
func AddRecordAverageWatchADNum(recordAverageWatchADNum *RecordAverageWatchADNum) (int64, error) {
|
||||
result := connection.GetAdminDB().Create(&recordAverageWatchADNum) // 通过数据的指针来创建
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("添加平均看广告次数记录失败 错误信息:%s", result.Error)
|
||||
}
|
||||
return recordAverageWatchADNum.ID, nil
|
||||
}
|
||||
|
||||
// 获取某日某服玩家的平均看广告次数和总人数
|
||||
func GetRecordAverageWatchADNum(date int64, severId int32) (float32, int64, error) {
|
||||
var recordAverageWatchADNum *RecordAverageWatchADNum
|
||||
result := connection.GetAdminDB().Where("recorddate = ? AND severid = ?", date, severId).First(&recordAverageWatchADNum)
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("查询平均看广告次数记录失败 错误信息:%s", result.Error)
|
||||
return 0, 0, result.Error
|
||||
}
|
||||
return recordAverageWatchADNum.AverageWatchADNum, recordAverageWatchADNum.PlayerNum, nil
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"sync"
|
||||
|
||||
_ "admincenter/internal/admin"
|
||||
_ "common/resultStatus"
|
||||
"common/webServer"
|
||||
)
|
||||
|
||||
|
||||
@ -36,6 +36,18 @@ var (
|
||||
EsUrls string
|
||||
|
||||
BaseDay int
|
||||
|
||||
// Rabbitmq 配置
|
||||
Rabbitmq string
|
||||
|
||||
// RabbitMQName mq队列名称
|
||||
RabbitMQName string
|
||||
|
||||
// SqlUseMQ 是否使用mq执行sql
|
||||
SqlUseMQ bool
|
||||
|
||||
//微信登录相关配置
|
||||
Wxconfig WxConfig
|
||||
)
|
||||
|
||||
// initBaseConfig
|
||||
@ -69,6 +81,16 @@ func initBaseConfig() {
|
||||
EsUrls = root.EsUrls
|
||||
|
||||
BaseDay = root.BaseDay
|
||||
|
||||
// rabbitmq配置
|
||||
Rabbitmq = root.RabbitMQAddress
|
||||
|
||||
RabbitMQName = root.RabbitMQName
|
||||
|
||||
SqlUseMQ = root.SqlUseMQ
|
||||
|
||||
Wxconfig = root.Wxconfig
|
||||
|
||||
}
|
||||
|
||||
// GetDebug
|
||||
@ -77,14 +99,18 @@ func initBaseConfig() {
|
||||
// return:
|
||||
// @bool:
|
||||
func GetDebug() bool {
|
||||
return ConfigYaml.Root.Debug
|
||||
return DEBUG
|
||||
}
|
||||
|
||||
// GetWebServerAddress 返回Web服务器的地址。
|
||||
// 该函数通过访问ConfigYaml中的配置信息,获取并返回Web服务器的地址。
|
||||
// 主要用于需要与Web服务器建立连接的场景。
|
||||
func GetWebServerAddress() string {
|
||||
return ConfigYaml.Root.WebServerAddress
|
||||
return WebServerAddress
|
||||
}
|
||||
|
||||
func GetWxconfig() WxConfig {
|
||||
return Wxconfig
|
||||
}
|
||||
|
||||
// GetEsUrls 返回配置文件中 Elasticsearch 的 URL 地址。
|
||||
@ -93,5 +119,17 @@ func GetWebServerAddress() string {
|
||||
// 并将其作为字符串返回。这提供了一种简单的方法来获取 Elasticsearch 数据库的连接信息,
|
||||
// 而无需直接访问配置文件。
|
||||
func GetEsUrls() string {
|
||||
return ConfigYaml.Root.EsUrls
|
||||
return EsUrls
|
||||
}
|
||||
|
||||
func GetRabbitMQAddress() string {
|
||||
return Rabbitmq
|
||||
}
|
||||
|
||||
func GetRabbitMQName() string {
|
||||
return RabbitMQName
|
||||
}
|
||||
|
||||
func GetSqlUseMQ() bool {
|
||||
return SqlUseMQ
|
||||
}
|
||||
@ -21,6 +21,9 @@ type Root struct {
|
||||
// logmgr 配置
|
||||
LogMgr LogMgr `yaml:"log_mgr"`
|
||||
|
||||
// 微信登录配置
|
||||
Wxconfig WxConfig `yaml:"wx_config"`
|
||||
|
||||
// Web 服务监听地址和端口
|
||||
WebServerAddress string `yaml:"web_server_address"`
|
||||
|
||||
@ -43,6 +46,15 @@ type Root struct {
|
||||
// ES 地址
|
||||
EsUrls string `yaml:"es_urls"`
|
||||
|
||||
// rabbitMQ 地址
|
||||
RabbitMQAddress string `yaml:"rabbitmq_address"`
|
||||
|
||||
// mq队列名称
|
||||
RabbitMQName string `yaml:"mq_queue_name"`
|
||||
|
||||
// 是否使用mq执行sql
|
||||
SqlUseMQ bool `yaml:"sql_use_mq"`
|
||||
|
||||
// 数据库配置
|
||||
DbConfig DBConfig `yaml:"db_config"`
|
||||
|
||||
@ -53,6 +65,14 @@ type Root struct {
|
||||
FunctionConfig FunctionConf `yaml:"function_config"`
|
||||
}
|
||||
|
||||
type WxConfig struct {
|
||||
|
||||
//微信移动应用appId
|
||||
AppId string `yaml:"appId"`
|
||||
//微信移动应用appSecret
|
||||
AppSecret string `yaml:"appSecret"`
|
||||
}
|
||||
|
||||
// ManagerCenterConf 是 ManagerCenter 的配置结构体
|
||||
type ManagerCenterConf struct {
|
||||
// ManagerCenter API 的 URL
|
||||
@ -80,12 +100,18 @@ type LogMgr struct {
|
||||
// DBConfig 包含数据库和 Redis 的配置
|
||||
type DBConfig struct {
|
||||
|
||||
// 实时更新数据库数量{玩家库/用户库}
|
||||
DBNum []int `yaml:"db_num"`
|
||||
|
||||
//管理员数据库配置
|
||||
AdminDB DatabaseConfig `yaml:"admin_db"`
|
||||
|
||||
// 用户数据库配置
|
||||
UserDB DatabaseConfig `yaml:"user_db"`
|
||||
|
||||
// 用户数据库配置
|
||||
PayDB DatabaseConfig `yaml:"pay_db"`
|
||||
|
||||
// 游戏模型数据库配置
|
||||
GameModel DatabaseConfig `yaml:"game_model"`
|
||||
|
||||
@ -12,12 +12,18 @@ import (
|
||||
// @description: mysql配置对象
|
||||
type DbConfig struct {
|
||||
|
||||
// 实时更新数据库数量{玩家库/用户库}
|
||||
dbNum []int
|
||||
|
||||
// 管理员数据库链接字符串
|
||||
adminConfig *mysqlUtil.DBConfig
|
||||
|
||||
// 用户数据库链接字符串
|
||||
userConfig *mysqlUtil.DBConfig
|
||||
|
||||
// 充值数据库链接字符串
|
||||
payConfig *mysqlUtil.DBConfig
|
||||
|
||||
// 游戏模型数据库链接字符串
|
||||
gameModelConfig *mysqlUtil.DBConfig
|
||||
|
||||
@ -62,6 +68,19 @@ func (config *DbConfig) GetUserConfig() *mysqlUtil.DBConfig {
|
||||
return config.userConfig
|
||||
}
|
||||
|
||||
// GetPayConfig
|
||||
// @description: 获取pay库配置
|
||||
// parameter:
|
||||
//
|
||||
// @receiver config:config
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*mysqlUtil.DBConfig:user库配置
|
||||
func (config *DbConfig) GetPayConfig() *mysqlUtil.DBConfig {
|
||||
return config.payConfig
|
||||
}
|
||||
|
||||
// GetGameModelConfig
|
||||
// @description: 获取model库配置
|
||||
// parameter:
|
||||
@ -128,13 +147,15 @@ func (config *DbConfig) GetRedisConfig() *redisUtil.RedisConfig {
|
||||
// return:
|
||||
//
|
||||
// @*DbConfig:
|
||||
func newMysqlConfig(_adminConfig *mysqlUtil.DBConfig, _userConfig *mysqlUtil.DBConfig, _gameModelConfig *mysqlUtil.DBConfig,
|
||||
func newMysqlConfig(_dbNum []int, _adminConfig *mysqlUtil.DBConfig, _userConfig *mysqlUtil.DBConfig, _payConfig *mysqlUtil.DBConfig, _gameModelConfig *mysqlUtil.DBConfig,
|
||||
_gameConfig *mysqlUtil.DBConfig,
|
||||
_playerConfig *mysqlUtil.DBConfig,
|
||||
_redisConfig *redisUtil.RedisConfig) *DbConfig {
|
||||
return &DbConfig{
|
||||
dbNum: _dbNum,
|
||||
adminConfig: _adminConfig,
|
||||
userConfig: _userConfig,
|
||||
payConfig: _payConfig,
|
||||
gameModelConfig: _gameModelConfig,
|
||||
gameConfig: _gameConfig,
|
||||
redisConfig: _redisConfig,
|
||||
@ -158,6 +179,7 @@ func initDbConfig() error {
|
||||
logUtilPlus.DebugLog("开始加载DbConfig")
|
||||
|
||||
redisConfig := ConfigYaml.Root.DbConfig.RedisConfig
|
||||
dbConfig := ConfigYaml.Root.DbConfig
|
||||
|
||||
//if redisConfig == nil {
|
||||
// logUtilPlus.DebugLog("redis配置为空")
|
||||
@ -165,12 +187,13 @@ func initDbConfig() error {
|
||||
//}
|
||||
|
||||
// 初始化mysql配置对象
|
||||
dbConfigObj = newMysqlConfig(
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.AdminDB.ConnectionString, ConfigYaml.Root.DbConfig.AdminDB.MaxOpenConns, ConfigYaml.Root.DbConfig.AdminDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.UserDB.ConnectionString, ConfigYaml.Root.DbConfig.UserDB.MaxOpenConns, ConfigYaml.Root.DbConfig.UserDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.GameModel.ConnectionString, ConfigYaml.Root.DbConfig.GameModel.MaxOpenConns, ConfigYaml.Root.DbConfig.GameModel.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.GameDB.ConnectionString, ConfigYaml.Root.DbConfig.GameDB.MaxOpenConns, ConfigYaml.Root.DbConfig.GameDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.PlayerDB.ConnectionString, ConfigYaml.Root.DbConfig.PlayerDB.MaxOpenConns, ConfigYaml.Root.DbConfig.PlayerDB.MaxIdleConns),
|
||||
dbConfigObj = newMysqlConfig(dbConfig.DBNum,
|
||||
mysqlUtil.NewDBConfig(dbConfig.AdminDB.ConnectionString, dbConfig.AdminDB.MaxOpenConns, dbConfig.AdminDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(dbConfig.UserDB.ConnectionString, dbConfig.UserDB.MaxOpenConns, dbConfig.UserDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(dbConfig.PayDB.ConnectionString, dbConfig.PayDB.MaxOpenConns, dbConfig.PayDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(dbConfig.GameModel.ConnectionString, dbConfig.GameModel.MaxOpenConns, dbConfig.GameModel.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(dbConfig.GameDB.ConnectionString, dbConfig.GameDB.MaxOpenConns, dbConfig.GameDB.MaxIdleConns),
|
||||
mysqlUtil.NewDBConfig(dbConfig.PlayerDB.ConnectionString, dbConfig.PlayerDB.MaxOpenConns, dbConfig.PlayerDB.MaxIdleConns),
|
||||
redisUtil.NewRedisConfig2(redisConfig.ConnectionString, redisConfig.Password, redisConfig.Database, redisConfig.MaxActive, redisConfig.MaxIdle, time.Duration(redisConfig.IdleTimeout)*time.Second, time.Duration(redisConfig.DialConnectTimeout)*time.Second))
|
||||
return nil
|
||||
}
|
||||
@ -186,3 +209,7 @@ func initDbConfig() error {
|
||||
func GetDbConfig() *DbConfig {
|
||||
return dbConfigObj
|
||||
}
|
||||
|
||||
func GetDBNum() []int {
|
||||
return dbConfigObj.dbNum
|
||||
}
|
||||
@ -4,11 +4,12 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"framework/sqlAsyncMgr"
|
||||
"goutil/logUtilPlus"
|
||||
"time"
|
||||
|
||||
goredis "github.com/go-redis/redis/v8"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"goutil/logUtilPlus"
|
||||
"time"
|
||||
|
||||
// _ "github.com/go-sql-driver/mysql"
|
||||
config "common/configsYaml"
|
||||
@ -19,6 +20,7 @@ import (
|
||||
var (
|
||||
adminDB *gorm.DB //管理员数据库对象
|
||||
userDB *gorm.DB //用户数据库对象
|
||||
payDB *gorm.DB //充值数据库对象
|
||||
gameModelDB *gorm.DB // 游戏模型数据库对象
|
||||
gameDB *gorm.DB // 游戏数据库
|
||||
gamePlayerDB *gorm.DB // 玩家库
|
||||
@ -53,6 +55,7 @@ func init() {
|
||||
//管理中心数据库配置
|
||||
adminDB = initMysql(config.GetDbConfig().GetAdminConfig())
|
||||
userDB = initMysql(config.GetDbConfig().GetUserConfig())
|
||||
payDB = initMysql(config.GetDbConfig().GetPayConfig())
|
||||
|
||||
// 初始化游戏模型数据库
|
||||
gameModelDBConfig := config.GetDbConfig().GetGameModelConfig()
|
||||
@ -90,12 +93,12 @@ func initMysql(dbConfig *mysqlUtil.DBConfig) *gorm.DB {
|
||||
if dbConfig == nil || dbConfig.ConnectionString == "" {
|
||||
return nil
|
||||
}
|
||||
logUtilPlus.WarnLog("开始连接mysql:%s", dbConfig.ConnectionString)
|
||||
dbObj, err := gorm.Open(mysql.Open(dbConfig.ConnectionString), &gorm.Config{})
|
||||
logUtilPlus.DebugLog("开始连接mysql:%s", dbConfig.ConnectionString)
|
||||
dbObj, err := gorm.Open(mysql.Open(dbConfig.ConnectionString), &gorm.Config{PrepareStmt: true})
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("初始化数据库:%s失败,错误信息为:%s", dbConfig.ConnectionString, err))
|
||||
}
|
||||
logUtilPlus.WarnLog("连接mysql:%s成功", dbConfig.ConnectionString)
|
||||
logUtilPlus.DebugLog("连接mysql:%s成功", dbConfig.ConnectionString)
|
||||
|
||||
return dbObj
|
||||
}
|
||||
@ -124,7 +127,7 @@ func initRedis(redisConfig *redisUtil.RedisConfig) *goredis.Client {
|
||||
panic(fmt.Errorf("ping->redis:%s失败,DB:%s,错误信息为:%s", redisConfig.ConnectionString, redisConfig.Database, err))
|
||||
}
|
||||
|
||||
logUtilPlus.WarnLog("ping->redis:%s成功,信息为:%s", redisConfig.ConnectionString, ping)
|
||||
logUtilPlus.DebugLog("ping->redis:%s成功,信息为:%s", redisConfig.ConnectionString, ping)
|
||||
return client
|
||||
}
|
||||
|
||||
@ -146,6 +149,15 @@ func GetUserDB() *gorm.DB {
|
||||
return userDB
|
||||
}
|
||||
|
||||
// GetPayDB
|
||||
// @description: 获取pay库db实例
|
||||
// parameter:
|
||||
// return:
|
||||
// @*gorm.DB:pay库db实例
|
||||
func GetPayDB() *gorm.DB {
|
||||
return payDB
|
||||
}
|
||||
|
||||
// GetGameDB
|
||||
// @description: 获取game库db实例
|
||||
// parameter:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package connection
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@ -29,3 +30,7 @@ func TestExecute(t *testing.T) {
|
||||
_ = result.Error // 返回 error
|
||||
_ = result.RowsAffected // 返回插入记录的条数
|
||||
}
|
||||
|
||||
func TestGetDBName(t *testing.T) {
|
||||
fmt.Print(time.Now().Format("200601"))
|
||||
}
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
package connection
|
||||
|
||||
import "gorm.io/gorm"
|
||||
import (
|
||||
config "common/configsYaml"
|
||||
"common/rabbitmq"
|
||||
"gorm.io/gorm"
|
||||
"goutil/logUtilPlus"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
// 存放实体结构
|
||||
@ -10,6 +17,14 @@ var (
|
||||
modelDB *gorm.DB
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
// 启动异步处理
|
||||
go ExecuteCreateChan()
|
||||
go ExecuteSaveChan()
|
||||
go ExecuteDeleteChan()
|
||||
}
|
||||
|
||||
// RegisterDBModel 注册数据库模型到全局变量dbModelMap中。
|
||||
// 这个函数接受一个interface{}类型的参数dbModel,表示数据库模型。
|
||||
// 函数的目的是将传入的数据库模型添加到全局变量dbModelMap中,
|
||||
@ -20,7 +35,7 @@ func RegisterDBModel(dbModel interface{}) {
|
||||
dbModelMap = append(dbModelMap, &dbModel)
|
||||
}
|
||||
|
||||
// 设置modelDB 类型
|
||||
// SetModelDB 设置modelDB 类型
|
||||
func SetModelDB(db *gorm.DB) {
|
||||
modelDB = db
|
||||
}
|
||||
@ -32,10 +47,219 @@ func BuildDB() {
|
||||
for _, dbModel := range dbModelMap {
|
||||
|
||||
// 检查数据库中是否存在与dbModel对应的表
|
||||
tableExists := modelDB.Migrator().HasTable(dbModel)
|
||||
if !tableExists {
|
||||
// 如果表不存在,则进行自动迁移
|
||||
modelDB.AutoMigrate(dbModel)
|
||||
CheckTableExists(modelDB, dbModel)
|
||||
}
|
||||
}
|
||||
|
||||
// CheckTableExists 检查表是否存在,不存在则添加
|
||||
func CheckTableExists(db *gorm.DB, value interface{}) bool {
|
||||
|
||||
// 检查数据库中是否存在与dbModel对应的表
|
||||
tableExists := db.Migrator().HasTable(value)
|
||||
if !tableExists {
|
||||
// 如果表不存在,则进行自动迁移
|
||||
err := db.AutoMigrate(value)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("CheckTableExists is err: %v", err.Error())
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// GetMonth 获取当前月份
|
||||
func GetMonth() int32 {
|
||||
month, err := strconv.Atoi(time.Now().Format("200601"))
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("GetMonth is err: %v", err.Error())
|
||||
return 0
|
||||
}
|
||||
return int32(month)
|
||||
}
|
||||
|
||||
// GetToMonthAdd 获取当前月份 加上指定个月
|
||||
func GetToMonthAdd(monthCount int32) int32 {
|
||||
month, err := strconv.Atoi(time.Now().AddDate(0, int(monthCount), 0).Format("200601"))
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("GetToMonthAdd is err: %v", err.Error())
|
||||
return 0
|
||||
}
|
||||
return int32(month)
|
||||
}
|
||||
|
||||
// Create 添加数据
|
||||
// @param db 数据库连接
|
||||
// @param value 值
|
||||
// @param dbIndex mq队列索引
|
||||
func Create(db *gorm.DB, value interface{}, dbIndex int32) *gorm.DB {
|
||||
|
||||
result := &gorm.DB{Error: nil}
|
||||
|
||||
//检查表是否存在
|
||||
CheckTableExists(db, value)
|
||||
|
||||
//转换sql mq远程执行
|
||||
if config.GetSqlUseMQ() {
|
||||
sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
|
||||
return tx.Model(value).Create(value)
|
||||
})
|
||||
|
||||
//推送数据到mq
|
||||
rabbitmq.SendMqData(dbIndex, sql)
|
||||
|
||||
//直接返回
|
||||
return result
|
||||
}
|
||||
|
||||
result = db.Create(value)
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("数据创建失败:", result.Error.Error())
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Save 保存数据
|
||||
func Save(db *gorm.DB, value interface{}, dbIndex int32) *gorm.DB {
|
||||
|
||||
result := &gorm.DB{Error: nil}
|
||||
|
||||
//转换sql mq远程执行
|
||||
if config.GetSqlUseMQ() {
|
||||
sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
|
||||
return tx.Model(value).Save(value)
|
||||
})
|
||||
|
||||
//推送数据到mq
|
||||
rabbitmq.SendMqData(dbIndex, sql)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
result = db.Save(value)
|
||||
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("数据保存失败:", result.Error.Error())
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// DBData 添加数据通道
|
||||
type DBData struct {
|
||||
DB *gorm.DB
|
||||
Value any
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
// 添加数据通道
|
||||
createChan = make(chan DBData)
|
||||
|
||||
// 保存数据通道
|
||||
saveChan = make(chan DBData)
|
||||
|
||||
// 删除数据通道
|
||||
deleteChan = make(chan DBData)
|
||||
)
|
||||
|
||||
// AsyncCreate 异步创建数据
|
||||
func AsyncCreate(db *gorm.DB, value interface{}) {
|
||||
|
||||
createChan <- DBData{
|
||||
DB: db,
|
||||
Value: value,
|
||||
}
|
||||
}
|
||||
|
||||
// ExecuteCreateChan 执行添加数据通道
|
||||
func ExecuteCreateChan() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logUtilPlus.ErrorLog("AsyncCreate is err: %v", err)
|
||||
|
||||
//停止程序
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
select {
|
||||
case createData := <-createChan:
|
||||
db := createData.DB
|
||||
value := createData.Value
|
||||
|
||||
//检查表是否存在
|
||||
CheckTableExists(db, value)
|
||||
result := db.Create(value)
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("AsyncCreate is err: %v", result.Error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AsyncSave 异步保存数据
|
||||
func AsyncSave(db *gorm.DB, value interface{}) {
|
||||
|
||||
saveChan <- DBData{
|
||||
DB: db,
|
||||
Value: value,
|
||||
}
|
||||
}
|
||||
|
||||
// ExecuteSaveChan 执行保存数据通道
|
||||
func ExecuteSaveChan() {
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logUtilPlus.ErrorLog("AsyncSave is err: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case saveData := <-saveChan:
|
||||
db := saveData.DB
|
||||
value := saveData.Value
|
||||
|
||||
result := db.Save(value)
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("AsyncSave is err : %v", result.Error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AsyncDelete 异步删除数据
|
||||
func AsyncDelete(db *gorm.DB, value interface{}) {
|
||||
|
||||
deleteChan <- DBData{
|
||||
DB: db,
|
||||
Value: value,
|
||||
}
|
||||
}
|
||||
|
||||
// ExecuteDeleteChan 执行删除数据通道
|
||||
func ExecuteDeleteChan() {
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logUtilPlus.ErrorLog("AsyncDelete is err: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case deleteData := <-deleteChan:
|
||||
db := deleteData.DB
|
||||
value := deleteData.Value
|
||||
|
||||
result := db.Delete(value)
|
||||
if result.Error != nil {
|
||||
logUtilPlus.ErrorLog("AsyncDelete is err : %v", result.Error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ replace (
|
||||
require (
|
||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/streadway/amqp v1.1.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
gorm.io/driver/mysql v1.5.7
|
||||
gorm.io/gorm v1.25.12
|
||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
||||
@ -24,6 +26,8 @@ require (
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/gomodule/redigo v1.8.9 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
|
||||
@ -1,109 +1,47 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Shopify/sarama v1.29.1/go.mod h1:mdtqvCSg8JOxk8PmpTNGyo6wzd4BMm4QXSfDnTXmgkE=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
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/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 h1:OoL469zqSNrTLSz5zeVF/I6VOO7fiw2bzSzQe4J557c=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4/go.mod h1:xe9a/L2aeOgFKKgrO3ibQTnMdpAeL0GC+5/HpGScSa4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
|
||||
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
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/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
|
||||
github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
|
||||
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
|
||||
github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc=
|
||||
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
|
||||
github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q=
|
||||
github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
|
||||
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.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
@ -111,115 +49,40 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
||||
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
||||
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/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.230/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vms v1.0.230/go.mod h1:zElyabRGi8DktckzhT3krsYChstFJdSrzDb7pwF2P58=
|
||||
github.com/xdg/scram v1.0.3/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
|
||||
github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd h1:GGJVjV8waZKRHrgwvtH66z9ZGVurTD1MT0n1Bb+q4aM=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 h1:/6y1LfuqNuQdHAm0jjtPtgRcxIxjVZgm5OTu8/QhZvk=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
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.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||
@ -227,5 +90,3 @@ gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkD
|
||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
||||
@ -3,11 +3,11 @@ package httpServer
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"goutil/logUtilPlus"
|
||||
"goutil/typeUtil"
|
||||
"goutil/zlibUtil"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"goutil/logUtilPlus"
|
||||
"goutil/typeUtil"
|
||||
"goutil/zlibUtil"
|
||||
)
|
||||
|
||||
// ApiContext
|
||||
@ -184,6 +184,7 @@ func NewApiContext(_request *http.Request, _responseWriter http.ResponseWriter,
|
||||
// 读取数据
|
||||
_, errMsg := context.readContent(isZlib)
|
||||
if errMsg != nil {
|
||||
|
||||
return nil, errMsg
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package httpServer
|
||||
|
||||
import (
|
||||
"common/webServer"
|
||||
"net/http"
|
||||
|
||||
"common/resultStatus"
|
||||
"common/webServer"
|
||||
)
|
||||
|
||||
// 处理函数
|
||||
@ -59,7 +59,7 @@ func (this *ApiHandler) FuncParamNames() []string {
|
||||
// @receiver this: this
|
||||
// @r:
|
||||
// return:
|
||||
// @resultStatus.ResultStatus: 状态码数据
|
||||
// @resultstatus.ResultStatus: 状态码数据
|
||||
func (this *ApiHandler) CheckParam(r *http.Request) resultStatus.ResultStatus {
|
||||
for _, name := range this.funcParamNames {
|
||||
if r.Form[name] == nil || len(r.Form[name]) == 0 {
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"goutil/logUtil"
|
||||
"goutil/logUtilPlus"
|
||||
|
||||
// "log"
|
||||
"net/http/pprof"
|
||||
|
||||
|
||||
26
trunk/center/common/mytime/timefuncs.go
Normal file
26
trunk/center/common/mytime/timefuncs.go
Normal file
@ -0,0 +1,26 @@
|
||||
package mytime
|
||||
|
||||
import (
|
||||
"goutil/logUtilPlus"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 计算两个时间戳之间间隔多少天
|
||||
func DiffDays(new, old int64) int64 {
|
||||
newZeroTime := ZeroTime(new, 0)
|
||||
oldZeroTime := ZeroTime(old, 0)
|
||||
logUtilPlus.ErrorLog("newZeroTime=%d,oldZeroTime=%d", newZeroTime, oldZeroTime)
|
||||
return newZeroTime/86400 - oldZeroTime/86400
|
||||
}
|
||||
|
||||
func ZeroTime(sec, nsec int64) int64 {
|
||||
dateStr := time.Unix(sec, nsec).Format("2006-01-02")
|
||||
t, _ := time.ParseInLocation("2006-01-02", dateStr, time.Local)
|
||||
return t.Unix()
|
||||
}
|
||||
|
||||
func IsSameDay(first, second int64) bool {
|
||||
firstZero := ZeroTime(first, 0)
|
||||
secondZero := ZeroTime(second, 0)
|
||||
return firstZero == secondZero
|
||||
}
|
||||
61
trunk/center/common/rabbitmq/config.go
Normal file
61
trunk/center/common/rabbitmq/config.go
Normal file
@ -0,0 +1,61 @@
|
||||
package rabbitmq
|
||||
|
||||
import (
|
||||
configYaml "common/configsYaml"
|
||||
"goutil/logUtil"
|
||||
"strconv"
|
||||
|
||||
"github.com/streadway/amqp"
|
||||
)
|
||||
|
||||
var RabbitMQConn *amqp.Connection
|
||||
var RabbitMQChannel *amqp.Channel
|
||||
|
||||
// 初始化rabbitMQ
|
||||
func init() {
|
||||
|
||||
rabbitMQAddress := configYaml.GetRabbitMQAddress()
|
||||
|
||||
//是否有mq配置
|
||||
if rabbitMQAddress == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// 连接到 RabbitMQ 服务器
|
||||
var err error
|
||||
RabbitMQConn, err = amqp.Dial(rabbitMQAddress)
|
||||
if err != nil {
|
||||
|
||||
//抛出一个异常
|
||||
logUtil.FatalLog("Failed to connect to RabbitMQ: %s,err:%s", rabbitMQAddress, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 打开一个通道
|
||||
RabbitMQChannel, err = RabbitMQConn.Channel()
|
||||
if err != nil {
|
||||
|
||||
//抛出一个异常
|
||||
logUtil.FatalLog("Failed to open a channel,err:%s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
//循环数据库数量
|
||||
for _, index := range configYaml.GetDBNum() {
|
||||
//队列名称
|
||||
queueName := configYaml.GetRabbitMQName() + ":" + strconv.Itoa(index)
|
||||
|
||||
// 声明一个队列
|
||||
_, err = RabbitMQChannel.QueueDeclare(
|
||||
queueName, // 队列名称
|
||||
true, // 是否持久化
|
||||
false, // 是否在使用后删除
|
||||
false, // 是否排他
|
||||
false, // 是否阻塞
|
||||
nil, // 其他参数
|
||||
)
|
||||
if err != nil {
|
||||
logUtil.FatalLog("Failed to declare a queue,queueName:%s,err:%s", queueName, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
55
trunk/center/common/rabbitmq/consume_data.go
Normal file
55
trunk/center/common/rabbitmq/consume_data.go
Normal file
@ -0,0 +1,55 @@
|
||||
package rabbitmq
|
||||
|
||||
import (
|
||||
configYaml "common/configsYaml"
|
||||
"goutil/logUtilPlus"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// ConsumeData 消费mq数据
|
||||
func ConsumeData(handler func(data string) error) {
|
||||
|
||||
// 确保通道启用了 Publisher Confirms
|
||||
if err := RabbitMQChannel.Confirm(false); err != nil {
|
||||
logUtilPlus.ErrorLog("channel could not be put into confirm mode: %w", err)
|
||||
}
|
||||
|
||||
//循环数据库数量
|
||||
for _, index := range configYaml.GetDBNum() {
|
||||
|
||||
rabbitMQName := configYaml.GetRabbitMQName() + ":" + strconv.Itoa(index)
|
||||
|
||||
// 注册一个消费者
|
||||
msgs, err := RabbitMQChannel.Consume(
|
||||
rabbitMQName, // 队列名称
|
||||
"", // 消费者名称
|
||||
false, // 是否自动确认
|
||||
false, // 是否排他
|
||||
false, // 是否本地
|
||||
false, // 是否阻塞
|
||||
nil, // 其他参数
|
||||
)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("Failed to register a consumer,err:%s", err.Error())
|
||||
}
|
||||
|
||||
// 启动一个 goroutine 来处理消息
|
||||
go func() {
|
||||
for d := range msgs {
|
||||
|
||||
// 消息处理
|
||||
if err = handler(string(d.Body)); err != nil {
|
||||
|
||||
// 消息处理失败,记录错误日志
|
||||
|
||||
logUtilPlus.ErrorLog("Failed to handle message, err:%s", err.Error())
|
||||
}
|
||||
|
||||
// 消息处理完成后手动确认
|
||||
if err := d.Ack(false); err != nil {
|
||||
logUtilPlus.ErrorLog("Failed to acknowledge message, err:%s", err.Error())
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
34
trunk/center/common/rabbitmq/send_data.go
Normal file
34
trunk/center/common/rabbitmq/send_data.go
Normal file
@ -0,0 +1,34 @@
|
||||
package rabbitmq
|
||||
|
||||
import (
|
||||
configYaml "common/configsYaml"
|
||||
"goutil/logUtilPlus"
|
||||
"strconv"
|
||||
|
||||
"github.com/streadway/amqp"
|
||||
)
|
||||
|
||||
// SendMqData 发送单挑mq消息
|
||||
func SendMqData(dbIndex int32, data string) {
|
||||
|
||||
rabbitMQName := configYaml.GetRabbitMQName() + ":" + strconv.Itoa(int(dbIndex))
|
||||
|
||||
// 确保通道启用了 Publisher Confirms
|
||||
if err := RabbitMQChannel.Confirm(false); err != nil {
|
||||
logUtilPlus.ErrorLog("channel could not be put into confirm mode: %w", err)
|
||||
}
|
||||
|
||||
// 发布消息到队列
|
||||
err := RabbitMQChannel.Publish(
|
||||
"", // 交换机名称
|
||||
rabbitMQName, // 路由键
|
||||
false, // 是否强制
|
||||
false, // 是否立即
|
||||
amqp.Publishing{
|
||||
ContentType: "text/plain",
|
||||
Body: []byte(data),
|
||||
})
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("Failed to publish a message,err:%s", err.Error())
|
||||
}
|
||||
}
|
||||
54
trunk/center/common/rebbitMQ/config.go
Normal file
54
trunk/center/common/rebbitMQ/config.go
Normal file
@ -0,0 +1,54 @@
|
||||
package rebbitMQ
|
||||
|
||||
import (
|
||||
configYaml "common/configsYaml"
|
||||
"github.com/streadway/amqp"
|
||||
"goutil/logUtil"
|
||||
)
|
||||
|
||||
var RabbitMQConn *amqp.Connection
|
||||
var RabbitMQChannel *amqp.Channel
|
||||
|
||||
// 初始化rabbitMQ
|
||||
func init() {
|
||||
|
||||
rabbitMQAddress := configYaml.GetRabbitMQAddress()
|
||||
|
||||
//是否有mq配置
|
||||
if rabbitMQAddress == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// 连接到 RabbitMQ 服务器
|
||||
var err error
|
||||
RabbitMQConn, err = amqp.Dial(rabbitMQAddress)
|
||||
if err != nil {
|
||||
|
||||
//抛出一个异常
|
||||
logUtil.FatalLog("Failed to connect to RabbitMQ: %s,err:%s", rabbitMQAddress, err.Error())
|
||||
}
|
||||
|
||||
// 打开一个通道
|
||||
RabbitMQChannel, err = RabbitMQConn.Channel()
|
||||
if err != nil {
|
||||
|
||||
//抛出一个异常
|
||||
logUtil.FatalLog("Failed to open a channel,err:%s", err.Error())
|
||||
}
|
||||
|
||||
//队列名称
|
||||
queueName := configYaml.GetRabbitMQName()
|
||||
|
||||
// 声明一个队列
|
||||
_, err = RabbitMQChannel.QueueDeclare(
|
||||
queueName, // 队列名称
|
||||
true, // 是否持久化
|
||||
false, // 是否在使用后删除
|
||||
false, // 是否排他
|
||||
false, // 是否阻塞
|
||||
nil, // 其他参数
|
||||
)
|
||||
if err != nil {
|
||||
logUtil.FatalLog("Failed to declare a queue,queueName:%s,err:%s", queueName, err.Error())
|
||||
}
|
||||
}
|
||||
25
trunk/center/common/rebbitMQ/sendData.go
Normal file
25
trunk/center/common/rebbitMQ/sendData.go
Normal file
@ -0,0 +1,25 @@
|
||||
package rebbitMQ
|
||||
|
||||
import (
|
||||
configYaml "common/configsYaml"
|
||||
"github.com/streadway/amqp"
|
||||
"goutil/logUtilPlus"
|
||||
)
|
||||
|
||||
// 发送单挑mq消息
|
||||
func sendMqData(data string) {
|
||||
|
||||
// 发布消息到队列
|
||||
err := RabbitMQChannel.Publish(
|
||||
"", // 交换机名称
|
||||
configYaml.GetRabbitMQName(), // 路由键
|
||||
false, // 是否强制
|
||||
false, // 是否立即
|
||||
amqp.Publishing{
|
||||
ContentType: "text/plain",
|
||||
Body: []byte(data),
|
||||
})
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("Failed to publish a message,err:%s", err.Error())
|
||||
}
|
||||
}
|
||||
@ -1,910 +0,0 @@
|
||||
package resultStatus
|
||||
|
||||
// 系统错误码
|
||||
var (
|
||||
// 成功
|
||||
Success = NewResultStatus(0, "Success")
|
||||
|
||||
// 数据库错误
|
||||
DBError = NewResultStatus(-2, "DBError")
|
||||
|
||||
// 方法未定义
|
||||
MethodNotDefined = NewResultStatus(-3, "MethodNotDefined")
|
||||
|
||||
// 参数无效
|
||||
ParamInValid = NewResultStatus(-4, "ParamInValid")
|
||||
|
||||
// 参数不匹配
|
||||
ParamNotMatch = NewResultStatus(-5, "ParamNotMatch")
|
||||
|
||||
// 功能未开启
|
||||
ModuleNotOpen = NewResultStatus(-6, "ModuleNotOpen")
|
||||
|
||||
// 只支持Post
|
||||
OnlySupportPOST = NewResultStatus(-7, "OnlySupportPOST")
|
||||
|
||||
// API未定义
|
||||
APINotDefined = NewResultStatus(-8, "APINotDefined")
|
||||
|
||||
// API数据错误
|
||||
APIDataError = NewResultStatus(-9, "APIDataError")
|
||||
|
||||
// API参数错误
|
||||
APIParamError = NewResultStatus(-10, "APIParamError")
|
||||
|
||||
// IP被禁用
|
||||
IPForbid = NewResultStatus(-11, "IPForbid")
|
||||
|
||||
// 没有有效的服务器
|
||||
NoAvailableServer = NewResultStatus(-12, "NoAvailableServer")
|
||||
|
||||
// 服务器组不存在
|
||||
ServerGroupNotExists = NewResultStatus(-13, "ServerGroupNotExists")
|
||||
|
||||
// 测试接口只能debug下调用
|
||||
DebugInterface = NewResultStatus(-14, "DebugInterface")
|
||||
|
||||
// 模块不存在
|
||||
ModuleNotExists = NewResultStatus(-15, "ModuleNotExists")
|
||||
|
||||
// 未能找到指定方法
|
||||
NotSpecificMethod = NewResultStatus(-16, "NotSpecificMethod")
|
||||
|
||||
// 非指定区域
|
||||
NotMatchRegion = NewResultStatus(-17, "NotMatchRegion")
|
||||
|
||||
// 发送空数据
|
||||
SendNullData = NewResultStatus(-18, "SendNullData")
|
||||
|
||||
// 序列化失败
|
||||
MarshalDataError = NewResultStatus(-19, "MarshalDataError")
|
||||
|
||||
//未登录
|
||||
NotLogin = NewResultStatus(-20, "NotLogin")
|
||||
|
||||
// 数据错误
|
||||
DataError = NewResultStatus(-31, "DataError")
|
||||
|
||||
// 战区合并维护中,敬请期待
|
||||
MergeDataRunning = NewResultStatus(-67, "MergeDataRunning")
|
||||
|
||||
// 下载器内容未配置
|
||||
QcDownloadConfigNotExists = NewResultStatus(-68, "QcDownloadConfigNotExists")
|
||||
|
||||
// 下载器奖励已领取
|
||||
QcDownloadHasReward = NewResultStatus(-69, "QcDownloadHasReward")
|
||||
|
||||
// 下载器奖励没有奖励可领取
|
||||
QcDownloadNotReward = NewResultStatus(-70, "QcDownloadNotReward")
|
||||
|
||||
// 下载器奖励积分不足
|
||||
QcDownloadNotScore = NewResultStatus(-71, "QcDownloadNotScore")
|
||||
)
|
||||
|
||||
// 玩家
|
||||
var (
|
||||
|
||||
// 玩家不存在
|
||||
PlayerNotExist = NewResultStatus(-1110, "PlayerNotExist")
|
||||
|
||||
// 没有合适的玩家
|
||||
NotSuitablePlayer = NewResultStatus(-1155, "NotSuitablePlayer")
|
||||
|
||||
// 玩家阵容不存在
|
||||
PlayerSlotFormationNotExist = NewResultStatus(-1156, "PlayerSlotFormationNotExist")
|
||||
)
|
||||
|
||||
// 仙盟和GS保持同步
|
||||
var (
|
||||
// 玩家不在仙盟中
|
||||
GuildNotIn = NewResultStatus(-9401, "玩家不在仙盟中")
|
||||
|
||||
// 仙盟不存在
|
||||
GuildNotExist = NewResultStatus(-9402, "仙盟不存在")
|
||||
|
||||
// 玩家已在仙盟中
|
||||
GuildHasIn = NewResultStatus(-9403, "玩家已在仙盟中")
|
||||
|
||||
// 玩家操作目标和所在仙盟不一致
|
||||
TargetGuildNotMatch = NewResultStatus(-9404, "玩家操作目标和所在仙盟不一致")
|
||||
|
||||
// 仙盟不存在成员
|
||||
GuildMemberNotExist = NewResultStatus(-9405, "仙盟不存在成员")
|
||||
|
||||
// vip等级不足
|
||||
GuildNeedVip = NewResultStatus(-9406, "vip等级不足")
|
||||
|
||||
// 仙盟权限不足
|
||||
GuildNeedAuth = NewResultStatus(-9407, "仙盟权限不足")
|
||||
|
||||
// boss节点今日未开放
|
||||
GuildBossTodayNotOpen = NewResultStatus(-9411, "boss节点今日未开放")
|
||||
|
||||
// 职位人数已满
|
||||
GuildPostEnough = NewResultStatus(-9415, "职位人数已满")
|
||||
|
||||
// boss开启错误
|
||||
GuildBossOpenError = NewResultStatus(-9416, "boss开启错误")
|
||||
|
||||
// boss开启条件不足
|
||||
GuildBossOpenEnough = NewResultStatus(-9417, "boss开启条件不足")
|
||||
|
||||
// 仙盟名称已存在
|
||||
GuildNameHasExist = NewResultStatus(-9419, "仙盟名称已存在")
|
||||
|
||||
// 该职位人数达上限
|
||||
GuildPostLimit = NewResultStatus(-9420, "该职位人数达上限")
|
||||
|
||||
// 世界喊话CD中
|
||||
GuildShareCd = NewResultStatus(-9423, "世界喊话CD中")
|
||||
|
||||
// 弹劾条件不足
|
||||
GuildImpeachNotEnough = NewResultStatus(-9424, "弹劾条件不足")
|
||||
|
||||
// 不是成员或者长老
|
||||
GuildIsNotMember = NewResultStatus(-9428, "不是成员或者长老")
|
||||
|
||||
// boss已开启
|
||||
GuildBossHasOpen = NewResultStatus(-9429, "boss已开启")
|
||||
|
||||
// 盟主不允许退盟
|
||||
GuildLeaderNotAllowedExit = NewResultStatus(-9430, "盟主不允许退盟")
|
||||
|
||||
// 盟主公告锁定
|
||||
GuildNoticeIsLock = NewResultStatus(-9431, "盟主公告锁定")
|
||||
|
||||
// 仙盟次数不足
|
||||
GuildMiniGameNumNotAllow = NewResultStatus(-9439, "仙盟次数不足")
|
||||
|
||||
// 仙盟名称已被占用
|
||||
GuildNameIsNotValid = NewResultStatus(-9445, "仙盟名称已存在")
|
||||
|
||||
// 不是盟主
|
||||
GuildPlayerNotLeader = NewResultStatus(-9454, "不是盟主")
|
||||
|
||||
// 模式切换未到冷却时间
|
||||
GuildSwitchModeNotCool = NewResultStatus(-9455, "模式切换未到冷却时间")
|
||||
|
||||
// 该玩家职位变更还在冷却中
|
||||
GuildChangePostNotCool = NewResultStatus(-9460, "该玩家职位变更还在冷却中")
|
||||
|
||||
// 当前仙盟管理模式不可任命
|
||||
GuildModeCanNotAppoint = NewResultStatus(-9461, "当前仙盟管理模式不可任命")
|
||||
|
||||
// 当前仙盟管理模式不可挑战
|
||||
GuildModeCanNotFight = NewResultStatus(-9463, "当前仙盟管理模式不可挑战")
|
||||
|
||||
// 玩家等级不满足仙盟等级要求
|
||||
GuildPlayerLvLessThanNeedLv = NewResultStatus(-9465, "玩家等级不满足仙盟等级要求")
|
||||
|
||||
// 玩家未申请
|
||||
GuildPlayerNotApply = NewResultStatus(-9466, "玩家未申请")
|
||||
|
||||
// 仙盟信息未变更
|
||||
GuildInfoNotChange = NewResultStatus(-9483, "仙盟信息未变更")
|
||||
|
||||
// 战略编辑次数不足,明日再来
|
||||
GuildStrategyEditNum = NewResultStatus(-9486, "战略编辑次数不足,明日再来")
|
||||
|
||||
// 建筑不存在
|
||||
GuildBuildNotExist = NewResultStatus(-9489, "建筑不存在")
|
||||
|
||||
// 礼包已采购
|
||||
GuildWelfarePurchased = NewResultStatus(-9490, "该礼包已采购")
|
||||
|
||||
// 礼包已采购
|
||||
GuildWelfareCaptailNotEnough = NewResultStatus(-9491, "采购礼包所需资金不足")
|
||||
|
||||
// 礼包已采购
|
||||
GuildWelfareLvNotEnough = NewResultStatus(-9492, "仙盟等级不足,无法采购")
|
||||
|
||||
// 建筑经验超过最大值
|
||||
GuildBuildExpOverMax = NewResultStatus(-9496, "建筑经验超过最大值")
|
||||
|
||||
// 未能设置该类型职位信息
|
||||
GuildSetPostTypeNot = NewResultStatus(-9497, "未能设置该类型职位信息")
|
||||
|
||||
// 仙盟成员已达上限
|
||||
GuildNumMax = NewResultStatus(-9499, "仙盟成员已达上限")
|
||||
|
||||
// 建筑尚未开启
|
||||
GuildBuildIsLock = NewResultStatus(-109013, "建筑尚未开启")
|
||||
|
||||
// 建筑配置未获取
|
||||
GuildBuildConfigNotExist = NewResultStatus(-109014, "未获取到建筑配置")
|
||||
|
||||
// 等级不匹配
|
||||
GuildWelfareLvNotMatch = NewResultStatus(-109015, "等级不匹配")
|
||||
|
||||
// 建筑等级已达到满级
|
||||
GuildBuildHasMaxLv = NewResultStatus(-109017, "建筑等级已达到满级")
|
||||
|
||||
// 采购礼包ID不存在
|
||||
GuildGiftIdNotExist = NewResultStatus(-109018, "采购礼包ID不存在")
|
||||
|
||||
// 盟主令次数不足
|
||||
GuildLeaderOrderCount = NewResultStatus(-109019, "盟主令次数不足")
|
||||
|
||||
// 仙盟每日可踢出人数已达上限
|
||||
GuildTodayKickOutCountIsMax = NewResultStatus(-109020, "仙盟每日可踢出人数已达上限")
|
||||
|
||||
// 已申请该仙盟,请耐心等待审核
|
||||
GuildHasApply = NewResultStatus(-109499, "已申请该仙盟,请耐心等待审核")
|
||||
)
|
||||
|
||||
// 仙盟试炼
|
||||
var (
|
||||
GuildTrainBoxRewardDrawed = NewResultStatus(-109001, "仙盟试炼宝箱已领取")
|
||||
|
||||
// 仙盟boss战报不存在
|
||||
GuildTimeBossReportNotExists = NewResultStatus(-109002, "仙盟boss战报不存在")
|
||||
|
||||
// 仙盟试炼节点不存在
|
||||
GuildTrainNodeNotExists = NewResultStatus(-109003, "仙盟试炼节点不存在")
|
||||
|
||||
// 仙盟试炼奖励槽位不存在
|
||||
GuildTrainBoxSlotNotExists = NewResultStatus(-109004, "仙盟试炼奖励槽位不存在")
|
||||
|
||||
// 仙盟试炼目标位置奖励信息已变化
|
||||
GuildTrainBoxSlotHasRefresh = NewResultStatus(-109005, "仙盟试炼目标位置奖励信息已变化")
|
||||
|
||||
// 仙盟限时boss开启积分不足
|
||||
GuildTimedOpenNotEnougth = NewResultStatus(-109006, "仙盟限时boss开启积分不足")
|
||||
|
||||
// 仙盟限时boss开启积分不足
|
||||
GuildTrainNotKill = NewResultStatus(-109007, "BOSS未镇压,无法领奖")
|
||||
|
||||
// 试炼章节暂未开启
|
||||
GuildTrainNodeNotOpen = NewResultStatus(-109010, "试炼章节暂未开启")
|
||||
|
||||
// 试炼已经镇压
|
||||
GuildTrainIsKilled = NewResultStatus(-109011, "BOSS已镇压,不可挑战")
|
||||
)
|
||||
|
||||
// 仙盟红包
|
||||
var (
|
||||
// 仙盟红包不存在
|
||||
GuildRedPacketNotExist = NewResultStatus(-9950, "仙盟红包不存在")
|
||||
|
||||
// 仙盟玩家红包不存在
|
||||
GuildPlayerRedPacketNotExist = NewResultStatus(-9959, "仙盟玩家红包不存在")
|
||||
|
||||
// 仙盟红包已过期
|
||||
GuildRedPacketIsExpire = NewResultStatus(-9953, "仙盟红包已过期")
|
||||
|
||||
// 仙盟红包没有奖励可以领取
|
||||
GuildRedPacketNotReward = NewResultStatus(-9960, "仙盟红包没有奖励可以领取")
|
||||
|
||||
// 仙盟红包奖励已领取
|
||||
GuildRedPacketHasRewarded = NewResultStatus(-9954, "仙盟红包奖励已领取")
|
||||
)
|
||||
|
||||
// 组队副本
|
||||
var (
|
||||
// 房间不存在
|
||||
TeamCopyRoomNotExists = NewResultStatus(-9612, "TeamCopyRoomNotExists")
|
||||
|
||||
// 成员不存在
|
||||
TeamCopyMemberNotExists = NewResultStatus(-9613, "TeamCopyMemberNotExists")
|
||||
|
||||
// 不是房主
|
||||
TeamCopyNotIsLeader = NewResultStatus(-9614, "TeamCopyNotIsLeader")
|
||||
|
||||
// 战斗失败
|
||||
TeamCopyFigthFail = NewResultStatus(-9615, "TeamCopyFigthFail")
|
||||
|
||||
// 房间玩家未准备
|
||||
TeamCopyNotAllReady = NewResultStatus(-9616, "TeamCopyNotAllReady")
|
||||
|
||||
// 玩家人数不足
|
||||
TeamCopyNotEnough = NewResultStatus(-9617, "TeamCopyNotEnough")
|
||||
|
||||
// 玩家战力不足
|
||||
TeamCopyFapNotEnough = NewResultStatus(-9618, "TeamCopyFapNotEnough")
|
||||
|
||||
// 仍有奖励未领取
|
||||
TeamCopyHasReward = NewResultStatus(-9619, "TeamCopyHasReward")
|
||||
|
||||
// 未被邀请
|
||||
TeamCopyNotShare = NewResultStatus(-9620, "TeamCopyNotShare")
|
||||
|
||||
// 目标节点尚未开启
|
||||
TeamCopyNodeNotOpen = NewResultStatus(-9622, "TeamCopyNodeNotOpen")
|
||||
|
||||
// 人数已满
|
||||
TeamCopyIsMax = NewResultStatus(-9624, "TeamCopyIsMax")
|
||||
|
||||
// 没有权限进入房间
|
||||
TeamCopyNotAuth = NewResultStatus(-9625, "TeamCopyNotAuth")
|
||||
|
||||
// 组队战斗已开始
|
||||
TeamCopyIsFighting = NewResultStatus(-9626, "TeamCopyIsFighting")
|
||||
|
||||
// 邀请已存在
|
||||
TeamCopyIsExistShare = NewResultStatus(-9627, "TeamCopyIsExistShare")
|
||||
|
||||
// 队伍不能为全部助战状态
|
||||
TeamCopyIsAllHelp = NewResultStatus(-9633, "TeamCopyIsAllHelp")
|
||||
|
||||
// 您已被踢出
|
||||
TeamCopyKickOut = NewResultStatus(-9638, "TeamCopyKickOut")
|
||||
|
||||
// 房间已经解散
|
||||
TeamCopyRoomRemove = NewResultStatus(-9639, "房间已经解散")
|
||||
|
||||
// 玩家不在房间中
|
||||
TeamCopyRoomMemberNotIn = NewResultStatus(-9644, "玩家不在房间中")
|
||||
|
||||
// 玩家战力不足
|
||||
TeamCopyPlayerFapLimit = NewResultStatus(-9647, "玩家战力不足")
|
||||
|
||||
// 布阵阵容错误
|
||||
TeamCopyFormationError = NewResultStatus(-212603, "布阵阵容错误")
|
||||
|
||||
// 单人模式不允许加入
|
||||
TeamCopySingleNotJoin = NewResultStatus(-212604, "单人模式不允许加入")
|
||||
|
||||
// 队员未准备
|
||||
PlayerNotReady = NewResultStatus(-212605, "队员未准备")
|
||||
)
|
||||
|
||||
// 矿战
|
||||
var (
|
||||
// 矿战玩家信息不存在
|
||||
KuangzhanPlayerNotExist = NewResultStatus(-36131, "KuangzhanPlayerNotExist")
|
||||
|
||||
// 占领节点错误
|
||||
KuangzhanOccupyNode = NewResultStatus(-36113, "KuangzhanOccupyNode")
|
||||
|
||||
// 矿战节点不存在
|
||||
NodeConfigNotExist = NewResultStatus(-36132, "NodeConfigNotExist")
|
||||
|
||||
// 此洞府正在被攻击
|
||||
TheOtherPlayerFighting = NewResultStatus(-36114, "TheOtherPlayerFighting")
|
||||
|
||||
// 该节点已经被占领
|
||||
KuangzhanoverOccupyNode = NewResultStatus(-36113, "KuangzhanoverOccupyNode")
|
||||
|
||||
// 占领节点玩家无阵容
|
||||
KuangzhanPlayerNoFormation = NewResultStatus(-36133, "KuangzhanPlayerNoFormation")
|
||||
|
||||
// 获取阵容失败
|
||||
KuangzhanPlayerGetFormationFail = NewResultStatus(-36134, "KuangzhanPlayerGetFormationFail")
|
||||
|
||||
// 已占领洞府节点
|
||||
KuangzhanOverLoad = NewResultStatus(-36115, "KuangzhanOverLoad")
|
||||
|
||||
// 今日抢夺次数已经用完
|
||||
KuangzhanDailyLootOver = NewResultStatus(-36117, "KuangzhanDailyLootOver")
|
||||
|
||||
// 此洞府今日已无法被抢夺
|
||||
KuangzhanDailyRobbedOver = NewResultStatus(-36118, "KuangzhanDailyRobbedOver")
|
||||
|
||||
// 洞天抢夺暂未开启
|
||||
KuangzhanRobbedTimeNotOpen = NewResultStatus(-36119, "KuangzhanRobbedTimeNotOpen")
|
||||
|
||||
// 剩余洞天宝石不可抢夺
|
||||
KuangzhanGemIsOver = NewResultStatus(-36120, "KuangzhanGemIsOver")
|
||||
|
||||
// 玩家不匹配
|
||||
KuangzhanPlayerNotMatching = NewResultStatus(-36122, "KuangzhanPlayerNotMatching")
|
||||
|
||||
// 不是被邀请的玩家
|
||||
KuangzhanInviteFailed = NewResultStatus(-36123, "邀请好友失败")
|
||||
|
||||
// 不是被邀请的玩家
|
||||
KuangzhanNotInvited = NewResultStatus(-36124, "不是被邀请的玩家")
|
||||
|
||||
// 协助信息已失效
|
||||
KuangzhanInviteExpired = NewResultStatus(-36125, "协助信息已失效")
|
||||
|
||||
// 已经帮助过该玩家
|
||||
KuangzhanAlreadyHelped = NewResultStatus(-36135, "已经帮助过该玩家")
|
||||
|
||||
// 对方任务已经完成
|
||||
KuangzhanTaskFinished = NewResultStatus(-36136, "对方任务已经完成")
|
||||
)
|
||||
|
||||
// 蜀山论剑
|
||||
var (
|
||||
// 战斗校验出现异常
|
||||
FightException = NewResultStatus(-1354, "FightException")
|
||||
|
||||
// 比武大会玩家信息不存在
|
||||
HegeMonyPlayerInfoNotExist = NewResultStatus(-9701, "HegeMonyPlayerInfoNotExist")
|
||||
|
||||
// 比武大会玩家已有匹配
|
||||
HegeMonyHasMatch = NewResultStatus(-9702, "HegeMonyHasMatch")
|
||||
|
||||
// 比武大会玩家未找到匹配
|
||||
HegeMonyNotMatch = NewResultStatus(-9703, "HegeMonyNotMatch")
|
||||
|
||||
// 比武大会玩家未找到阵容
|
||||
HegeMonyFormationNotExist = NewResultStatus(-9704, "HegeMonyFormationNotExist")
|
||||
|
||||
// 比武大会对手玩家信息不存在
|
||||
HegeMonyTargetPlayerInfoNotExist = NewResultStatus(-9705, "HegeMonyTargetPlayerInfoNotExist")
|
||||
|
||||
// 比武大会玩家未匹配
|
||||
HegeMonyPlayerNotMatch = NewResultStatus(-9706, "HegeMonyPlayerNotMatch")
|
||||
|
||||
// 比武大会赛季不匹配
|
||||
SeasonNotMatch = NewResultStatus(-9707, "SeasonNotMatch")
|
||||
|
||||
// 比武大会战报信息不存在
|
||||
HegeMonyReportNotExist = NewResultStatus(-9730, "HegeMonyReportNotExist")
|
||||
|
||||
// 比武大会战斗未能找到匹配对手
|
||||
HegeMonyFightNotMatch = NewResultStatus(-9731, "HegeMonyFightNotMatch")
|
||||
|
||||
// 比武大会荣耀玩家不存在
|
||||
HegeMonyHonorPlayerNotExist = NewResultStatus(-9732, "HegeMonyHonorPlayerNotExist")
|
||||
)
|
||||
|
||||
// 战报
|
||||
var (
|
||||
// 战报信息不存在
|
||||
FightReportNotExist = NewResultStatus(-9707, "FightReportNotExist")
|
||||
|
||||
// 数据解析错误
|
||||
JsonDecodeDataError = NewResultStatus(-9708, "JsonDecodeDataError")
|
||||
)
|
||||
|
||||
// 喜信
|
||||
var (
|
||||
// 信息Id错误
|
||||
HappyNewsIdError = NewResultStatus(-40103, "HappyNewsIdError")
|
||||
|
||||
// 信息序号错误
|
||||
HappyNewsOrderIdError = NewResultStatus(-40104, "HappyNewsOrderIdError")
|
||||
|
||||
// 喜信获取好友失败
|
||||
HappyNewsGetFriendsError = NewResultStatus(-40105, "HappyNewsGetFriendsError")
|
||||
|
||||
// 没有好友
|
||||
NoFriend = NewResultStatus(-8565, "NoFriend")
|
||||
)
|
||||
|
||||
// 仙盟远征
|
||||
var (
|
||||
// 仙盟远征错误
|
||||
GuildExpeditionError = NewResultStatus(-29900, "GuildExpeditionError")
|
||||
|
||||
// 仙盟远征活动未开启
|
||||
GuildExpeditionActivityNotOpen = NewResultStatus(-29906, "GuildExpeditionActivityNotOpen")
|
||||
|
||||
// 仙盟远征公会未匹配
|
||||
GuildExpeditionGuildNotMatch = NewResultStatus(-29908, "GuildExpeditionGuildNotMatch")
|
||||
|
||||
// 仙盟远征阵容无法解析
|
||||
GuildExpeditionFormationUnknow = NewResultStatus(-29909, "GuildExpeditionFormationUnknow")
|
||||
|
||||
// 仙盟远征房间信息不存在
|
||||
GuildExpeditionRoomInfoError = NewResultStatus(-29912, "GuildExpeditionRoomInfoError")
|
||||
|
||||
// 仙盟远征阶段一挑战次数不足
|
||||
GuildExpeditionFirstStepTimesIsNotEnough = NewResultStatus(-29913, "GuildExpeditionfirstStepTimesIsNotEnough")
|
||||
|
||||
// 仙盟远征阶段一挑战次数不足
|
||||
GuildExpeditionSecondStepTimesIsNotEnough = NewResultStatus(-29914, "GuildExpeditionSecondStepTimesIsNotEnough")
|
||||
|
||||
// 仙盟远征房间已锁定
|
||||
GuildExpeditionRoomIsLock = NewResultStatus(-29915, "GuildExpeditionRoomIsLock")
|
||||
|
||||
// 不是参与远征的仙盟成员
|
||||
GuildExpeditionIsNotJoinMember = NewResultStatus(-29916, "GuildExpeditionIsNotJoinMember")
|
||||
|
||||
// 目标没有防御阵容
|
||||
GuildExpeditionTargetNoDefenceFormation = NewResultStatus(-29917, "GuildExpeditionTargetNoDefenceFormation")
|
||||
|
||||
// 仙盟远征战斗验证失败
|
||||
GuildExpeditionFightValidFail = NewResultStatus(-29918, "GuildExpeditionFightValidFail")
|
||||
)
|
||||
|
||||
// 义结金兰
|
||||
var (
|
||||
// 玩家未结交,标记g_yjjl对象
|
||||
YjjlPlayerNotExist = NewResultStatus(-33501, "YjjlPlayerNotExist")
|
||||
|
||||
// 玩家未结义,标记g_yjjl_player对象
|
||||
YjjlPlayerNotExistForPlayer = NewResultStatus(-33588, "YjjlPlayerNotExistForPlayer")
|
||||
|
||||
// 玩家未结义,标记玩家对象属于第三者
|
||||
YjjlPlayerNotMatch = NewResultStatus(-33589, "YjjlPlayerNotMatch")
|
||||
|
||||
// 玩家已结交
|
||||
YjjlPlayerHasExist = NewResultStatus(-33502, "YjjlPlayerHasExist")
|
||||
|
||||
// 玩家已设置本特效
|
||||
QingyiLvSpecialeffectsIsExists = NewResultStatus(-33515, "QingyiLvSpecialeffectsIsExists")
|
||||
|
||||
// 亲密付已达月上限
|
||||
HelpPayIsLimit = NewResultStatus(-33571, "HelpPayIsLimit")
|
||||
|
||||
// 玩家当前未培养花卉
|
||||
FlowerNotExist = NewResultStatus(-33523, "FlowerNotExist")
|
||||
|
||||
// 玩家当前花卉经验值已满
|
||||
FlowerExpIsMax = NewResultStatus(-33524, "FlowerExpIsMax")
|
||||
|
||||
// 玩家当前花卉经验值未满
|
||||
FlowerExpNotEnough = NewResultStatus(-33525, "FlowerExpNotEnough")
|
||||
|
||||
// 玩家已培养花卉
|
||||
FlowerIsExists = NewResultStatus(-33530, "FlowerIsExists")
|
||||
|
||||
// 培养的花卉不匹配
|
||||
FlowerNotMatch = NewResultStatus(-33531, "FlowerNotMatch")
|
||||
|
||||
// 花卉可收获,不能重置
|
||||
FlowerCanGet = NewResultStatus(-33532, "FlowerCanGet")
|
||||
|
||||
// 同心榜CP组唯一标识错误
|
||||
RankGroupIdError = NewResultStatus(-33541, "RankGroupIdError")
|
||||
|
||||
// 暂无留言
|
||||
RankTipNotExists = NewResultStatus(-33542, "RankTipNotExists")
|
||||
|
||||
// 结交好友匹配错误
|
||||
RankCpMatchError = NewResultStatus(-33544, "RankCpMatchError")
|
||||
|
||||
// 留言点赞和玩家结义数据不匹配
|
||||
RankCpMessageZanNotMatch = NewResultStatus(-33545, "RankCpMessageZanNotMatch")
|
||||
|
||||
// 该玩家今日已点赞!
|
||||
PlayerGood = NewResultStatus(-212301, "PlayerGood")
|
||||
|
||||
// 义结金兰没有任务数据
|
||||
YjjlTaskNoData = NewResultStatus(-33547, "YjjlTaskNoData")
|
||||
|
||||
// 金兰契奖励节点错误
|
||||
YjjlRewardNodeError = NewResultStatus(-33568, "YjjlRewardNodeError")
|
||||
|
||||
// 亲密等级不足
|
||||
IntimacyLvNotEnough = NewResultStatus(-33569, "IntimacyLvNotEnough")
|
||||
|
||||
// 活动期间获取的亲密度不足
|
||||
AddIntimacyNotEnough = NewResultStatus(-33583, "活动期间获取的亲密度不足")
|
||||
|
||||
// 亲密度奖励已经领取
|
||||
HasAddIntimacyReward = NewResultStatus(-33584, "亲密度奖励已经领取")
|
||||
|
||||
// 亲密等级不足,未解锁
|
||||
YjjlShowIsLock = NewResultStatus(-33586, "亲密等级不足,未解锁")
|
||||
|
||||
// 活动还没结束
|
||||
TimedActivityNotClose = NewResultStatus(-2006, "活动还没结束")
|
||||
)
|
||||
|
||||
// 蜀山之巅(跨服Pvp冠军赛)
|
||||
var (
|
||||
// 赛季未开启
|
||||
WeekChampionSeasonNotOpen = NewResultStatus(-4000, "WeekChampionSeasonNotOpen")
|
||||
|
||||
// 赛季分组数据不存在
|
||||
WeekChampionNoExistGroupMatch = NewResultStatus(-4007, "WeekChampionNoExistGroupMatch")
|
||||
|
||||
// 跨服蜀山之巅竞猜玩家错误
|
||||
WeekChampionBetPlayerError = NewResultStatus(-4008, "WeekChampionBetPlayerError")
|
||||
|
||||
// 战报信息不存在
|
||||
WeekChampionFightReportNotExist = NewResultStatus(-4009, "WeekChampionFightReportNotExist")
|
||||
|
||||
// 战报信息解析错误
|
||||
WeekChampionFightReportJsonDecodeDataError = NewResultStatus(-4010, "WeekChampionFightReportJsonDecodeDataError")
|
||||
)
|
||||
|
||||
var (
|
||||
// SocialSquareGiftNotExist 礼物不存在
|
||||
SocialSquareGiftNotExist = NewResultStatus(-40400, "SocialSquareGiftNotExist")
|
||||
|
||||
// SocialSquarePlayerNotExist 社交广场玩家不存在
|
||||
SocialSquarePlayerNotExist = NewResultStatus(-40401, "SocialSquarePlayerNotExist")
|
||||
|
||||
// SocialSquarePhotoNotExist 社交广场玩家不存在
|
||||
SocialSquarePhotoNotExist = NewResultStatus(-40402, "SocialSquarePhotoNotExist")
|
||||
)
|
||||
|
||||
var (
|
||||
// 模块错误
|
||||
VideoModuleError = NewResultStatus(-38183, "VideoModuleError")
|
||||
|
||||
// 未检测到该战报
|
||||
VideoIdError = NewResultStatus(-38184, "VideoIdError")
|
||||
)
|
||||
|
||||
var (
|
||||
// 金兰宴玩家对象不是举办方
|
||||
YjjlFeastIsNotHost = NewResultStatus(-44108, "YjjlFeastIsNotHost")
|
||||
|
||||
// 宴会还在准备中
|
||||
YjjlFeastIsPreraring = NewResultStatus(-44111, "YjjlFeastIsPreraring")
|
||||
|
||||
// 金兰宴宴会已开始
|
||||
YjjlFeastRandomIsStart = NewResultStatus(-44112, "YjjlFeastRandomIsStart")
|
||||
|
||||
// 金兰宴房间类型错误
|
||||
YjjlFeastRoomTypeError = NewResultStatus(-44116, "YjjlFeastRoomTypeError")
|
||||
|
||||
// 金兰宴房间不存在
|
||||
YjjlFeastRoomNotExist = NewResultStatus(-44118, "YjjlFeastRoomNotExist")
|
||||
|
||||
// 金兰宴玩家不能加入该房间
|
||||
YjjlFeastPlayerCantEnterThisRoom = NewResultStatus(-44119, "YjjlFeastPlayerCantEnterThisRoom")
|
||||
|
||||
// 金兰宴玩家不能同时主办两场及以上的宴会
|
||||
YjjlFeastHostBuySamePlayer = NewResultStatus(-44120, "YjjlFeastHostBuySamePlayer")
|
||||
|
||||
// 金兰宴宾客人数达到上限
|
||||
YjjlFeastRoomGuestMax = NewResultStatus(-44121, "YjjlFeastRoomGuestMax")
|
||||
|
||||
// 金兰宴玩家不在房间
|
||||
YjjlFeastIsNotInScene = NewResultStatus(-44122, "YjjlFeastIsNotInScene")
|
||||
|
||||
// 金兰宴不是来宾
|
||||
YjjlFeastIsHost = NewResultStatus(-44123, "YjjlFeastIsHost")
|
||||
|
||||
// 金兰宴红包不存在
|
||||
YjjlFeastRedPacketNotExist = NewResultStatus(-44124, "YjjlFeastRedPacketNotExist")
|
||||
|
||||
// 金兰宴红包已领取或已领完
|
||||
YjjlFeastRedPacketHadDraw = NewResultStatus(-44125, "YjjlFeastRedPacketHadDraw")
|
||||
)
|
||||
|
||||
var (
|
||||
// 全服红包id错误
|
||||
RedPacketIdError = NewResultStatus(-40501, "RedPacketIdError")
|
||||
|
||||
// 全服红包已经领取完
|
||||
RedPacketHaveOver = NewResultStatus(-40502, "RedPacketHaveOver")
|
||||
|
||||
// 全服红包不可领取
|
||||
RedPacketCanNotDraw = NewResultStatus(-40503, "RedPacketCanNotDraw")
|
||||
|
||||
// 已经领取该红包
|
||||
RedPacketHaveDraw = NewResultStatus(-40504, "RedPacketHaveDraw")
|
||||
|
||||
// 红包领取失败
|
||||
RedPacketDrawError = NewResultStatus(-40505, "RedPacketDrawError")
|
||||
)
|
||||
|
||||
// 跨服昆仑神虚
|
||||
var (
|
||||
// 昆仑之墟尚未开启
|
||||
GlobalCitywarMapNotOpen = NewResultStatus(-45003, "昆仑之墟尚未开启")
|
||||
|
||||
// 仙盟未参与
|
||||
CitywarCsGuildNotParticipate = NewResultStatus(-50000, "CitywarCsGuildNotParticipate")
|
||||
|
||||
// 跨服昆仑神虚地图不存在
|
||||
CitywarCsMapNotExist = NewResultStatus(-50001, "CitywarCsMapNotExist")
|
||||
|
||||
// 跨服昆仑神虚城池不存在
|
||||
CitywarCsLandNotExist = NewResultStatus(-50002, "CitywarCsLandNotExist")
|
||||
|
||||
// 跨服昆仑神虚城池未占领
|
||||
CitywarCsLandNotOccupy = NewResultStatus(-50003, "CitywarCsLandNotOccupy")
|
||||
|
||||
// 跨服昆仑神虚城池正在战斗中
|
||||
CitywarCsLandIsFighting = NewResultStatus(-50004, "CitywarCsLandIsFighting")
|
||||
|
||||
// 昆仑之墟节点坐标不匹配
|
||||
CitywarCsAxisNotRight = NewResultStatus(-50011, "CitywarCsAxisNotRight")
|
||||
|
||||
// 昆仑之墟玩家队伍不存在
|
||||
CitywarCsPlayerTeamNotExist = NewResultStatus(-50012, "CitywarCsPlayerTeamNotExist")
|
||||
|
||||
// 昆仑之墟玩家队伍复活中
|
||||
CitywarCsPlayerTeamReviving = NewResultStatus(-50013, "CitywarCsPlayerTeamReviving")
|
||||
|
||||
// 昆仑之墟玩家已派遣
|
||||
CitywarCsPlayerTeamIsMoving = NewResultStatus(-50014, "CitywarCsPlayerTeamIsMoving")
|
||||
|
||||
// 昆仑之墟玩家未派遣
|
||||
CitywarCsPlayerTeamNoMoving = NewResultStatus(-50015, "CitywarCsPlayerTeamNoMoving")
|
||||
|
||||
// 昆仑之墟玩家玩家队伍已经死亡
|
||||
CitywarCsTeamIdDead = NewResultStatus(-50016, "CitywarCsTeamIdDead")
|
||||
|
||||
// 没有奖励可以领取
|
||||
CitywarCsNotDrawReward = NewResultStatus(-50017, "CitywarCsNotDrawReward")
|
||||
|
||||
// 昆仑之墟休战中
|
||||
CitywarCsNotFightTime = NewResultStatus(-50018, "CitywarCsNotFightTime")
|
||||
|
||||
// 昆仑之墟已经结束
|
||||
CitywarCsIsEnd = NewResultStatus(-50019, "CitywarCsIsEnd")
|
||||
|
||||
// 玩家昆仑之墟出征次数不足
|
||||
CitywarCsFightNumNotEnough = NewResultStatus(-50020, "CitywarCsFightNumNotEnough")
|
||||
|
||||
// 昆仑之墟出生地无法操作
|
||||
CitywarCsLandIsBirth = NewResultStatus(-50021, "CitywarCsLandIsBirth")
|
||||
|
||||
// 昆仑之墟队伍已放入仙盟大营中
|
||||
CitywarCsPlayerTeamInGuildTeam = NewResultStatus(-50022, "CitywarCsPlayerTeamInGuildTeam")
|
||||
|
||||
// 昆仑之墟队伍不在仙盟大营中
|
||||
CitywarCsPlayerTeamNotInGuildTeam = NewResultStatus(-50023, "CitywarCsPlayerTeamNotInGuildTeam")
|
||||
|
||||
// 昆仑神墟未选择仙盟大营中队伍
|
||||
CitywarCsGuildTeamNotExist = NewResultStatus(-50024, "CitywarCsGuildTeamNotExist")
|
||||
|
||||
// 昆仑神墟地块正在燃烧
|
||||
CitywarCsLandIsFire = NewResultStatus(-50025, "CitywarCsLandIsFire")
|
||||
|
||||
// 非相邻地不允许攻击
|
||||
CitywarCsLandNotAdjoinNotAtk = NewResultStatus(-50027, "CitywarCsLandNotAdjoinNotAtk")
|
||||
)
|
||||
|
||||
var (
|
||||
// 巅峰对决信息不存在
|
||||
PeakInfoNotExist = NewResultStatus(-40804, "PeakInfoNotExist")
|
||||
|
||||
// 该位置不是空位置
|
||||
PeakRankNotEmpty = NewResultStatus(-40805, "PeakRankNotEmpty")
|
||||
|
||||
// 不能挑战低于自己的对手
|
||||
PeakCantFight = NewResultStatus(-40806, "PeakCantFight")
|
||||
|
||||
// 排位已经变化
|
||||
PeakNeedRefresh = NewResultStatus(-40808, "PeakNeedRefresh")
|
||||
|
||||
// 当前排名不可挑战,挑战列表已刷新
|
||||
PeakNeedRefreshTwo = NewResultStatus(-40814, "PeakNeedRefreshTwo")
|
||||
|
||||
// 不可挑战前三
|
||||
PeakCantFightTopThree = NewResultStatus(-40815, "PeakCantFightTopThree")
|
||||
)
|
||||
|
||||
// 蜀山论剑PvpTournament
|
||||
var (
|
||||
// 玩家信息不存在
|
||||
PvpTournamentInfoNotExist = NewResultStatus(-40901, "PvpTournamentInfoNotExist")
|
||||
|
||||
// 玩家未找到阵容
|
||||
PvpTournamentFormationNotExist = NewResultStatus(-40902, "PvpTournamentFormationNotExist")
|
||||
|
||||
// 排位已经变化
|
||||
PvpTournamentNeedRefresh = NewResultStatus(-40903, "PvpTournamentNeedRefresh")
|
||||
|
||||
// 不能挑战太靠前的玩家
|
||||
PvpTournamentCantFight = NewResultStatus(-40907, "PvpTournamentCantFight")
|
||||
)
|
||||
|
||||
// 幸运彩卡luckyCard
|
||||
var (
|
||||
// 幸运彩卡奖励配置不存在
|
||||
LuckyCardRewardConfigNotExist = NewResultStatus(-42610, "LuckyCardRewardConfigNotExist")
|
||||
|
||||
// 幸运彩卡奖励不足
|
||||
LuckyCardRewardNotEnough = NewResultStatus(-42611, "LuckyCardRewardNotEnough")
|
||||
|
||||
// 幸运彩卡青钻奖励不足
|
||||
LuckyCardRewardQingzuanNotEnough = NewResultStatus(-42612, "LuckyCardRewardQingzuanNotEnough")
|
||||
|
||||
// 用户青钻额度不足
|
||||
LuckyCardQingzuanNotEnough = NewResultStatus(-42613, "LuckyCardQingzuanNotEnough")
|
||||
|
||||
// 交换信息不存在
|
||||
LuckyCardExchangeMessageNotExist = NewResultStatus(-42615, "LuckyCardExchangeMessageNotExist")
|
||||
)
|
||||
|
||||
// 新版金兰宴
|
||||
var (
|
||||
// NewFeastHaveAppointment 已经预约过
|
||||
NewFeastHaveAppointment = NewResultStatus(-41101, "NewFeastHaveAppointment")
|
||||
|
||||
// NewFeastAppointmentTimeOut 时间已过
|
||||
NewFeastAppointmentTimeOut = NewResultStatus(-41102, "NewFeastAppointmentTimeOut")
|
||||
|
||||
// NotAppointment 没有预约
|
||||
NewFeastNotAppointment = NewResultStatus(-41103, "NewFeastNotAppointment")
|
||||
|
||||
// NewFeastHaveInvite 已经邀请
|
||||
NewFeastHaveInvite = NewResultStatus(-41104, "NewFeastHaveInvite")
|
||||
|
||||
// NewFeastAppointmentOverdue 宴会已过期
|
||||
NewFeastAppointmentOverdue = NewResultStatus(-41105, "NewFeastAppointmentOverdue")
|
||||
|
||||
// 金兰宴房间不存在
|
||||
NewFeastRoomNotExist = NewResultStatus(-41106, "NewFeastRoomNotExist")
|
||||
|
||||
// 金兰宴玩家不存在
|
||||
NewFeastPlayerNotInRoom = NewResultStatus(-41107, "NewFeastPlayerNotInRoom")
|
||||
|
||||
// 金兰宴对方玩家不存在
|
||||
NewFeastTargetPlayerPlayerNotInRoom = NewResultStatus(-41108, "NewFeastTargetPlayerPlayerNotInRoom")
|
||||
|
||||
// 道具已被抢
|
||||
NewFeastPropBeRobbed = NewResultStatus(-41109, "NewFeastPropBeRobbed")
|
||||
|
||||
// 变身球数量不足
|
||||
NewFeastBallNotEnough = NewResultStatus(-41110, "NewFeastBallNotEnough")
|
||||
|
||||
// 已拥有烟花
|
||||
NewFeastHaveFirework = NewResultStatus(-41111, "NewFeastHaveFirework")
|
||||
|
||||
// 宴会已结束
|
||||
NewFeastEnd = NewResultStatus(-41112, "NewFeastEnd")
|
||||
|
||||
// 已经品菜过了
|
||||
NewFeastHaveEatFood = NewResultStatus(-41113, "NewFeastHaveEatFood")
|
||||
|
||||
// 不在品菜时间内
|
||||
NewFeastNotEatFoodTime = NewResultStatus(-41114, "NewFeastNotEatFoodTime")
|
||||
|
||||
// 房间人气不足
|
||||
NewFeastRoomPopularNotEnough = NewResultStatus(-41115, "NewFeastRoomPopularNotEnough")
|
||||
|
||||
// 密码不正确
|
||||
NewFeastBoxPasswordError = NewResultStatus(-41116, "NewFeastBoxPasswordError")
|
||||
|
||||
// 不是房主
|
||||
NewFeastNotHsot = NewResultStatus(-41117, "NewFeastNotHsot")
|
||||
|
||||
// 已经领取
|
||||
NewFeastBoxHaveDraw = NewResultStatus(-41118, "NewFeastBoxHaveDraw")
|
||||
|
||||
// 房间人数已满
|
||||
NewFeastRoomPlayerMax = NewResultStatus(-41119, "NewFeastRoomPlayerMax")
|
||||
|
||||
// 不能邀请
|
||||
NewFeastCantInvite = NewResultStatus(-41120, "NewFeastCantInvite")
|
||||
|
||||
// 被其他人预约
|
||||
NewFeastAppointmentByOthers = NewResultStatus(-41121, "NewFeastAppointmentByOthers")
|
||||
)
|
||||
|
||||
// NoWorldBossDamageData 世界boss1.0
|
||||
var (
|
||||
NoWorldBossDamageData = NewResultStatus(-41200, "NoWorldBossDamageData")
|
||||
)
|
||||
var (
|
||||
// 拍卖行商品不存在
|
||||
AuctionGoodsNotExist = NewResultStatus(-41301, "AuctionGoodsNotExist")
|
||||
|
||||
// 拍卖行加价失败
|
||||
AuctionAddPriceErr = NewResultStatus(-41302, "AuctionAddPriceErr")
|
||||
|
||||
// 仙盟拍卖暂无商品
|
||||
AuctionGuildNoGoods = NewResultStatus(-41303, "AuctionGuildNoGoods")
|
||||
|
||||
// 仙盟拍卖未结束
|
||||
AuctionGuildNotEnd = NewResultStatus(-41304, "AuctionGuildNotEnd")
|
||||
|
||||
// 分红已经领取
|
||||
AuctionBonusHaveDraw = NewResultStatus(-41305, "AuctionBonusHaveDraw")
|
||||
|
||||
// 暂无分红
|
||||
AuctionNoBonus = NewResultStatus(-41306, "AuctionNoBonus")
|
||||
|
||||
// 不能取消关注
|
||||
AuctionCantCancelFollow = NewResultStatus(-41307, "AuctionCantCancelFollow")
|
||||
|
||||
// 拍卖未开始
|
||||
AuctionNotStart = NewResultStatus(-41308, "AuctionNotStart")
|
||||
|
||||
// 该商品已经售出
|
||||
AuctionGoodsHaveAuction = NewResultStatus(-41309, "AuctionGoodsHaveAuction")
|
||||
|
||||
// 该商品已经流拍
|
||||
AuctionGoodsHaveNoPrice = NewResultStatus(-41310, "AuctionGoodsHaveNoPrice")
|
||||
|
||||
// 玩家金龙不足
|
||||
AuctionPlayerGoldNotEnough = NewResultStatus(-41311, "AuctionPlayerGoldNotEnough")
|
||||
|
||||
//该商品拍卖时间已结束
|
||||
AuctionGoodsEnd = NewResultStatus(-41312, "AuctionGoodsEnd")
|
||||
|
||||
//未参与决战神虚,不可分红
|
||||
AuctionCantBonus = NewResultStatus(-41313, "AuctionCantBonus")
|
||||
)
|
||||
|
||||
var (
|
||||
// 交易行商品不存在
|
||||
TradeProductNotExistInfoNotExist = NewResultStatus(-41500, "TradeProductNotExistInfoNotExist")
|
||||
|
||||
// 交易行审核类型不存在
|
||||
TradeAuditTypeNotExist = NewResultStatus(-41501, "TradeAuditTypeNotExist")
|
||||
)
|
||||
@ -7,7 +7,8 @@ import (
|
||||
type StatusCode int
|
||||
|
||||
// ResultStatus
|
||||
// @description: 状态码数据
|
||||
//
|
||||
// @description: 状态码数据
|
||||
type ResultStatus struct {
|
||||
// 状态码
|
||||
code StatusCode
|
||||
@ -17,31 +18,46 @@ type ResultStatus struct {
|
||||
}
|
||||
|
||||
// Code
|
||||
// @description: 状态码
|
||||
//
|
||||
// @description: 状态码
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @StatusCode: 状态码
|
||||
func (this *ResultStatus) Code() StatusCode {
|
||||
return this.code
|
||||
}
|
||||
|
||||
// Message
|
||||
// @description: 错误信息
|
||||
//
|
||||
// @description: 错误信息
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @string:
|
||||
func (this *ResultStatus) Message() string {
|
||||
return this.message
|
||||
}
|
||||
|
||||
// NewResultStatus
|
||||
// @description: 创建新的状态码对象
|
||||
//
|
||||
// @description: 创建新的状态码对象
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @_code: 错误码
|
||||
// @_message: 提示消息
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @ResultStatus: 状态码对象
|
||||
func NewResultStatus(_code StatusCode, _message string) ResultStatus {
|
||||
return ResultStatus{
|
||||
@ -51,20 +67,30 @@ func NewResultStatus(_code StatusCode, _message string) ResultStatus {
|
||||
}
|
||||
|
||||
// IsSuccess
|
||||
// @description: 是否是成功
|
||||
//
|
||||
// @description: 是否是成功
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @bool: true:成功 false:失败
|
||||
func (this *ResultStatus) IsSuccess() bool {
|
||||
return this.code == Success.Code()
|
||||
}
|
||||
|
||||
// String
|
||||
// @description: 打印状态码信息
|
||||
//
|
||||
// @description: 打印状态码信息
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @string: 状态码信息
|
||||
func (this *ResultStatus) String() string {
|
||||
return fmt.Sprintf("Code:%d,Message:%s", this.code, this.message)
|
||||
107
trunk/center/common/resultstatus/resultStatusCode.go
Normal file
107
trunk/center/common/resultstatus/resultStatusCode.go
Normal file
@ -0,0 +1,107 @@
|
||||
package resultStatus
|
||||
|
||||
// 系统错误码
|
||||
var (
|
||||
// 成功
|
||||
Success = NewResultStatus(0, "Success")
|
||||
|
||||
// 数据库错误
|
||||
DBError = NewResultStatus(-2, "DBError")
|
||||
|
||||
// 方法未定义
|
||||
MethodNotDefined = NewResultStatus(-3, "MethodNotDefined")
|
||||
|
||||
// 参数无效
|
||||
ParamInValid = NewResultStatus(-4, "ParamInValid")
|
||||
|
||||
// 参数不匹配
|
||||
ParamNotMatch = NewResultStatus(-5, "ParamNotMatch")
|
||||
|
||||
// 功能未开启
|
||||
ModuleNotOpen = NewResultStatus(-6, "ModuleNotOpen")
|
||||
|
||||
// 只支持Post
|
||||
OnlySupportPOST = NewResultStatus(-7, "OnlySupportPOST")
|
||||
|
||||
// API未定义
|
||||
APINotDefined = NewResultStatus(-8, "APINotDefined")
|
||||
|
||||
// API数据错误
|
||||
APIDataError = NewResultStatus(-9, "APIDataError")
|
||||
|
||||
// API参数错误
|
||||
APIParamError = NewResultStatus(-10, "APIParamError")
|
||||
|
||||
// IP被禁用
|
||||
IPForbid = NewResultStatus(-11, "IPForbid")
|
||||
|
||||
// 没有有效的服务器
|
||||
NoAvailableServer = NewResultStatus(-12, "NoAvailableServer")
|
||||
|
||||
// 服务器组不存在
|
||||
ServerGroupNotExists = NewResultStatus(-13, "ServerGroupNotExists")
|
||||
|
||||
// 测试接口只能debug下调用
|
||||
DebugInterface = NewResultStatus(-14, "DebugInterface")
|
||||
|
||||
// 模块不存在
|
||||
ModuleNotExists = NewResultStatus(-15, "ModuleNotExists")
|
||||
|
||||
// 未能找到指定方法
|
||||
NotSpecificMethod = NewResultStatus(-16, "NotSpecificMethod")
|
||||
|
||||
// 非指定区域
|
||||
NotMatchRegion = NewResultStatus(-17, "NotMatchRegion")
|
||||
|
||||
// 发送空数据
|
||||
SendNullData = NewResultStatus(-18, "SendNullData")
|
||||
|
||||
// 序列化失败
|
||||
MarshalDataError = NewResultStatus(-19, "MarshalDataError")
|
||||
|
||||
//未登录
|
||||
NotLogin = NewResultStatus(-20, "NotLogin")
|
||||
|
||||
// 数据错误
|
||||
DataError = NewResultStatus(-31, "DataError")
|
||||
|
||||
// 战区合并维护中,敬请期待
|
||||
MergeDataRunning = NewResultStatus(-67, "MergeDataRunning")
|
||||
|
||||
// 下载器内容未配置
|
||||
QcDownloadConfigNotExists = NewResultStatus(-68, "QcDownloadConfigNotExists")
|
||||
|
||||
// 下载器奖励已领取
|
||||
QcDownloadHasReward = NewResultStatus(-69, "QcDownloadHasReward")
|
||||
|
||||
// 下载器奖励没有奖励可领取
|
||||
QcDownloadNotReward = NewResultStatus(-70, "QcDownloadNotReward")
|
||||
|
||||
// 下载器奖励积分不足
|
||||
QcDownloadNotScore = NewResultStatus(-71, "QcDownloadNotScore")
|
||||
)
|
||||
|
||||
// 微信登录
|
||||
var (
|
||||
RequestError = NewResultStatus(-60001, "WrongRequeststatus")
|
||||
EmptyResp = NewResultStatus(-60002, "The result is empty")
|
||||
UnmarshalError = NewResultStatus(-60003, "Unmarshal is error")
|
||||
)
|
||||
|
||||
// 玩家
|
||||
var (
|
||||
|
||||
// 玩家不存在
|
||||
PlayerNotExist = NewResultStatus(-1110, "PlayerNotExist")
|
||||
// 玩家uid和服务器id不匹配
|
||||
PlayerNotMatchSever = NewResultStatus(-1111, "PlayerNotMatchSever")
|
||||
|
||||
// 没有合适的玩家
|
||||
NotSuitablePlayer = NewResultStatus(-1155, "NotSuitablePlayer")
|
||||
|
||||
// 玩家阵容不存在
|
||||
PlayerSlotFormationNotExist = NewResultStatus(-1156, "PlayerSlotFormationNotExist")
|
||||
|
||||
//玩家已经下线
|
||||
PlayerIsLoginOut = NewResultStatus(-1157, "PlayerIsLoginOut")
|
||||
)
|
||||
159
trunk/center/common/timer/timer_handler.go
Normal file
159
trunk/center/common/timer/timer_handler.go
Normal file
@ -0,0 +1,159 @@
|
||||
package timer
|
||||
|
||||
import (
|
||||
"goutil/logUtilPlus"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 触发类型
|
||||
const (
|
||||
// TriggerTypeMinute 一分钟
|
||||
TriggerTypeMinute = iota + 1
|
||||
// TriggerTypeFiveMinute 五分钟
|
||||
TriggerTypeFiveMinute
|
||||
// TriggerTypeTenMinute 十分钟
|
||||
TriggerTypeTenMinute
|
||||
// TriggerTypeHalfHour 半小时
|
||||
TriggerTypeHalfHour
|
||||
// TriggerTypeHour 一小时
|
||||
TriggerTypeHour
|
||||
// TriggerTypeEightHour 八小时
|
||||
TriggerTypeEightHour
|
||||
// TriggerTypeDay 一天 每天0点触发
|
||||
TriggerTypeDay
|
||||
// TriggerTypeWeek 一周 (周日0点触发)
|
||||
TriggerTypeWeek
|
||||
// TriggerTypeMonth 每月1号0点触发
|
||||
TriggerTypeMonth
|
||||
)
|
||||
|
||||
// TimerHandlerFunc 定义可执行的函数类型
|
||||
type timerHandlerFunc func(nowTime time.Time) error
|
||||
|
||||
// 时间触发管理
|
||||
var (
|
||||
timerHandlerMap = make(map[int][]timerHandlerFunc)
|
||||
timerTypeMap = map[int]struct{}{
|
||||
TriggerTypeMinute: {},
|
||||
TriggerTypeFiveMinute: {},
|
||||
TriggerTypeTenMinute: {},
|
||||
TriggerTypeHalfHour: {},
|
||||
TriggerTypeHour: {},
|
||||
TriggerTypeEightHour: {},
|
||||
TriggerTypeDay: {},
|
||||
TriggerTypeWeek: {},
|
||||
TriggerTypeMonth: {},
|
||||
}
|
||||
)
|
||||
|
||||
// Register 注册时间触发器
|
||||
// @param timerType 时间触发类型
|
||||
// @param timerFunc 时间触发函数
|
||||
func Register(timerType int, timerFunc timerHandlerFunc) {
|
||||
|
||||
// 检查timerType是否在常量中
|
||||
if _, ok := timerTypeMap[timerType]; !ok {
|
||||
logUtilPlus.ErrorLog("注册时间触发器失败,类型不存在", "timerType", timerType)
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := timerHandlerMap[timerType]; !ok {
|
||||
timerHandlerMap[timerType] = make([]timerHandlerFunc, 0)
|
||||
}
|
||||
timerHandlerMap[timerType] = append(timerHandlerMap[timerType], timerFunc)
|
||||
}
|
||||
|
||||
// Execute 执行时间触发器
|
||||
// @param timerType 时间触发类型
|
||||
// @param nowTime 当前时间
|
||||
func Execute(timerType int, nowTime time.Time) {
|
||||
if _, ok := timerHandlerMap[timerType]; !ok {
|
||||
return
|
||||
}
|
||||
for _, timerHandlerFunc := range timerHandlerMap[timerType] {
|
||||
if err := timerHandlerFunc(nowTime); err != nil {
|
||||
logUtilPlus.ErrorLog("执行时间触发器失败", "timerType", timerType, "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化init
|
||||
func init() {
|
||||
go timerHandler()
|
||||
}
|
||||
|
||||
// 定时触发函数
|
||||
func timerHandler() {
|
||||
|
||||
// 每一分钟执行一次
|
||||
ticker := time.NewTicker(time.Minute)
|
||||
defer ticker.Stop()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logUtilPlus.ErrorLog("定时触发函数异常", "err", err)
|
||||
restartTimerHandler()
|
||||
}
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case nowTime := <-ticker.C:
|
||||
go func() {
|
||||
// 触发minute
|
||||
Execute(TriggerTypeMinute, nowTime)
|
||||
// 触发fiveMinute
|
||||
if nowTime.Minute()%5 == 0 {
|
||||
Execute(TriggerTypeFiveMinute, nowTime)
|
||||
}
|
||||
// 触发tenMinute
|
||||
if nowTime.Minute()%10 == 0 {
|
||||
Execute(TriggerTypeTenMinute, nowTime)
|
||||
}
|
||||
// 触发halfHour
|
||||
if nowTime.Minute()%30 == 0 {
|
||||
Execute(TriggerTypeHalfHour, nowTime)
|
||||
}
|
||||
// 触发hour
|
||||
if nowTime.Minute() == 0 {
|
||||
Execute(TriggerTypeHour, nowTime)
|
||||
}
|
||||
// 触发eightHour
|
||||
if nowTime.Hour()%8 == 0 {
|
||||
Execute(TriggerTypeEightHour, nowTime)
|
||||
}
|
||||
// 触发day 0点触发
|
||||
if nowTime.Hour() == 0 && nowTime.Minute() == 0 {
|
||||
Execute(TriggerTypeDay, nowTime)
|
||||
}
|
||||
// 触发week 周日0点触发
|
||||
if nowTime.Weekday() == time.Sunday && nowTime.Hour() == 0 && nowTime.Minute() == 0 {
|
||||
Execute(TriggerTypeWeek, nowTime)
|
||||
}
|
||||
// 触发month 1号0点触发
|
||||
if nowTime.Day() == 1 && nowTime.Hour() == 0 && nowTime.Minute() == 0 {
|
||||
Execute(TriggerTypeMonth, nowTime)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// restartTimerHandler 重启定时器
|
||||
func restartTimerHandler() {
|
||||
// 设置重试次数
|
||||
maxRetries := 5
|
||||
retryCount := 0
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-time.After(5 * time.Minute): // 等待5分钟后重试
|
||||
if retryCount >= maxRetries {
|
||||
logUtilPlus.ErrorLog("定时器重启失败,达到最大重试次数")
|
||||
return
|
||||
}
|
||||
logUtilPlus.InfoLog("重新启动定时器,重试次数: %d", retryCount+1)
|
||||
go timerHandler()
|
||||
return
|
||||
}
|
||||
retryCount++
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ import (
|
||||
"goutil/logUtilPlus"
|
||||
"goutil/typeUtil"
|
||||
"goutil/zlibUtil"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@ -72,7 +72,7 @@ func (this *ApiContext) readContent(isZlib bool) (content []byte, err error) {
|
||||
var buffer []byte
|
||||
|
||||
defer this.request.Body.Close()
|
||||
if buffer, err = ioutil.ReadAll(this.request.Body); err != nil {
|
||||
if buffer, err = io.ReadAll(this.request.Body); err != nil {
|
||||
logUtilPlus.ErrorLog(fmt.Sprintf("url:%s,读取数据出错,错误信息为:%s", this.request.RequestURI, err))
|
||||
return
|
||||
}
|
||||
@ -80,7 +80,7 @@ func (this *ApiContext) readContent(isZlib bool) (content []byte, err error) {
|
||||
// 不压缩,则直接返回
|
||||
if isZlib == false {
|
||||
this.requestBytes = buffer
|
||||
|
||||
logUtilPlus.ErrorLog(fmt.Sprintf("buffer=%v", buffer))
|
||||
return buffer, err
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ func (this *ApiHandler) FuncParamNames() []string {
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @resultStatus.ResultStatus: 状态码数据
|
||||
// @resultstatus.ResultStatus: 状态码数据
|
||||
func (this *ApiHandler) CheckParam(r *http.Request) resultStatus.ResultStatus {
|
||||
for _, name := range this.funcParamNames {
|
||||
if r.Form[name] == nil || len(r.Form[name]) == 0 {
|
||||
@ -15,20 +15,28 @@ var (
|
||||
)
|
||||
|
||||
// RegisterRemarkFunc
|
||||
// @description: 注册文档api方法
|
||||
//
|
||||
// @description: 注册文档api方法
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @_remarkFunc: _remarkFunc
|
||||
//
|
||||
// return:
|
||||
func RegisterRemarkFunc(_remarkFunc func(w http.ResponseWriter, r *http.Request)) {
|
||||
remarkFunc = _remarkFunc
|
||||
}
|
||||
|
||||
// RegisterHandleFunc
|
||||
// @description: 注册处理方法
|
||||
//
|
||||
// @description: 注册处理方法
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @apiName: API名称
|
||||
// @callback: 回调方法
|
||||
// @paramNames: 参数名称集合
|
||||
//
|
||||
// return:
|
||||
func RegisterHandleFunc(apiName string, callback HandleFunc, paramNames ...string) {
|
||||
apiFullName := fmt.Sprintf("/API/%s", apiName)
|
||||
@ -41,10 +49,15 @@ func RegisterHandleFunc(apiName string, callback HandleFunc, paramNames ...strin
|
||||
}
|
||||
|
||||
// GetHandleFunc
|
||||
// @description: 获取请求方法
|
||||
//
|
||||
// @description: 获取请求方法
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @apiFullName: 方法名称
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*ApiHandler: 请求方法
|
||||
// @bool: 是否存在
|
||||
func GetHandleFunc(apiFullName string) (*ApiHandler, bool) {
|
||||
@ -5,7 +5,8 @@ import (
|
||||
)
|
||||
|
||||
// methodAndInOutTypes
|
||||
// @description: 反射的方法和输入、输出参数类型组合类型
|
||||
//
|
||||
// @description: 反射的方法和输入、输出参数类型组合类型
|
||||
type methodAndInOutTypes struct {
|
||||
// 反射出来的对应方法对象
|
||||
Method reflect.Value
|
||||
@ -18,12 +19,17 @@ type methodAndInOutTypes struct {
|
||||
}
|
||||
|
||||
// newmethodAndInOutTypes
|
||||
// @description: newmethodAndInOutTypes
|
||||
//
|
||||
// @description: newmethodAndInOutTypes
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @_method: _method
|
||||
// @_inTypes: _inTypes
|
||||
// @_outTypes: _outTypes
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*methodAndInOutTypes: methodAndInOutTypes
|
||||
func newmethodAndInOutTypes(_method reflect.Value, _inTypes []reflect.Type, _outTypes []reflect.Type) *methodAndInOutTypes {
|
||||
return &methodAndInOutTypes{
|
||||
@ -1,7 +1,8 @@
|
||||
package webServer
|
||||
|
||||
// RequestObject
|
||||
// @description: 请求对象
|
||||
//
|
||||
// @description: 请求对象
|
||||
type RequestObject struct {
|
||||
// 以下属性是由客户端直接传入的,可以直接反序列化直接得到的
|
||||
// 请求的模块名称
|
||||
@ -15,12 +16,17 @@ type RequestObject struct {
|
||||
}
|
||||
|
||||
// NewRequestObject
|
||||
// @description: NewRequestObject
|
||||
//
|
||||
// @description: NewRequestObject
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @_ModuleName: _ModuleName
|
||||
// @_MethodName: _MethodName
|
||||
// @_Parameters: _Parameters
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @*RequestObject: RequestObject
|
||||
func NewRequestObject(_ModuleName string, _MethodName string, _Parameters []interface{}) *RequestObject {
|
||||
return &RequestObject{
|
||||
@ -115,6 +115,13 @@ func (mux *selfDefineMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
params = append([]interface{}{tokenData.UserInfo}, params...)
|
||||
}
|
||||
|
||||
//是否需要请求信息
|
||||
if IsNeedGetRequestInfo(strs[0], strs[1]) {
|
||||
|
||||
//添加请求信息到最后一个参数
|
||||
params = append(params, r)
|
||||
}
|
||||
|
||||
resquestData := NewRequestObject(strs[0], strs[1], params)
|
||||
resp := CallFunction(resquestData)
|
||||
if isJson {
|
||||
@ -14,6 +14,9 @@ var (
|
||||
|
||||
//跳过验证token的页面
|
||||
skipVerifyTokenPage = make(map[string]bool)
|
||||
|
||||
//需要获取请求信息
|
||||
needGetRequestInfo = make(map[string]bool)
|
||||
)
|
||||
|
||||
type TokenInfo struct {
|
||||
@ -97,10 +100,12 @@ func CheckToken(token int64) (bool, *TokenInfo) {
|
||||
return true, tokenInfo
|
||||
}
|
||||
|
||||
// AddSkipVerifyTokenPage 添加跳过验证token的页面
|
||||
func AddSkipVerifyTokenPage(moduleName, methodName string) {
|
||||
skipVerifyTokenPage[moduleName+"_"+methodName] = true
|
||||
}
|
||||
|
||||
// IsSkipVerifyTokenPage 判断是否跳过验证token的页面
|
||||
func IsSkipVerifyTokenPage(moduleName, methodName string) bool {
|
||||
exist, ok := skipVerifyTokenPage[moduleName+"_"+methodName]
|
||||
if !exist {
|
||||
@ -108,3 +113,17 @@ func IsSkipVerifyTokenPage(moduleName, methodName string) bool {
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
// AddNeedGetRequestInfo 添加需要获取请求信息的页面
|
||||
func AddNeedGetRequestInfo(moduleName, methodName string) {
|
||||
needGetRequestInfo[moduleName+"_"+methodName] = true
|
||||
}
|
||||
|
||||
// IsNeedGetRequestInfo 判断是否需要获取请求信息的页面
|
||||
func IsNeedGetRequestInfo(moduleName, methodName string) bool {
|
||||
exist, ok := needGetRequestInfo[moduleName+"_"+methodName]
|
||||
if !exist {
|
||||
return false
|
||||
}
|
||||
return ok
|
||||
}
|
||||
104
trunk/center/dbcenter/01_test.go
Normal file
104
trunk/center/dbcenter/01_test.go
Normal file
@ -0,0 +1,104 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
amqp "github.com/streadway/amqp"
|
||||
)
|
||||
|
||||
// failOnError 检查错误并记录致命错误
|
||||
func failOnError(err error, msg string) {
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", msg, err)
|
||||
}
|
||||
}
|
||||
|
||||
// 测试函数
|
||||
func Test001(t *testing.T) {
|
||||
// 连接到 RabbitMQ 服务器
|
||||
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
|
||||
failOnError(err, "连接到 RabbitMQ 失败")
|
||||
defer conn.Close()
|
||||
|
||||
// 打开一个通道
|
||||
ch, err := conn.Channel()
|
||||
failOnError(err, "打开通道失败")
|
||||
defer ch.Close()
|
||||
|
||||
// 声明一个队列
|
||||
q, err := ch.QueueDeclare(
|
||||
"hello", // 队列名称
|
||||
true, // 是否持久化
|
||||
false, // 是否在使用后删除
|
||||
false, // 是否排他
|
||||
false, // 是否阻塞
|
||||
nil, // 其他参数
|
||||
)
|
||||
failOnError(err, "声明队列失败")
|
||||
|
||||
// 注册一个消费者
|
||||
msgs, err := ch.Consume(
|
||||
q.Name, // 队列名称
|
||||
"", // 消费者名称
|
||||
true, // 是否自动确认
|
||||
false, // 是否排他
|
||||
false, // 是否本地
|
||||
false, // 是否阻塞
|
||||
nil, // 其他参数
|
||||
)
|
||||
failOnError(err, "注册消费者失败")
|
||||
|
||||
// 创建一个无缓冲的通道,用于阻塞主 goroutine
|
||||
forever := make(chan bool)
|
||||
|
||||
// 启动一个 goroutine 来处理消息
|
||||
go func() {
|
||||
for d := range msgs {
|
||||
log.Printf("收到消息: %s", d.Body)
|
||||
}
|
||||
}()
|
||||
|
||||
log.Printf(" [*] 等待消息。按 CTRL+C 退出")
|
||||
<-forever
|
||||
}
|
||||
|
||||
func Test002(t *testing.T) {
|
||||
// 连接到 RabbitMQ 服务器
|
||||
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
|
||||
failOnError(err, "连接到 RabbitMQ 失败")
|
||||
defer conn.Close()
|
||||
|
||||
// 打开一个通道
|
||||
ch, err := conn.Channel()
|
||||
failOnError(err, "打开通道失败")
|
||||
defer ch.Close()
|
||||
|
||||
// 声明一个队列
|
||||
q, err := ch.QueueDeclare(
|
||||
"hello", // 队列名称
|
||||
true, // 是否持久化
|
||||
false, // 是否在使用后删除
|
||||
false, // 是否排他
|
||||
false, // 是否阻塞
|
||||
nil, // 其他参数
|
||||
)
|
||||
failOnError(err, "声明队列失败")
|
||||
|
||||
// 定义要发送的消息内容
|
||||
body := "Hello World!1111"
|
||||
|
||||
// 发布消息到队列
|
||||
err = ch.Publish(
|
||||
"", // 交换机名称
|
||||
q.Name, // 路由键
|
||||
false, // 是否强制
|
||||
false, // 是否立即
|
||||
amqp.Publishing{
|
||||
ContentType: "text/plain",
|
||||
Body: []byte(body),
|
||||
})
|
||||
failOnError(err, "发布消息失败")
|
||||
|
||||
log.Printf(" [x] 发送 %s", body)
|
||||
}
|
||||
40
trunk/center/dbcenter/Dockerfile
Normal file
40
trunk/center/dbcenter/Dockerfile
Normal file
@ -0,0 +1,40 @@
|
||||
# 使用官方的 Go 镜像作为构建环境
|
||||
FROM golang:1.22.10-alpine AS builder
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 设置 Go 代理
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
# 禁用 CGO
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
# 复制所有源代码文件
|
||||
COPY . .
|
||||
|
||||
WORKDIR /app/dbServer
|
||||
|
||||
# 构建应用程序,并确认生成的文件
|
||||
RUN go build -o dbServer -ldflags="-s -w"
|
||||
|
||||
# 使用官方的 Alpine 镜像作为运行环境
|
||||
FROM alpine:latest
|
||||
|
||||
# 设置作者标签
|
||||
LABEL authors="tp"
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 从构建阶段复制编译好的可执行文件
|
||||
COPY --from=builder /app/dbServer/dbServer .
|
||||
|
||||
# 复制配置文件
|
||||
COPY --from=builder /app/dbServer/config.yaml .
|
||||
|
||||
# 暴露端口(假设 adminserver 监听 10051 端口)
|
||||
EXPOSE 10051
|
||||
|
||||
# 设置容器启动时运行 adminserver
|
||||
ENTRYPOINT ["./dbServer"]
|
||||
21
trunk/center/dbcenter/buildLiunx.sh
Normal file
21
trunk/center/dbcenter/buildLiunx.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 设置 Go 环境变量,确保使用 Linux 架构
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
|
||||
echo "开始编译..."
|
||||
|
||||
# 编译 Go 代码
|
||||
go build -o dbServer
|
||||
|
||||
# 检查编译是否成功
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "编译成功!"
|
||||
else
|
||||
echo "编译失败!"
|
||||
fi
|
||||
|
||||
# 等待用户输入任意键
|
||||
read -p "编译完成,按任意键继续..."
|
||||
exit 1
|
||||
63
trunk/center/dbcenter/config.yaml
Normal file
63
trunk/center/dbcenter/config.yaml
Normal file
@ -0,0 +1,63 @@
|
||||
# 配置根节点
|
||||
root:
|
||||
# 是否是调试模式
|
||||
debug: true
|
||||
|
||||
# Web服务监听地址和端口
|
||||
web_server_address: "192.168.50.85:10051"
|
||||
|
||||
# Elasticsearch 地址
|
||||
es_urls: "http://10.252.0.70:18099"
|
||||
|
||||
# RabbitMQ 配置
|
||||
rabbitmq_address: "amqp://admin:admin@192.168.50.85:5672/"
|
||||
|
||||
# mq队列名称
|
||||
mq_queue_name: "admin_center"
|
||||
|
||||
# 数据库配置
|
||||
db_config:
|
||||
# 实时更新数据库数量{玩家库/用户库}
|
||||
db_num: [ 0 ]
|
||||
|
||||
admin_db:
|
||||
# 最大处于开启状态的连接数
|
||||
max_open_conns: 0
|
||||
|
||||
# 最大处于空闲状态的连接数
|
||||
max_idle_conns: 0
|
||||
|
||||
# 数据库连接字符串
|
||||
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
||||
|
||||
user_db:
|
||||
# 最大处于开启状态的连接数
|
||||
max_open_conns: 0
|
||||
|
||||
# 最大处于空闲状态的连接数
|
||||
max_idle_conns: 0
|
||||
|
||||
# 数据库连接字符串
|
||||
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/user?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
||||
|
||||
redis_config:
|
||||
# 数据库连接字符串
|
||||
connection_string: "192.168.50.110:6379"
|
||||
|
||||
# 密码, 如果要设置用户Id,则密码设置为:"UserId:Password"
|
||||
password: ""
|
||||
|
||||
# 数据库序号
|
||||
database: 5
|
||||
|
||||
# 最大活跃连接数
|
||||
max_active: 500
|
||||
|
||||
# 最大空闲的连接数
|
||||
max_idle: 200
|
||||
|
||||
# 连接空闲超时时间,单位:秒
|
||||
idle_timeout: 300
|
||||
|
||||
# 连接超时时间, 单位:秒
|
||||
dial_connect_timeout: 10
|
||||
BIN
trunk/center/dbcenter/dbServer
Normal file
BIN
trunk/center/dbcenter/dbServer
Normal file
Binary file not shown.
28
trunk/center/dbcenter/dockerRun.sh
Normal file
28
trunk/center/dbcenter/dockerRun.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 导航到 Dockerfile 所在目录
|
||||
#cd D:\workspace\e2023\goProject\trunk\center\admincenter
|
||||
|
||||
# 构建 Docker 镜像
|
||||
echo "开始构建 Docker 镜像..."
|
||||
docker build -t adminserver-image .
|
||||
|
||||
# 检查构建是否成功
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "构建失败!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "镜像构建成功!"
|
||||
|
||||
# 运行 Docker 容器
|
||||
echo "开始运行 Docker 容器..."
|
||||
docker run -d -p 10051:10051 --name adminserver-container adminserver-image
|
||||
|
||||
# 检查容器是否成功运行
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器启动失败!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "容器启动成功!"
|
||||
@ -1,6 +1,6 @@
|
||||
module admincenter
|
||||
module dbcenter
|
||||
|
||||
go 1.22.2
|
||||
go 1.22.10
|
||||
|
||||
replace (
|
||||
common => ../common
|
||||
@ -14,14 +14,13 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/gomodule/redigo v1.8.9 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
||||
@ -29,10 +28,11 @@ require (
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/streadway/amqp v1.1.0
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
)
|
||||
89
trunk/center/dbcenter/go.sum
Normal file
89
trunk/center/dbcenter/go.sum
Normal file
@ -0,0 +1,89 @@
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 h1:OoL469zqSNrTLSz5zeVF/I6VOO7fiw2bzSzQe4J557c=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4/go.mod h1:xe9a/L2aeOgFKKgrO3ibQTnMdpAeL0GC+5/HpGScSa4=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
|
||||
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
|
||||
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/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q=
|
||||
github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
|
||||
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.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
||||
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd h1:GGJVjV8waZKRHrgwvtH66z9ZGVurTD1MT0n1Bb+q4aM=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 h1:/6y1LfuqNuQdHAm0jjtPtgRcxIxjVZgm5OTu8/QhZvk=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
37
trunk/center/dbcenter/internal/db_heandler.go
Normal file
37
trunk/center/dbcenter/internal/db_heandler.go
Normal file
@ -0,0 +1,37 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"goutil/logUtilPlus"
|
||||
)
|
||||
|
||||
// ExecSql 执行sql
|
||||
func ExecSql(sql string) error {
|
||||
|
||||
defer func() error {
|
||||
if err := recover(); err != nil {
|
||||
logUtilPlus.ErrorLog("mq远程执行sql异常,对应sql:%s", sql)
|
||||
|
||||
//写入失败的文件,便于后续排查
|
||||
AddSqlErr(sql)
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
|
||||
//获取数据库连接
|
||||
db := connection.GetAdminDB()
|
||||
|
||||
logUtilPlus.InfoLog("执行sql:%s", sql)
|
||||
|
||||
//执行sql
|
||||
err := db.Exec(sql).Error
|
||||
|
||||
//判断错误
|
||||
if err != nil {
|
||||
|
||||
//记录错误
|
||||
logUtilPlus.ErrorLog("ExecSql error:", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
60
trunk/center/dbcenter/internal/sql_err.go
Normal file
60
trunk/center/dbcenter/internal/sql_err.go
Normal file
@ -0,0 +1,60 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"goutil/fileUtil"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
sqlErrList []string
|
||||
sqlErrListLock sync.RWMutex
|
||||
|
||||
fileName = "ErrSql"
|
||||
)
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
for {
|
||||
|
||||
//休息一秒
|
||||
time.Sleep(time.Second)
|
||||
|
||||
WriteErrSql()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// AddSqlErr 添加异常sql
|
||||
func AddSqlErr(sql string) {
|
||||
|
||||
//数据库过大就不再写入
|
||||
if len(sqlErrList) > 10000 {
|
||||
return
|
||||
}
|
||||
|
||||
func() {
|
||||
sqlErrListLock.Lock()
|
||||
defer sqlErrListLock.Unlock()
|
||||
sqlErrList = append(sqlErrList, sql)
|
||||
}()
|
||||
}
|
||||
|
||||
// WriteErrSql 获取异常sql 写入文件
|
||||
func WriteErrSql() {
|
||||
sqlErrListLock.RLock()
|
||||
defer sqlErrListLock.RUnlock()
|
||||
|
||||
//文件名拼接
|
||||
filePath := fileName + "/" + time.Now().Format("2006-01-02")
|
||||
fileName := time.Now().Format("2006-01-02 09") + ".txt"
|
||||
|
||||
for _, sql := range sqlErrList {
|
||||
//sql 添加换行符
|
||||
sql += ";\r\n"
|
||||
fileUtil.WriteFile(filePath, fileName, true, sql)
|
||||
|
||||
//删除已经执行的sql
|
||||
sqlErrList = sqlErrList[1:]
|
||||
}
|
||||
}
|
||||
43
trunk/center/dbcenter/main.go
Normal file
43
trunk/center/dbcenter/main.go
Normal file
@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"common/rabbitmq"
|
||||
"dbcenter/internal"
|
||||
"sync"
|
||||
|
||||
_ "common/resultStatus"
|
||||
)
|
||||
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 设置WaitGroup需要等待的数量,只要有一个服务器出现错误都停止服务器
|
||||
wg.Add(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
//加载配置
|
||||
loadConfig()
|
||||
|
||||
// 启动mq监听
|
||||
rabbitmq.ConsumeData(internal.ExecSql)
|
||||
|
||||
// 阻塞等待,以免main线程退出
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// loadConfig 用于加载配置信息。
|
||||
// 该函数会读取配置文件或环境变量中的设置,并根据这些设置初始化程序所需的配置。
|
||||
// 目前函数的实现为空,需要根据实际的配置加载逻辑进行填充。
|
||||
func loadConfig() {
|
||||
|
||||
//设置数据类型
|
||||
connection.SetModelDB(connection.GetAdminDB())
|
||||
|
||||
//构建数据库
|
||||
connection.BuildDB()
|
||||
}
|
||||
20
trunk/center/dbcenter/run.sh
Normal file
20
trunk/center/dbcenter/run.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 赋予可执行权限
|
||||
chmod +x dbServer
|
||||
|
||||
echo "启动中..."
|
||||
|
||||
# 接受命令行传入一个参数
|
||||
case "$1" in
|
||||
d)
|
||||
# 使用 nohup 将进程放到后台运行,并将输出重定向到 nohup.out 文件
|
||||
nohup ./dbServer > nohup.out 2>&1 &
|
||||
echo "启动完成"
|
||||
;;
|
||||
*)
|
||||
./dbServer
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "启动完成"
|
||||
16
trunk/center/dbcenter/stop.sh
Normal file
16
trunk/center/dbcenter/stop.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 查找 dbServer 的 PID
|
||||
PID=$(pgrep dbServer)
|
||||
|
||||
if [ -z "$PID" ]; then
|
||||
echo "dbServer 进程未找到"
|
||||
else
|
||||
echo "停止中... (PID: $PID)"
|
||||
kill $PID
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "dbServer 进程已终止 (PID: $PID)"
|
||||
else
|
||||
echo "无法终止 dbServer 进程 (PID: $PID)"
|
||||
fi
|
||||
fi
|
||||
40
trunk/center/paycenter/Dockerfile
Normal file
40
trunk/center/paycenter/Dockerfile
Normal file
@ -0,0 +1,40 @@
|
||||
# 使用官方的 Go 镜像作为构建环境
|
||||
FROM golang:1.22.10-alpine AS builder
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 设置 Go 代理
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
# 禁用 CGO
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
# 复制所有源代码文件
|
||||
COPY . .
|
||||
|
||||
WORKDIR /app/admincenter
|
||||
|
||||
# 构建应用程序,并确认生成的文件
|
||||
RUN go build -o adminserver -ldflags="-s -w"
|
||||
|
||||
# 使用官方的 Alpine 镜像作为运行环境
|
||||
FROM alpine:latest
|
||||
|
||||
# 设置作者标签
|
||||
LABEL authors="tp"
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 从构建阶段复制编译好的可执行文件
|
||||
COPY --from=builder /app/admincenter/adminserver .
|
||||
|
||||
# 复制配置文件
|
||||
COPY --from=builder /app/admincenter/config.yaml .
|
||||
|
||||
# 暴露端口(假设 adminserver 监听 10051 端口)
|
||||
EXPOSE 10051
|
||||
|
||||
# 设置容器启动时运行 adminserver
|
||||
ENTRYPOINT ["./adminserver"]
|
||||
21
trunk/center/paycenter/buildLiunx.sh
Normal file
21
trunk/center/paycenter/buildLiunx.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 设置 Go 环境变量,确保使用 Linux 架构
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
|
||||
echo "开始编译..."
|
||||
|
||||
# 编译 Go 代码
|
||||
go build -o adminServer
|
||||
|
||||
# 检查编译是否成功
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "编译成功!"
|
||||
else
|
||||
echo "编译失败!"
|
||||
fi
|
||||
|
||||
# 等待用户输入任意键
|
||||
read -p "编译完成,按任意键继续..."
|
||||
exit 1
|
||||
62
trunk/center/paycenter/config.yaml
Normal file
62
trunk/center/paycenter/config.yaml
Normal file
@ -0,0 +1,62 @@
|
||||
# 配置根节点
|
||||
root:
|
||||
# 是否是调试模式
|
||||
debug: true
|
||||
|
||||
# Web服务监听地址和端口
|
||||
web_server_address: "192.168.50.85:10052"
|
||||
|
||||
# Elasticsearch 地址
|
||||
es_urls: "http://10.252.0.70:18099"
|
||||
|
||||
# 数据库配置
|
||||
db_config:
|
||||
admin_db:
|
||||
# 最大处于开启状态的连接数
|
||||
max_open_conns: 0
|
||||
|
||||
# 最大处于空闲状态的连接数
|
||||
max_idle_conns: 0
|
||||
|
||||
# 数据库连接字符串
|
||||
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
||||
|
||||
user_db:
|
||||
# 最大处于开启状态的连接数
|
||||
max_open_conns: 0
|
||||
|
||||
# 最大处于空闲状态的连接数
|
||||
max_idle_conns: 0
|
||||
|
||||
# 数据库连接字符串
|
||||
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/pay?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
||||
|
||||
redis_config:
|
||||
# 数据库连接字符串
|
||||
connection_string: "192.168.50.110:6379"
|
||||
|
||||
# 密码, 如果要设置用户Id,则密码设置为:"UserId:Password"
|
||||
password: ""
|
||||
|
||||
# 数据库序号
|
||||
database: 5
|
||||
|
||||
# 最大活跃连接数
|
||||
max_active: 500
|
||||
|
||||
# 最大空闲的连接数
|
||||
max_idle: 200
|
||||
|
||||
# 连接空闲超时时间,单位:秒
|
||||
idle_timeout: 300
|
||||
|
||||
# 连接超时时间, 单位:秒
|
||||
dial_connect_timeout: 10
|
||||
|
||||
# 微信相关配置
|
||||
wx_config:
|
||||
|
||||
# 微信移动应用appId
|
||||
appId: "45678"
|
||||
# 微信移动应用appSecret
|
||||
appSecret: "954821"
|
||||
37
trunk/center/paycenter/docker-compose.yml
Normal file
37
trunk/center/paycenter/docker-compose.yml
Normal file
@ -0,0 +1,37 @@
|
||||
version: '3'
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: mysql-admin
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: 123456
|
||||
MYSQL_DATABASE: admin,pay
|
||||
volumes:
|
||||
- /my/own/datadir:/var/lib/mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
redis:
|
||||
image: redis:7.0
|
||||
container_name: redis-admin
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
restart: always
|
||||
command: ["redis-server", "--appendonly", "yes"]
|
||||
|
||||
admin-center:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: admin-center
|
||||
ports:
|
||||
- "10051:10051"
|
||||
volumes:
|
||||
- ./app:/app
|
||||
depends_on:
|
||||
- mysql
|
||||
- redis
|
||||
|
||||
volumes:
|
||||
redis_data:
|
||||
28
trunk/center/paycenter/dockerRun.sh
Normal file
28
trunk/center/paycenter/dockerRun.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 导航到 Dockerfile 所在目录
|
||||
#cd D:\workspace\e2023\goProject\trunk\center\admincenter
|
||||
|
||||
# 构建 Docker 镜像
|
||||
echo "开始构建 Docker 镜像..."
|
||||
docker build -t adminserver-image .
|
||||
|
||||
# 检查构建是否成功
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "构建失败!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "镜像构建成功!"
|
||||
|
||||
# 运行 Docker 容器
|
||||
echo "开始运行 Docker 容器..."
|
||||
docker run -d -p 10051:10051 --name adminserver-container adminserver-image
|
||||
|
||||
# 检查容器是否成功运行
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器启动失败!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "容器启动成功!"
|
||||
@ -1,5 +1,44 @@
|
||||
module main.go
|
||||
module paycenter
|
||||
|
||||
go 1.22.10
|
||||
|
||||
require github.com/wechatpay-apiv3/wechatpay-go v0.2.20
|
||||
replace (
|
||||
common => ../common
|
||||
framework => ../../framework
|
||||
goutil => ../../goutil
|
||||
)
|
||||
|
||||
require (
|
||||
common v0.0.0-00010101000000-000000000000
|
||||
github.com/go-pay/gopay v1.5.108
|
||||
github.com/wechatpay-apiv3/wechatpay-go v0.2.20
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-pay/crypto v0.0.1 // indirect
|
||||
github.com/go-pay/util v0.0.4 // indirect
|
||||
github.com/go-pay/xlog v0.0.3 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/gomodule/redigo v1.8.9 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/streadway/amqp v1.1.0 // indirect
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
)
|
||||
|
||||
@ -1,20 +1,110 @@
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw=
|
||||
github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
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/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 h1:OoL469zqSNrTLSz5zeVF/I6VOO7fiw2bzSzQe4J557c=
|
||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4/go.mod h1:xe9a/L2aeOgFKKgrO3ibQTnMdpAeL0GC+5/HpGScSa4=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/go-pay/crypto v0.0.1 h1:B6InT8CLfSLc6nGRVx9VMJRBBazFMjr293+jl0lLXUY=
|
||||
github.com/go-pay/crypto v0.0.1/go.mod h1:41oEIvHMKbNcYlWUlRWtsnC6+ASgh7u29z0gJXe5bes=
|
||||
github.com/go-pay/gopay v1.5.108 h1:hMhDfucGz+q/XLlz7uZ2LLLg2oJmahpcCUhi5ifEd/0=
|
||||
github.com/go-pay/gopay v1.5.108/go.mod h1:O41QrjYtfGfxyzDVJVrRDHG63cIqfZuv55Eo0NaGnWw=
|
||||
github.com/go-pay/util v0.0.4 h1:TuwSU9o3Qd7m9v1PbzFuIA/8uO9FJnA6P7neG/NwPyk=
|
||||
github.com/go-pay/util v0.0.4/go.mod h1:Tsdhs8Ib9J9b4+NKNO1PHh5hWHhlg98PthsX0ckq6PM=
|
||||
github.com/go-pay/xlog v0.0.3 h1:avyMhCL/JgBHreoGx/am/kHxfs1udDOAeVqbmzP/Yes=
|
||||
github.com/go-pay/xlog v0.0.3/go.mod h1:mH47xbobrdsSHWsmFtSF5agWbMHFP+tK0ZbVCk5OAEw=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
|
||||
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
|
||||
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/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q=
|
||||
github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
|
||||
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.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
||||
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
||||
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=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/wechatpay-apiv3/wechatpay-go v0.2.20 h1:gS8oFn1bHGnyapR2Zb4aqTV6l4kJWgbtqjCq6k1L9DQ=
|
||||
github.com/wechatpay-apiv3/wechatpay-go v0.2.20/go.mod h1:A254AUBVB6R+EqQFo3yTgeh7HtyqRRtN2w9hQSOrd4Q=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 h1:/6y1LfuqNuQdHAm0jjtPtgRcxIxjVZgm5OTu8/QhZvk=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
|
||||
88
trunk/center/paycenter/internal/alipay.go
Normal file
88
trunk/center/paycenter/internal/alipay.go
Normal file
@ -0,0 +1,88 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/go-pay/gopay"
|
||||
"github.com/go-pay/gopay/alipay/v3"
|
||||
"github.com/go-pay/gopay/pkg/js"
|
||||
"goutil/logUtilPlus"
|
||||
"paycenter/internal/cert"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.Background()
|
||||
client *alipay.ClientV3
|
||||
err error
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 初始化支付宝客V3户端
|
||||
// appid:应用ID
|
||||
// privateKey:应用私钥,支持PKCS1和PKCS8
|
||||
// isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。
|
||||
client, err = alipay.NewClientV3(cert.Appid, cert.PrivateKey, false)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("new alipay client err:%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 自定义配置http请求接收返回结果body大小,默认 10MB
|
||||
//client.SetBodySize() // 没有特殊需求,可忽略此配置
|
||||
|
||||
// Debug开关,输出/关闭日志
|
||||
client.DebugSwitch = gopay.DebugOn
|
||||
|
||||
// 设置自定义RequestId生成方法
|
||||
//client.SetRequestIdFunc()
|
||||
|
||||
// 设置biz_content加密KEY,设置此参数默认开启加密(目前不可用)
|
||||
//client.SetAESKey("KvKUTqSVZX2fUgmxnFyMaQ==")
|
||||
|
||||
// 传入证书内容
|
||||
err = client.SetCert(cert.AppPublicContent, cert.AlipayRootContent, cert.AlipayPublicContentRSA2)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("set cert err:%s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// AliPayPlace 函数用于发起预支付请求。
|
||||
// 参数:
|
||||
//
|
||||
// outTradeNo: 商户订单号。
|
||||
// currency: 订单金额,单位为分。
|
||||
// storeId: 商户门店编号。
|
||||
// clientIp: 用户的客户端IP。
|
||||
// description: 订单描述。
|
||||
//
|
||||
// 返回值:
|
||||
//
|
||||
// 成功时返回预支付ID和nil错误。
|
||||
// 失败时返回空字符串和错误对象。
|
||||
func AliPayPlace(outTradeNo int64, currency int64, storeId string, clientIp string, description string) (string, error) {
|
||||
// 请求参数
|
||||
bm := make(gopay.BodyMap)
|
||||
bm.Set("subject", "预创建创建订单").
|
||||
Set("out_trade_no", strconv.FormatInt(outTradeNo, 10)).
|
||||
Set("total_amount", currency)
|
||||
|
||||
rsp := new(struct {
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
QrCode string `json:"qr_code"`
|
||||
})
|
||||
// 创建订单
|
||||
res, err := client.DoAliPayAPISelfV3(ctx, alipay.MethodPost, alipay.V3TradePrecreate, bm, rsp)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("client.TradePrecreate(), err:%v", err)
|
||||
return "", err
|
||||
}
|
||||
logUtilPlus.DebugLog("aliRsp:%s", js.Marshal(rsp))
|
||||
if res.StatusCode != alipay.Success {
|
||||
logUtilPlus.ErrorLog("aliRsp.StatusCode:%d", res.StatusCode)
|
||||
return "", errors.New("aliRsp.StatusCode:" + strconv.Itoa(res.StatusCode))
|
||||
}
|
||||
|
||||
return "Success", nil
|
||||
}
|
||||
88
trunk/center/paycenter/internal/alipay/alipay.go
Normal file
88
trunk/center/paycenter/internal/alipay/alipay.go
Normal file
@ -0,0 +1,88 @@
|
||||
package alipay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/go-pay/gopay"
|
||||
"github.com/go-pay/gopay/alipay/v3"
|
||||
"github.com/go-pay/gopay/pkg/js"
|
||||
"goutil/logUtilPlus"
|
||||
"paycenter/internal/cert"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.Background()
|
||||
client *alipay.ClientV3
|
||||
err error
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 初始化支付宝客V3户端
|
||||
// appid:应用ID
|
||||
// privateKey:应用私钥,支持PKCS1和PKCS8
|
||||
// isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。
|
||||
client, err = alipay.NewClientV3(cert.Appid, cert.PrivateKey, false)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("new alipay client err:%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 自定义配置http请求接收返回结果body大小,默认 10MB
|
||||
//client.SetBodySize() // 没有特殊需求,可忽略此配置
|
||||
|
||||
// Debug开关,输出/关闭日志
|
||||
client.DebugSwitch = gopay.DebugOn
|
||||
|
||||
// 设置自定义RequestId生成方法
|
||||
//client.SetRequestIdFunc()
|
||||
|
||||
// 设置biz_content加密KEY,设置此参数默认开启加密(目前不可用)
|
||||
//client.SetAESKey("KvKUTqSVZX2fUgmxnFyMaQ==")
|
||||
|
||||
// 传入证书内容
|
||||
err = client.SetCert(cert.AppPublicContent, cert.AlipayRootContent, cert.AlipayPublicContentRSA2)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("set cert err:%s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// AliPayPlace 函数用于发起预支付请求。
|
||||
// 参数:
|
||||
//
|
||||
// outTradeNo: 商户订单号。
|
||||
// currency: 订单金额,单位为分。
|
||||
// storeId: 商户门店编号。
|
||||
// clientIp: 用户的客户端IP。
|
||||
// description: 订单描述。
|
||||
//
|
||||
// 返回值:
|
||||
//
|
||||
// 成功时返回预支付ID和nil错误。
|
||||
// 失败时返回空字符串和错误对象。
|
||||
func AliPayPlace(outTradeNo int64, currency int64, storeId string, clientIp string, description string) (string, error) {
|
||||
// 请求参数
|
||||
bm := make(gopay.BodyMap)
|
||||
bm.Set("subject", "预创建创建订单").
|
||||
Set("out_trade_no", strconv.FormatInt(outTradeNo, 10)).
|
||||
Set("total_amount", currency)
|
||||
|
||||
rsp := new(struct {
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
QrCode string `json:"qr_code"`
|
||||
})
|
||||
// 创建订单
|
||||
res, err := client.DoAliPayAPISelfV3(ctx, alipay.MethodPost, alipay.V3TradePrecreate, bm, rsp)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("client.TradePrecreate(), err:%v", err)
|
||||
return "", err
|
||||
}
|
||||
logUtilPlus.DebugLog("aliRsp:%s", js.Marshal(rsp))
|
||||
if res.StatusCode != alipay.Success {
|
||||
logUtilPlus.ErrorLog("aliRsp.StatusCode:%d", res.StatusCode)
|
||||
return "", errors.New("aliRsp.StatusCode:" + strconv.Itoa(res.StatusCode))
|
||||
}
|
||||
|
||||
return "Success", nil
|
||||
}
|
||||
38
trunk/center/paycenter/internal/cert/alipayPublicCert.crt
Normal file
38
trunk/center/paycenter/internal/cert/alipayPublicCert.crt
Normal file
@ -0,0 +1,38 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDszCCApugAwIBAgIQICMGCYNKwsloIKi8XMlUgzANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE
|
||||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv
|
||||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1
|
||||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjMwNjA5MTI1MjAzWhcNMjQwNjA4MTI1MjAzWjCB
|
||||
hDELMAkGA1UEBhMCQ04xHzAdBgNVBAoMFmxhZ21pczYyNTRAc2FuZGJveC5jb20xDzANBgNVBAsM
|
||||
BkFsaXBheTFDMEEGA1UEAww65pSv5LuY5a6dKOS4reWbvSnnvZHnu5zmioDmnK/mnInpmZDlhazl
|
||||
j7gtMjA4ODcyMTAwMzIzNjQ0MjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJN/z9yl
|
||||
+66sFRDJG2ZWPND6gSsTR7DAeKucCm6SlNimX3w4opVd2z6Rz5tcB2iRyh7nZoq1Vo5+uZSLKaiD
|
||||
IAOEaFNwn9LBLPDH/WgM79BeOygFm9qAYQ8kHGBrR37Sxu6tphgWpVyu0yVlgNvgwdlALX2RCwUW
|
||||
lYbGhe2wpBndxo00lwWXMlwEoYJx/eAu8k69iEW7/kp8HnU3Qih8V76D0bwAcpTvSq8fDIsiRAgQ
|
||||
X0EnAOu0rC/hNTCojFXTKJs5UxEO1tFBALc5huGkTM0qd9C4IIrdcR+xysjloEhN18tC0+/FSm6h
|
||||
kbggE+iE+QAPY6kgGzgX7e4oCRZM/bMCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3
|
||||
DQEBCwUAA4IBAQCcCBpLhvl+6fO21kJvL+FIaWgAoCpLuQGQYS1cX9pn+BNHNL8Ur2i0Se7IkL4z
|
||||
USM4ETULw6RtzoARgIlpSbpSQkZOvyUysOv+ou5rmhUZGtSA2BHwoTHoNWdpmlbps61v7AjQeZTX
|
||||
rhzdJ7ipLutSNsFiQf0TRjshq79wpIFPwsDO68hrDx6QTMlFqW0/uXv7dERDac9uemCBvePeJVrt
|
||||
xhqFXuzE5ZvgtuFXW9pIeXwq7B4xNuwfpXQWdxAPyo2Up//0wJdy90gtfESfO8fCYATPtptnB4lP
|
||||
KHqoqQsuV3xw2P4o/+pmMBgj6hhhoZILLNUJ2Il9PgLEkvkCwRXR
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDszCCApugAwIBAgIQIBkIGbgVxq210KxLJ+YA/TANBgkqhkiG9w0BAQsFADCBhDELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxJTAjBgNVBAsMHENlcnRpZmljYXRpb24gQXV0
|
||||
aG9yaXR5IHRlc3QxNjA0BgNVBAMMLUFudCBGaW5hbmNpYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
|
||||
dHkgUjEgdGVzdDAeFw0xOTA4MTkxMTE2MDBaFw0yNDA4MDExMTE2MDBaMIGRMQswCQYDVQQGEwJD
|
||||
TjEbMBkGA1UECgwSQW50IEZpbmFuY2lhbCB0ZXN0MSUwIwYDVQQLDBxDZXJ0aWZpY2F0aW9uIEF1
|
||||
dGhvcml0eSB0ZXN0MT4wPAYDVQQDDDVBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y
|
||||
aXR5IENsYXNzIDIgUjEgdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMh4FKYO
|
||||
ZyRQHD6eFbPKZeSAnrfjfU7xmS9Yoozuu+iuqZlb6Z0SPLUqqTZAFZejOcmr07ln/pwZxluqplxC
|
||||
5+B48End4nclDMlT5HPrDr3W0frs6Xsa2ZNcyil/iKNB5MbGll8LRAxntsKvZZj6vUTMb705gYgm
|
||||
VUMILwi/ZxKTQqBtkT/kQQ5y6nOZsj7XI5rYdz6qqOROrpvS/d7iypdHOMIM9Iz9DlL1mrCykbBi
|
||||
t25y+gTeXmuisHUwqaRpwtCGK4BayCqxRGbNipe6W73EK9lBrrzNtTr9NaysesT/v+l25JHCL9tG
|
||||
wpNr1oWFzk4IHVOg0ORiQ6SUgxZUTYcCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3
|
||||
DQEBCwUAA4IBAQBWThEoIaQoBX2YeRY/I8gu6TYnFXtyuCljANnXnM38ft+ikhE5mMNgKmJYLHvT
|
||||
yWWWgwHoSAWEuml7EGbE/2AK2h3k0MdfiWLzdmpPCRG/RJHk6UB1pMHPilI+c0MVu16OPpKbg5Vf
|
||||
LTv7dsAB40AzKsvyYw88/Ezi1osTXo6QQwda7uefvudirtb8FcQM9R66cJxl3kt1FXbpYwheIm/p
|
||||
j1mq64swCoIYu4NrsUYtn6CV542DTQMI5QdXkn+PzUUly8F6kDp+KpMNd0avfWNL5+O++z+F5Szy
|
||||
1CPta1D7EQ/eYmMP+mOQ35oifWIoFCpN6qQVBS/Hob1J/UUyg7BW
|
||||
-----END CERTIFICATE-----
|
||||
88
trunk/center/paycenter/internal/cert/alipayRootCert.crt
Normal file
88
trunk/center/paycenter/internal/cert/alipayRootCert.crt
Normal file
@ -0,0 +1,88 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG
|
||||
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw
|
||||
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO
|
||||
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE
|
||||
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT
|
||||
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti
|
||||
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ
|
||||
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b
|
||||
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI
|
||||
pDoiVhsLwg==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIF0zCCA7ugAwIBAgIIH8+hjWpIDREwDQYJKoZIhvcNAQELBQAwejELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmlj
|
||||
YXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmlj
|
||||
YXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMyMTEzNDg0MFoXDTM4MDIyODEzNDg0
|
||||
MFowejELMAkGA1UEBhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNV
|
||||
BAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5j
|
||||
aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMIICIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAg8AMIICCgKCAgEAtytTRcBNuur5h8xuxnlKJetT65cHGemGi8oD+beHFPTk
|
||||
rUTlFt9Xn7fAVGo6QSsPb9uGLpUFGEdGmbsQ2q9cV4P89qkH04VzIPwT7AywJdt2
|
||||
xAvMs+MgHFJzOYfL1QkdOOVO7NwKxH8IvlQgFabWomWk2Ei9WfUyxFjVO1LVh0Bp
|
||||
dRBeWLMkdudx0tl3+21t1apnReFNQ5nfX29xeSxIhesaMHDZFViO/DXDNW2BcTs6
|
||||
vSWKyJ4YIIIzStumD8K1xMsoaZBMDxg4itjWFaKRgNuPiIn4kjDY3kC66Sl/6yTl
|
||||
YUz8AybbEsICZzssdZh7jcNb1VRfk79lgAprm/Ktl+mgrU1gaMGP1OE25JCbqli1
|
||||
Pbw/BpPynyP9+XulE+2mxFwTYhKAwpDIDKuYsFUXuo8t261pCovI1CXFzAQM2w7H
|
||||
DtA2nOXSW6q0jGDJ5+WauH+K8ZSvA6x4sFo4u0KNCx0ROTBpLif6GTngqo3sj+98
|
||||
SZiMNLFMQoQkjkdN5Q5g9N6CFZPVZ6QpO0JcIc7S1le/g9z5iBKnifrKxy0TQjtG
|
||||
PsDwc8ubPnRm/F82RReCoyNyx63indpgFfhN7+KxUIQ9cOwwTvemmor0A+ZQamRe
|
||||
9LMuiEfEaWUDK+6O0Gl8lO571uI5onYdN1VIgOmwFbe+D8TcuzVjIZ/zvHrAGUcC
|
||||
AwEAAaNdMFswCwYDVR0PBAQDAgEGMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFF90
|
||||
tATATwda6uWx2yKjh0GynOEBMB8GA1UdIwQYMBaAFF90tATATwda6uWx2yKjh0Gy
|
||||
nOEBMA0GCSqGSIb3DQEBCwUAA4ICAQCVYaOtqOLIpsrEikE5lb+UARNSFJg6tpkf
|
||||
tJ2U8QF/DejemEHx5IClQu6ajxjtu0Aie4/3UnIXop8nH/Q57l+Wyt9T7N2WPiNq
|
||||
JSlYKYbJpPF8LXbuKYG3BTFTdOVFIeRe2NUyYh/xs6bXGr4WKTXb3qBmzR02FSy3
|
||||
IODQw5Q6zpXj8prYqFHYsOvGCEc1CwJaSaYwRhTkFedJUxiyhyB5GQwoFfExCVHW
|
||||
05ZFCAVYFldCJvUzfzrWubN6wX0DD2dwultgmldOn/W/n8at52mpPNvIdbZb2F41
|
||||
T0YZeoWnCJrYXjq/32oc1cmifIHqySnyMnavi75DxPCdZsCOpSAT4j4lAQRGsfgI
|
||||
kkLPGQieMfNNkMCKh7qjwdXAVtdqhf0RVtFILH3OyEodlk1HYXqX5iE5wlaKzDop
|
||||
PKwf2Q3BErq1xChYGGVS+dEvyXc/2nIBlt7uLWKp4XFjqekKbaGaLJdjYP5b2s7N
|
||||
1dM0MXQ/f8XoXKBkJNzEiM3hfsU6DOREgMc1DIsFKxfuMwX3EkVQM1If8ghb6x5Y
|
||||
jXayv+NLbidOSzk4vl5QwngO/JYFMkoc6i9LNwEaEtR9PhnrdubxmrtM+RjfBm02
|
||||
77q3dSWFESFQ4QxYWew4pHE0DpWbWy/iMIKQ6UZ5RLvB8GEcgt8ON7BBJeMc+Dyi
|
||||
kT9qhqn+lw==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICiDCCAgygAwIBAgIIQX76UsB/30owDAYIKoZIzj0EAwMFADB6MQswCQYDVQQG
|
||||
EwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UECwwXQ2VydGlmaWNh
|
||||
dGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNpYWwgQ2VydGlmaWNh
|
||||
dGlvbiBBdXRob3JpdHkgRTEwHhcNMTkwNDI4MTYyMDQ0WhcNNDkwNDIwMTYyMDQ0
|
||||
WjB6MQswCQYDVQQGEwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNp
|
||||
YWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgRTEwdjAQBgcqhkjOPQIBBgUrgQQA
|
||||
IgNiAASCCRa94QI0vR5Up9Yr9HEupz6hSoyjySYqo7v837KnmjveUIUNiuC9pWAU
|
||||
WP3jwLX3HkzeiNdeg22a0IZPoSUCpasufiLAnfXh6NInLiWBrjLJXDSGaY7vaokt
|
||||
rpZvAdmjXTBbMAsGA1UdDwQEAwIBBjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBRZ
|
||||
4ZTgDpksHL2qcpkFkxD2zVd16TAfBgNVHSMEGDAWgBRZ4ZTgDpksHL2qcpkFkxD2
|
||||
zVd16TAMBggqhkjOPQQDAwUAA2gAMGUCMQD4IoqT2hTUn0jt7oXLdMJ8q4vLp6sg
|
||||
wHfPiOr9gxreb+e6Oidwd2LDnC4OUqCWiF8CMAzwKs4SnDJYcMLf2vpkbuVE4dTH
|
||||
Rglz+HGcTLWsFs4KxLsq7MuU+vJTBUeDJeDjdA==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDxTCCAq2gAwIBAgIUEMdk6dVgOEIS2cCP0Q43P90Ps5YwDQYJKoZIhvcNAQEF
|
||||
BQAwajELMAkGA1UEBhMCQ04xEzARBgNVBAoMCmlUcnVzQ2hpbmExHDAaBgNVBAsM
|
||||
E0NoaW5hIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMMH2lUcnVzQ2hpbmEgQ2xhc3Mg
|
||||
MiBSb290IENBIC0gRzMwHhcNMTMwNDE4MDkzNjU2WhcNMzMwNDE4MDkzNjU2WjBq
|
||||
MQswCQYDVQQGEwJDTjETMBEGA1UECgwKaVRydXNDaGluYTEcMBoGA1UECwwTQ2hp
|
||||
bmEgVHJ1c3QgTmV0d29yazEoMCYGA1UEAwwfaVRydXNDaGluYSBDbGFzcyAyIFJv
|
||||
b3QgQ0EgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOPPShpV
|
||||
nJbMqqCw6Bz1kehnoPst9pkr0V9idOwU2oyS47/HjJXk9Rd5a9xfwkPO88trUpz5
|
||||
4GmmwspDXjVFu9L0eFaRuH3KMha1Ak01citbF7cQLJlS7XI+tpkTGHEY5pt3EsQg
|
||||
wykfZl/A1jrnSkspMS997r2Gim54cwz+mTMgDRhZsKK/lbOeBPpWtcFizjXYCqhw
|
||||
WktvQfZBYi6o4sHCshnOswi4yV1p+LuFcQ2ciYdWvULh1eZhLxHbGXyznYHi0dGN
|
||||
z+I9H8aXxqAQfHVhbdHNzi77hCxFjOy+hHrGsyzjrd2swVQ2iUWP8BfEQqGLqM1g
|
||||
KgWKYfcTGdbPB1MCAwEAAaNjMGEwHQYDVR0OBBYEFG/oAMxTVe7y0+408CTAK8hA
|
||||
uTyRMB8GA1UdIwQYMBaAFG/oAMxTVe7y0+408CTAK8hAuTyRMA8GA1UdEwEB/wQF
|
||||
MAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBLnUTfW7hp
|
||||
emMbuUGCk7RBswzOT83bDM6824EkUnf+X0iKS95SUNGeeSWK2o/3ALJo5hi7GZr3
|
||||
U8eLaWAcYizfO99UXMRBPw5PRR+gXGEronGUugLpxsjuynoLQu8GQAeysSXKbN1I
|
||||
UugDo9u8igJORYA+5ms0s5sCUySqbQ2R5z/GoceyI9LdxIVa1RjVX8pYOj8JFwtn
|
||||
DJN3ftSFvNMYwRuILKuqUYSHc2GPYiHVflDh5nDymCMOQFcFG3WsEuB+EYQPFgIU
|
||||
1DHmdZcz7Llx8UOZXX2JupWCYzK1XhJb+r4hK5ncf/w8qGtYlmyJpxk3hr1TfUJX
|
||||
Yf4Zr0fJsGuv
|
||||
-----END CERTIFICATE-----
|
||||
19
trunk/center/paycenter/internal/cert/appPublicCert.crt
Normal file
19
trunk/center/paycenter/internal/cert/appPublicCert.crt
Normal file
@ -0,0 +1,19 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDmTCCAoGgAwIBAgIQICMGCXK2Am4QGbc/5Yi2QjANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE
|
||||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv
|
||||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1
|
||||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjMwNjA5MTI1MjAyWhcNMjQwNjEzMTI1MjAyWjBr
|
||||
MQswCQYDVQQGEwJDTjEfMB0GA1UECgwWbGFnbWlzNjI1NEBzYW5kYm94LmNvbTEPMA0GA1UECwwG
|
||||
QWxpcGF5MSowKAYDVQQDDCEyMDg4NzIxMDAzMjM2NDQyLTIwMjEwMDAxMjI2NzIzODgwggEiMA0G
|
||||
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDTHpBfR55b5dE2Hi78EbVGzK5hiweap6eTgas9XwS
|
||||
WtQQ3qctHBJcZIgi4i7IKjS3izAI2n1DniD4BSakB114EJiEcqsBgbifXUyddRiiwR7jfDNSF3s9
|
||||
penFy0WVIqEWBgGJftxCD87xOEcknQfRDL6T000naAyd8/KmT3/jcOy0eYoRVC+BClyCeGVsrxfi
|
||||
2EgrjNbTHAeAOFIB5m71Au9/9xzY90qZ3nGJRQzsns+3BPtW9sojbt9g4F7WHHGu+ljq9wYYZqXz
|
||||
GE04oP56KpcCA+AhFi5eouk+Bpg4iaOecf2UinOOsI7SextrVPi2icOOnmO/QVpIrA5MCM7pAgMB
|
||||
AAGjEjAQMA4GA1UdDwEB/wQEAwIE8DANBgkqhkiG9w0BAQsFAAOCAQEAZc2RyiGKftnKi/0zIUUl
|
||||
xKDPyUdVBBYDagcraHROKXafsZEnhO/cdBPC3VAJEiygNvddB51l088cGb8pGS2VqTQqR/Ehmd1x
|
||||
kLMleWlUocX0Mwctz/J6jNp9/JKcVe1jk492HR7Csqjf+hvsajIVliIWzuhzB7C0eNEb46Js/G8T
|
||||
QmsX92eHI0r2pcmsVr+PmDioLu4H4miKrDRhXNXLQ2AQfxPOCOtxt0tSNrB97bDNSwB1O4OItmr/
|
||||
Cimb7l1nqxY3BOY5o8iAWLv4wG4giYu9LSrEJW0nWa2JG059kMlWLSVe7Afx0GzMVQUP6NJNdulP
|
||||
ddebveu2CNZcJ7ipbA==
|
||||
-----END CERTIFICATE-----
|
||||
162
trunk/center/paycenter/internal/cert/cert.go
Normal file
162
trunk/center/paycenter/internal/cert/cert.go
Normal file
@ -0,0 +1,162 @@
|
||||
package cert
|
||||
|
||||
var (
|
||||
Appid = "2021000122672388"
|
||||
|
||||
// 应用私钥
|
||||
PrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3DCgphWsp4OyB5pxF7ImUHHC7luATNfACFiK9qCvMRX1Ot0j4Ll64HUwVWaTfYbS00QyWPZLxwmGIAvh0y+9odu699oAb047p1XG1Q5eQa4qYrlxKGDeGUdWjK0C8qqeVHMAa8FK3xGukPYNersUbQ5E/eQqD7o6m51xR8AzhZ1lwWdW6PPAN51sH9o/MSvGZTmYAOWsErhSKZ0Eb613oG/rfxrvuBH3tFAqHva/cjNPznukieWCHrD5OUXlM48MEK2Ht8rFXs2HG6ZDdMNUMJuz15H5HQ3Plt1KYLy6b6Y6a7NtE1VWGvlmhT1Quzeudkb4lyYMC7DBCE4cZtMBlAgMBAAECggEAAfjNjfTz/JWBtryHPnGX4dKUnFC5xTs1hLA8W5KuNhshiHGNBa9qMc2O/kPi9M0Wp0QBQLUVGimf51kw2AFCaPuvArjfFG2pAnfcK7m4rkOaUJ7AO8QbBQVoqcNThTTJbV/L6f5gxb4F8tT+z0xOr0aBEA/7vwQY4U9ovTE60krIDbd3hE2Eh8RdrKebLrUvvGZ2LPFF3suuGbHHhQwRIzF8Enfa5TjyEJxGz3C3cdCEDjhA/tbMh05egeDhu1qu+Nx1FXzcyc/bFTKF2qPXeE27rclw8U07wggiegHPntJJ9Fgso918f0n8URlzhwpRQ5EjbBNOiVjkKGxQD0rLGQKBgQDl81Jk1iw2WWMuBxZKtxy43sXKjWY8umhrhK0gDjfRXokppCf91+tC3t/7BEc+X8HuAEYCuPs+tnv0XYdhfOeBpy/GHB7NQqYqCiu3Ptm3KnIm/q+CnnPA1HY7222Sa/9NptbfOfrPIlINnglAwjpZ2tn5h0uNvZfMP4Yh+x6aTwKBgQDLyKADd6Iw5jshwVF2SIlv/qHH5w8UKFmkLDT5l6RAqIg0mqY5tPpOEm5JohfYRmp9+ny4U8+V0CNNehN7FLreLJm5ksDvcOuIlEXPCzuEzyO8tkHFuW1pXLcdNnzZmdQ3S8o0mDllegEbwV0OK10RcJ96NRJnngNYp7rohrUxCwKBgHAvHmJtjpJRV66r7Hc1EIEsxehExb0Y4DqcNu4toZO2gEpdeNlBztgH7dQDyVIn22/mmEFZx9FXq++S9apdCoDZdNg8/dX8Dx7xaVR0CDlxLtHRbQTXkvdfb/NR4QoPQDW9EJVFLxSA1PEpya/bUiZmO/OdywFynq0ZzLGlVs/HAoGBALyLV2Fd4vaTTcqhbpmd62tvkIfARLdFzgqTzD/SCeq5A6yIGZvy0lRBwUDndGBqZkVA6PwyrzHRbZhVhoiuWWcOpPyJx3DCbWnkpeI2Zk8ux8Xma1xhf9WoLtQcgc9jAHJY8TFQVmqJQ1VGxq5BeM6WATe0ut6b2ETCi7BwUlyZAoGAV4kL7eiV2rcHa8IROWh8oo+8fgPMb5MSmbU78n/o4tXRTdUmg/6ghE1t9dWK867/PEubVFEvO8F15oQvwLHYdD+SPeLmp/CLf20jzNSjkImFxMG7xmnpre5+sfgIGjioI1rFkwrVk7II7GfvmGpDTbOSLWeiymdFsmmPnjs8I5Q="
|
||||
|
||||
PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtwwoKYVrKeDsgeacReyJlBxwu5bgEzXwAhYivagrzEV9TrdI+C5euB1MFVmk32G0tNEMlj2S8cJhiAL4dMvvaHbuvfaAG9OO6dVxtUOXkGuKmK5cShg3hlHVoytAvKqnlRzAGvBSt8RrpD2DXq7FG0ORP3kKg+6OpudcUfAM4WdZcFnVujzwDedbB/aPzErxmU5mADlrBK4UimdBG+td6Bv638a77gR97RQKh72v3IzT857pInlgh6w+TlF5TOPDBCth7fKxV7NhxumQ3TDVDCbs9eR+R0Nz5bdSmC8um+mOmuzbRNVVhr5ZoU9ULs3rnZG+JcmDAuwwQhOHGbTAZQIDAQAB"
|
||||
|
||||
// 支付宝公钥证书
|
||||
AlipayPublicContentRSA2 = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIIDszCCApugAwIBAgIQICMGCYNKwsloIKi8XMlUgzANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE
|
||||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv
|
||||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1
|
||||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjMwNjA5MTI1MjAzWhcNMjQwNjA4MTI1MjAzWjCB
|
||||
hDELMAkGA1UEBhMCQ04xHzAdBgNVBAoMFmxhZ21pczYyNTRAc2FuZGJveC5jb20xDzANBgNVBAsM
|
||||
BkFsaXBheTFDMEEGA1UEAww65pSv5LuY5a6dKOS4reWbvSnnvZHnu5zmioDmnK/mnInpmZDlhazl
|
||||
j7gtMjA4ODcyMTAwMzIzNjQ0MjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJN/z9yl
|
||||
+66sFRDJG2ZWPND6gSsTR7DAeKucCm6SlNimX3w4opVd2z6Rz5tcB2iRyh7nZoq1Vo5+uZSLKaiD
|
||||
IAOEaFNwn9LBLPDH/WgM79BeOygFm9qAYQ8kHGBrR37Sxu6tphgWpVyu0yVlgNvgwdlALX2RCwUW
|
||||
lYbGhe2wpBndxo00lwWXMlwEoYJx/eAu8k69iEW7/kp8HnU3Qih8V76D0bwAcpTvSq8fDIsiRAgQ
|
||||
X0EnAOu0rC/hNTCojFXTKJs5UxEO1tFBALc5huGkTM0qd9C4IIrdcR+xysjloEhN18tC0+/FSm6h
|
||||
kbggE+iE+QAPY6kgGzgX7e4oCRZM/bMCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3
|
||||
DQEBCwUAA4IBAQCcCBpLhvl+6fO21kJvL+FIaWgAoCpLuQGQYS1cX9pn+BNHNL8Ur2i0Se7IkL4z
|
||||
USM4ETULw6RtzoARgIlpSbpSQkZOvyUysOv+ou5rmhUZGtSA2BHwoTHoNWdpmlbps61v7AjQeZTX
|
||||
rhzdJ7ipLutSNsFiQf0TRjshq79wpIFPwsDO68hrDx6QTMlFqW0/uXv7dERDac9uemCBvePeJVrt
|
||||
xhqFXuzE5ZvgtuFXW9pIeXwq7B4xNuwfpXQWdxAPyo2Up//0wJdy90gtfESfO8fCYATPtptnB4lP
|
||||
KHqoqQsuV3xw2P4o/+pmMBgj6hhhoZILLNUJ2Il9PgLEkvkCwRXR
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDszCCApugAwIBAgIQIBkIGbgVxq210KxLJ+YA/TANBgkqhkiG9w0BAQsFADCBhDELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxJTAjBgNVBAsMHENlcnRpZmljYXRpb24gQXV0
|
||||
aG9yaXR5IHRlc3QxNjA0BgNVBAMMLUFudCBGaW5hbmNpYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
|
||||
dHkgUjEgdGVzdDAeFw0xOTA4MTkxMTE2MDBaFw0yNDA4MDExMTE2MDBaMIGRMQswCQYDVQQGEwJD
|
||||
TjEbMBkGA1UECgwSQW50IEZpbmFuY2lhbCB0ZXN0MSUwIwYDVQQLDBxDZXJ0aWZpY2F0aW9uIEF1
|
||||
dGhvcml0eSB0ZXN0MT4wPAYDVQQDDDVBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y
|
||||
aXR5IENsYXNzIDIgUjEgdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMh4FKYO
|
||||
ZyRQHD6eFbPKZeSAnrfjfU7xmS9Yoozuu+iuqZlb6Z0SPLUqqTZAFZejOcmr07ln/pwZxluqplxC
|
||||
5+B48End4nclDMlT5HPrDr3W0frs6Xsa2ZNcyil/iKNB5MbGll8LRAxntsKvZZj6vUTMb705gYgm
|
||||
VUMILwi/ZxKTQqBtkT/kQQ5y6nOZsj7XI5rYdz6qqOROrpvS/d7iypdHOMIM9Iz9DlL1mrCykbBi
|
||||
t25y+gTeXmuisHUwqaRpwtCGK4BayCqxRGbNipe6W73EK9lBrrzNtTr9NaysesT/v+l25JHCL9tG
|
||||
wpNr1oWFzk4IHVOg0ORiQ6SUgxZUTYcCAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgTwMA0GCSqGSIb3
|
||||
DQEBCwUAA4IBAQBWThEoIaQoBX2YeRY/I8gu6TYnFXtyuCljANnXnM38ft+ikhE5mMNgKmJYLHvT
|
||||
yWWWgwHoSAWEuml7EGbE/2AK2h3k0MdfiWLzdmpPCRG/RJHk6UB1pMHPilI+c0MVu16OPpKbg5Vf
|
||||
LTv7dsAB40AzKsvyYw88/Ezi1osTXo6QQwda7uefvudirtb8FcQM9R66cJxl3kt1FXbpYwheIm/p
|
||||
j1mq64swCoIYu4NrsUYtn6CV542DTQMI5QdXkn+PzUUly8F6kDp+KpMNd0avfWNL5+O++z+F5Szy
|
||||
1CPta1D7EQ/eYmMP+mOQ35oifWIoFCpN6qQVBS/Hob1J/UUyg7BW
|
||||
-----END CERTIFICATE-----
|
||||
`)
|
||||
|
||||
// 支付宝根证书
|
||||
AlipayRootContent = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG
|
||||
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw
|
||||
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO
|
||||
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE
|
||||
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT
|
||||
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti
|
||||
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ
|
||||
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b
|
||||
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI
|
||||
pDoiVhsLwg==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIF0zCCA7ugAwIBAgIIH8+hjWpIDREwDQYJKoZIhvcNAQELBQAwejELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmlj
|
||||
YXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmlj
|
||||
YXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMyMTEzNDg0MFoXDTM4MDIyODEzNDg0
|
||||
MFowejELMAkGA1UEBhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNV
|
||||
BAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5j
|
||||
aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMIICIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAg8AMIICCgKCAgEAtytTRcBNuur5h8xuxnlKJetT65cHGemGi8oD+beHFPTk
|
||||
rUTlFt9Xn7fAVGo6QSsPb9uGLpUFGEdGmbsQ2q9cV4P89qkH04VzIPwT7AywJdt2
|
||||
xAvMs+MgHFJzOYfL1QkdOOVO7NwKxH8IvlQgFabWomWk2Ei9WfUyxFjVO1LVh0Bp
|
||||
dRBeWLMkdudx0tl3+21t1apnReFNQ5nfX29xeSxIhesaMHDZFViO/DXDNW2BcTs6
|
||||
vSWKyJ4YIIIzStumD8K1xMsoaZBMDxg4itjWFaKRgNuPiIn4kjDY3kC66Sl/6yTl
|
||||
YUz8AybbEsICZzssdZh7jcNb1VRfk79lgAprm/Ktl+mgrU1gaMGP1OE25JCbqli1
|
||||
Pbw/BpPynyP9+XulE+2mxFwTYhKAwpDIDKuYsFUXuo8t261pCovI1CXFzAQM2w7H
|
||||
DtA2nOXSW6q0jGDJ5+WauH+K8ZSvA6x4sFo4u0KNCx0ROTBpLif6GTngqo3sj+98
|
||||
SZiMNLFMQoQkjkdN5Q5g9N6CFZPVZ6QpO0JcIc7S1le/g9z5iBKnifrKxy0TQjtG
|
||||
PsDwc8ubPnRm/F82RReCoyNyx63indpgFfhN7+KxUIQ9cOwwTvemmor0A+ZQamRe
|
||||
9LMuiEfEaWUDK+6O0Gl8lO571uI5onYdN1VIgOmwFbe+D8TcuzVjIZ/zvHrAGUcC
|
||||
AwEAAaNdMFswCwYDVR0PBAQDAgEGMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFF90
|
||||
tATATwda6uWx2yKjh0GynOEBMB8GA1UdIwQYMBaAFF90tATATwda6uWx2yKjh0Gy
|
||||
nOEBMA0GCSqGSIb3DQEBCwUAA4ICAQCVYaOtqOLIpsrEikE5lb+UARNSFJg6tpkf
|
||||
tJ2U8QF/DejemEHx5IClQu6ajxjtu0Aie4/3UnIXop8nH/Q57l+Wyt9T7N2WPiNq
|
||||
JSlYKYbJpPF8LXbuKYG3BTFTdOVFIeRe2NUyYh/xs6bXGr4WKTXb3qBmzR02FSy3
|
||||
IODQw5Q6zpXj8prYqFHYsOvGCEc1CwJaSaYwRhTkFedJUxiyhyB5GQwoFfExCVHW
|
||||
05ZFCAVYFldCJvUzfzrWubN6wX0DD2dwultgmldOn/W/n8at52mpPNvIdbZb2F41
|
||||
T0YZeoWnCJrYXjq/32oc1cmifIHqySnyMnavi75DxPCdZsCOpSAT4j4lAQRGsfgI
|
||||
kkLPGQieMfNNkMCKh7qjwdXAVtdqhf0RVtFILH3OyEodlk1HYXqX5iE5wlaKzDop
|
||||
PKwf2Q3BErq1xChYGGVS+dEvyXc/2nIBlt7uLWKp4XFjqekKbaGaLJdjYP5b2s7N
|
||||
1dM0MXQ/f8XoXKBkJNzEiM3hfsU6DOREgMc1DIsFKxfuMwX3EkVQM1If8ghb6x5Y
|
||||
jXayv+NLbidOSzk4vl5QwngO/JYFMkoc6i9LNwEaEtR9PhnrdubxmrtM+RjfBm02
|
||||
77q3dSWFESFQ4QxYWew4pHE0DpWbWy/iMIKQ6UZ5RLvB8GEcgt8ON7BBJeMc+Dyi
|
||||
kT9qhqn+lw==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICiDCCAgygAwIBAgIIQX76UsB/30owDAYIKoZIzj0EAwMFADB6MQswCQYDVQQG
|
||||
EwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UECwwXQ2VydGlmaWNh
|
||||
dGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNpYWwgQ2VydGlmaWNh
|
||||
dGlvbiBBdXRob3JpdHkgRTEwHhcNMTkwNDI4MTYyMDQ0WhcNNDkwNDIwMTYyMDQ0
|
||||
WjB6MQswCQYDVQQGEwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNp
|
||||
YWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgRTEwdjAQBgcqhkjOPQIBBgUrgQQA
|
||||
IgNiAASCCRa94QI0vR5Up9Yr9HEupz6hSoyjySYqo7v837KnmjveUIUNiuC9pWAU
|
||||
WP3jwLX3HkzeiNdeg22a0IZPoSUCpasufiLAnfXh6NInLiWBrjLJXDSGaY7vaokt
|
||||
rpZvAdmjXTBbMAsGA1UdDwQEAwIBBjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBRZ
|
||||
4ZTgDpksHL2qcpkFkxD2zVd16TAfBgNVHSMEGDAWgBRZ4ZTgDpksHL2qcpkFkxD2
|
||||
zVd16TAMBggqhkjOPQQDAwUAA2gAMGUCMQD4IoqT2hTUn0jt7oXLdMJ8q4vLp6sg
|
||||
wHfPiOr9gxreb+e6Oidwd2LDnC4OUqCWiF8CMAzwKs4SnDJYcMLf2vpkbuVE4dTH
|
||||
Rglz+HGcTLWsFs4KxLsq7MuU+vJTBUeDJeDjdA==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDxTCCAq2gAwIBAgIUEMdk6dVgOEIS2cCP0Q43P90Ps5YwDQYJKoZIhvcNAQEF
|
||||
BQAwajELMAkGA1UEBhMCQ04xEzARBgNVBAoMCmlUcnVzQ2hpbmExHDAaBgNVBAsM
|
||||
E0NoaW5hIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMMH2lUcnVzQ2hpbmEgQ2xhc3Mg
|
||||
MiBSb290IENBIC0gRzMwHhcNMTMwNDE4MDkzNjU2WhcNMzMwNDE4MDkzNjU2WjBq
|
||||
MQswCQYDVQQGEwJDTjETMBEGA1UECgwKaVRydXNDaGluYTEcMBoGA1UECwwTQ2hp
|
||||
bmEgVHJ1c3QgTmV0d29yazEoMCYGA1UEAwwfaVRydXNDaGluYSBDbGFzcyAyIFJv
|
||||
b3QgQ0EgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOPPShpV
|
||||
nJbMqqCw6Bz1kehnoPst9pkr0V9idOwU2oyS47/HjJXk9Rd5a9xfwkPO88trUpz5
|
||||
4GmmwspDXjVFu9L0eFaRuH3KMha1Ak01citbF7cQLJlS7XI+tpkTGHEY5pt3EsQg
|
||||
wykfZl/A1jrnSkspMS997r2Gim54cwz+mTMgDRhZsKK/lbOeBPpWtcFizjXYCqhw
|
||||
WktvQfZBYi6o4sHCshnOswi4yV1p+LuFcQ2ciYdWvULh1eZhLxHbGXyznYHi0dGN
|
||||
z+I9H8aXxqAQfHVhbdHNzi77hCxFjOy+hHrGsyzjrd2swVQ2iUWP8BfEQqGLqM1g
|
||||
KgWKYfcTGdbPB1MCAwEAAaNjMGEwHQYDVR0OBBYEFG/oAMxTVe7y0+408CTAK8hA
|
||||
uTyRMB8GA1UdIwQYMBaAFG/oAMxTVe7y0+408CTAK8hAuTyRMA8GA1UdEwEB/wQF
|
||||
MAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBLnUTfW7hp
|
||||
emMbuUGCk7RBswzOT83bDM6824EkUnf+X0iKS95SUNGeeSWK2o/3ALJo5hi7GZr3
|
||||
U8eLaWAcYizfO99UXMRBPw5PRR+gXGEronGUugLpxsjuynoLQu8GQAeysSXKbN1I
|
||||
UugDo9u8igJORYA+5ms0s5sCUySqbQ2R5z/GoceyI9LdxIVa1RjVX8pYOj8JFwtn
|
||||
DJN3ftSFvNMYwRuILKuqUYSHc2GPYiHVflDh5nDymCMOQFcFG3WsEuB+EYQPFgIU
|
||||
1DHmdZcz7Llx8UOZXX2JupWCYzK1XhJb+r4hK5ncf/w8qGtYlmyJpxk3hr1TfUJX
|
||||
Yf4Zr0fJsGuv
|
||||
-----END CERTIFICATE-----`)
|
||||
|
||||
// 应用公钥证书
|
||||
AppPublicContent = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIIDmTCCAoGgAwIBAgIQICQJJiIfTmxJDlWhVlLYPjANBgkqhkiG9w0BAQsFADCBkTELMAkGA1UE
|
||||
BhMCQ04xGzAZBgNVBAoMEkFudCBGaW5hbmNpYWwgdGVzdDElMCMGA1UECwwcQ2VydGlmaWNhdGlv
|
||||
biBBdXRob3JpdHkgdGVzdDE+MDwGA1UEAww1QW50IEZpbmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1
|
||||
dGhvcml0eSBDbGFzcyAyIFIxIHRlc3QwHhcNMjQwOTI2MTU0ODExWhcNMjUxMDAxMTU0ODExWjBr
|
||||
MQswCQYDVQQGEwJDTjEfMB0GA1UECgwWbGFnbWlzNjI1NEBzYW5kYm94LmNvbTEPMA0GA1UECwwG
|
||||
QWxpcGF5MSowKAYDVQQDDCEyMDg4NzIxMDAzMjM2NDQyLTIwMjEwMDAxMjI2NzIzODgwggEiMA0G
|
||||
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3DCgphWsp4OyB5pxF7ImUHHC7luATNfACFiK9qCvM
|
||||
RX1Ot0j4Ll64HUwVWaTfYbS00QyWPZLxwmGIAvh0y+9odu699oAb047p1XG1Q5eQa4qYrlxKGDeG
|
||||
UdWjK0C8qqeVHMAa8FK3xGukPYNersUbQ5E/eQqD7o6m51xR8AzhZ1lwWdW6PPAN51sH9o/MSvGZ
|
||||
TmYAOWsErhSKZ0Eb613oG/rfxrvuBH3tFAqHva/cjNPznukieWCHrD5OUXlM48MEK2Ht8rFXs2HG
|
||||
6ZDdMNUMJuz15H5HQ3Plt1KYLy6b6Y6a7NtE1VWGvlmhT1Quzeudkb4lyYMC7DBCE4cZtMBlAgMB
|
||||
AAGjEjAQMA4GA1UdDwEB/wQEAwIE8DANBgkqhkiG9w0BAQsFAAOCAQEAeMqluNI07JunRvkeOdN3
|
||||
u4l1EicBtaMA63h6Ico92YanIgAzvZY9etwBiCP9ULmqckw+jo6+taXERe3fXSoUqyCH+3Hnb30f
|
||||
MHp+oHlmpxCG93GLYBe9QcugrbEKg7RJ1l8ikyXMt3nkxBcQochCuNxdhGGYM4rxlGtwU1j0v+CV
|
||||
Ne4IsK8fbpMF8wfYGOwDb+P1Mqx2Hv1D0qLu4S2ztz+br8Opg5leGY8wMt9+mW5aKwEKX3FVDi5J
|
||||
ijiKYWzTm718zrmMJ+sN2VrapDvtj92bibOt0PKXUtQ5I++RtjG//dRpjAg9aS5pjvui80tNtwAc
|
||||
xaEqw58KZ41dIaw3Zw==
|
||||
-----END CERTIFICATE-----`)
|
||||
)
|
||||
9
trunk/center/paycenter/internal/internal.go
Normal file
9
trunk/center/paycenter/internal/internal.go
Normal file
@ -0,0 +1,9 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
_ "paycenter/internal/alipay"
|
||||
_ "paycenter/internal/cert"
|
||||
_ "paycenter/internal/mesqueue"
|
||||
_ "paycenter/internal/pay"
|
||||
_ "paycenter/internal/wxpay"
|
||||
)
|
||||
123
trunk/center/paycenter/internal/mesqueue/game_msg.go
Normal file
123
trunk/center/paycenter/internal/mesqueue/game_msg.go
Normal file
@ -0,0 +1,123 @@
|
||||
package mesqueue
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"goutil/fileUtil"
|
||||
"goutil/logUtilPlus"
|
||||
"goutil/webUtil"
|
||||
"time"
|
||||
)
|
||||
|
||||
type GameMsg struct {
|
||||
|
||||
//订单id
|
||||
OrderID int64
|
||||
|
||||
//玩家id
|
||||
PlayerID string
|
||||
|
||||
//区服id
|
||||
ServerID int64
|
||||
|
||||
//游戏id
|
||||
GameId string
|
||||
|
||||
//充值金额
|
||||
price int64
|
||||
|
||||
// 充值商品id
|
||||
storeId int64
|
||||
|
||||
// 推送次数
|
||||
pushCount int32
|
||||
}
|
||||
|
||||
var (
|
||||
//消息队列
|
||||
msgQueue = make(chan GameMsg, 100)
|
||||
|
||||
fileName = "ErrPushMsg"
|
||||
)
|
||||
|
||||
func init() {
|
||||
go ConsumeQueue()
|
||||
}
|
||||
|
||||
// AddQueue 添加消息队列
|
||||
func AddQueue(gameMsg GameMsg) {
|
||||
msgQueue <- gameMsg
|
||||
}
|
||||
|
||||
// ConsumeQueue 消费消息队列
|
||||
func ConsumeQueue() {
|
||||
//捕获异常
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
//TODO 捕获异常
|
||||
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||
|
||||
//重新开启
|
||||
restartConsumer()
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
gameMsg := <-msgQueue
|
||||
|
||||
url := fmt.Sprintf("http://www.game.com/pay %s", gameMsg.GameId)
|
||||
|
||||
//消费消息队列 推送重置信息到game
|
||||
result, err := webUtil.GetWebData(url, map[string]string{})
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||
|
||||
//放入消息队列重新推送
|
||||
if gameMsg.pushCount < 3 {
|
||||
msgQueue <- gameMsg
|
||||
gameMsg.pushCount++
|
||||
} else { //加入文件放弃推送
|
||||
WriteErrPushMsg(url)
|
||||
}
|
||||
}
|
||||
|
||||
if string(result) != "" {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WriteErrPushMsg 推送异常消息 写入文件
|
||||
func WriteErrPushMsg(messages string) {
|
||||
|
||||
//文件名拼接
|
||||
filePath := fileName + "/" + time.Now().Format("2006-01-02")
|
||||
fileName := time.Now().Format("2006-01-02 09") + ".txt"
|
||||
|
||||
//消息 添加换行符
|
||||
messages += ";\r\n"
|
||||
err := fileUtil.WriteFile(filePath, fileName, true, messages)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog(" MegPush 写入文件失败 err:%s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// restartConsumer 重启消费者
|
||||
func restartConsumer() {
|
||||
// 设置重试次数
|
||||
maxRetries := 5
|
||||
retryCount := 0
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-time.After(5 * time.Second): // 等待5秒后重试
|
||||
if retryCount >= maxRetries {
|
||||
logUtilPlus.ErrorLog("消费者重启失败,达到最大重试次数")
|
||||
return
|
||||
}
|
||||
logUtilPlus.InfoLog("重新启动消费者,重试次数: %d", retryCount+1)
|
||||
go ConsumeQueue()
|
||||
return
|
||||
}
|
||||
retryCount++
|
||||
}
|
||||
}
|
||||
252
trunk/center/paycenter/internal/pay.go
Normal file
252
trunk/center/paycenter/internal/pay.go
Normal file
@ -0,0 +1,252 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/app"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/utils"
|
||||
"goutil/logUtilPlus"
|
||||
"log"
|
||||
_ "paycenter/internal/pay"
|
||||
"paycenter/internal/wxpaycofnig"
|
||||
_ "paycenter/internal/wxpaycofnig"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
mchID string = wxpaycofnig.GetWxPayConfig().MchID // 商户号
|
||||
mchCertificateSerialNumber string = wxpaycofnig.GetWxPayConfig().MchCertificateSerialNumber // 商户证书序列号
|
||||
mchAPIv3Key string = wxpaycofnig.GetWxPayConfig().MchAPIv3Key // 商户APIv3密钥
|
||||
appId string = wxpaycofnig.GetWxPayConfig().AppId // 应用ID
|
||||
Address string = "成都市XXXXXXXXXXXXXXXXXXXXXXX" //公司地址
|
||||
wxPayApiUrl string = wxpaycofnig.GetWxPayConfig().NotifyUrl //支付成功回调地址
|
||||
)
|
||||
|
||||
// Prepay 函数用于发起预支付请求。
|
||||
// 参数:
|
||||
//
|
||||
// outTradeNo: 商户订单号。
|
||||
// currency: 订单金额,单位为分。
|
||||
// storeId: 商户门店编号。
|
||||
// clientIp: 用户的客户端IP。
|
||||
// description: 订单描述。
|
||||
//
|
||||
// 返回值:
|
||||
//
|
||||
// 成功时返回预支付ID和nil错误。
|
||||
// 失败时返回空字符串和错误对象。
|
||||
func Prepay(outTradeNo int64, currency int64, storeId string, clientIp string, description string) (string, error) {
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("load merchant private key error")
|
||||
return "", err
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("new wechat pay client err:%s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
resp, result, err := svc.Prepay(ctx,
|
||||
app.PrepayRequest{
|
||||
Appid: core.String(appId),
|
||||
Mchid: core.String(mchID),
|
||||
Description: core.String(description),
|
||||
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||
TimeExpire: core.Time(time.Now().Add(time.Hour * 2)), //支付时效时间 2 小时后失效
|
||||
Attach: core.String(""), //附加数据 这里不需要,有个订单id 可以获取订单详细信息
|
||||
NotifyUrl: core.String(fmt.Sprintf(wxPayApiUrl, strconv.FormatInt(outTradeNo, 10))), //回调地址
|
||||
//GoodsTag: core.String("WXG"),//优惠标记 这里没用
|
||||
//LimitPay: []string{"LimitPay_example"},
|
||||
SupportFapiao: core.Bool(false),
|
||||
Amount: &app.Amount{
|
||||
Currency: core.String("CNY"),
|
||||
Total: core.Int64(currency),
|
||||
},
|
||||
Detail: &app.Detail{
|
||||
//CostPrice: core.Int64(608800),
|
||||
GoodsDetail: []app.GoodsDetail{app.GoodsDetail{
|
||||
GoodsName: core.String(storeId), //商品编号
|
||||
MerchantGoodsId: core.String(description),
|
||||
Quantity: core.Int64(1),
|
||||
UnitPrice: core.Int64(currency),
|
||||
//WechatpayGoodsId: core.String("1001"),
|
||||
}},
|
||||
//InvoiceId: core.String("wx123"),
|
||||
},
|
||||
SceneInfo: &app.SceneInfo{
|
||||
//DeviceId: core.String("013467007045764"),
|
||||
PayerClientIp: core.String(clientIp),
|
||||
StoreInfo: &app.StoreInfo{
|
||||
Address: core.String(Address),
|
||||
//AreaCode: core.String("440305"),
|
||||
//Id: core.String("0001"),
|
||||
//Name: core.String("腾讯大厦分店"),
|
||||
},
|
||||
},
|
||||
SettleInfo: &app.SettleInfo{
|
||||
ProfitSharing: core.Bool(false),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
logUtilPlus.ErrorLog("call Prepay err:%s", err.Error())
|
||||
return "", err
|
||||
}
|
||||
|
||||
if result.Response.StatusCode != 200 {
|
||||
errStr := fmt.Sprintf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||
logUtilPlus.ErrorLog(errStr)
|
||||
return "", errors.New(errStr)
|
||||
}
|
||||
|
||||
return *resp.PrepayId, nil
|
||||
}
|
||||
|
||||
// CloseOrder 关闭订单
|
||||
func CloseOrder(outTradeNo int64) error {
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
log.Print("加载商家私钥错误")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
log.Printf("新的 WeChat Pay 客户端 Err:%s", err)
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
_, err = svc.CloseOrder(ctx,
|
||||
app.CloseOrderRequest{
|
||||
|
||||
//商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯
|
||||
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||
|
||||
//直连商户的商户号,由微信支付生成并下发。
|
||||
Mchid: core.String(mchID),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
logUtilPlus.ErrorLog("call CloseOrder err:%s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryOrderById 根据商户订单号查询订单
|
||||
func QueryOrderById() {
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
log.Print("load merchant private key error")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
log.Printf("new wechat pay client err:%s", err)
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
resp, result, err := svc.QueryOrderById(ctx,
|
||||
app.QueryOrderByIdRequest{
|
||||
TransactionId: core.String("TransactionId_example"),
|
||||
Mchid: core.String("Mchid_example"),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
log.Printf("call QueryOrderById err:%s", err)
|
||||
} else {
|
||||
// 处理返回结果
|
||||
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||
}
|
||||
}
|
||||
|
||||
// QueryOrderByOutTradeNo 根据商户订单号查询订单
|
||||
func QueryOrderByOutTradeNo(outTradeNo int64) (string, error) {
|
||||
|
||||
//循环查询次数
|
||||
var count int = 0
|
||||
|
||||
loop:
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
log.Print("load merchant private key error")
|
||||
return "", err
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
log.Printf("new wechat pay client err:%s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
resp, result, err := svc.QueryOrderByOutTradeNo(ctx,
|
||||
app.QueryOrderByOutTradeNoRequest{
|
||||
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||
Mchid: &mchID,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
log.Printf("call QueryOrderByOutTradeNo err:%s", err)
|
||||
return "", err
|
||||
} else {
|
||||
// 处理返回结果
|
||||
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||
|
||||
//支付成功
|
||||
if resp.TradeState == core.String("SUCCESS") {
|
||||
return "SUCCESS", nil
|
||||
|
||||
} else if resp.TradeState == core.String("NOTPAY") && count < 3 { //未支付,循环查找订单
|
||||
//休息200毫秒
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
count++
|
||||
goto loop
|
||||
}
|
||||
|
||||
//支付失败
|
||||
return *resp.TradeState, nil
|
||||
}
|
||||
}
|
||||
214
trunk/center/paycenter/internal/pay/api.go
Normal file
214
trunk/center/paycenter/internal/pay/api.go
Normal file
@ -0,0 +1,214 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"common/remark"
|
||||
"common/resultStatus"
|
||||
"common/webServer"
|
||||
"goutil/logUtilPlus"
|
||||
"goutil/webUtil"
|
||||
"net/http"
|
||||
"paycenter/internal/alipay"
|
||||
"paycenter/internal/wxpay"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
//注册接口
|
||||
webServer.RegisterFunction(new(PayApi))
|
||||
}
|
||||
|
||||
func init() {
|
||||
moduleName := "PayApi"
|
||||
desc := "用户接口"
|
||||
author := "tangping"
|
||||
mendor := ""
|
||||
date := "2025年1月8日15:49:03"
|
||||
remark.RegisterModuleRemark(moduleName, desc, author, mendor, date)
|
||||
}
|
||||
|
||||
// PayApi 支付接口
|
||||
type PayApi struct {
|
||||
}
|
||||
|
||||
// ---------------------------------------- 接口 --------------------------------------------------
|
||||
func init() {
|
||||
moduleName := "PayApi"
|
||||
methodName := "PlaceAnOrder"
|
||||
skipVerifyTokenPage := true
|
||||
methodDesc := "下单"
|
||||
methodAuthor := "tangping"
|
||||
methodMendor := ""
|
||||
methodDate := "2025年1月8日15:51:34"
|
||||
methodInParam := []string{"int64:订单id(由服务器生成),int32:充值模版id,int64:充值金额,string:商品id, string:客户端IP地址,string:玩家id,int32:区服id"}
|
||||
methodOutParam := `
|
||||
{
|
||||
"Code '类型:int'": "响应结果的状态值",
|
||||
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||
"Data '类型:interface{}'": "响应结果的数据"
|
||||
{
|
||||
"OrderID '类型:int64'": "订单id",
|
||||
"prepayId '类型:int64'": "预支付会话id",
|
||||
}
|
||||
}`
|
||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||
}
|
||||
|
||||
// 需要获取请求信息
|
||||
func init() {
|
||||
moduleName := "PayApi"
|
||||
methodName := "PlaceAnOrder"
|
||||
webServer.AddNeedGetRequestInfo(moduleName, methodName)
|
||||
}
|
||||
func (a *PayApi) PlaceAnOrder(orderId int64, modelID int32, currency int64, storeId string, playerID string, serverID int64, r *http.Request) (responseObj *webServer.ResponseObject) {
|
||||
responseObj = webServer.GetInitResponseObj()
|
||||
|
||||
//校验参数
|
||||
if modelID == 0 || playerID == "" || serverID == 0 {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
|
||||
//获取对应充值配置
|
||||
|
||||
//客户端请求ip
|
||||
clientIp := webUtil.GetRequestIP(r)
|
||||
|
||||
//下微信订单
|
||||
prepayId, err := wxpay.Prepay(orderId, currency, storeId, clientIp, "描述!!!!!!!!!!")
|
||||
if err != nil {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
//处理数据
|
||||
order := NewOrder(orderId, prepayId, playerID, serverID, 1)
|
||||
|
||||
//添加到数据库
|
||||
AddOrder(order)
|
||||
|
||||
resultMap := make(map[string]any)
|
||||
resultMap["orderID"] = order.OrderID
|
||||
resultMap["prepayId"] = order.PrepayId
|
||||
responseObj.SetData(resultMap)
|
||||
return
|
||||
}
|
||||
|
||||
func init() {
|
||||
moduleName := "PayApi"
|
||||
methodName := "CallBack"
|
||||
skipVerifyTokenPage := true
|
||||
methodDesc := "支付成功回调"
|
||||
methodAuthor := "tangping"
|
||||
methodMendor := ""
|
||||
methodDate := "2025年1月21日16:40:57"
|
||||
methodInParam := []string{"string:订单id"}
|
||||
methodOutParam := `
|
||||
{
|
||||
"Code '类型:int'": "响应结果的状态值",
|
||||
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||
"Data '类型:interface{}'": "响应结果的数据"
|
||||
{
|
||||
"OrderID '类型:int64'": "订单id",
|
||||
"prepayId '类型:int64'": "预支付会话id",
|
||||
}
|
||||
}`
|
||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||
}
|
||||
func (a *PayApi) CallBack(orderIDStr string) (responseObj *webServer.ResponseObject) {
|
||||
responseObj = webServer.GetInitResponseObj()
|
||||
|
||||
//参数错误
|
||||
if orderIDStr == "" {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
|
||||
//orderID 转换成string
|
||||
orderID, err := strconv.ParseInt(orderIDStr, 10, 64)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("订单id转换失败", err.Error())
|
||||
responseObj.SetResultStatus(resultStatus.APIParamError)
|
||||
return
|
||||
}
|
||||
|
||||
//是否已经处理
|
||||
order, err := GetUserByID(orderID)
|
||||
|
||||
//支付成功
|
||||
if err == nil && order != nil && order.OrderStatus == 1 {
|
||||
return
|
||||
}
|
||||
|
||||
//查询订单状态
|
||||
statusStr, err := wxpay.QueryOrderByOutTradeNo(orderID)
|
||||
if err != nil {
|
||||
responseObj.SetResultStatus(resultStatus.DataError)
|
||||
return
|
||||
}
|
||||
|
||||
//状态错误
|
||||
if statusStr != "SUCCESS" {
|
||||
logUtilPlus.WarnLog("订单状态错误", statusStr)
|
||||
return
|
||||
}
|
||||
|
||||
err = ChangeOrderStatus(orderID, 1)
|
||||
if err != nil {
|
||||
responseObj.SetResultStatus(resultStatus.DataError)
|
||||
return
|
||||
}
|
||||
|
||||
return responseObj
|
||||
}
|
||||
|
||||
func init() {
|
||||
moduleName := "PayApi"
|
||||
methodName := "AliPayPlaceAnOrder"
|
||||
skipVerifyTokenPage := true
|
||||
methodDesc := "下单"
|
||||
methodAuthor := "tangping"
|
||||
methodMendor := ""
|
||||
methodDate := "2025年1月8日15:51:34"
|
||||
methodInParam := []string{"int64:订单id(由服务器生成),int32:充值模版id,int64:充值金额,string:商品id, string:客户端IP地址,string:玩家id,int32:区服id"}
|
||||
methodOutParam := `
|
||||
{
|
||||
"Code '类型:int'": "响应结果的状态值",
|
||||
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||
"Data '类型:interface{}'": "响应结果的数据"
|
||||
{
|
||||
"OrderID '类型:int64'": "订单id",
|
||||
"prepayId '类型:int64'": "预支付会话id",
|
||||
}
|
||||
}`
|
||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||
}
|
||||
|
||||
func (a *PayApi) AliPayPlaceAnOrder(orderId int64, modelID int32, currency int64, storeId string, playerID string, serverID int64, r *http.Request) (responseObj *webServer.ResponseObject) {
|
||||
responseObj = webServer.GetInitResponseObj()
|
||||
if orderId == 0 || modelID == 0 || playerID == "" || serverID == 0 {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
|
||||
//客户端请求ip
|
||||
clientIp := webUtil.GetRequestIP(r)
|
||||
|
||||
//下微信订单
|
||||
prepayId, err := alipay.AliPayPlace(orderId, currency, storeId, clientIp, "描述!!!!!!!!!!")
|
||||
if err != nil {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
|
||||
//处理数据
|
||||
order := NewOrder(orderId, prepayId, playerID, serverID, 1)
|
||||
|
||||
//添加到数据库
|
||||
AddOrder(order)
|
||||
|
||||
resultMap := make(map[string]any)
|
||||
resultMap["orderID"] = order.OrderID
|
||||
resultMap["prepayId"] = order.PrepayId
|
||||
responseObj.SetData(resultMap)
|
||||
return responseObj
|
||||
}
|
||||
69
trunk/center/paycenter/internal/pay/check_order.go
Normal file
69
trunk/center/paycenter/internal/pay/check_order.go
Normal file
@ -0,0 +1,69 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"common/timer"
|
||||
"goutil/logUtilPlus"
|
||||
"paycenter/internal/wxpay"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
timer.Register(timer.TriggerTypeHalfHour, CheckOrderStatus)
|
||||
}
|
||||
|
||||
// CheckOrderStatus 检查订单状态
|
||||
// @return error
|
||||
func CheckOrderStatus(nowTime time.Time) error {
|
||||
|
||||
//检索最近一个月的订单
|
||||
for i := 0; i < 2; i++ {
|
||||
|
||||
//取i的负数
|
||||
dbDate := connection.GetToMonthAdd(int32(-i))
|
||||
var orders []Order // 使用切片存储查询结果
|
||||
|
||||
//这里使用原始sql
|
||||
sql := "select * from order_" + strconv.Itoa(int(dbDate)) + " where order_status = 0"
|
||||
dbResult := connection.GetPayDB().Exec(sql).Find(&orders)
|
||||
if dbResult.Error != nil {
|
||||
logUtilPlus.ErrorLog("查询订单状态失败", dbResult.Error.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
// 处理查询结果
|
||||
for _, order := range orders {
|
||||
|
||||
//查询订单状态
|
||||
statusStr, err := wxpay.QueryOrderByOutTradeNo(order.OrderID)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("查询订单状态失败", err.Error())
|
||||
continue
|
||||
}
|
||||
if statusStr == "SUCCESS" {
|
||||
//修改订单状态
|
||||
err = ChangeOrderStatus(order.OrderID, 1)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("修改订单状态失败", err.Error())
|
||||
continue
|
||||
}
|
||||
} else if statusStr == "CLOSED" { //已关闭
|
||||
order.OrderStatus = 2
|
||||
//修改订单状态
|
||||
connection.AsyncSave(connection.GetPayDB(), &order)
|
||||
} else if order.OrderTime.Add(time.Hour * 1).Before(time.Now()) { //超一个小时未支付 直接关闭订单
|
||||
//直接关闭订单
|
||||
err = wxpay.CloseOrder(order.OrderID)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("关闭订单失败", err.Error())
|
||||
continue
|
||||
}
|
||||
order.OrderStatus = 2
|
||||
connection.AsyncSave(connection.GetPayDB(), &order)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
100
trunk/center/paycenter/internal/pay/logic.go
Normal file
100
trunk/center/paycenter/internal/pay/logic.go
Normal file
@ -0,0 +1,100 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"fmt"
|
||||
"paycenter/internal/mesqueue"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
// 用户缓存对象
|
||||
orderMap = make(map[int64]*Order)
|
||||
rwmu sync.RWMutex
|
||||
)
|
||||
|
||||
// GetUserByID 根据用户id获取用户信息
|
||||
func GetUserByID(orderID int64) (*Order, error) {
|
||||
|
||||
//判断缓存是否存在
|
||||
var order *Order
|
||||
|
||||
func() *Order {
|
||||
rwmu.RLock()
|
||||
defer rwmu.RUnlock()
|
||||
ok := true
|
||||
if order, ok = orderMap[orderID]; ok {
|
||||
return order
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
|
||||
if order != nil {
|
||||
return order, nil
|
||||
}
|
||||
|
||||
result := connection.GetPayDB().First(&order, orderID)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
//添加缓存
|
||||
func() {
|
||||
rwmu.Lock()
|
||||
defer rwmu.Unlock()
|
||||
orderMap[order.OrderID] = order
|
||||
}()
|
||||
|
||||
return order, nil
|
||||
}
|
||||
|
||||
// AddOrderCache 添加用户缓存
|
||||
func AddOrderCache(order *Order) {
|
||||
rwmu.Lock()
|
||||
defer rwmu.Unlock()
|
||||
orderMap[order.OrderID] = order
|
||||
}
|
||||
|
||||
// AddOrder 添加订单
|
||||
func AddOrder(order *Order) (int64, error) {
|
||||
|
||||
//处理一些验证
|
||||
|
||||
// 异步 写入到数据库
|
||||
connection.AsyncCreate(connection.GetPayDB(), &order)
|
||||
|
||||
//添加缓存
|
||||
AddOrderCache(order)
|
||||
|
||||
return order.OrderID, nil
|
||||
}
|
||||
|
||||
// ChangeOrderStatus 改变订单状态
|
||||
func ChangeOrderStatus(orderID int64, status int32) error {
|
||||
|
||||
//根据订单id获取订单
|
||||
order, err := GetUserByID(orderID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//判断订单是否存在
|
||||
if order == nil {
|
||||
return fmt.Errorf("订单不存在,订单id %d", orderID)
|
||||
}
|
||||
|
||||
if status == 1 {
|
||||
mesqueue.AddQueue(mesqueue.GameMsg{
|
||||
GameId: "",
|
||||
OrderID: orderID,
|
||||
})
|
||||
}
|
||||
|
||||
//更新订单状态
|
||||
order.OrderStatus = status
|
||||
order.IsNotifyGameServer = 1
|
||||
|
||||
//异步更新数据库
|
||||
connection.AsyncSave(connection.GetPayDB(), &order)
|
||||
return nil
|
||||
}
|
||||
67
trunk/center/paycenter/internal/pay/order.go
Normal file
67
trunk/center/paycenter/internal/pay/order.go
Normal file
@ -0,0 +1,67 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
//注册数据库
|
||||
connection.RegisterDBModel(&Order{})
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
//订单id
|
||||
OrderID int64 `gorm:"column:order_id;primary_key;comment:订单id" json:"order_id"`
|
||||
//订单号
|
||||
PrepayId string `gorm:"column:prepay_id;comment:预支付交易会话标识" json:"prepay_id"`
|
||||
//订单金额
|
||||
OrderMoney int64 `gorm:"column:order_money;comment:订单金额" json:"order_money"`
|
||||
//订单状态 0:未支付 1:已支付 2:已关闭
|
||||
OrderStatus int32 `gorm:"column:order_status;comment:订单状态" json:"order_status"`
|
||||
//用户id
|
||||
UserID string `gorm:"column:user_id;comment:用户id" json:"user_id"`
|
||||
//区服id
|
||||
ServerID int64 `gorm:"column:server_id;comment:区服id" json:"server_id"`
|
||||
//玩家标识
|
||||
PlayerID string `gorm:"column:player_id;comment:玩家标识" json:"player_id"`
|
||||
//是否通知游戏服 0:未通知 1:已通知
|
||||
IsNotifyGameServer int32 `gorm:"column:is_notify_game_server;comment:是否通知游戏服" json:"is_notify_game_server"`
|
||||
//订单日期
|
||||
OrderDate time.Time `gorm:"column:order_date;comment:订单日期" json:"order_date"`
|
||||
//订单时间
|
||||
OrderTime time.Time `gorm:"column:order_time;type:date;comment:订单时间" json:"order_time"`
|
||||
//订单类型 1:微信支付 2:支付宝支付
|
||||
OrderType int32 `gorm:"column:order_type;comment:订单类型" json:"order_type"`
|
||||
|
||||
//表的名字 这里是表的后缀
|
||||
TableNameData int32 `gorm:"column:table_name;comment:表的名字 这里是表的后缀" json:"table_name"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (order *Order) TableName() string {
|
||||
return "order_" + strconv.Itoa(int(order.TableNameData))
|
||||
}
|
||||
|
||||
// NewOrder 创建订单
|
||||
// @param orderId 订单id
|
||||
// @param prepayId 预支付id
|
||||
// @param playerID 玩家id
|
||||
// @param serverID 服务器id
|
||||
// @param orderType 订单类型
|
||||
func NewOrder(orderId int64, prepayId string, playerID string, serverID int64, orderType int32) *Order {
|
||||
return &Order{
|
||||
OrderID: orderId,
|
||||
PrepayId: prepayId,
|
||||
OrderMoney: 100,
|
||||
OrderStatus: 1,
|
||||
PlayerID: playerID,
|
||||
ServerID: serverID,
|
||||
UserID: playerID,
|
||||
OrderDate: time.Now(),
|
||||
OrderTime: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
OrderType: orderType,
|
||||
TableNameData: connection.GetMonth(),
|
||||
}
|
||||
}
|
||||
64
trunk/center/paycenter/internal/wxpay/config.go
Normal file
64
trunk/center/paycenter/internal/wxpay/config.go
Normal file
@ -0,0 +1,64 @@
|
||||
package wxpay
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
"goutil/yamlUtil"
|
||||
"log"
|
||||
)
|
||||
|
||||
type WxPayConfig struct {
|
||||
MchID string
|
||||
MchCertificateSerialNumber string
|
||||
MchAPIv3Key string
|
||||
AppId string
|
||||
NotifyUrl string
|
||||
}
|
||||
|
||||
var (
|
||||
wxPayConfig = &WxPayConfig{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
//加载配置
|
||||
reloadConfig()
|
||||
|
||||
//校验配置
|
||||
CheckConfig()
|
||||
}
|
||||
|
||||
// reloadConfig
|
||||
//
|
||||
// @description: reloadConfig
|
||||
//
|
||||
// parameter:
|
||||
// return:
|
||||
//
|
||||
// @error: 错误信息
|
||||
func reloadConfig() error {
|
||||
|
||||
yamlFile, err := yamlUtil.LoadFromFile("payconfig/wxpayconfig.yml")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 解析 YAML 文件
|
||||
err = yaml.Unmarshal(yamlFile, wxPayConfig)
|
||||
if err != nil {
|
||||
log.Fatalf("Error unmarshalling config file: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckConfig 校验配置
|
||||
func CheckConfig() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetWxPayConfig 获取配置
|
||||
func GetWxPayConfig() *WxPayConfig {
|
||||
return wxPayConfig
|
||||
}
|
||||
249
trunk/center/paycenter/internal/wxpay/pay.go
Normal file
249
trunk/center/paycenter/internal/wxpay/pay.go
Normal file
@ -0,0 +1,249 @@
|
||||
package wxpay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/app"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/utils"
|
||||
"goutil/logUtilPlus"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
mchID string = GetWxPayConfig().MchID // 商户号
|
||||
mchCertificateSerialNumber string = GetWxPayConfig().MchCertificateSerialNumber // 商户证书序列号
|
||||
mchAPIv3Key string = GetWxPayConfig().MchAPIv3Key // 商户APIv3密钥
|
||||
appId string = GetWxPayConfig().AppId // 应用ID
|
||||
Address string = "成都市XXXXXXXXXXXXXXXXXXXXXXX" //公司地址
|
||||
wxPayApiUrl string = GetWxPayConfig().NotifyUrl //支付成功回调地址
|
||||
)
|
||||
|
||||
// Prepay 函数用于发起预支付请求。
|
||||
// 参数:
|
||||
//
|
||||
// outTradeNo: 商户订单号。
|
||||
// currency: 订单金额,单位为分。
|
||||
// storeId: 商户门店编号。
|
||||
// clientIp: 用户的客户端IP。
|
||||
// description: 订单描述。
|
||||
//
|
||||
// 返回值:
|
||||
//
|
||||
// 成功时返回预支付ID和nil错误。
|
||||
// 失败时返回空字符串和错误对象。
|
||||
func Prepay(outTradeNo int64, currency int64, storeId string, clientIp string, description string) (string, error) {
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("load merchant private key error")
|
||||
return "", err
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
logUtilPlus.ErrorLog("new wechat pay client err:%s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
resp, result, err := svc.Prepay(ctx,
|
||||
app.PrepayRequest{
|
||||
Appid: core.String(appId),
|
||||
Mchid: core.String(mchID),
|
||||
Description: core.String(description),
|
||||
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||
TimeExpire: core.Time(time.Now().Add(time.Hour * 2)), //支付时效时间 2 小时后失效
|
||||
Attach: core.String(""), //附加数据 这里不需要,有个订单id 可以获取订单详细信息
|
||||
NotifyUrl: core.String(fmt.Sprintf(wxPayApiUrl, strconv.FormatInt(outTradeNo, 10))), //回调地址
|
||||
//GoodsTag: core.String("WXG"),//优惠标记 这里没用
|
||||
//LimitPay: []string{"LimitPay_example"},
|
||||
SupportFapiao: core.Bool(false),
|
||||
Amount: &app.Amount{
|
||||
Currency: core.String("CNY"),
|
||||
Total: core.Int64(currency),
|
||||
},
|
||||
Detail: &app.Detail{
|
||||
//CostPrice: core.Int64(608800),
|
||||
GoodsDetail: []app.GoodsDetail{app.GoodsDetail{
|
||||
GoodsName: core.String(storeId), //商品编号
|
||||
MerchantGoodsId: core.String(description),
|
||||
Quantity: core.Int64(1),
|
||||
UnitPrice: core.Int64(currency),
|
||||
//WechatpayGoodsId: core.String("1001"),
|
||||
}},
|
||||
//InvoiceId: core.String("wx123"),
|
||||
},
|
||||
SceneInfo: &app.SceneInfo{
|
||||
//DeviceId: core.String("013467007045764"),
|
||||
PayerClientIp: core.String(clientIp),
|
||||
StoreInfo: &app.StoreInfo{
|
||||
Address: core.String(Address),
|
||||
//AreaCode: core.String("440305"),
|
||||
//Id: core.String("0001"),
|
||||
//Name: core.String("腾讯大厦分店"),
|
||||
},
|
||||
},
|
||||
SettleInfo: &app.SettleInfo{
|
||||
ProfitSharing: core.Bool(false),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
logUtilPlus.ErrorLog("call Prepay err:%s", err.Error())
|
||||
return "", err
|
||||
}
|
||||
|
||||
if result.Response.StatusCode != 200 {
|
||||
errStr := fmt.Sprintf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||
logUtilPlus.ErrorLog(errStr)
|
||||
return "", errors.New(errStr)
|
||||
}
|
||||
|
||||
return *resp.PrepayId, nil
|
||||
}
|
||||
|
||||
// CloseOrder 关闭订单
|
||||
func CloseOrder(outTradeNo int64) error {
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
log.Print("加载商家私钥错误")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
log.Printf("新的 WeChat Pay 客户端 Err:%s", err)
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
_, err = svc.CloseOrder(ctx,
|
||||
app.CloseOrderRequest{
|
||||
|
||||
//商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯
|
||||
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||
|
||||
//直连商户的商户号,由微信支付生成并下发。
|
||||
Mchid: core.String(mchID),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
logUtilPlus.ErrorLog("call CloseOrder err:%s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryOrderById 根据商户订单号查询订单
|
||||
func QueryOrderById() {
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
log.Print("load merchant private key error")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
log.Printf("new wechat pay client err:%s", err)
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
resp, result, err := svc.QueryOrderById(ctx,
|
||||
app.QueryOrderByIdRequest{
|
||||
TransactionId: core.String("TransactionId_example"),
|
||||
Mchid: core.String("Mchid_example"),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
log.Printf("call QueryOrderById err:%s", err)
|
||||
} else {
|
||||
// 处理返回结果
|
||||
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||
}
|
||||
}
|
||||
|
||||
// QueryOrderByOutTradeNo 根据商户订单号查询订单
|
||||
func QueryOrderByOutTradeNo(outTradeNo int64) (string, error) {
|
||||
|
||||
//循环查询次数
|
||||
var count int = 0
|
||||
|
||||
loop:
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
log.Print("load merchant private key error")
|
||||
return "", err
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
log.Printf("new wechat pay client err:%s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
svc := app.AppApiService{Client: client}
|
||||
resp, result, err := svc.QueryOrderByOutTradeNo(ctx,
|
||||
app.QueryOrderByOutTradeNoRequest{
|
||||
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||
Mchid: &mchID,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
log.Printf("call QueryOrderByOutTradeNo err:%s", err)
|
||||
return "", err
|
||||
} else {
|
||||
// 处理返回结果
|
||||
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||
|
||||
//支付成功
|
||||
if resp.TradeState == core.String("SUCCESS") {
|
||||
return "SUCCESS", nil
|
||||
|
||||
} else if resp.TradeState == core.String("NOTPAY") && count < 3 { //未支付,循环查找订单
|
||||
//休息200毫秒
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
count++
|
||||
goto loop
|
||||
}
|
||||
|
||||
//支付失败
|
||||
return *resp.TradeState, nil
|
||||
}
|
||||
}
|
||||
64
trunk/center/paycenter/internal/wxpaycofnig/payconfig.go
Normal file
64
trunk/center/paycenter/internal/wxpaycofnig/payconfig.go
Normal file
@ -0,0 +1,64 @@
|
||||
package wxpaycofnig
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
"goutil/yamlUtil"
|
||||
"log"
|
||||
)
|
||||
|
||||
type WxPayConfig struct {
|
||||
MchID string
|
||||
MchCertificateSerialNumber string
|
||||
MchAPIv3Key string
|
||||
AppId string
|
||||
NotifyUrl string
|
||||
}
|
||||
|
||||
var (
|
||||
wxPayConfig = &WxPayConfig{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
//加载配置
|
||||
reloadConfig()
|
||||
|
||||
//校验配置
|
||||
CheckConfig()
|
||||
}
|
||||
|
||||
// reloadConfig
|
||||
//
|
||||
// @description: reloadConfig
|
||||
//
|
||||
// parameter:
|
||||
// return:
|
||||
//
|
||||
// @error: 错误信息
|
||||
func reloadConfig() error {
|
||||
|
||||
yamlFile, err := yamlUtil.LoadFromFile("payconfig/wxpayconfig.yml")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 解析 YAML 文件
|
||||
err = yaml.Unmarshal(yamlFile, wxPayConfig)
|
||||
if err != nil {
|
||||
log.Fatalf("Error unmarshalling config file: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckConfig 校验配置
|
||||
func CheckConfig() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetWxPayConfig 获取配置
|
||||
func GetWxPayConfig() *WxPayConfig {
|
||||
return wxPayConfig
|
||||
}
|
||||
@ -1,73 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/native"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/utils"
|
||||
"log"
|
||||
"common/connection"
|
||||
"sync"
|
||||
|
||||
_ "common/resultStatus"
|
||||
"common/webServer"
|
||||
_ "paycenter/internal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
mchID string = "190000****" // 商户号
|
||||
mchCertificateSerialNumber string = "3775B6A45ACD588826D15E583A95F5DD********" // 商户证书序列号
|
||||
mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥
|
||||
)
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||
if err != nil {
|
||||
log.Fatal("load merchant private key error")
|
||||
}
|
||||
ctx := context.Background()
|
||||
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
||||
opts := []core.ClientOption{
|
||||
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
|
||||
}
|
||||
client, err := core.NewClient(ctx, opts...)
|
||||
if err != nil {
|
||||
log.Fatalf("new wechat pay client err:%s", err)
|
||||
}
|
||||
// 以 Native 支付为例
|
||||
svc := native.NativeApiService{Client: client}
|
||||
// 发送请求
|
||||
resp, result, err := svc.Prepay(ctx,
|
||||
native.PrepayRequest{
|
||||
Appid: core.String("wxd678efh567hg6787"),
|
||||
Mchid: core.String("1900009191"),
|
||||
Description: core.String("Image形象店-深圳腾大-QQ公仔"),
|
||||
OutTradeNo: core.String("1217752501201407033233368018"),
|
||||
Attach: core.String("自定义数据说明"),
|
||||
NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
|
||||
Amount: &native.Amount{
|
||||
Total: core.Int64(100),
|
||||
},
|
||||
},
|
||||
)
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
// 使用微信扫描 resp.code_url 对应的二维码,即可体验Native支付
|
||||
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||
svc1 := jsapi.JsapiApiService{Client: client}
|
||||
// 得到prepay_id,以及调起支付所需的参数和签名
|
||||
resp1, result, err := svc1.PrepayWithRequestPayment(ctx,
|
||||
jsapi.PrepayRequest{
|
||||
Appid: core.String("wxd678efh567hg6787"),
|
||||
Mchid: core.String("1900009191"),
|
||||
Description: core.String("Image形象店-深圳腾大-QQ公仔"),
|
||||
OutTradeNo: core.String("1217752501201407033233368018"),
|
||||
Attach: core.String("自定义数据说明"),
|
||||
NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
|
||||
Amount: &jsapi.Amount{
|
||||
Total: core.Int64(100),
|
||||
},
|
||||
Payer: &jsapi.Payer{
|
||||
Openid: core.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
// 使用微信扫描 resp.code_url 对应的二维码,即可体验Native支付
|
||||
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp1)
|
||||
func init() {
|
||||
// 设置WaitGroup需要等待的数量,只要有一个服务器出现错误都停止服务器
|
||||
wg.Add(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
//加载配置
|
||||
loadConfig()
|
||||
|
||||
// 启动webserver
|
||||
go webServer.Start(&wg)
|
||||
|
||||
// 阻塞等待,以免main线程退出
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// loadConfig 用于加载配置信息。
|
||||
// 该函数会读取配置文件或环境变量中的设置,并根据这些设置初始化程序所需的配置。
|
||||
// 目前函数的实现为空,需要根据实际的配置加载逻辑进行填充。
|
||||
func loadConfig() {
|
||||
|
||||
//设置数据类型
|
||||
connection.SetModelDB(connection.GetPayDB())
|
||||
|
||||
//构建数据库
|
||||
connection.BuildDB()
|
||||
}
|
||||
|
||||
9
trunk/center/paycenter/payconfig/wxpayconfig.yaml
Normal file
9
trunk/center/paycenter/payconfig/wxpayconfig.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
#微信支付相关配置
|
||||
#商户id
|
||||
MchID: '1900000109'
|
||||
|
||||
#商户证书序列号
|
||||
MchCertificateSerialNumber: '3775D15B3B9A7F6D'
|
||||
|
||||
#商户APIv3密钥
|
||||
MchAPIv3Key: 'X5g0l1vL9kRvP0VB2WlhtyVwqEG9zvGf'
|
||||
15
trunk/center/paycenter/payconfig/wxpayconfig.yml
Normal file
15
trunk/center/paycenter/payconfig/wxpayconfig.yml
Normal file
@ -0,0 +1,15 @@
|
||||
#微信支付相关配置
|
||||
#商户id
|
||||
MchID: '1900000109'
|
||||
|
||||
#商户证书序列号
|
||||
MchCertificateSerialNumber: '3775D15B3B9A7F6D'
|
||||
|
||||
#商户APIv3密钥
|
||||
MchAPIv3Key: 'X5g0l1vL9kRvP0VB2WlhtyVwqEG9zvGf'
|
||||
|
||||
# appId
|
||||
AppID: 'wx8888888888888888'
|
||||
|
||||
# 微信回调地址
|
||||
NotifyUrl: 'https://www.example.com/wxpay/notify?orderId=%s'
|
||||
20
trunk/center/paycenter/run.sh
Normal file
20
trunk/center/paycenter/run.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 赋予可执行权限
|
||||
chmod +x adminServer
|
||||
|
||||
echo "启动中..."
|
||||
|
||||
# 接受命令行传入一个参数
|
||||
case "$1" in
|
||||
d)
|
||||
# 使用 nohup 将进程放到后台运行,并将输出重定向到 nohup.out 文件
|
||||
nohup ./adminServer > nohup.out 2>&1 &
|
||||
echo "启动完成"
|
||||
;;
|
||||
*)
|
||||
./adminServer
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "启动完成"
|
||||
16
trunk/center/paycenter/stop.sh
Normal file
16
trunk/center/paycenter/stop.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 查找 adminServer 的 PID
|
||||
PID=$(pgrep adminServer)
|
||||
|
||||
if [ -z "$PID" ]; then
|
||||
echo "adminServer 进程未找到"
|
||||
else
|
||||
echo "停止中... (PID: $PID)"
|
||||
kill $PID
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "adminServer 进程已终止 (PID: $PID)"
|
||||
else
|
||||
echo "无法终止 adminServer 进程 (PID: $PID)"
|
||||
fi
|
||||
fi
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user