过期时间调整
This commit is contained in:
parent
772d3d6f33
commit
795a468e93
@ -14,6 +14,7 @@ type apiComp struct {
|
||||
module *Hero
|
||||
chat comm.IChat
|
||||
}
|
||||
|
||||
type DBHeroDrawCardRecord struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID 主键id
|
||||
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
|
||||
|
@ -8,8 +8,6 @@ import (
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"math/big"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
func (this *apiComp) DrawCardCheck(session comm.IUserSession, req *pb.HeroDrawCardReq) (errdata *pb.ErrorData) {
|
||||
@ -324,18 +322,8 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
if req.DrawType != 1 {
|
||||
// 任务统计
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.module.modelDrawRecode.AddDrawRecord(session, szCards)
|
||||
|
||||
if _, err = this.module.modelDrawRecode.DBModel.DB.InsertOne("drawrecode", &DBHeroDrawCardRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: session.GetUserId(),
|
||||
HeroId: szCards,
|
||||
Drawtype: 1,
|
||||
Ctime: configure.Now().Unix(),
|
||||
ExpireAt: configure.Now(),
|
||||
}); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
var szHero []*pb.DBHero
|
||||
for _, hero := range add { // 奖励一次性发放
|
||||
if user, err := this.module.ModuleUser.GetUser(session.GetUserId()); err == nil { // 广播 首次获得英雄
|
||||
|
@ -3,10 +3,7 @@ package hero
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
@ -127,17 +124,8 @@ func (this *apiComp) SelectCard(session comm.IUserSession, req *pb.HeroSelectCar
|
||||
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
|
||||
if _, err = this.module.modelDrawRecode.DBModel.DB.InsertOne("drawrecode", &DBHeroDrawCardRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: session.GetUserId(),
|
||||
HeroId: curSzCard,
|
||||
Drawtype: 1,
|
||||
Ctime: configure.Now().Unix(),
|
||||
ExpireAt: configure.Now(),
|
||||
}); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
this.module.modelDrawRecode.AddDrawRecord(session, curSzCard)
|
||||
|
||||
this.module.HeroLibrary(session, curSzCard, szHero)
|
||||
this.module.SendTaskMsg(session, szStar, 10, 1, curSzCard)
|
||||
})
|
||||
|
@ -6,8 +6,11 @@ import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"time"
|
||||
|
||||
"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"
|
||||
mgooptions "go.mongodb.org/mongo-driver/mongo/options"
|
||||
@ -24,21 +27,37 @@ func (this *modelDrawRecode) Init(service core.IService, module core.IModule, co
|
||||
this.TableName = comm.TableDrawRecode
|
||||
this.MCompModel.Init(service, module, comp, opt)
|
||||
this.module = module.(*Hero)
|
||||
|
||||
// 通过uid创建索引
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{})
|
||||
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||
})
|
||||
indexModel := mongo.IndexModel{
|
||||
Keys: bson.M{"expireAt": 1},
|
||||
Options: mgooptions.Index().SetExpireAfterSeconds(6 * 30 * 24 * 3600),
|
||||
if _, err = this.DB.CreateMany(core.SqlTable(this.TableName), []mongo.IndexModel{
|
||||
{
|
||||
Keys: bsonx.Doc{
|
||||
{Key: "uid", Value: bsonx.Int32(1)},
|
||||
{Key: "ctime", Value: bsonx.Int32(1)},
|
||||
},
|
||||
}, {
|
||||
Keys: bson.M{"expireAt": 1},
|
||||
Options: mgooptions.Index().SetExpireAfterSeconds(0),
|
||||
},
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
_, err = this.DB.CreateIndex(core.SqlTable(this.TableName), indexModel) //设置 验证码过期时间索引
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelDrawRecode) AddDrawRecord(session comm.IUserSession, curSzCard []string) {
|
||||
ExpireTime := time.Unix(configure.Now().Unix()+3*30*24*3600, 0)
|
||||
if _, err := this.DBModel.DB.InsertOne("drawrecode", &DBHeroDrawCardRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: session.GetUserId(),
|
||||
HeroId: curSzCard,
|
||||
Drawtype: 1,
|
||||
Ctime: configure.Now().Unix(),
|
||||
ExpireAt: ExpireTime,
|
||||
}); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
func (this *modelDrawRecode) InstertDrawCardRecord(record *pb.DBHeroDrawRecord) (err error) {
|
||||
if _, err = this.DBModel.DB.InsertOne(core.SqlTable(this.TableName), record); err != nil {
|
||||
this.module.Errorln(err)
|
||||
|
Loading…
Reference in New Issue
Block a user