上传gm工具修复

This commit is contained in:
liwei 2023-07-12 15:49:30 +08:00
parent db0418df82
commit f90f2aa62e
11 changed files with 159 additions and 60 deletions

View File

@ -547,5 +547,6 @@ type (
//战令
IWarorder interface {
Delivery(session IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets)
OpenWarorder(wtype int32, opentime int64)
}
)

View File

@ -535,7 +535,8 @@ func (this *Equipment) GMGetAllEquip(session comm.IUserSession, ismaxlv bool) (e
var (
configure *cfg.GameEquip
equipments []*pb.DB_Equipment = make([]*pb.DB_Equipment, 0)
equipments map[string]*pb.DB_Equipment = make(map[string]*pb.DB_Equipment)
changes []*pb.DB_Equipment = make([]*pb.DB_Equipment, 0)
equipment *pb.DB_Equipment
model *db.DBModel
err error
@ -556,7 +557,8 @@ func (this *Equipment) GMGetAllEquip(session comm.IUserSession, ismaxlv bool) (e
Message: err.Error(),
}
}
equipments = append(equipments, equipment)
equipments[equipment.Id] = equipment
changes = append(changes, equipment)
}
if len(equipments) > 0 {
@ -575,7 +577,8 @@ func (this *Equipment) GMGetAllEquip(session comm.IUserSession, ismaxlv bool) (e
return
}
}
this.equipmentsChangePush(session, equipments)
this.equipmentsChangePush(session, changes)
}
return
}

View File

@ -45,7 +45,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.PayInfoReq) (errdat
if info.Items[v.Id] == nil {
info.Items[v.Id] = &pb.PayDailyItem{
Id: v.Id,
Buyunm: v.BuyNum,
Buyunm: 0,
Lastrefresh: configure.Now().Unix(),
}
}

View File

@ -1,6 +1,7 @@
package warorder
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
@ -16,6 +17,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e
var (
warorders *pb.DBWarorders
info *pb.Warorder
otime int64
err error
ok bool
)
@ -31,15 +33,34 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WarorderInfoReq) (e
return
}
if info, ok = warorders.Items[req.Rtype]; !ok {
info = &pb.Warorder{
Vip: false,
Free: make([]int32, 0),
Pay: make([]int32, 0),
Progress: 0,
if otime, ok = this.module.modelWarorder.getopentime(req.Rtype); !ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_WarorderNoOpen,
Title: pb.ErrorCode_WarorderNoOpen.ToString(),
Message: fmt.Sprintf("Activity:%d no open", req.Rtype),
}
return
}
if info, ok = warorders.Items[req.Rtype]; !ok {
info = &pb.Warorder{}
warorders.Items[req.Rtype] = info
}
if info.Opentime != otime {
info.Opentime = otime
info.Freeprogress = 0
info.Payprogress = 0
if err = this.module.modelWarorder.updateUserWarorders(session.GetUserId(), warorders); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
}
session.SendMsg(string(this.module.GetType()), "info", &pb.WarorderInfoResp{Info: info})
return
}

View File

@ -1,8 +1,12 @@
package warorder
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
)
// 参数校验
@ -16,6 +20,9 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.WarorderReceiveR
var (
warorders *pb.DBWarorders
info *pb.Warorder
confs []*cfg.GamePassCheckData
awards []*cfg.Gameatn
days int32
err error
ok bool
)
@ -30,15 +37,43 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.WarorderReceiveR
}
return
}
if info, ok = warorders.Items[req.Rtype]; !ok {
info = &pb.Warorder{
Vip: false,
Free: make([]int32, 0),
Pay: make([]int32, 0),
Progress: 0,
if confs, err = this.module.configure.getorder(req.Rtype); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
warorders.Items[req.Rtype] = info
return
}
if info, ok = warorders.Items[req.Rtype]; !ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_WarorderNoOpen,
Title: pb.ErrorCode_WarorderNoOpen.ToString(),
Message: fmt.Sprintf("Activity:%d no open", req.Rtype),
}
return
}
days = int32(utils.DiffDays(configure.Now().Unix(), info.Opentime))
awards = make([]*cfg.Gameatn, 0)
for _, v := range confs {
if v.Parameter <= days {
if info.Freeprogress < v.Parameter {
awards = append(awards, v.FreeReward)
}
if info.Vip {
if info.Payprogress < v.Parameter {
awards = append(awards, v.PayReward)
}
}
}
}
info.Freeprogress = days
if info.Vip {
info.Payprogress = days
}
if errdata = this.module.DispenseRes(session, awards, true); errdata != nil {
return
}
session.SendMsg(string(this.module.GetType()), "receive", &pb.WarorderReceiveResp{Info: info})
return

View File

@ -33,6 +33,15 @@ func (this *configureComp) getproduct() map[string]int32 {
defer this.lock.RUnlock()
return this.product
}
func (this *configureComp) getorder(wtype int32) (results []*cfg.GamePassCheckData, err error) {
this.lock.RLock()
defer this.lock.RUnlock()
var ok bool
if results, ok = this.order[wtype]; !ok {
err = fmt.Errorf("no found wtype:%d", wtype)
}
return
}
// 读取任务配置表
func (this *configureComp) getPassCheckCfg() (data *cfg.GamePassCheck, err error) {

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"sync"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -15,19 +16,38 @@ import (
type modelWarorder struct {
modules.MCompModel
module *Warorder
module *Warorder
lock sync.RWMutex
opentime map[int32]int64
}
func (this *modelWarorder) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TableWarorder
this.module = module.(*Warorder)
this.lock.Lock()
this.opentime = make(map[int32]int64)
this.lock.Unlock()
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})
return
}
func (this *modelWarorder) getopentime(wtype int32) (otime int64, open bool) {
this.lock.RLock()
otime, open = this.opentime[wtype]
this.lock.RUnlock()
return
}
func (this *modelWarorder) setopentime(wtype int32, opentime int64) {
this.lock.RLock()
this.opentime[wtype] = opentime
this.lock.RUnlock()
return
}
// 获取用户全部的埋点数据
func (this *modelWarorder) getUserWarorders(uid string) (results *pb.DBWarorders, err error) {
results = &pb.DBWarorders{}

View File

@ -77,10 +77,7 @@ func (this *Warorder) Delivery(session comm.IUserSession, pid string) (errdata *
if info, ok = warorders.Items[wtype]; !ok {
info = &pb.Warorder{
Vip: false,
Free: make([]int32, 0),
Pay: make([]int32, 0),
Progress: 0,
Vip: true,
}
warorders.Items[wtype] = info
}
@ -88,3 +85,8 @@ func (this *Warorder) Delivery(session comm.IUserSession, pid string) (errdata *
this.modelWarorder.updateUserWarorders(session.GetUserId(), warorders)
return
}
// 开启战令
func (this *Warorder) OpenWarorder(wtype int32, opentime int64) {
this.modelWarorder.setopentime(wtype, opentime)
}

View File

@ -411,6 +411,8 @@ const (
ErrorCode_PassonHeroNumNotEnough ErrorCode = 4701 //英雄数量不足
ErrorCode_PassonHeroUnavailable ErrorCode = 4702 //当前英雄不可用
ErrorCode_PassonSeatStateErr ErrorCode = 4703 //传功塔状态错误
//战令
ErrorCode_WarorderNoOpen ErrorCode = 4801 //活动未开启
)
// Enum value maps for ErrorCode.
@ -764,6 +766,7 @@ var (
4701: "PassonHeroNumNotEnough",
4702: "PassonHeroUnavailable",
4703: "PassonSeatStateErr",
4801: "WarorderNoOpen",
}
ErrorCode_value = map[string]int32{
"Success": 0,
@ -1114,6 +1117,7 @@ var (
"PassonHeroNumNotEnough": 4701,
"PassonHeroUnavailable": 4702,
"PassonSeatStateErr": 4703,
"WarorderNoOpen": 4801,
}
)
@ -1148,7 +1152,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0x89, 0x40, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0x9e, 0x40, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76,
@ -1660,8 +1664,10 @@ var file_errorcode_proto_rawDesc = []byte{
0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xdd, 0x24, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x61, 0x73, 0x73,
0x6f, 0x6e, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c,
0x65, 0x10, 0xde, 0x24, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x61, 0x73, 0x73, 0x6f, 0x6e, 0x53, 0x65,
0x61, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x72, 0x72, 0x10, 0xdf, 0x24, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x61, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x72, 0x72, 0x10, 0xdf, 0x24, 0x12, 0x13, 0x0a,
0x0e, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x4f, 0x70, 0x65, 0x6e, 0x10,
0xc1, 0x25, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (

View File

@ -90,10 +90,10 @@ type Warorder struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Vip bool `protobuf:"varint,1,opt,name=vip,proto3" json:"vip"`
Free []int32 `protobuf:"varint,2,rep,packed,name=free,proto3" json:"free"`
Pay []int32 `protobuf:"varint,3,rep,packed,name=pay,proto3" json:"pay"`
Progress int32 `protobuf:"varint,4,opt,name=progress,proto3" json:"progress"`
Opentime int64 `protobuf:"varint,1,opt,name=opentime,proto3" json:"opentime"`
Freeprogress int32 `protobuf:"varint,2,opt,name=freeprogress,proto3" json:"freeprogress"`
Payprogress int32 `protobuf:"varint,3,opt,name=payprogress,proto3" json:"payprogress"`
Vip bool `protobuf:"varint,4,opt,name=vip,proto3" json:"vip"`
}
func (x *Warorder) Reset() {
@ -128,6 +128,27 @@ func (*Warorder) Descriptor() ([]byte, []int) {
return file_warorder_warorder_db_proto_rawDescGZIP(), []int{1}
}
func (x *Warorder) GetOpentime() int64 {
if x != nil {
return x.Opentime
}
return 0
}
func (x *Warorder) GetFreeprogress() int32 {
if x != nil {
return x.Freeprogress
}
return 0
}
func (x *Warorder) GetPayprogress() int32 {
if x != nil {
return x.Payprogress
}
return 0
}
func (x *Warorder) GetVip() bool {
if x != nil {
return x.Vip
@ -135,27 +156,6 @@ func (x *Warorder) GetVip() bool {
return false
}
func (x *Warorder) GetFree() []int32 {
if x != nil {
return x.Free
}
return nil
}
func (x *Warorder) GetPay() []int32 {
if x != nil {
return x.Pay
}
return nil
}
func (x *Warorder) GetProgress() int32 {
if x != nil {
return x.Progress
}
return 0
}
var File_warorder_warorder_db_proto protoreflect.FileDescriptor
var file_warorder_warorder_db_proto_rawDesc = []byte{
@ -171,13 +171,15 @@ var file_warorder_warorder_db_proto_rawDesc = []byte{
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x57,
0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,
0x38, 0x01, 0x22, 0x5e, 0x0a, 0x08, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x10,
0x0a, 0x03, 0x76, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, 0x69, 0x70,
0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x65, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x04,
0x66, 0x72, 0x65, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x61, 0x79, 0x18, 0x03, 0x20, 0x03, 0x28,
0x05, 0x52, 0x03, 0x70, 0x61, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65,
0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65,
0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x38, 0x01, 0x22, 0x7e, 0x0a, 0x08, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x1a,
0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x72,
0x65, 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
0x52, 0x0c, 0x66, 0x72, 0x65, 0x65, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20,
0x0a, 0x0b, 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20,
0x01, 0x28, 0x05, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73,
0x12, 0x10, 0x0a, 0x03, 0x76, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76,
0x69, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}

View File

@ -29,7 +29,7 @@ func IsSameWeek(d int64) bool {
return t1FirstDay.Equal(t2FirstDay)
}
//判断是否大于1周
// 判断是否大于1周
func IsAfterWeek(d int64) bool {
tt := time.Unix(d, 0)
nowt := configure.Now()
@ -138,7 +138,7 @@ func GetTodayZeroTime(curTime int64) int64 {
return startTime.Unix()
}
// 计算自然天数
// 计算自然天数
func DiffDays(t1, t2 int64) int {
if t1 == t2 {
return -1