Merge remote-tracking branch 'origin/develop' into dev_slots
This commit is contained in:
commit
aaf417c9fe
|
@ -130,6 +130,7 @@ func TsToStrTime(tc int64) string {
|
|||
//return time.Now().Format("2018-07-02 19:14:00")
|
||||
return time.Unix(tc, 0).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func TsToStrDateTime(tc int64) string {
|
||||
//return time.Now().Format("2018-07-02 19:14:00")
|
||||
return time.Unix(tc, 0).Format("2006-01-02")
|
||||
|
@ -198,3 +199,8 @@ func HMSToTime(h, m, s int) time.Time {
|
|||
func IntToTime(n int) time.Time {
|
||||
return HMSToTime(n/10000, n%10000/100, n%100)
|
||||
}
|
||||
|
||||
func StrTimeToTime(s string) time.Time {
|
||||
t, _ := time.ParseInLocation("2006-01-02 15:04:05", s, time.Local)
|
||||
return t
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -71,7 +71,7 @@
|
|||
"Name": "十三张(四人场)",
|
||||
"GameId": 211,
|
||||
"Params": [
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
@ -84,7 +84,7 @@
|
|||
"Name": "十三张(八人场)",
|
||||
"GameId": 212,
|
||||
"Params": [
|
||||
8,
|
||||
1,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
@ -97,7 +97,7 @@
|
|||
"Name": "十三张(自由场经典场)",
|
||||
"GameId": 213,
|
||||
"Params": [
|
||||
8,
|
||||
1,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
@ -110,7 +110,7 @@
|
|||
"Name": "十三张(自由场癞子场)",
|
||||
"GameId": 214,
|
||||
"Params": [
|
||||
8,
|
||||
1,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
"PermitAwardTitle": "{\"zh\":\"通行证排行奖励\",\"vi\":\"Vượt qua phần thưởng xếp hạng\",\"en\":\"Pass Ranking Rewards\",\"kh\":\"រង្វាន់ចំណាត់ថ្នាក់ឆ្លងកាត់\"}",
|
||||
"PermitAward": "{\"zh\":\"恭喜您在上个赛季通行证排行中名次达到%v名,排行奖励已发放,请查收\",\"vi\":\"Chúc mừng bạn đã đạt được %v trong bảng xếp hạng vượt qua. Phần thưởng xếp hạng đã được phân phối, vui lòng kiểm tra.\",\"en\":\"Congratulations on reaching %vth place in the pass ranking. Ranking rewards have been issued. Please check.\",\"kh\":\"សូមអបអរសាទរចំពោះការឈានដល់ចំណាត់ថ្នាក់ទី %v ក្នុងចំណាត់ថ្នាក់ឆ្លងកាត់។ រង្វាន់ចំណាត់ថ្នាក់ត្រូវបានចេញ។ សូមត្រួតពិនិត្យ។\"}",
|
||||
"UpgradeTitle": "{\"zh\":\"更新奖励\",\"vi\":\"Phần thưởng cập nhật\",\"en\":\"Update Rewards\",\"kh\":\"រង្វាន់ដំឡើង\"}",
|
||||
"Upgrade": "{\"zh\":\"感谢您更新客户端,更新奖励已发放至附近,请注意查收\",\"vi\":\"Cảm ơn bạn đã cập nhật ứng dụng khách. Phần thưởng cập nhật đã được phân phối gần đó, vui lòng chú ý kiểm tra nhận\",\"en\":\"Thank you for updating the client. The update reward has been distributed to everyone. Please check it carefully.\",\"kh\":\"អរគុណសម្រាប់ការធ្វើបច្ចុប្បន្នភាពហ្គេម។ រង្វាន់នៃការធ្វើបច្ចុប្បន្នភាពត្រូវបានចែកចាយទៅគ្រប់គ្នា។ សូមពិនិត្យអោយបានច្បាស់លាស់។\"}",
|
||||
"LotteryTitle": "{\"zh\":\"玩游戏抽奖品\",\"vi\":\"Chơi game rút thưởng\",\"en\":\"Play games, draw prizes\",\"kh\":\"លេងហ្គេម ចាប់រង្វាន់\"}",
|
||||
"Lottery": "{\"zh\":\"恭喜您在好友房玩游戏抽奖品活动中获得了大奖,奖品随邮件发放,请注意查收\",\"vi\":\"Chúc mừng bạn đã trúng giải thưởng lớn trong hoạt động rút thưởng trò chơi tại phòng bạn bè. Giải thưởng sẽ được gửi qua email, vui lòng kiểm tra cẩn thận.\",\"en\":\"Congratulations on winning the grand prize in the lucky draw activity in the friend room. The prize will be sent via email, please check it carefully.\",\"kh\":\"សូមអបអរសាទរចំពោះការឈ្នះរង្វាន់ធំក្នុងសកម្មភាពចាប់រង្វាន់ក្នុងបន្ទប់មិត្តភ័ក្តិរបស់អ្នក រង្វាន់នឹងត្រូវបានផ្ញើតាមអ៊ីម៉ែល សូមពិនិត្យមើលវាដោយយកចិត្តទុកដាក់។\"}"
|
||||
"Upgrade": "{\"zh\":\"感谢您更新客户端,更新奖励已发放至附近,请注意查收\",\"vi\":\"Cảm ơn bạn đã cập nhật ứng dụng khách. Phần thưởng cập nhật đã được phân phối gần đó, vui lòng chú ý kiểm tra nhận\",\"en\":\"Thank you for updating the client. The update reward has been distributed to everyone. Please check it carefully.\",\"kh\":\"អរគុណសម្រាប់ការធ្វើបច្ចុប្បន្នភាពហ្គេម។ រង្វាន់នៃការធ្វើបច្ចុប្បន្នភាពត្រូវបានចែកចាយទៅគ្រប់គ្នា។ សូមពិនិត្យអោយបានច្បាស់លាស់។\"}",
|
||||
"LotteryTitle": "{\"zh\":\"玩游戏抽奖品\",\"vi\":\"Chơi game rút thưởng\",\"en\":\"Play games, draw prizes\",\"kh\":\"លេងហ្គេម ចាប់រង្វាន់\"}",
|
||||
"Lottery": "{\"zh\":\"恭喜您在好友房玩游戏抽奖品活动中获得了大奖,奖品随邮件发放,请注意查收\",\"vi\":\"Chúc mừng bạn đã trúng giải thưởng lớn trong hoạt động rút thưởng trò chơi tại phòng bạn bè. Giải thưởng sẽ được gửi qua email, vui lòng kiểm tra cẩn thận.\",\"en\":\"Congratulations on winning the grand prize in the lucky draw activity in the friend room. The prize will be sent via email, please check it carefully.\",\"kh\":\"សូមអបអរសាទរចំពោះការឈ្នះរង្វាន់ធំក្នុងសកម្មភាពចាប់រង្វាន់ក្នុងបន្ទប់មិត្តភ័ក្តិរបស់អ្នក រង្វាន់នឹងត្រូវបានផ្ញើតាមអ៊ីម៉ែល សូមពិនិត្យមើលវាដោយយកចិត្តទុកដាក់។\"}",
|
||||
"TelCodeTitle": "{\"zh\":\"话费卡兑换码\",\"vi\":\"Mã đổi thẻ điện thoại\",\"en\":\"Phone card redemption code\",\"kh\":\"លេខកូដប្រោសលោះកាតទូរស័ព្ទ\"}"
|
||||
}
|
|
@ -1,312 +0,0 @@
|
|||
// --------------------------------------------------------------------------------------------
|
||||
// The following code is automatically generated by the mongo-dao-generator tool.
|
||||
// Please do not modify this code manually to avoid being overwritten in the next generation.
|
||||
// For more tool details, please click the link to view https://github.com/dobyte/mongo-dao-generator
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
modelpkg "mongo.games.com/game/db/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserFilterFunc func(cols *UserColumns) interface{}
|
||||
type UserUpdateFunc func(cols *UserColumns) interface{}
|
||||
type UserPipelineFunc func(cols *UserColumns) interface{}
|
||||
type UserCountOptionsFunc func(cols *UserColumns) *options.CountOptions
|
||||
type UserAggregateOptionsFunc func(cols *UserColumns) *options.AggregateOptions
|
||||
type UserFindOneOptionsFunc func(cols *UserColumns) *options.FindOneOptions
|
||||
type UserFindManyOptionsFunc func(cols *UserColumns) *options.FindOptions
|
||||
type UserUpdateOptionsFunc func(cols *UserColumns) *options.UpdateOptions
|
||||
type UserDeleteOptionsFunc func(cols *UserColumns) *options.DeleteOptions
|
||||
type UserInsertOneOptionsFunc func(cols *UserColumns) *options.InsertOneOptions
|
||||
type UserInsertManyOptionsFunc func(cols *UserColumns) *options.InsertManyOptions
|
||||
|
||||
type User struct {
|
||||
Columns *UserColumns
|
||||
Database *mongo.Database
|
||||
Collection *mongo.Collection
|
||||
}
|
||||
|
||||
type UserColumns struct {
|
||||
ID string
|
||||
Account string // 用户账号
|
||||
Password string // 用户密码
|
||||
Salt string // 密码
|
||||
Mobile string // 用户手机
|
||||
Email string // 用户邮箱
|
||||
Nickname string // 用户昵称
|
||||
Signature string // 用户签名
|
||||
Level string // 用户等级
|
||||
Experience string // 用户经验
|
||||
Coin string // 用户金币
|
||||
DeviceID string // 设备ID
|
||||
RegisterIP string // 注册IP
|
||||
RegisterTime string // 注册时间
|
||||
LastLoginIP string // 最近登录IP
|
||||
LastLoginTime string // 最近登录时间
|
||||
}
|
||||
|
||||
var userColumns = &UserColumns{
|
||||
ID: "_id",
|
||||
Account: "account", // 用户账号
|
||||
Password: "password", // 用户密码
|
||||
Salt: "salt", // 密码
|
||||
Mobile: "mobile", // 用户手机
|
||||
Email: "email", // 用户邮箱
|
||||
Nickname: "nickname", // 用户昵称
|
||||
Signature: "signature", // 用户签名
|
||||
Level: "level", // 用户等级
|
||||
Experience: "experience", // 用户经验
|
||||
Coin: "coin", // 用户金币
|
||||
DeviceID: "device_id", // 设备ID
|
||||
RegisterIP: "register_ip", // 注册IP
|
||||
RegisterTime: "register_time", // 注册时间
|
||||
LastLoginIP: "last_login_ip", // 最近登录IP
|
||||
LastLoginTime: "last_login_time", // 最近登录时间
|
||||
}
|
||||
|
||||
func NewUser(db *mongo.Database) *User {
|
||||
return &User{
|
||||
Columns: userColumns,
|
||||
Database: db,
|
||||
Collection: db.Collection("user"),
|
||||
}
|
||||
}
|
||||
|
||||
// Count returns the number of documents in the collection.
|
||||
func (dao *User) Count(ctx context.Context, filterFunc UserFilterFunc, optionsFunc ...UserCountOptionsFunc) (int64, error) {
|
||||
var (
|
||||
opts *options.CountOptions
|
||||
filter = filterFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.CountDocuments(ctx, filter, opts)
|
||||
}
|
||||
|
||||
// Aggregate executes an aggregate command against the collection and returns a cursor over the resulting documents.
|
||||
func (dao *User) Aggregate(ctx context.Context, pipelineFunc UserPipelineFunc, optionsFunc ...UserAggregateOptionsFunc) (*mongo.Cursor, error) {
|
||||
var (
|
||||
opts *options.AggregateOptions
|
||||
pipeline = pipelineFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.Aggregate(ctx, pipeline, opts)
|
||||
}
|
||||
|
||||
// InsertOne executes an insert command to insert a single document into the collection.
|
||||
func (dao *User) InsertOne(ctx context.Context, model *modelpkg.User, optionsFunc ...UserInsertOneOptionsFunc) (*mongo.InsertOneResult, error) {
|
||||
if model == nil {
|
||||
return nil, errors.New("model is nil")
|
||||
}
|
||||
|
||||
if err := dao.autofill(ctx, model); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var opts *options.InsertOneOptions
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.InsertOne(ctx, model, opts)
|
||||
}
|
||||
|
||||
// InsertMany executes an insert command to insert multiple documents into the collection.
|
||||
func (dao *User) InsertMany(ctx context.Context, models []*modelpkg.User, optionsFunc ...UserInsertManyOptionsFunc) (*mongo.InsertManyResult, error) {
|
||||
if len(models) == 0 {
|
||||
return nil, errors.New("models is empty")
|
||||
}
|
||||
|
||||
documents := make([]interface{}, 0, len(models))
|
||||
for i := range models {
|
||||
model := models[i]
|
||||
if err := dao.autofill(ctx, model); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
documents = append(documents, model)
|
||||
}
|
||||
|
||||
var opts *options.InsertManyOptions
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.InsertMany(ctx, documents, opts)
|
||||
}
|
||||
|
||||
// UpdateOne executes an update command to update at most one document in the collection.
|
||||
func (dao *User) UpdateOne(ctx context.Context, filterFunc UserFilterFunc, updateFunc UserUpdateFunc, optionsFunc ...UserUpdateOptionsFunc) (*mongo.UpdateResult, error) {
|
||||
var (
|
||||
opts *options.UpdateOptions
|
||||
filter = filterFunc(dao.Columns)
|
||||
update = updateFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.UpdateOne(ctx, filter, update, opts)
|
||||
}
|
||||
|
||||
// UpdateOneByID executes an update command to update at most one document in the collection.
|
||||
func (dao *User) UpdateOneByID(ctx context.Context, id string, updateFunc UserUpdateFunc, optionsFunc ...UserUpdateOptionsFunc) (*mongo.UpdateResult, error) {
|
||||
objectID, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dao.UpdateOne(ctx, func(cols *UserColumns) interface{} {
|
||||
return bson.M{"_id": objectID}
|
||||
}, updateFunc, optionsFunc...)
|
||||
}
|
||||
|
||||
// UpdateMany executes an update command to update documents in the collection.
|
||||
func (dao *User) UpdateMany(ctx context.Context, filterFunc UserFilterFunc, updateFunc UserUpdateFunc, optionsFunc ...UserUpdateOptionsFunc) (*mongo.UpdateResult, error) {
|
||||
var (
|
||||
opts *options.UpdateOptions
|
||||
filter = filterFunc(dao.Columns)
|
||||
update = updateFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.UpdateMany(ctx, filter, update, opts)
|
||||
}
|
||||
|
||||
// FindOne executes a find command and returns a model for one document in the collection.
|
||||
func (dao *User) FindOne(ctx context.Context, filterFunc UserFilterFunc, optionsFunc ...UserFindOneOptionsFunc) (*modelpkg.User, error) {
|
||||
var (
|
||||
opts *options.FindOneOptions
|
||||
model = &modelpkg.User{}
|
||||
filter = filterFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
err := dao.Collection.FindOne(ctx, filter, opts).Decode(model)
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// FindOneByID executes a find command and returns a model for one document in the collection.
|
||||
func (dao *User) FindOneByID(ctx context.Context, id string, optionsFunc ...UserFindOneOptionsFunc) (*modelpkg.User, error) {
|
||||
objectID, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dao.FindOne(ctx, func(cols *UserColumns) interface{} {
|
||||
return bson.M{"_id": objectID}
|
||||
}, optionsFunc...)
|
||||
}
|
||||
|
||||
// FindMany executes a find command and returns many models the matching documents in the collection.
|
||||
func (dao *User) FindMany(ctx context.Context, filterFunc UserFilterFunc, optionsFunc ...UserFindManyOptionsFunc) ([]*modelpkg.User, error) {
|
||||
var (
|
||||
opts *options.FindOptions
|
||||
filter = filterFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
cur, err := dao.Collection.Find(ctx, filter, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
models := make([]*modelpkg.User, 0)
|
||||
|
||||
if err = cur.All(ctx, &models); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return models, nil
|
||||
}
|
||||
|
||||
// DeleteOne executes a delete command to delete at most one document from the collection.
|
||||
func (dao *User) DeleteOne(ctx context.Context, filterFunc UserFilterFunc, optionsFunc ...UserDeleteOptionsFunc) (*mongo.DeleteResult, error) {
|
||||
var (
|
||||
opts *options.DeleteOptions
|
||||
filter = filterFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.DeleteOne(ctx, filter, opts)
|
||||
}
|
||||
|
||||
// DeleteOneByID executes a delete command to delete at most one document from the collection.
|
||||
func (dao *User) DeleteOneByID(ctx context.Context, id string, optionsFunc ...UserDeleteOptionsFunc) (*mongo.DeleteResult, error) {
|
||||
objectID, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dao.DeleteOne(ctx, func(cols *UserColumns) interface{} {
|
||||
return bson.M{"_id": objectID}
|
||||
}, optionsFunc...)
|
||||
}
|
||||
|
||||
// DeleteMany executes a delete command to delete documents from the collection.
|
||||
func (dao *User) DeleteMany(ctx context.Context, filterFunc UserFilterFunc, optionsFunc ...UserDeleteOptionsFunc) (*mongo.DeleteResult, error) {
|
||||
var (
|
||||
opts *options.DeleteOptions
|
||||
filter = filterFunc(dao.Columns)
|
||||
)
|
||||
|
||||
if len(optionsFunc) > 0 {
|
||||
opts = optionsFunc[0](dao.Columns)
|
||||
}
|
||||
|
||||
return dao.Collection.DeleteMany(ctx, filter, opts)
|
||||
}
|
||||
|
||||
// autofill when inserting data
|
||||
func (dao *User) autofill(ctx context.Context, model *modelpkg.User) error {
|
||||
if model.ID.IsZero() {
|
||||
model.ID = primitive.NewObjectID()
|
||||
}
|
||||
|
||||
if model.RegisterTime == 0 {
|
||||
model.RegisterTime = primitive.NewDateTimeFromTime(time.Now())
|
||||
}
|
||||
|
||||
if model.LastLoginTime == 0 {
|
||||
model.LastLoginTime = primitive.NewDateTimeFromTime(time.Now())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"mongo.games.com/game/db/dao/internal"
|
||||
)
|
||||
|
||||
type UserColumns = internal.UserColumns
|
||||
|
||||
type User struct {
|
||||
*internal.User
|
||||
}
|
||||
|
||||
func NewUser(db *mongo.Database, c *mongo.Collection) *User {
|
||||
v := internal.NewUser(nil)
|
||||
v.Database = db
|
||||
v.Collection = c
|
||||
panic("创建索引")
|
||||
//c.Indexes().CreateOne()
|
||||
//c.Indexes().CreateMany()
|
||||
return &User{User: v}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
mongoctl -model-dir=./model -model-names=User -dao-dir=./dao
|
||||
protoc --proto_path=./proto --go_out=../../../ --go-grpc_out=../../../ ./proto/*.proto
|
|
@ -1,25 +0,0 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
//go:generate mongoctl -model-dir=. -model-names=User -dao-dir=../dao
|
||||
type User struct {
|
||||
ID primitive.ObjectID `bson:"_id" gen:"autoFill"`
|
||||
Account string `bson:"account"` // 用户账号
|
||||
Password string `bson:"password"` // 用户密码
|
||||
Salt string `bson:"salt"` // 密码
|
||||
Mobile string `bson:"mobile"` // 用户手机
|
||||
Email string `bson:"email"` // 用户邮箱
|
||||
Nickname string `bson:"nickname"` // 用户昵称
|
||||
Signature string `bson:"signature"` // 用户签名
|
||||
Level int `bson:"level"` // 用户等级
|
||||
Experience int `bson:"experience"` // 用户经验
|
||||
Coin int `bson:"coin"` // 用户金币
|
||||
DeviceID string `bson:"device_id"` // 设备ID
|
||||
RegisterIP string `bson:"register_ip"` // 注册IP
|
||||
RegisterTime primitive.DateTime `bson:"register_time" gen:"autoFill"` // 注册时间
|
||||
LastLoginIP string `bson:"last_login_ip"` // 最近登录IP
|
||||
LastLoginTime primitive.DateTime `bson:"last_login_time" gen:"autoFill"` // 最近登录时间
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package public;
|
||||
option go_package = "mongo.games.com/game/db/proto/public";
|
||||
|
||||
// 通用数据结构
|
||||
|
||||
message Item {
|
||||
int32 Id = 1; // id
|
||||
int64 Num = 2; // 数量
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1-devel
|
||||
// protoc v3.19.4
|
||||
// source: public.proto
|
||||
|
||||
package public
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Item struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // id
|
||||
Num int64 `protobuf:"varint,2,opt,name=Num,proto3" json:"Num,omitempty"` // 数量
|
||||
}
|
||||
|
||||
func (x *Item) Reset() {
|
||||
*x = Item{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_public_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Item) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Item) ProtoMessage() {}
|
||||
|
||||
func (x *Item) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_public_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Item.ProtoReflect.Descriptor instead.
|
||||
func (*Item) Descriptor() ([]byte, []int) {
|
||||
return file_public_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Item) GetId() int32 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Item) GetNum() int64 {
|
||||
if x != nil {
|
||||
return x.Num
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_public_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_public_proto_rawDesc = []byte{
|
||||
0x0a, 0x0c, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06,
|
||||
0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x22, 0x28, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, 0x12, 0x10,
|
||||
0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x4e, 0x75, 0x6d,
|
||||
0x42, 0x26, 0x5a, 0x24, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x64, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_public_proto_rawDescOnce sync.Once
|
||||
file_public_proto_rawDescData = file_public_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_public_proto_rawDescGZIP() []byte {
|
||||
file_public_proto_rawDescOnce.Do(func() {
|
||||
file_public_proto_rawDescData = protoimpl.X.CompressGZIP(file_public_proto_rawDescData)
|
||||
})
|
||||
return file_public_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_public_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_public_proto_goTypes = []interface{}{
|
||||
(*Item)(nil), // 0: public.Item
|
||||
}
|
||||
var file_public_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_public_proto_init() }
|
||||
func file_public_proto_init() {
|
||||
if File_public_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_public_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Item); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_public_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_public_proto_goTypes,
|
||||
DependencyIndexes: file_public_proto_depIdxs,
|
||||
MessageInfos: file_public_proto_msgTypes,
|
||||
}.Build()
|
||||
File_public_proto = out.File
|
||||
file_public_proto_rawDesc = nil
|
||||
file_public_proto_goTypes = nil
|
||||
file_public_proto_depIdxs = nil
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package user;
|
||||
option go_package = "mongo.games.com/game/db/proto/user";
|
||||
|
||||
import "public.proto";
|
||||
|
||||
service UserServer {
|
||||
rpc Save (SaveReq) returns (SaveRsp){}
|
||||
}
|
||||
|
||||
//客户端发送给服务端
|
||||
message SaveReq {
|
||||
string Platform = 1;
|
||||
string name = 2;
|
||||
repeated public.Item Items = 3;
|
||||
}
|
||||
|
||||
//服务端返回给客户端
|
||||
message SaveRsp {
|
||||
string msg = 1 ;
|
||||
}
|
|
@ -1,235 +0,0 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1-devel
|
||||
// protoc v3.19.4
|
||||
// source: user.proto
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
public "mongo.games.com/game/db/proto/public"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
//客户端发送给服务端
|
||||
type SaveReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Platform string `protobuf:"bytes,1,opt,name=Platform,proto3" json:"Platform,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Items []*public.Item `protobuf:"bytes,3,rep,name=Items,proto3" json:"Items,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SaveReq) Reset() {
|
||||
*x = SaveReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SaveReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SaveReq) ProtoMessage() {}
|
||||
|
||||
func (x *SaveReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SaveReq.ProtoReflect.Descriptor instead.
|
||||
func (*SaveReq) Descriptor() ([]byte, []int) {
|
||||
return file_user_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *SaveReq) GetPlatform() string {
|
||||
if x != nil {
|
||||
return x.Platform
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SaveReq) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SaveReq) GetItems() []*public.Item {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//服务端返回给客户端
|
||||
type SaveRsp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SaveRsp) Reset() {
|
||||
*x = SaveRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SaveRsp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SaveRsp) ProtoMessage() {}
|
||||
|
||||
func (x *SaveRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SaveRsp.ProtoReflect.Descriptor instead.
|
||||
func (*SaveRsp) Descriptor() ([]byte, []int) {
|
||||
return file_user_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SaveRsp) GetMsg() string {
|
||||
if x != nil {
|
||||
return x.Msg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_user_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_user_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73,
|
||||
0x65, 0x72, 0x1a, 0x0c, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x22, 0x5d, 0x0a, 0x07, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x50,
|
||||
0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50,
|
||||
0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x75, 0x62,
|
||||
0x6c, 0x69, 0x63, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22,
|
||||
0x1b, 0x0a, 0x07, 0x53, 0x61, 0x76, 0x65, 0x52, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73,
|
||||
0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0x34, 0x0a, 0x0a,
|
||||
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x04, 0x53, 0x61,
|
||||
0x76, 0x65, 0x12, 0x0d, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65,
|
||||
0x71, 0x1a, 0x0d, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x73, 0x70,
|
||||
0x22, 0x00, 0x42, 0x24, 0x5a, 0x22, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65,
|
||||
0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x64, 0x62, 0x2f, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_user_proto_rawDescOnce sync.Once
|
||||
file_user_proto_rawDescData = file_user_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_user_proto_rawDescGZIP() []byte {
|
||||
file_user_proto_rawDescOnce.Do(func() {
|
||||
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
|
||||
})
|
||||
return file_user_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_user_proto_goTypes = []interface{}{
|
||||
(*SaveReq)(nil), // 0: user.SaveReq
|
||||
(*SaveRsp)(nil), // 1: user.SaveRsp
|
||||
(*public.Item)(nil), // 2: public.Item
|
||||
}
|
||||
var file_user_proto_depIdxs = []int32{
|
||||
2, // 0: user.SaveReq.Items:type_name -> public.Item
|
||||
0, // 1: user.UserServer.Save:input_type -> user.SaveReq
|
||||
1, // 2: user.UserServer.Save:output_type -> user.SaveRsp
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_user_proto_init() }
|
||||
func file_user_proto_init() {
|
||||
if File_user_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SaveReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SaveRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_user_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_user_proto_goTypes,
|
||||
DependencyIndexes: file_user_proto_depIdxs,
|
||||
MessageInfos: file_user_proto_msgTypes,
|
||||
}.Build()
|
||||
File_user_proto = out.File
|
||||
file_user_proto_rawDesc = nil
|
||||
file_user_proto_goTypes = nil
|
||||
file_user_proto_depIdxs = nil
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v3.19.4
|
||||
// source: user.proto
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
UserServer_Save_FullMethodName = "/user.UserServer/Save"
|
||||
)
|
||||
|
||||
// UserServerClient is the client API for UserServer service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type UserServerClient interface {
|
||||
Save(ctx context.Context, in *SaveReq, opts ...grpc.CallOption) (*SaveRsp, error)
|
||||
}
|
||||
|
||||
type userServerClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewUserServerClient(cc grpc.ClientConnInterface) UserServerClient {
|
||||
return &userServerClient{cc}
|
||||
}
|
||||
|
||||
func (c *userServerClient) Save(ctx context.Context, in *SaveReq, opts ...grpc.CallOption) (*SaveRsp, error) {
|
||||
out := new(SaveRsp)
|
||||
err := c.cc.Invoke(ctx, UserServer_Save_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// UserServerServer is the server API for UserServer service.
|
||||
// All implementations must embed UnimplementedUserServerServer
|
||||
// for forward compatibility
|
||||
type UserServerServer interface {
|
||||
Save(context.Context, *SaveReq) (*SaveRsp, error)
|
||||
mustEmbedUnimplementedUserServerServer()
|
||||
}
|
||||
|
||||
// UnimplementedUserServerServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServerServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServerServer) Save(context.Context, *SaveReq) (*SaveRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Save not implemented")
|
||||
}
|
||||
func (UnimplementedUserServerServer) mustEmbedUnimplementedUserServerServer() {}
|
||||
|
||||
// UnsafeUserServerServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to UserServerServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeUserServerServer interface {
|
||||
mustEmbedUnimplementedUserServerServer()
|
||||
}
|
||||
|
||||
func RegisterUserServerServer(s grpc.ServiceRegistrar, srv UserServerServer) {
|
||||
s.RegisterService(&UserServer_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _UserServer_Save_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SaveReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServerServer).Save(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserServer_Save_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServerServer).Save(ctx, req.(*SaveReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// UserServer_ServiceDesc is the grpc.ServiceDesc for UserServer service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var UserServer_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "user.UserServer",
|
||||
HandlerType: (*UserServerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Save",
|
||||
Handler: _UserServer_Save_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "user.proto",
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
"mongo.games.com/game/db/proto/user"
|
||||
"mongo.games.com/game/db/rpc/server"
|
||||
"mongo.games.com/game/db/rpc/svc"
|
||||
)
|
||||
|
||||
// GrpcServer grpc服务
|
||||
var GrpcServer *grpc.Server
|
||||
|
||||
// GrpcClientConn grpc客户端连接
|
||||
var GrpcClientConn *grpc.ClientConn
|
||||
|
||||
// RunGrpcServer 启动grpc服务端
|
||||
func RunGrpcServer(addr string) {
|
||||
GrpcServer = grpc.NewServer()
|
||||
registerGrpcServer()
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
panic(errors.New("db grpc failed to listen: " + err.Error()))
|
||||
}
|
||||
|
||||
err = GrpcServer.Serve(ln)
|
||||
if err != nil {
|
||||
panic(errors.New("db grpc failed to serve: " + err.Error()))
|
||||
}
|
||||
logger.Logger.Infof("db grpc start success")
|
||||
}
|
||||
|
||||
// NewGrpcClientConn 创建grpc客户端连接
|
||||
func NewGrpcClientConn(addr string) {
|
||||
var err error
|
||||
GrpcClientConn, err = grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
panic(errors.New("db grpc failed to dial: " + err.Error()))
|
||||
}
|
||||
registerGrpcClient()
|
||||
}
|
||||
|
||||
// registerGrpcServer 注册grpc服务
|
||||
func registerGrpcServer() {
|
||||
ctx := svc.NewServiceContext()
|
||||
user.RegisterUserServerServer(GrpcServer, server.NewUserServer(ctx))
|
||||
}
|
||||
|
||||
var UserClient user.UserServerClient
|
||||
|
||||
func registerGrpcClient() {
|
||||
UserClient = user.NewUserServerClient(GrpcClientConn)
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mongo.games.com/game/db/dao"
|
||||
"mongo.games.com/game/db/model"
|
||||
"mongo.games.com/game/db/proto/user"
|
||||
"mongo.games.com/game/db/rpc/svc"
|
||||
)
|
||||
|
||||
type UserLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLogic {
|
||||
return &UserLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UserLogic) Save(in *user.SaveReq) (*user.SaveRsp, error) {
|
||||
u, err := svc.GetUserCollection(in.GetPlatform(), model.User{}, dao.NewUser)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = u.InsertOne(l.ctx, &model.User{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &user.SaveRsp{}, nil
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.7.2
|
||||
// Source: user.proto
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mongo.games.com/game/db/proto/user"
|
||||
"mongo.games.com/game/db/rpc/logic"
|
||||
"mongo.games.com/game/db/rpc/svc"
|
||||
)
|
||||
|
||||
type UserServer struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
user.UnimplementedUserServerServer
|
||||
}
|
||||
|
||||
func NewUserServer(svcCtx *svc.ServiceContext) *UserServer {
|
||||
return &UserServer{
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *UserServer) Save(ctx context.Context, in *user.SaveReq) (*user.SaveRsp, error) {
|
||||
l := logic.NewUserLogic(ctx, s.svcCtx)
|
||||
return l.Save(in)
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
mon "mongo.games.com/game/mongo"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
// ServiceContext 服务上下文
|
||||
// 依赖注入
|
||||
type ServiceContext struct {
|
||||
}
|
||||
|
||||
func NewServiceContext() *ServiceContext {
|
||||
|
||||
vp := common.GetViper("mgo", "json")
|
||||
// mongo初始化
|
||||
conf := &mon.Config{}
|
||||
err := vp.Unmarshal(conf)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("mongo config error: %v", err))
|
||||
}
|
||||
mon.Init(conf)
|
||||
|
||||
return &ServiceContext{}
|
||||
}
|
||||
|
||||
type TableName interface {
|
||||
TableName() string
|
||||
}
|
||||
|
||||
// GetTableName 获取表名
|
||||
func GetTableName(model any) string {
|
||||
if m, ok := model.(TableName); ok {
|
||||
return m.TableName()
|
||||
}
|
||||
|
||||
t := reflect.TypeOf(model)
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
if t.Kind() != reflect.Struct {
|
||||
panic("model must be a struct or a pointer to a struct")
|
||||
}
|
||||
|
||||
return strings.ToLower(t.Name())
|
||||
}
|
||||
|
||||
// GetUserCollection 用户库
|
||||
func GetUserCollection[T any](platform string, model any, f func(database *mongo.Database, c *mongo.Collection) T) (T, error) {
|
||||
c, err := mon.GetUserCollection(platform, GetTableName(model))
|
||||
if err != nil {
|
||||
var z T
|
||||
logger.Logger.Errorf("GetUserCollection error: %v", err)
|
||||
return z, err
|
||||
}
|
||||
return f(c.Database.Database, c.Collection), nil
|
||||
}
|
||||
|
||||
// GetLogCollection 日志库
|
||||
func GetLogCollection[T any](platform string, model any, f func(database *mongo.Database, c *mongo.Collection) T) (T, error) {
|
||||
c, err := mon.GetLogCollection(platform, GetTableName(model))
|
||||
if err != nil {
|
||||
var z T
|
||||
logger.Logger.Errorf("GetLogCollection error: %v", err)
|
||||
return z, err
|
||||
}
|
||||
return f(c.Database.Database, c.Collection), nil
|
||||
}
|
||||
|
||||
// GetGlobalUserCollection 全局用户库
|
||||
func GetGlobalUserCollection[T any](model any, f func(database *mongo.Database, c *mongo.Collection) T) (T, error) {
|
||||
c, err := mon.GetGlobalUserCollection(GetTableName(model))
|
||||
if err != nil {
|
||||
var z T
|
||||
logger.Logger.Errorf("GetGlobalUserCollection error: %v", err)
|
||||
return z, err
|
||||
}
|
||||
return f(c.Database.Database, c.Collection), nil
|
||||
}
|
||||
|
||||
// GetGlobalLogCollection 全局日志库
|
||||
func GetGlobalLogCollection[T any](model any, f func(database *mongo.Database, c *mongo.Collection) T) (T, error) {
|
||||
c, err := mon.GetGlobalLogCollection(GetTableName(model))
|
||||
if err != nil {
|
||||
var z T
|
||||
logger.Logger.Errorf("GetGlobalLogCollection error: %v", err)
|
||||
return z, err
|
||||
}
|
||||
return f(c.Database.Database, c.Collection), nil
|
||||
}
|
|
@ -216,7 +216,7 @@ func (this *Player) IsAuto() bool {
|
|||
}
|
||||
|
||||
func (this *Player) IsGameing() bool {
|
||||
return !this.IsMarkFlag(PlayerState_WaitNext) && !this.IsMarkFlag(PlayerState_GameBreak) && !this.IsMarkFlag(PlayerState_Bankruptcy) && !this.IsMarkFlag(PlayerState_Audience)
|
||||
return !this.IsMarkFlag(PlayerState_WaitNext) && !this.IsMarkFlag(PlayerState_GameBreak) && !this.IsMarkFlag(PlayerState_Audience)
|
||||
}
|
||||
|
||||
func (this *Player) IsAllFollow() bool {
|
||||
|
@ -640,8 +640,8 @@ func (this *Player) ReportGameEvent(tax, taxex, changeCoin, validbet, validFlow,
|
|||
|
||||
gamingTime := int32(time.Now().Sub(this.scene.GameNowTime).Seconds())
|
||||
mq.Write(model.CreatePlayerGameRecEvent(this.SnId, tax, taxex, changeCoin, validbet, validFlow, in, out,
|
||||
int32(this.scene.GameId), this.scene.GetGameFreeId(), int32(this.scene.GameMode),
|
||||
this.scene.GetRecordId(), this.Channel, this.BeUnderAgentCode, this.Platform, this.City, this.DeviceOS,
|
||||
this.scene.GameId, this.scene.GetGameFreeId(), int32(this.scene.GameMode),
|
||||
this.scene.GetRecordId(), this.Channel, this.ChannelId, this.BeUnderAgentCode, this.Platform, this.City, this.DeviceOS,
|
||||
this.CreateTime, gamingTime, gameFirstTime, gameFreeFirstTime, gameTimes, gameFreeTimes, this.LastLoginTime,
|
||||
this.TelephonePromoter, this.DeviceId), mq.BackGameRecord)
|
||||
}
|
||||
|
|
|
@ -591,6 +591,11 @@ func (this *SceneBaseStateTienLen) CanChangeTo(s base.SceneState) bool {
|
|||
|
||||
// 当前状态能否换桌
|
||||
func (this *SceneBaseStateTienLen) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
||||
if s.IsCustom() {
|
||||
if s.NumOfGames > 0 && s.NumOfGames < int(s.TotalOfGames) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return !p.IsGameing() || s.GetDestroyed() || !s.GetGaming()
|
||||
}
|
||||
|
||||
|
|
9
go.mod
9
go.mod
|
@ -33,10 +33,13 @@ require (
|
|||
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
|
||||
google.golang.org/grpc v1.67.1
|
||||
google.golang.org/protobuf v1.35.1
|
||||
gorm.io/driver/mysql v1.5.7
|
||||
gorm.io/gorm v1.25.12
|
||||
mongo.games.com/goserver v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1 // indirect
|
||||
github.com/containrrr/shoutrrr v0.6.1 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
|
@ -45,6 +48,7 @@ require (
|
|||
github.com/dlclark/regexp2 v1.10.0 // indirect
|
||||
github.com/fatih/color v1.17.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/gocarina/gocsv v0.0.0-20221105105431-c8ef78125b99 // indirect
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
|
@ -53,9 +57,12 @@ require (
|
|||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/innopals/sls-logrus-hook v0.0.0-20190808032145-2fe1d6f7ce00 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
||||
github.com/klauspost/reedsolomon v1.12.4 // indirect
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
|
||||
github.com/lestrrat-go/strftime v1.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
|
@ -68,7 +75,7 @@ require (
|
|||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
|
|
24
go.sum
24
go.sum
|
@ -1,5 +1,7 @@
|
|||
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=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1 h1:j56fC19WoD3z+u+ZHxm2XwRGyS1XmdSMk7058BLhdsM=
|
||||
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1/go.mod h1:gXEhMjm1VadSGjAzyDlBxmdYglP8eJpYWxpwJnmXRWw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
|
@ -92,6 +94,9 @@ github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w
|
|||
github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
|
||||
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
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/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gocarina/gocsv v0.0.0-20221105105431-c8ef78125b99 h1:qNAaZUnCulf2xIQc7rM6F3uGYr80h40rtilsVKyAHoM=
|
||||
github.com/gocarina/gocsv v0.0.0-20221105105431-c8ef78125b99/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
|
||||
|
@ -159,9 +164,13 @@ github.com/innopals/sls-logrus-hook v0.0.0-20190808032145-2fe1d6f7ce00 h1:QfdUfo
|
|||
github.com/innopals/sls-logrus-hook v0.0.0-20190808032145-2fe1d6f7ce00/go.mod h1:Q24O6QMGImDU3WY71P4YAxNb36NNn5qaznCfMUoXVfc=
|
||||
github.com/jarcoal/httpmock v1.0.4 h1:jp+dy/+nonJE4g4xbVtl9QdrUNbn6/3hDT5R4nDIZnA=
|
||||
github.com/jarcoal/httpmock v1.0.4/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
|
||||
github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
|
@ -186,6 +195,12 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4=
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
||||
github.com/lestrrat-go/strftime v1.1.0 h1:gMESpZy44/4pXLO/m+sL0yBd1W6LjgjrrD4a68Gapyg=
|
||||
github.com/lestrrat-go/strftime v1.1.0/go.mod h1:uzeIB52CeUJenCo1syghlugshMysrqUT51HlxphXVeI=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
|
@ -282,8 +297,8 @@ github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKz
|
|||
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
|
@ -581,6 +596,11 @@ 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=
|
||||
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=
|
||||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/now"
|
||||
|
@ -90,30 +88,30 @@ type LuckyDiceGameNoteData struct {
|
|||
}
|
||||
|
||||
// 在线统计
|
||||
type PlayerOnlineEvent struct {
|
||||
Online map[int]int
|
||||
Time time.Time
|
||||
}
|
||||
|
||||
func MarshalPlayerOnlineEvent(source int32, online map[string]int) (data string, err error) {
|
||||
m := map[int]int{}
|
||||
for k, v := range online {
|
||||
i, _ := strconv.Atoi(k)
|
||||
m[i] = v
|
||||
}
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: &PlayerOnlineEvent{
|
||||
Online: m,
|
||||
Time: time.Now(),
|
||||
},
|
||||
}
|
||||
d, err := json.Marshal(raw)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return string(d), nil
|
||||
}
|
||||
//type PlayerOnlineEvent struct {
|
||||
// Online map[int]int
|
||||
// Time time.Time
|
||||
//}
|
||||
//
|
||||
//func MarshalPlayerOnlineEvent(source int32, online map[string]int) (data string, err error) {
|
||||
// m := map[int]int{}
|
||||
// for k, v := range online {
|
||||
// i, _ := strconv.Atoi(k)
|
||||
// m[i] = v
|
||||
// }
|
||||
// raw := &RabbitMQDataRaw{
|
||||
// Source: source,
|
||||
// Data: &PlayerOnlineEvent{
|
||||
// Online: m,
|
||||
// Time: time.Now(),
|
||||
// },
|
||||
// }
|
||||
// d, err := json.Marshal(raw)
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// return string(d), nil
|
||||
//}
|
||||
|
||||
// 玩家登录
|
||||
type PlayerLoginEvent struct {
|
||||
|
@ -166,34 +164,34 @@ func CreatePlayerLoginEvent(snid int32, channel, promoter, platform, city, os, i
|
|||
}
|
||||
|
||||
// 用户升级账号
|
||||
type PlayerBindPhoneEvent struct {
|
||||
SnId int32 //用户ID
|
||||
Channel string //渠道
|
||||
Promoter string //推广
|
||||
Platform string //平台
|
||||
City string //城市
|
||||
OS string //操作系统
|
||||
Value int32 //占位用
|
||||
TelephonePromoter int32 //电销
|
||||
CreateTime int64 //创建日期
|
||||
BindTime int64 //绑定日期
|
||||
}
|
||||
|
||||
func CreatePlayerBindPhoneEvent(snid int32, channel, promoter, platform, city, os string,
|
||||
createTime time.Time, telephonePromoter int32) *PlayerBindPhoneEvent {
|
||||
return &PlayerBindPhoneEvent{
|
||||
SnId: snid,
|
||||
Channel: channel,
|
||||
Promoter: promoter,
|
||||
TelephonePromoter: telephonePromoter,
|
||||
Platform: platform,
|
||||
City: city,
|
||||
OS: os,
|
||||
Value: 1,
|
||||
CreateTime: createTime.Unix(),
|
||||
BindTime: time.Now().Unix(),
|
||||
}
|
||||
}
|
||||
//type PlayerBindPhoneEvent struct {
|
||||
// SnId int32 //用户ID
|
||||
// Channel string //渠道
|
||||
// Promoter string //推广
|
||||
// Platform string //平台
|
||||
// City string //城市
|
||||
// OS string //操作系统
|
||||
// Value int32 //占位用
|
||||
// TelephonePromoter int32 //电销
|
||||
// CreateTime int64 //创建日期
|
||||
// BindTime int64 //绑定日期
|
||||
//}
|
||||
//
|
||||
//func CreatePlayerBindPhoneEvent(snid int32, channel, promoter, platform, city, os string,
|
||||
// createTime time.Time, telephonePromoter int32) *PlayerBindPhoneEvent {
|
||||
// return &PlayerBindPhoneEvent{
|
||||
// SnId: snid,
|
||||
// Channel: channel,
|
||||
// Promoter: promoter,
|
||||
// TelephonePromoter: telephonePromoter,
|
||||
// Platform: platform,
|
||||
// City: city,
|
||||
// OS: os,
|
||||
// Value: 1,
|
||||
// CreateTime: createTime.Unix(),
|
||||
// BindTime: time.Now().Unix(),
|
||||
// }
|
||||
//}
|
||||
|
||||
//func MarshalPlayerBindPhoneEvent(source, snid int32, channel, promoter, platform, city, os string,
|
||||
// createTime time.Time, telephonePromoter int32) (data string, err error) {
|
||||
|
@ -210,46 +208,46 @@ func CreatePlayerBindPhoneEvent(snid int32, channel, promoter, platform, city, o
|
|||
//}
|
||||
|
||||
// 用户升级账号
|
||||
type PlayerBindAlipayEvent struct {
|
||||
SnId int32 //用户ID
|
||||
Channel string //渠道
|
||||
Promoter string //推广
|
||||
TelephonePromoter int32 //电销
|
||||
Platform string //平台
|
||||
City string //城市
|
||||
OS string //操作系统
|
||||
Value int32 //占位用
|
||||
BindTime int64 //绑定日期
|
||||
}
|
||||
|
||||
func MarshalPlayerBindAlipayEvent(source, snid int32, channel, promoter, platform, city, os string, telephonePromoter int32) (data string, err error) {
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: &PlayerBindAlipayEvent{
|
||||
SnId: snid,
|
||||
Channel: channel,
|
||||
Promoter: promoter,
|
||||
Platform: platform,
|
||||
TelephonePromoter: telephonePromoter,
|
||||
City: city,
|
||||
OS: os,
|
||||
Value: 1,
|
||||
BindTime: time.Now().Local().Unix(),
|
||||
},
|
||||
}
|
||||
d, e := json.Marshal(raw)
|
||||
if e == nil {
|
||||
data = string(d[:])
|
||||
}
|
||||
err = e
|
||||
return
|
||||
}
|
||||
//type PlayerBindAlipayEvent struct {
|
||||
// SnId int32 //用户ID
|
||||
// Channel string //渠道
|
||||
// Promoter string //推广
|
||||
// TelephonePromoter int32 //电销
|
||||
// Platform string //平台
|
||||
// City string //城市
|
||||
// OS string //操作系统
|
||||
// Value int32 //占位用
|
||||
// BindTime int64 //绑定日期
|
||||
//}
|
||||
//
|
||||
//func MarshalPlayerBindAlipayEvent(source, snid int32, channel, promoter, platform, city, os string, telephonePromoter int32) (data string, err error) {
|
||||
// raw := &RabbitMQDataRaw{
|
||||
// Source: source,
|
||||
// Data: &PlayerBindAlipayEvent{
|
||||
// SnId: snid,
|
||||
// Channel: channel,
|
||||
// Promoter: promoter,
|
||||
// Platform: platform,
|
||||
// TelephonePromoter: telephonePromoter,
|
||||
// City: city,
|
||||
// OS: os,
|
||||
// Value: 1,
|
||||
// BindTime: time.Now().Local().Unix(),
|
||||
// },
|
||||
// }
|
||||
// d, e := json.Marshal(raw)
|
||||
// if e == nil {
|
||||
// data = string(d[:])
|
||||
// }
|
||||
// err = e
|
||||
// return
|
||||
//}
|
||||
|
||||
// 玩家游戏记录
|
||||
type PlayerGameRecEvent struct {
|
||||
RecordId string //游戏记录ID
|
||||
SnId int32 //用户ID
|
||||
Channel string //渠道
|
||||
Channel string //包类型
|
||||
Promoter string //推广
|
||||
Platform string //平台
|
||||
City string //城市
|
||||
|
@ -258,26 +256,26 @@ type PlayerGameRecEvent struct {
|
|||
GameId int32 //游戏id
|
||||
ModeId int32 //游戏模式
|
||||
Tax int64 //税收
|
||||
//Taxex int64 //税收2
|
||||
Amount int64 //金币变化(正值为赢;负值为输)
|
||||
CreateTime int64 //创建时间
|
||||
CreateDayTime int64 //账号创建时间0点
|
||||
ValidBet int64 //有效下注数量
|
||||
ValidFlow int64 //有效流水数量
|
||||
Out int64 //产出
|
||||
In int64 //投入
|
||||
IsNew int32 //是否是新人
|
||||
GameFreeID int32 //游戏freeid
|
||||
GamingTime int32 //游戏开始到玩家结算的时长 单位:秒
|
||||
FirstTime int64 //首次玩该场次游戏时间
|
||||
PlayTimes int64 //该场次游戏次数
|
||||
FirstGameTime int64 //首次玩游戏时间
|
||||
PlayGameTimes int64 //该游戏总次数
|
||||
LastLoginTime int64 //最后登录时间
|
||||
DeviceId string //设备id
|
||||
Amount int64 //金币变化(正值为赢;负值为输)
|
||||
CreateTime int64 //创建时间
|
||||
CreateDayTime int64 //账号创建时间0点
|
||||
ValidBet int64 //有效下注数量
|
||||
ValidFlow int64 //有效流水数量
|
||||
Out int64 //产出
|
||||
In int64 //投入
|
||||
IsNew int32 //是否是新人
|
||||
GameFreeID int32 //游戏freeid
|
||||
GamingTime int32 //游戏开始到玩家结算的时长 单位:秒
|
||||
FirstTime int64 //首次玩该场次游戏时间
|
||||
PlayTimes int64 //该场次游戏次数
|
||||
FirstGameTime int64 //首次玩游戏时间
|
||||
PlayGameTimes int64 //该游戏总次数
|
||||
LastLoginTime int64 //最后登录时间
|
||||
DeviceId string //设备id
|
||||
ChannelId string //推广渠道id
|
||||
}
|
||||
|
||||
func CreatePlayerGameRecEvent(snid int32, tax, taxex, amount, validbet, validflow, in, out int64, gameid, gameFreeId, modeid int32, recordId, channel, promoter,
|
||||
func CreatePlayerGameRecEvent(snid int32, tax, taxex, amount, validbet, validflow, in, out int64, gameid, gameFreeId, modeid int32, recordId, channel, channelId, promoter,
|
||||
platform, city, os string, createDayTime time.Time, gamingTime int32, firstGameFreeTime, firstGameTime time.Time,
|
||||
playGameFreeTimes, playerGameTimes int64, lastLoginTime time.Time, teleponePromoter int32, deviceId string) *PlayerGameRecEvent {
|
||||
isNewbie := int32(0)
|
||||
|
@ -315,242 +313,227 @@ func CreatePlayerGameRecEvent(snid int32, tax, taxex, amount, validbet, validflo
|
|||
PlayTimes: playGameFreeTimes,
|
||||
PlayGameTimes: playerGameTimes,
|
||||
LastLoginTime: lastLoginTime.Unix(),
|
||||
DeviceId: deviceId}
|
||||
}
|
||||
|
||||
func MarshalPlayerGameRecEvent(source, snid int32, tax, taxex, amount, validbet, validflow, in, out int64, gameid, gameFreeId, modeid int32, recordId, channel, promoter,
|
||||
platform, city, os string, createDayTime time.Time, gamingTime int32, firstGameFreeTime time.Time,
|
||||
playGameFreeTimes int64, lastLoginTime time.Time, telephonePromoter int32, firstGameTime time.Time,
|
||||
playGameTimes int64, deviceId string) (data string, err error) {
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: CreatePlayerGameRecEvent(snid, tax, taxex, amount, validbet, validflow, in, out, gameid, gameFreeId, modeid, recordId, channel, promoter,
|
||||
platform, city, os, createDayTime, gamingTime, firstGameFreeTime, firstGameTime, playGameFreeTimes, playGameTimes, lastLoginTime, telephonePromoter, deviceId),
|
||||
DeviceId: deviceId,
|
||||
ChannelId: channelId,
|
||||
}
|
||||
d, e := json.Marshal(raw)
|
||||
if e == nil {
|
||||
data = string(d[:])
|
||||
}
|
||||
err = e
|
||||
return
|
||||
}
|
||||
|
||||
// 玩家游戏记录
|
||||
type PlayerGameRecPayEvent struct {
|
||||
SnId int32 //用户ID
|
||||
Channel string //渠道
|
||||
Promoter string //推广
|
||||
Platform string //平台
|
||||
City string //城市
|
||||
OS string //操作系统
|
||||
TelephonePromoter int32 //电销标签
|
||||
IsNew int32 //是否新人
|
||||
IsPay int32 //是否付费
|
||||
IsGame int32 //是否游戏
|
||||
CreateTime int64 //记录创建时间
|
||||
CreateDayTime int64 //记录创建时间0点
|
||||
Time int64 //当前时间
|
||||
RegisterDayTime int64 //玩家注册时间
|
||||
}
|
||||
|
||||
func MarshalPlayerGameRecPayEvent(source, snid, isPay, isGame int32, channel, promoter, platform, city, os string,
|
||||
createDayTime time.Time, orderCreateTime int64, telephonePromoter int32) (data string, err error) {
|
||||
isNewbie := int32(0)
|
||||
if now.BeginningOfDay().Equal(now.New(createDayTime).BeginningOfDay()) {
|
||||
isNewbie = 1
|
||||
}
|
||||
tNow := time.Now()
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: &PlayerGameRecPayEvent{
|
||||
SnId: snid,
|
||||
Channel: channel,
|
||||
Promoter: promoter,
|
||||
Platform: platform,
|
||||
City: city,
|
||||
OS: os,
|
||||
IsNew: isNewbie,
|
||||
TelephonePromoter: telephonePromoter,
|
||||
IsPay: isPay,
|
||||
IsGame: isGame,
|
||||
RegisterDayTime: createDayTime.Local().Unix(),
|
||||
CreateTime: time.Unix(orderCreateTime, 0).Local().Unix(),
|
||||
CreateDayTime: now.New(time.Unix(orderCreateTime, 0)).BeginningOfDay().Local().Unix(),
|
||||
Time: tNow.Local().Unix(),
|
||||
},
|
||||
}
|
||||
d, e := json.Marshal(raw)
|
||||
if e == nil {
|
||||
data = string(d[:])
|
||||
}
|
||||
err = e
|
||||
return
|
||||
}
|
||||
|
||||
// 破产统计
|
||||
type BankruptcyEvent struct {
|
||||
SnId int32 //用户id
|
||||
Channel string //渠道
|
||||
Promoter string //推广
|
||||
Platform string //平台
|
||||
City string //城市
|
||||
Value int32 //值
|
||||
TelephonePromoter int32 //电销标签
|
||||
IsNew int32 //是否新人
|
||||
Time int64 //操作时间
|
||||
GameId int32 //游戏id
|
||||
GameMode int32 //游戏模式id
|
||||
GameFreeId int32 //游戏场次id
|
||||
}
|
||||
|
||||
func MarshalBankruptcyEvent(source, snid, telephonePromoter int32, channel, promoter, platform, city string, createDayTime time.Time, gameId, gameMode, gameFreeId int32) (data string, err error) {
|
||||
isNewbie := int32(0)
|
||||
if now.BeginningOfDay().Equal(now.New(createDayTime).BeginningOfDay()) {
|
||||
isNewbie = 1
|
||||
}
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: &BankruptcyEvent{
|
||||
SnId: snid,
|
||||
Channel: channel,
|
||||
Promoter: promoter,
|
||||
TelephonePromoter: telephonePromoter,
|
||||
Platform: platform,
|
||||
City: city,
|
||||
IsNew: isNewbie,
|
||||
Value: 0,
|
||||
Time: time.Now().Local().Unix(),
|
||||
GameId: gameId,
|
||||
GameMode: gameMode,
|
||||
GameFreeId: gameFreeId,
|
||||
},
|
||||
}
|
||||
d, e := json.Marshal(raw)
|
||||
if e == nil {
|
||||
data = string(d[:])
|
||||
}
|
||||
err = e
|
||||
return
|
||||
}
|
||||
|
||||
// 充值统计
|
||||
type PlayerPayEvent struct {
|
||||
SnId int32 //用户id
|
||||
Channel string //渠道
|
||||
Promoter string //推广
|
||||
Platform string //平台
|
||||
City string //城市
|
||||
TelephonePromoter int32 //电销标记
|
||||
Tag int32 //#充值类型 0 API直接充值 1在线充值
|
||||
BeforeCoin int32 //充值前钱包数量
|
||||
BeforeBank int32 //充值前保险柜数量
|
||||
Amount int32 //充值金额
|
||||
IsNew int32 //是否是新人
|
||||
Time int64 //操作时间
|
||||
}
|
||||
|
||||
func MarshalPlayerPayEvent(source, snid, tag, beforeCoin, beforeBank, amount int32, channel,
|
||||
promoter, platform, city string, createDayTime time.Time, orderCreateTime int64,
|
||||
telephonePromoter int32) (data string, err error) {
|
||||
isNewbie := int32(0)
|
||||
if now.BeginningOfDay().Equal(now.New(createDayTime).BeginningOfDay()) {
|
||||
isNewbie = 1
|
||||
}
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: &PlayerPayEvent{
|
||||
SnId: snid,
|
||||
Channel: channel,
|
||||
Promoter: promoter,
|
||||
Platform: platform,
|
||||
City: city,
|
||||
Tag: tag,
|
||||
TelephonePromoter: telephonePromoter,
|
||||
BeforeCoin: beforeCoin,
|
||||
BeforeBank: beforeBank,
|
||||
Amount: amount,
|
||||
IsNew: isNewbie,
|
||||
Time: time.Unix(orderCreateTime, 0).Local().Unix(),
|
||||
},
|
||||
}
|
||||
d, e := json.Marshal(raw)
|
||||
if e == nil {
|
||||
data = string(d[:])
|
||||
}
|
||||
err = e
|
||||
return
|
||||
}
|
||||
|
||||
// 系统赠送
|
||||
type SystemGiveEvent struct {
|
||||
SnId int32 //用户id
|
||||
Channel string //渠道
|
||||
Promoter string //推广
|
||||
Platform string //平台
|
||||
City string //城市
|
||||
TelephonePromoter int32 //电销
|
||||
Tag int32 //#充值类型 0 API直接充值 1在线充值
|
||||
Amount int32 //充值金额
|
||||
Time int64 //操作时间
|
||||
}
|
||||
|
||||
func MarshalSystemGiveEvent(source, snid, tag, amount int32, channel, promoter, platform, city string,
|
||||
telephonePromoter int32) (data string, err error) {
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: &SystemGiveEvent{
|
||||
SnId: snid,
|
||||
Channel: channel,
|
||||
Promoter: promoter,
|
||||
Platform: platform,
|
||||
TelephonePromoter: telephonePromoter,
|
||||
City: city,
|
||||
Tag: tag,
|
||||
Amount: amount,
|
||||
Time: time.Now().Local().Unix(),
|
||||
},
|
||||
}
|
||||
d, e := json.Marshal(raw)
|
||||
if e == nil {
|
||||
data = string(d[:])
|
||||
}
|
||||
err = e
|
||||
return
|
||||
}
|
||||
|
||||
// 水池变化记录
|
||||
type GameCoinPoolEvent struct {
|
||||
Platform string //平台
|
||||
GameId int32 //游戏id
|
||||
GroupId int32 //组id
|
||||
ChangeCoin int64 //变化金币
|
||||
CurCoin int64 //变化后金币
|
||||
UpCoin int64 //上限
|
||||
DownCoin int64 //下限
|
||||
Time int64 //操作时间
|
||||
}
|
||||
|
||||
func MarshalGameCoinPoolEvent(source int32, platform string, gameid, groupId int32, changeCoin,
|
||||
curCoin, upCoin, downCoin int64) (data string, err error) {
|
||||
|
||||
raw := &RabbitMQDataRaw{
|
||||
Source: source,
|
||||
Data: &GameCoinPoolEvent{
|
||||
Platform: platform,
|
||||
GameId: gameid,
|
||||
|
||||
GroupId: groupId,
|
||||
ChangeCoin: changeCoin,
|
||||
CurCoin: curCoin,
|
||||
UpCoin: upCoin,
|
||||
DownCoin: downCoin,
|
||||
Time: time.Now().Local().Unix(),
|
||||
},
|
||||
}
|
||||
d, e := json.Marshal(raw)
|
||||
if e == nil {
|
||||
data = string(d[:])
|
||||
}
|
||||
err = e
|
||||
return
|
||||
}
|
||||
//type PlayerGameRecPayEvent struct {
|
||||
// SnId int32 //用户ID
|
||||
// Channel string //渠道
|
||||
// Promoter string //推广
|
||||
// Platform string //平台
|
||||
// City string //城市
|
||||
// OS string //操作系统
|
||||
// TelephonePromoter int32 //电销标签
|
||||
// IsNew int32 //是否新人
|
||||
// IsPay int32 //是否付费
|
||||
// IsGame int32 //是否游戏
|
||||
// CreateTime int64 //记录创建时间
|
||||
// CreateDayTime int64 //记录创建时间0点
|
||||
// Time int64 //当前时间
|
||||
// RegisterDayTime int64 //玩家注册时间
|
||||
//}
|
||||
//
|
||||
//func MarshalPlayerGameRecPayEvent(source, snid, isPay, isGame int32, channel, promoter, platform, city, os string,
|
||||
// createDayTime time.Time, orderCreateTime int64, telephonePromoter int32) (data string, err error) {
|
||||
// isNewbie := int32(0)
|
||||
// if now.BeginningOfDay().Equal(now.New(createDayTime).BeginningOfDay()) {
|
||||
// isNewbie = 1
|
||||
// }
|
||||
// tNow := time.Now()
|
||||
// raw := &RabbitMQDataRaw{
|
||||
// Source: source,
|
||||
// Data: &PlayerGameRecPayEvent{
|
||||
// SnId: snid,
|
||||
// Channel: channel,
|
||||
// Promoter: promoter,
|
||||
// Platform: platform,
|
||||
// City: city,
|
||||
// OS: os,
|
||||
// IsNew: isNewbie,
|
||||
// TelephonePromoter: telephonePromoter,
|
||||
// IsPay: isPay,
|
||||
// IsGame: isGame,
|
||||
// RegisterDayTime: createDayTime.Local().Unix(),
|
||||
// CreateTime: time.Unix(orderCreateTime, 0).Local().Unix(),
|
||||
// CreateDayTime: now.New(time.Unix(orderCreateTime, 0)).BeginningOfDay().Local().Unix(),
|
||||
// Time: tNow.Local().Unix(),
|
||||
// },
|
||||
// }
|
||||
// d, e := json.Marshal(raw)
|
||||
// if e == nil {
|
||||
// data = string(d[:])
|
||||
// }
|
||||
// err = e
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 破产统计
|
||||
//type BankruptcyEvent struct {
|
||||
// SnId int32 //用户id
|
||||
// Channel string //渠道
|
||||
// Promoter string //推广
|
||||
// Platform string //平台
|
||||
// City string //城市
|
||||
// Value int32 //值
|
||||
// TelephonePromoter int32 //电销标签
|
||||
// IsNew int32 //是否新人
|
||||
// Time int64 //操作时间
|
||||
// GameId int32 //游戏id
|
||||
// GameMode int32 //游戏模式id
|
||||
// GameFreeId int32 //游戏场次id
|
||||
//}
|
||||
//
|
||||
//func MarshalBankruptcyEvent(source, snid, telephonePromoter int32, channel, promoter, platform, city string, createDayTime time.Time, gameId, gameMode, gameFreeId int32) (data string, err error) {
|
||||
// isNewbie := int32(0)
|
||||
// if now.BeginningOfDay().Equal(now.New(createDayTime).BeginningOfDay()) {
|
||||
// isNewbie = 1
|
||||
// }
|
||||
// raw := &RabbitMQDataRaw{
|
||||
// Source: source,
|
||||
// Data: &BankruptcyEvent{
|
||||
// SnId: snid,
|
||||
// Channel: channel,
|
||||
// Promoter: promoter,
|
||||
// TelephonePromoter: telephonePromoter,
|
||||
// Platform: platform,
|
||||
// City: city,
|
||||
// IsNew: isNewbie,
|
||||
// Value: 0,
|
||||
// Time: time.Now().Local().Unix(),
|
||||
// GameId: gameId,
|
||||
// GameMode: gameMode,
|
||||
// GameFreeId: gameFreeId,
|
||||
// },
|
||||
// }
|
||||
// d, e := json.Marshal(raw)
|
||||
// if e == nil {
|
||||
// data = string(d[:])
|
||||
// }
|
||||
// err = e
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 充值统计
|
||||
//type PlayerPayEvent struct {
|
||||
// SnId int32 //用户id
|
||||
// Channel string //渠道
|
||||
// Promoter string //推广
|
||||
// Platform string //平台
|
||||
// City string //城市
|
||||
// TelephonePromoter int32 //电销标记
|
||||
// Tag int32 //#充值类型 0 API直接充值 1在线充值
|
||||
// BeforeCoin int32 //充值前钱包数量
|
||||
// BeforeBank int32 //充值前保险柜数量
|
||||
// Amount int32 //充值金额
|
||||
// IsNew int32 //是否是新人
|
||||
// Time int64 //操作时间
|
||||
//}
|
||||
//
|
||||
//func MarshalPlayerPayEvent(source, snid, tag, beforeCoin, beforeBank, amount int32, channel,
|
||||
// promoter, platform, city string, createDayTime time.Time, orderCreateTime int64,
|
||||
// telephonePromoter int32) (data string, err error) {
|
||||
// isNewbie := int32(0)
|
||||
// if now.BeginningOfDay().Equal(now.New(createDayTime).BeginningOfDay()) {
|
||||
// isNewbie = 1
|
||||
// }
|
||||
// raw := &RabbitMQDataRaw{
|
||||
// Source: source,
|
||||
// Data: &PlayerPayEvent{
|
||||
// SnId: snid,
|
||||
// Channel: channel,
|
||||
// Promoter: promoter,
|
||||
// Platform: platform,
|
||||
// City: city,
|
||||
// Tag: tag,
|
||||
// TelephonePromoter: telephonePromoter,
|
||||
// BeforeCoin: beforeCoin,
|
||||
// BeforeBank: beforeBank,
|
||||
// Amount: amount,
|
||||
// IsNew: isNewbie,
|
||||
// Time: time.Unix(orderCreateTime, 0).Local().Unix(),
|
||||
// },
|
||||
// }
|
||||
// d, e := json.Marshal(raw)
|
||||
// if e == nil {
|
||||
// data = string(d[:])
|
||||
// }
|
||||
// err = e
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 系统赠送
|
||||
//type SystemGiveEvent struct {
|
||||
// SnId int32 //用户id
|
||||
// Channel string //渠道
|
||||
// Promoter string //推广
|
||||
// Platform string //平台
|
||||
// City string //城市
|
||||
// TelephonePromoter int32 //电销
|
||||
// Tag int32 //#充值类型 0 API直接充值 1在线充值
|
||||
// Amount int32 //充值金额
|
||||
// Time int64 //操作时间
|
||||
//}
|
||||
//
|
||||
//func MarshalSystemGiveEvent(source, snid, tag, amount int32, channel, promoter, platform, city string,
|
||||
// telephonePromoter int32) (data string, err error) {
|
||||
// raw := &RabbitMQDataRaw{
|
||||
// Source: source,
|
||||
// Data: &SystemGiveEvent{
|
||||
// SnId: snid,
|
||||
// Channel: channel,
|
||||
// Promoter: promoter,
|
||||
// Platform: platform,
|
||||
// TelephonePromoter: telephonePromoter,
|
||||
// City: city,
|
||||
// Tag: tag,
|
||||
// Amount: amount,
|
||||
// Time: time.Now().Local().Unix(),
|
||||
// },
|
||||
// }
|
||||
// d, e := json.Marshal(raw)
|
||||
// if e == nil {
|
||||
// data = string(d[:])
|
||||
// }
|
||||
// err = e
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 水池变化记录
|
||||
//type GameCoinPoolEvent struct {
|
||||
// Platform string //平台
|
||||
// GameId int32 //游戏id
|
||||
// GroupId int32 //组id
|
||||
// ChangeCoin int64 //变化金币
|
||||
// CurCoin int64 //变化后金币
|
||||
// UpCoin int64 //上限
|
||||
// DownCoin int64 //下限
|
||||
// Time int64 //操作时间
|
||||
//}
|
||||
//
|
||||
//func MarshalGameCoinPoolEvent(source int32, platform string, gameid, groupId int32, changeCoin,
|
||||
// curCoin, upCoin, downCoin int64) (data string, err error) {
|
||||
//
|
||||
// raw := &RabbitMQDataRaw{
|
||||
// Source: source,
|
||||
// Data: &GameCoinPoolEvent{
|
||||
// Platform: platform,
|
||||
// GameId: gameid,
|
||||
//
|
||||
// GroupId: groupId,
|
||||
// ChangeCoin: changeCoin,
|
||||
// CurCoin: curCoin,
|
||||
// UpCoin: upCoin,
|
||||
// DownCoin: downCoin,
|
||||
// Time: time.Now().Local().Unix(),
|
||||
// },
|
||||
// }
|
||||
// d, e := json.Marshal(raw)
|
||||
// if e == nil {
|
||||
// data = string(d[:])
|
||||
// }
|
||||
// err = e
|
||||
// return
|
||||
//}
|
||||
|
|
|
@ -41,6 +41,7 @@ const (
|
|||
MSGTYPE_RANK_PermitReward // 通行证排行奖励
|
||||
MSGTYPE_ClientUpgrade // 客户端升级
|
||||
MSGTYPE_Lottery // 开奖码抽奖
|
||||
MSGTYPE_TelCode // 手机兑换码
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
144
mongo/export.go
144
mongo/export.go
|
@ -1,144 +0,0 @@
|
|||
package mongo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
"mongo.games.com/game/mongo/internal"
|
||||
)
|
||||
|
||||
type DatabaseType string
|
||||
|
||||
const (
|
||||
KeyGlobal = "global"
|
||||
DatabaseUser DatabaseType = "user"
|
||||
DatabaseLog DatabaseType = "log"
|
||||
)
|
||||
|
||||
var NotInitError = errors.New("mongo manager is nil, please call Init() first")
|
||||
|
||||
type Config = internal.Config
|
||||
type DatabaseConfig = internal.DatabaseConfig
|
||||
type Collection = internal.Collection
|
||||
type Database = internal.Database
|
||||
|
||||
var _manager *internal.Manager
|
||||
var _conf *internal.Config
|
||||
|
||||
// GetConfig 获取配置
|
||||
func GetConfig() *Config {
|
||||
return _conf
|
||||
}
|
||||
|
||||
// Init 初始化
|
||||
func Init(conf *Config) {
|
||||
_conf = conf
|
||||
_manager = internal.NewManager(_conf)
|
||||
}
|
||||
|
||||
// Restart 重启
|
||||
func Restart() {
|
||||
if _manager == nil {
|
||||
logger.Logger.Error(NotInitError)
|
||||
return
|
||||
}
|
||||
_manager.Restart(_conf)
|
||||
}
|
||||
|
||||
// Close 关闭
|
||||
func Close() {
|
||||
internal.Close(_manager)
|
||||
}
|
||||
|
||||
// GetDatabase 获取数据库
|
||||
// platform: 平台id
|
||||
// database: 数据库名称
|
||||
func GetDatabase(platform string, database DatabaseType) (*Database, error) {
|
||||
if _manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
|
||||
return _manager.GetDatabase(platform, string(database))
|
||||
}
|
||||
|
||||
func GetUserDatabase(platform string) (*Database, error) {
|
||||
return GetDatabase(platform, DatabaseUser)
|
||||
}
|
||||
|
||||
func GetLogDatabase(platform string) (*Database, error) {
|
||||
return GetDatabase(platform, DatabaseLog)
|
||||
}
|
||||
|
||||
// GetGlobalDatabase 获取全局库
|
||||
// database: 数据库名称
|
||||
func GetGlobalDatabase(database DatabaseType) (*Database, error) {
|
||||
if _manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
|
||||
return _manager.GetDatabase(KeyGlobal, string(database))
|
||||
}
|
||||
|
||||
func GetGlobalUserDatabase() (*Database, error) {
|
||||
return GetGlobalDatabase(DatabaseUser)
|
||||
}
|
||||
|
||||
func GetGlobalLogDatabase() (*Database, error) {
|
||||
return GetGlobalDatabase(DatabaseLog)
|
||||
}
|
||||
|
||||
// GetGlobalCollection 获取全局库
|
||||
// database: 数据库名称
|
||||
// collection: 集合名称
|
||||
func GetGlobalCollection(database DatabaseType, collection string) (*Collection, error) {
|
||||
if _manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
|
||||
return _manager.GetCollection(KeyGlobal, string(database), collection)
|
||||
}
|
||||
|
||||
func GetGlobalUserCollection(collection string) (*Collection, error) {
|
||||
return GetGlobalCollection(DatabaseUser, collection)
|
||||
}
|
||||
|
||||
func GetGlobalLogCollection(collection string) (*Collection, error) {
|
||||
return GetGlobalCollection(DatabaseLog, collection)
|
||||
}
|
||||
|
||||
// GetCollection 获取平台库
|
||||
// platform: 平台id
|
||||
// database: 数据库名称
|
||||
// collection: 集合名称
|
||||
func GetCollection(platform string, database DatabaseType, collection string) (*Collection, error) {
|
||||
if _manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
|
||||
return _manager.GetCollection(platform, string(database), collection)
|
||||
}
|
||||
|
||||
func GetUserCollection(platform string, collection string) (*Collection, error) {
|
||||
return GetCollection(platform, DatabaseUser, collection)
|
||||
}
|
||||
|
||||
func GetLogCollection(platform string, collection string) (*Collection, error) {
|
||||
return GetCollection(platform, DatabaseLog, collection)
|
||||
}
|
||||
|
||||
// GetClient 获取数据库连接
|
||||
// 默认获取的是 Global, log 的数据库连接
|
||||
func GetClient() (*mongo.Client, error) {
|
||||
if _manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
|
||||
c, err := _manager.GetCollection(KeyGlobal, string(DatabaseLog), "empty")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.Database.Client, nil
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Global map[string]*DatabaseConfig
|
||||
Platforms map[string]map[string]*DatabaseConfig
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
HostName string // 主机地址
|
||||
HostPort int32 // 端口
|
||||
Database string // 数据库名
|
||||
Username string // 用户名
|
||||
Password string // 密码
|
||||
Options string // 配置
|
||||
}
|
||||
|
||||
type Collection struct {
|
||||
Database *Database
|
||||
*mongo.Collection
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
*DatabaseConfig
|
||||
Client *mongo.Client
|
||||
Database *mongo.Database
|
||||
Collection sync.Map
|
||||
}
|
||||
|
||||
func (d *Database) Connect() error {
|
||||
if d.DatabaseConfig == nil {
|
||||
err := fmt.Errorf("mongo Connect error, DatabaseConifg not found")
|
||||
logger.Logger.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
login := ""
|
||||
if d.DatabaseConfig.Username != "" {
|
||||
login = d.DatabaseConfig.Username + ":" + d.DatabaseConfig.Password + "@"
|
||||
}
|
||||
host := d.DatabaseConfig.HostName
|
||||
if d.DatabaseConfig.HostName == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
port := d.DatabaseConfig.HostPort
|
||||
if d.DatabaseConfig.HostPort == 0 {
|
||||
port = 27017
|
||||
}
|
||||
myOptions := d.DatabaseConfig.Options
|
||||
if myOptions != "" {
|
||||
myOptions = "?" + myOptions
|
||||
}
|
||||
|
||||
s := fmt.Sprintf("mongodb://%s%s:%d/admin%s", login, host, port, myOptions)
|
||||
client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(s))
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mongo Connect %v error: %v config:%+v", s, err, *d.DatabaseConfig)
|
||||
return err
|
||||
}
|
||||
logger.Logger.Tracef("mongo connect success %+v", *d.DatabaseConfig)
|
||||
d.Client = client
|
||||
d.Database = client.Database(d.DatabaseConfig.Database)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Database) GetCollection(name string) (*Collection, error) {
|
||||
if d.Database == nil {
|
||||
err := fmt.Errorf("mongo GetCollection error, collection:%v, database is nil", name)
|
||||
logger.Logger.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
v, ok := d.Collection.Load(name)
|
||||
if !ok {
|
||||
v = &Collection{
|
||||
Database: d,
|
||||
Collection: d.Database.Collection(name),
|
||||
}
|
||||
d.Collection.Store(name, v)
|
||||
}
|
||||
c, _ := v.(*Collection)
|
||||
return c, nil
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
conf *Config
|
||||
global *sync.Map // 内部库名称:Database
|
||||
platforms *sync.Map // 平台id:内部库名称:Database
|
||||
}
|
||||
|
||||
func (m *Manager) GetCollection(key, database, collection string) (*Collection, error) {
|
||||
d, err := m.GetDatabase(key, database)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return d.GetCollection(collection)
|
||||
}
|
||||
|
||||
func (m *Manager) GetDatabase(key, database string) (*Database, error) {
|
||||
switch key {
|
||||
case "global":
|
||||
v, ok := m.global.Load(database)
|
||||
if !ok {
|
||||
db := &Database{
|
||||
DatabaseConfig: m.conf.Global[database],
|
||||
Collection: sync.Map{},
|
||||
}
|
||||
if err := db.Connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v = db
|
||||
m.global.Store(database, v)
|
||||
}
|
||||
d, _ := v.(*Database)
|
||||
return d, nil
|
||||
|
||||
default:
|
||||
var mp *sync.Map
|
||||
v, ok := m.platforms.Load(key) // 平台id
|
||||
if !ok {
|
||||
mp = new(sync.Map)
|
||||
m.platforms.Store(key, mp)
|
||||
} else {
|
||||
mp = v.(*sync.Map)
|
||||
}
|
||||
v, ok = mp.Load(database)
|
||||
if !ok {
|
||||
db := &Database{
|
||||
DatabaseConfig: m.conf.Platforms[key][database],
|
||||
Collection: sync.Map{},
|
||||
}
|
||||
if err := db.Connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v = db
|
||||
mp.Store(database, v)
|
||||
}
|
||||
d, _ := v.(*Database)
|
||||
return d, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) Restart(conf *Config) {
|
||||
logger.Logger.Infof("mongo manager restart...")
|
||||
old := *m
|
||||
time.AfterFunc(time.Minute, func() {
|
||||
Close(&old)
|
||||
})
|
||||
|
||||
m.conf = conf
|
||||
m.global = &sync.Map{}
|
||||
m.platforms = &sync.Map{}
|
||||
}
|
||||
|
||||
func Close(m *Manager) {
|
||||
logger.Logger.Infof("mongo manager close")
|
||||
m.global.Range(func(key, value any) bool {
|
||||
if v, ok := value.(*Database); ok {
|
||||
v.Client.Disconnect(nil)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
m.platforms.Range(func(key, value any) bool {
|
||||
if v, ok := value.(*sync.Map); ok {
|
||||
v.Range(func(key, value any) bool {
|
||||
if v, ok := value.(*Database); ok {
|
||||
v.Client.Disconnect(nil)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Manager) GetConfig() *Config {
|
||||
return m.conf
|
||||
}
|
||||
|
||||
func NewManager(conf *Config) *Manager {
|
||||
return &Manager{
|
||||
conf: conf,
|
||||
global: &sync.Map{},
|
||||
platforms: &sync.Map{},
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"mongo.games.com/game/mysql/internal"
|
||||
)
|
||||
|
||||
var NotInitError = errors.New("mysql manager is nil, please call Init() first")
|
||||
|
||||
type Config = internal.Config
|
||||
type DatabaseConfig = internal.DatabaseConfig
|
||||
type Database = internal.Database
|
||||
|
||||
var manager *internal.Manager
|
||||
|
||||
func Init(conf *Config) error {
|
||||
manager = internal.NewManager(conf)
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetAutoMigrateTables(tables []interface{}) {
|
||||
if manager == nil {
|
||||
return
|
||||
}
|
||||
manager.SetAutoMigrateTables(tables)
|
||||
}
|
||||
|
||||
func GetConfig() *Config {
|
||||
if manager == nil {
|
||||
return nil
|
||||
}
|
||||
return manager.GetConfig()
|
||||
}
|
||||
|
||||
func Close() {
|
||||
if manager == nil {
|
||||
return
|
||||
}
|
||||
manager.Close()
|
||||
}
|
||||
|
||||
func GetDatabase(platform string) (*Database, error) {
|
||||
if manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
return manager.GetDatabase(platform)
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Platforms map[string]*DatabaseConfig
|
||||
MaxIdleConns int
|
||||
MaxOpenConns int
|
||||
ConnMaxLifetime int
|
||||
ConnMaxIdletime int
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
HostName string
|
||||
HostPort int32
|
||||
Database string
|
||||
Username string
|
||||
Password string
|
||||
Options string
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
*Manager
|
||||
*Config
|
||||
*DatabaseConfig
|
||||
*gorm.DB
|
||||
}
|
||||
|
||||
func (d *Database) Connect() error {
|
||||
if d.DatabaseConfig == nil {
|
||||
err := fmt.Errorf("mysql Connect error, DatabaseConifg not found")
|
||||
logger.Logger.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
login := ""
|
||||
if d.DatabaseConfig.Username != "" {
|
||||
login = d.DatabaseConfig.Username + ":" + d.DatabaseConfig.Password + "@"
|
||||
}
|
||||
host := d.DatabaseConfig.HostName
|
||||
if d.DatabaseConfig.HostName == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
port := d.DatabaseConfig.HostPort
|
||||
if d.DatabaseConfig.HostPort == 0 {
|
||||
port = 3306
|
||||
}
|
||||
database := d.DatabaseConfig.Database
|
||||
if database == "" {
|
||||
database = "mysql"
|
||||
}
|
||||
myOptions := d.DatabaseConfig.Options
|
||||
if myOptions != "" {
|
||||
myOptions = "?" + myOptions
|
||||
}
|
||||
|
||||
// [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]
|
||||
s := fmt.Sprintf("%stcp(%s:%d)/%s%s", login, host, port, "mysql", myOptions)
|
||||
db, err := gorm.Open(mysql.Open(s), &gorm.Config{})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql Connect %v error: %v config:%+v", s, err, *d.DatabaseConfig)
|
||||
return err
|
||||
}
|
||||
logger.Logger.Tracef("mysql connect success %+v", *d.DatabaseConfig)
|
||||
|
||||
err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci", d.DatabaseConfig.Database)).Error
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql create database %s error: %v", d.DatabaseConfig.Database, err)
|
||||
return err
|
||||
}
|
||||
|
||||
s = fmt.Sprintf("%stcp(%s:%d)/%s%s", login, host, port, d.DatabaseConfig.Database, myOptions)
|
||||
db, err = gorm.Open(mysql.Open(s), &gorm.Config{SkipDefaultTransaction: true})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql Connect %v error: %v config:%+v", s, err, *d.DatabaseConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql get DB error: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if len(d.tables) > 0 {
|
||||
if err := db.AutoMigrate(d.tables...); err != nil {
|
||||
logger.Logger.Warnf("mysql migrate error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
sqlDB.SetMaxIdleConns(d.MaxIdleConns)
|
||||
sqlDB.SetMaxOpenConns(d.MaxOpenConns)
|
||||
sqlDB.SetConnMaxLifetime(time.Duration(d.ConnMaxLifetime))
|
||||
sqlDB.SetConnMaxIdleTime(time.Duration(d.ConnMaxIdletime))
|
||||
|
||||
d.DB = db.Session(&gorm.Session{SkipDefaultTransaction: true})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
conf *Config
|
||||
platforms sync.Map // 平台id:Database
|
||||
tables []interface{}
|
||||
}
|
||||
|
||||
func (m *Manager) GetConfig() *Config {
|
||||
return m.conf
|
||||
}
|
||||
|
||||
func (m *Manager) SetAutoMigrateTables(tables []interface{}) {
|
||||
m.tables = tables
|
||||
}
|
||||
|
||||
func (m *Manager) GetDatabase(key string) (*Database, error) {
|
||||
v, ok := m.platforms.Load(key) // 平台id
|
||||
if !ok {
|
||||
db := &Database{
|
||||
Manager: m,
|
||||
Config: m.conf,
|
||||
DatabaseConfig: m.conf.Platforms[key],
|
||||
}
|
||||
if err := db.Connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v = db
|
||||
m.platforms.Store(key, v)
|
||||
}
|
||||
d, _ := v.(*Database)
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (m *Manager) Close() {
|
||||
|
||||
}
|
||||
|
||||
func NewManager(conf *Config) *Manager {
|
||||
return &Manager{
|
||||
conf: conf,
|
||||
platforms: sync.Map{},
|
||||
}
|
||||
}
|
|
@ -3681,10 +3681,10 @@ type ShopWeight struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ShopType int32 `protobuf:"varint,1,opt,name=ShopType,proto3" json:"ShopType,omitempty"`
|
||||
Weight int32 `protobuf:"varint,2,opt,name=Weight,proto3" json:"Weight,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||
IsShow int32 `protobuf:"varint,4,opt,name=IsShow,proto3" json:"IsShow,omitempty"`
|
||||
ShopType int32 `protobuf:"varint,1,opt,name=ShopType,proto3" json:"ShopType,omitempty"` // 商品类型 对应 ExchangeShop.ShopType
|
||||
Weight int32 `protobuf:"varint,2,opt,name=Weight,proto3" json:"Weight,omitempty"` // 排序,从大到小
|
||||
Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"` // 分类名称, 多语言 {\"zh\":\"电子\",\"en\":\"electronic engineering\",\"vi\":\"Điện tử\",\"kh\":\"អេឡិចត្រូន\"}
|
||||
IsShow int32 `protobuf:"varint,4,opt,name=IsShow,proto3" json:"IsShow,omitempty"` // 是否显示 1显示
|
||||
Location []int32 `protobuf:"varint,5,rep,packed,name=Location,proto3" json:"Location,omitempty"` // 显示位置
|
||||
}
|
||||
|
||||
|
|
|
@ -419,10 +419,10 @@ message ExchangeShopList{
|
|||
}
|
||||
|
||||
message ShopWeight{
|
||||
int32 ShopType = 1;
|
||||
int32 Weight = 2;
|
||||
string Name = 3;
|
||||
int32 IsShow = 4;
|
||||
int32 ShopType = 1; // 商品类型 对应 ExchangeShop.ShopType
|
||||
int32 Weight = 2; // 排序,从大到小
|
||||
string Name = 3; // 分类名称, 多语言 {\"zh\":\"电子\",\"en\":\"electronic engineering\",\"vi\":\"Điện tử\",\"kh\":\"អេឡិចត្រូន\"}
|
||||
int32 IsShow = 4; // 是否显示 1显示
|
||||
repeated int32 Location = 5; // 显示位置
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -698,6 +698,8 @@ message ASCreateExchangeOrder {
|
|||
message SACreateExchangeOrder {
|
||||
TagCode Tag = 1; //错误码
|
||||
ReturnCPO ReturnCPO = 2;
|
||||
repeated ItemInfo Items = 3; // 道具变化
|
||||
string TelCode = 4; // 手机兑换码
|
||||
}
|
||||
//获取交易订单game_srv/get_exchange_order
|
||||
message ASGetExchangeOrder{
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
package balancequeue
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 平衡队列
|
||||
|
||||
type Element interface {
|
||||
BalanceQueueHandler()
|
||||
}
|
||||
|
||||
type elementWrapper struct {
|
||||
F func()
|
||||
}
|
||||
|
||||
func (e *elementWrapper) BalanceQueueHandler() {
|
||||
e.F()
|
||||
}
|
||||
|
||||
func ElementWrapper(f func()) Element {
|
||||
return &elementWrapper{F: f}
|
||||
}
|
||||
|
||||
type group struct {
|
||||
Array []Element
|
||||
queuePos int
|
||||
}
|
||||
|
||||
type groupArray struct {
|
||||
queue []*group
|
||||
}
|
||||
|
||||
type BalanceQueue struct {
|
||||
index int // 循环索引
|
||||
groups []*group // 固定的分组,长度不变,每次Update触发一个分组
|
||||
tables []*groupArray
|
||||
pool map[Element]*group
|
||||
}
|
||||
|
||||
// New 创建一个平衡队列
|
||||
// groupNumber 分组数量
|
||||
func New(groupNumber int) *BalanceQueue {
|
||||
ret := &BalanceQueue{
|
||||
groups: make([]*group, groupNumber),
|
||||
tables: make([]*groupArray, 10), // 本身会自动扩容,初始值不是很重要
|
||||
pool: make(map[Element]*group),
|
||||
}
|
||||
|
||||
for i := 0; i < len(ret.tables); i++ {
|
||||
ret.tables[i] = &groupArray{}
|
||||
}
|
||||
// 初始化平衡数组,所有平衡队列容量为0
|
||||
for i := 0; i < len(ret.groups); i++ {
|
||||
ret.groups[i] = &group{queuePos: i}
|
||||
ret.tables[0].queue = append(ret.tables[0].queue, ret.groups[i])
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (q *BalanceQueue) String() string {
|
||||
buf := strings.Builder{}
|
||||
buf.WriteString("BalanceQueue:\n")
|
||||
buf.WriteString(fmt.Sprintf("分组数量: %v\n", len(q.groups)))
|
||||
for k, v := range q.tables {
|
||||
buf.WriteString(fmt.Sprintf("元素数量%v: 组数量%v ==>", k, len(v.queue)))
|
||||
for _, vv := range v.queue {
|
||||
buf.WriteString(fmt.Sprintf("%v ", len(vv.Array)))
|
||||
}
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (q *BalanceQueue) Update() {
|
||||
if q.index == len(q.groups) {
|
||||
q.index = 0
|
||||
}
|
||||
for _, v := range q.groups[q.index].Array {
|
||||
v.BalanceQueueHandler()
|
||||
}
|
||||
q.index++
|
||||
}
|
||||
|
||||
func (q *BalanceQueue) Push(e Element) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := q.pool[e]; ok {
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range q.tables {
|
||||
size := len(v.queue)
|
||||
if size == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
arr := v.queue[size-1]
|
||||
if k+1 >= len(q.tables) {
|
||||
q.tables = append(q.tables, &groupArray{})
|
||||
}
|
||||
q.tables[k+1].queue = append(q.tables[k+1].queue, arr)
|
||||
q.tables[k].queue = v.queue[:size-1]
|
||||
arr.queuePos = len(q.tables[k+1].queue) - 1
|
||||
arr.Array = append(arr.Array, e)
|
||||
q.pool[e] = arr
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (q *BalanceQueue) Pop(e Element) {
|
||||
group, ok := q.pool[e]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
delete(q.pool, e)
|
||||
count := len(group.Array)
|
||||
for i := 0; i < count; i++ {
|
||||
if group.Array[i] == e {
|
||||
group.Array[i] = group.Array[count-1]
|
||||
group.Array = group.Array[:count-1]
|
||||
bqPos := group.queuePos
|
||||
queCount := len(q.tables[count].queue)
|
||||
q.tables[count].queue[bqPos] = q.tables[count].queue[queCount-1]
|
||||
q.tables[count].queue[bqPos].queuePos = bqPos
|
||||
q.tables[count].queue = q.tables[count].queue[:queCount-1]
|
||||
q.tables[count-1].queue = append(q.tables[count-1].queue, group)
|
||||
group.queuePos = len(q.tables[count-1].queue) - 1
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package balancequeue
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type A struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (a *A) BalanceQueueHandler() {
|
||||
|
||||
}
|
||||
|
||||
func TestOne(t *testing.T) {
|
||||
q := New(5)
|
||||
|
||||
var es []Element
|
||||
go func() {
|
||||
for {
|
||||
q.Update()
|
||||
fmt.Println(q)
|
||||
time.Sleep(time.Second)
|
||||
e := &A{Name: fmt.Sprint(time.Now().Unix())}
|
||||
es = append(es, e)
|
||||
q.Push(e)
|
||||
if rand.Intn(10) > 5 && len(es) >= 2 {
|
||||
for _, v := range es[:2] {
|
||||
q.Pop(v)
|
||||
}
|
||||
es = es[2:]
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
time.Sleep(time.Minute)
|
||||
}
|
|
@ -15,7 +15,6 @@ import (
|
|||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/game/protocol/friend"
|
||||
"mongo.games.com/game/protocol/welfare"
|
||||
"mongo.games.com/game/srvdata"
|
||||
)
|
||||
|
||||
|
@ -603,29 +602,6 @@ func (this *CSFuzzyQueryPlayerHandler) Process(s *netlib.Session, packetid int,
|
|||
return nil
|
||||
}
|
||||
|
||||
pack2 := &welfare.NotifyLotteryAward{
|
||||
Info: &welfare.LotteryInfo{
|
||||
Id: 45,
|
||||
StartTs: time.Now().Unix(),
|
||||
Index: int32(5),
|
||||
Award: []*welfare.PropInfo{
|
||||
{
|
||||
ItemId: 100001,
|
||||
ItemNum: 100,
|
||||
},
|
||||
},
|
||||
SnId: p.SnId,
|
||||
Name: p.Name,
|
||||
RoleId: p.Roles.ModId,
|
||||
Price: 1000,
|
||||
WinCode: "123456",
|
||||
},
|
||||
}
|
||||
|
||||
// 广播中奖结果
|
||||
PlayerMgrSington.BroadcastMessageToPlatform(p.Platform, int(welfare.SPacketID_PACKET_NotifyLotteryAward), pack2)
|
||||
logger.Logger.Tracef("广播中奖信息: %v", pack2)
|
||||
|
||||
queryContent := msg.GetQueryContent()
|
||||
if utf8.RuneCountInString(queryContent) < 3 {
|
||||
return nil
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/core/task"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
|
@ -29,6 +30,7 @@ func CSLotteryInfoHandler(s *netlib.Session, packetid int, data interface{}, sid
|
|||
|
||||
pack := &welfare.SCLotteryInfo{}
|
||||
|
||||
now := time.Now()
|
||||
var list []*welfare.LotteryInfo
|
||||
cfg := PlatformMgrSingleton.GetConfig(p.Platform).LotteryConfig
|
||||
if cfg != nil {
|
||||
|
@ -42,8 +44,11 @@ func CSLotteryInfoHandler(s *netlib.Session, packetid int, data interface{}, sid
|
|||
for _, v := range list {
|
||||
playerLottery := info.Lottery[v.GetId()]
|
||||
if playerLottery != nil && playerLottery.StartTs == v.GetStartTs() {
|
||||
v.CostRoomCard = playerLottery.CostCard
|
||||
v.Codes = playerLottery.Code
|
||||
// 活动开始和发奖期间显示
|
||||
if now.Unix() >= v.GetStartTs() && now.Unix() < v.GetWinTs() {
|
||||
v.CostRoomCard = playerLottery.CostCard
|
||||
v.Codes = playerLottery.Code
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3173,18 +3173,14 @@ func CSUpdateAttribute(s *netlib.Session, packetId int, data interface{}, sid in
|
|||
return nil
|
||||
}
|
||||
if msg.GuideId == common.GuideIdNewPlayer {
|
||||
if p.GuideStep >= 0 && p.GuideStep < model.GameParamData.GuideStepMaxNum {
|
||||
p.GuideStep = -1 // 跳过引导为 -1
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
p.GuideData[msg.GuideId] = int32(msg.Param[0])
|
||||
send()
|
||||
return nil
|
||||
p.GuideStep = -1 // 跳过引导为 -1
|
||||
}
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
if len(msg.Param) > 0 {
|
||||
p.GuideData[msg.GuideId] = int32(msg.Param[0])
|
||||
}
|
||||
send()
|
||||
return nil
|
||||
case common.AttributeGuideTest:
|
||||
if !common.Config.IsDevMode {
|
||||
return nil
|
||||
|
|
|
@ -735,6 +735,8 @@ func (this *CSUpdateVipShopHandler) Process(s *netlib.Session, packetid int, dat
|
|||
return nil
|
||||
}
|
||||
func init() {
|
||||
// 商城接口
|
||||
|
||||
// 获取商城商品信息列表
|
||||
common.RegisterHandler(int(shop.SPacketID_PACKET_CS_SHOP_INFO), &CSShopInfoHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CS_SHOP_INFO), &CSShopInfoPacketFactory{})
|
||||
|
@ -748,20 +750,22 @@ func init() {
|
|||
common.RegisterHandler(int(shop.SPacketID_PACKET_CSGETPAYINFOLIST), &CSGetPayInfoListHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CSGETPAYINFOLIST), &CSGetPayInfoListPacketFactory{})
|
||||
|
||||
// 兑换商城接口
|
||||
|
||||
// 获取商城商品兑换列表
|
||||
common.RegisterHandler(int(shop.SPacketID_PACKET_CS_SHOP_EXCHANGELIST), &CSShopExchangeListHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CS_SHOP_EXCHANGELIST), &CSShopExchangeListPacketFactory{})
|
||||
// 兑换商品(非现金)
|
||||
common.RegisterHandler(int(shop.SPacketID_PACKET_CS_SHOP_EXCHANGE), &CSShopExchangeHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CS_SHOP_EXCHANGE), &CSShopExchangePacketFactory{})
|
||||
// 兑换商品(现金,创建订单)
|
||||
common.RegisterHandler(int(shop.SPacketID_PACKET_CSPAYINFO), &CSPayInfoHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CSPAYINFO), &CSPayInfoPacketFactory{})
|
||||
// 获取兑换记录
|
||||
//todo 客户端走透传后台获取
|
||||
common.RegisterHandler(int(shop.SPacketID_PACKET_CS_SHOP_EXCHANGERECORD), &CSShopExchangeRecordHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CS_SHOP_EXCHANGERECORD), &CSShopExchangeRecordPacketFactory{})
|
||||
|
||||
// 现金,创建订单(所有现金订单)
|
||||
common.RegisterHandler(int(shop.SPacketID_PACKET_CSPAYINFO), &CSPayInfoHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CSPAYINFO), &CSPayInfoPacketFactory{})
|
||||
|
||||
//玩家地址操作
|
||||
common.RegisterHandler(int(shop.SPacketID_PACKET_CSPLAYERADDR), &CSPlayerAddrHandler{})
|
||||
netlib.RegisterFactory(int(shop.SPacketID_PACKET_CSPLAYERADDR), &CSPlayerAddrPacketFactory{})
|
||||
|
|
|
@ -41,6 +41,10 @@ func AddMail(param *AddMailParam) {
|
|||
return
|
||||
}
|
||||
|
||||
if param.SrcName == "" {
|
||||
param.SrcName = "{\"zh\":\"系统\",\"vi\":\"GM\",\"en\":\"GM\",\"kh\":\"GM\"}"
|
||||
}
|
||||
|
||||
opener := int32(1)
|
||||
if param.SrcId <= 0 {
|
||||
opener = 0
|
||||
|
@ -149,3 +153,17 @@ func AddMailLottery(plt string, snid int32, items []*model.ItemInfo) {
|
|||
ShowId: model.HallAll,
|
||||
})
|
||||
}
|
||||
|
||||
func AddMailTelCode(plt string, snid int32, code string) {
|
||||
title := i18n.Tr("languages", "TelCodeTitle")
|
||||
content := code
|
||||
|
||||
AddMail(&AddMailParam{
|
||||
Platform: plt,
|
||||
Tp: model.MSGTYPE_TelCode,
|
||||
SnId: snid,
|
||||
Title: title,
|
||||
Content: content,
|
||||
ShowId: model.HallTienlen,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -300,6 +300,8 @@ func (c *CustomRoomMgr) UpdateCreate(plt string, configId int32, mustCreate bool
|
|||
RoomConfigId: roomConfig.GetId(),
|
||||
CostType: 1,
|
||||
Voice: cfg.GetVoice(),
|
||||
Price: roomConfig.GetPrice(),
|
||||
ImageURL: roomConfig.GetImageURI(),
|
||||
},
|
||||
RoomConfigSystem: cfg,
|
||||
IsRecruit: true,
|
||||
|
|
|
@ -3,9 +3,8 @@ package main
|
|||
import (
|
||||
"time"
|
||||
|
||||
"mongo.games.com/goserver/core/container/balancequeue"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
|
||||
"mongo.games.com/game/util/balancequeue"
|
||||
)
|
||||
|
||||
var DbSaveInst = &DbSaver{
|
||||
|
|
|
@ -2,15 +2,17 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/goserver/core/basic"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
"mongo.games.com/goserver/core/task"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -236,6 +238,7 @@ func (this *LoginStateMgr) LogoutAllBySession(session *netlib.Session) {
|
|||
p := PlayerMgrSington.GetOnlinePlayer(sid)
|
||||
if p != nil {
|
||||
p.DropLine()
|
||||
internal.FirePlayerDropLine[*Player, *Scene](p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,22 @@ func init() {
|
|||
}
|
||||
}
|
||||
},
|
||||
OnMiniTimerFunc: func() {
|
||||
for i := range LotteryMgrInst.Data {
|
||||
for k := range LotteryMgrInst.Data[i] {
|
||||
d := LotteryMgrInst.Data[i][k]
|
||||
if d == nil {
|
||||
continue
|
||||
}
|
||||
lc := PlatformMgrSingleton.GetLotteryConfig(d.Platform, d.CId)
|
||||
if lc == nil || lc.GetOn() != common.On {
|
||||
continue
|
||||
}
|
||||
// 随机给机器人发放抽奖码
|
||||
d.sendRobotCode(1, 5)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -477,8 +493,6 @@ func (l *LotteryMgr) Update() {
|
|||
if lc == nil || lc.GetOn() != common.On {
|
||||
continue
|
||||
}
|
||||
// 随机给机器人发放抽奖码
|
||||
d.sendRobotCode(1, 5)
|
||||
// 活动结束,开始抽奖
|
||||
d.Done()
|
||||
// 开始发奖
|
||||
|
|
|
@ -86,6 +86,7 @@ type Player struct {
|
|||
changeIconTime time.Time //上次修改头像时间
|
||||
enterts time.Time //进入时间
|
||||
lastChangeScene time.Time //上次换桌时间
|
||||
dropTime time.Time // 掉线时间
|
||||
isAudience bool //是否是观众
|
||||
customerToken string //客服会话token
|
||||
isDelete bool //是否已删档用户
|
||||
|
@ -1124,7 +1125,6 @@ func (this *Player) IsOnLine() bool {
|
|||
|
||||
func (this *Player) SetOnline() {
|
||||
this.state = PlayerStateOnline
|
||||
this.UpdateLastLogoutTime()
|
||||
}
|
||||
|
||||
func (this *Player) IsOffline() bool {
|
||||
|
@ -1156,6 +1156,7 @@ func (this *Player) Kick(reason int32) {
|
|||
|
||||
LoginStateMgrSington.LogoutBySid(this.sid)
|
||||
this.DropLine()
|
||||
internal.FirePlayerDropLine[*Player, *Scene](this)
|
||||
}
|
||||
TournamentMgr.ForceQuit(this.Platform, this.SnId)
|
||||
}
|
||||
|
@ -1366,12 +1367,7 @@ func (this *Player) Time2Save() {
|
|||
return
|
||||
}
|
||||
|
||||
isForce := false
|
||||
if common.Config.IsDevMode {
|
||||
isForce = true // 开发模式下强制保存
|
||||
}
|
||||
|
||||
PlayerMgrSington.SavePlayer(this, true, isForce)
|
||||
PlayerMgrSington.SavePlayer(this, true, false)
|
||||
|
||||
if this.isDelete || (!this.IsOnLine() && !this.dirty && time.Now().Sub(this.lastSaved) > time.Minute*5 && this.scene == nil) {
|
||||
PlayerMgrSington.DelPlayer(this.SnId)
|
||||
|
@ -1633,10 +1629,19 @@ func (this *Player) OnSecTimer() {
|
|||
}
|
||||
|
||||
func (this *Player) OnMiniTimer() {
|
||||
TaskSubjectSingleton.Touch(common.TaskTypeOnlineTs, &TaskData{
|
||||
SnId: this.SnId,
|
||||
Num: 60,
|
||||
})
|
||||
if this.IsOnLine() {
|
||||
TaskSubjectSingleton.Touch(common.TaskTypeOnlineTs, &TaskData{
|
||||
SnId: this.SnId,
|
||||
Num: 60,
|
||||
})
|
||||
}
|
||||
// 长时间掉线又没有删除缓存
|
||||
if !this.dropTime.IsZero() && time.Now().Sub(this.dropTime).Minutes() > 20 {
|
||||
logger.Logger.Errorf("清除缓存异常玩家 snid:%v dirty:%v lastLogoutTime:%v lastGameId:%v", this.SnId, this.dirty, this.LastLogoutTime, this.LastGameId)
|
||||
if this.scene != nil {
|
||||
logger.Logger.Errorf("清除缓存异常玩家 sceneId:%v", this.scene.sceneId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Player) OnHourTimer() {
|
||||
|
@ -3885,10 +3890,12 @@ func (this *Player) SCDataConfig(tp int) {
|
|||
|
||||
func init() {
|
||||
internal.RegisterPlayerListenerFunc(&internal.PlayerListenerFunc[*Player, *Scene]{
|
||||
ClockFunc: common.ClockFunc{},
|
||||
OnPlayerLoginedFunc: nil,
|
||||
OnPlayerLogoutedFunc: nil,
|
||||
OnPlayerDropLineFunc: nil,
|
||||
ClockFunc: common.ClockFunc{},
|
||||
OnPlayerLoginedFunc: nil,
|
||||
OnPlayerLogoutedFunc: nil,
|
||||
OnPlayerDropLineFunc: func(p *Player) {
|
||||
p.dropTime = time.Now()
|
||||
},
|
||||
OnPlayerReholdFunc: nil,
|
||||
OnPlayerEnterSceneBeforeFunc: nil,
|
||||
OnPlayerEnterSceneAfterFunc: nil,
|
||||
|
|
|
@ -6,11 +6,11 @@ import (
|
|||
|
||||
"mongo.games.com/goserver/core"
|
||||
"mongo.games.com/goserver/core/basic"
|
||||
"mongo.games.com/goserver/core/container/balancequeue"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/core/task"
|
||||
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/util/balancequeue"
|
||||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
|
|
|
@ -173,7 +173,6 @@ func (this *PlayerMgr) SavePlayer(p *Player, isCopy, force bool) {
|
|||
|
||||
t1 := time.Now()
|
||||
|
||||
p.dirty = true
|
||||
// 跨天任务依赖LastLogoutTime的准确性,跨天任务是定时器common.ClockMgrSington触发的,所以这里要用定时器的触发时间
|
||||
p.LastLogoutTime = common.ClockMgrSingleton.LastTickTime
|
||||
pd.LastLogoutTime = common.ClockMgrSingleton.LastTickTime
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
serverproto "mongo.games.com/game/protocol/server"
|
||||
webapiproto "mongo.games.com/game/protocol/webapi"
|
||||
"mongo.games.com/game/srvdata"
|
||||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
type PlayerGameCtx struct {
|
||||
|
@ -193,6 +194,9 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
|||
}
|
||||
}
|
||||
|
||||
internal.FirePlayerEnterSceneBefore(p, this)
|
||||
defer internal.FirePlayerEnterSceneAfter(p, this)
|
||||
|
||||
// 非百人,设置座位
|
||||
if !this.IsHundredScene() {
|
||||
if pos != -1 {
|
||||
|
@ -515,6 +519,9 @@ func (this *Scene) lastScene(p *Player) {
|
|||
}
|
||||
|
||||
func (this *Scene) DelPlayer(p *Player) bool {
|
||||
internal.FirePlayerLeaveSceneBefore(p, this)
|
||||
defer internal.FirePlayerLeaveSceneAfter(p, this)
|
||||
|
||||
if p.scene != this {
|
||||
roomId := 0
|
||||
if p.scene != nil {
|
||||
|
|
|
@ -176,7 +176,9 @@ func (spd *ScenePolicyData) CostPayment(s *Scene, snid int32) bool {
|
|||
GameFreeId: int64(s.dbGameFree.GetId()),
|
||||
RoomConfigId: roomConfig.GetId(),
|
||||
})
|
||||
LotteryMgrInst.AddCostRoomCard(p.Platform, p.SnId, int64(n))
|
||||
if s.CustomParam.GetCostType() == 1 { // AA 是在游戏开始后扣的
|
||||
LotteryMgrInst.AddCostRoomCard(p.Platform, p.SnId, int64(n))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -973,6 +973,7 @@ func (this *ShopMgr) Exchange(param *ExchangeParam) {
|
|||
param.CallBackFunc(shop.OpResultCode_OPRC_Error)
|
||||
return
|
||||
}
|
||||
logger.Logger.Tracef("API_CreateExchange: %v", as)
|
||||
//dbShop
|
||||
var ret shop.OpResultCode
|
||||
if as.Tag == webapi_proto.TagCode_SUCCESS {
|
||||
|
@ -1009,6 +1010,30 @@ func (this *ShopMgr) Exchange(param *ExchangeParam) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// 加道具
|
||||
if as.GetItems() != nil {
|
||||
var itemInfo []*model.Item
|
||||
for _, v := range as.GetItems() {
|
||||
itemInfo = append(itemInfo, &model.Item{
|
||||
ItemId: v.GetItemId(),
|
||||
ItemNum: v.GetItemNum(),
|
||||
})
|
||||
}
|
||||
BagMgrSingleton.AddItemsOffline(&model.AddItemParam{
|
||||
Platform: param.Platform,
|
||||
SnId: param.SnId,
|
||||
Change: itemInfo,
|
||||
GainWay: common.GainWay_Exchange,
|
||||
Operator: "system",
|
||||
Remark: "兑换获得",
|
||||
}, nil)
|
||||
}
|
||||
|
||||
// 发手机兑换码
|
||||
if as.GetTelCode() != "" {
|
||||
AddMailTelCode(param.Platform, param.SnId, as.GetTelCode())
|
||||
}
|
||||
|
||||
ret = shop.OpResultCode_OPRC_Sucess
|
||||
} else {
|
||||
if as.GetReturnCPO() != nil {
|
||||
|
@ -1025,7 +1050,6 @@ func (this *ShopMgr) Exchange(param *ExchangeParam) {
|
|||
ret = shop.OpResultCode_OPRC_ExchangeSoldOut
|
||||
}
|
||||
}
|
||||
logger.Logger.Trace("API_CreateExchange: ", as.Tag, as.GetReturnCPO())
|
||||
if len(itemInfo) > 0 {
|
||||
BagMgrSingleton.AddItemsOffline(&model.AddItemParam{
|
||||
Platform: param.Platform,
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue