活动优化
This commit is contained in:
parent
ad79b477e6
commit
5c6f49ad1f
@ -19,6 +19,7 @@ func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdD
|
||||
result []*pb.DBActivityData
|
||||
activity *pb.DBHuodong
|
||||
err error
|
||||
list *pb.DBActivityData
|
||||
)
|
||||
curTime := configure.Now().Unix()
|
||||
for _, id := range req.Oid {
|
||||
@ -27,8 +28,7 @@ func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdD
|
||||
continue
|
||||
}
|
||||
}
|
||||
//key := fmt.Sprintf("%s-%s", session.GetUserId(), id)
|
||||
list, _ := this.module.modelhdData.getHddataByOid(session.GetUserId(), id)
|
||||
list, _ = this.module.modelhdData.getHddataByOid(session.GetUserId(), id)
|
||||
if activity.Itype == comm.HdTypeSign && !utils.IsToday(list.Lasttime) {
|
||||
list.Lasttime = curTime
|
||||
list.Val += 1
|
||||
@ -55,29 +55,36 @@ func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdD
|
||||
// 获取开服庆典活动
|
||||
if activity.Itype == comm.HdCelebration {
|
||||
// key := fmt.Sprintf("%s-%s", session.GetUserId(), id)
|
||||
if data, err := this.module.modelhdData.getHddataByOid(session.GetUserId(), id); err == nil {
|
||||
// 注意 Gotarr:map[int32]int32 key value 已经挑战的次数
|
||||
if !utils.IsToday(data.Lasttime) { // 不是今天重置
|
||||
data.Lasttime = configure.Now().Unix()
|
||||
data.Gotarr = make(map[int32]int32)
|
||||
if list, err = this.module.modelhdData.getHddataByOid(session.GetUserId(), id); err == nil {
|
||||
|
||||
if !utils.IsToday(list.Lasttime) || list.Val == 0 { // 不是今天重置
|
||||
list.Lasttime = configure.Now().Unix()
|
||||
list.Gotarr = make(map[int32]int32)
|
||||
update := make(map[string]interface{})
|
||||
// 计算进度
|
||||
data.Val = int32((configure.Now().Unix()-activity.Stime)/24*3600) + 1
|
||||
update := make(map[string]interface{})
|
||||
update["lasttime"] = data.Lasttime
|
||||
update["val"] = data.Val
|
||||
update["gotarr"] = data.Gotarr
|
||||
this.module.modelhdData.ModifyActivityList(session.GetUserId(), data.Id, update)
|
||||
result = append(result, data)
|
||||
} else { // 第一次进入
|
||||
_sub := (configure.Now().Unix() - activity.Stime)
|
||||
data.Val = int32(_sub/(24*3600)) + 1
|
||||
update := make(map[string]interface{})
|
||||
update["val"] = data.Val
|
||||
this.module.modelhdData.ModifyActivityList(session.GetUserId(), data.Id, update)
|
||||
update["lasttime"] = list.Lasttime
|
||||
update["val"] = list.Val
|
||||
update["gotarr"] = list.Gotarr
|
||||
|
||||
_days := this.module.configure.GetHDCelebrationData()
|
||||
var pos int32
|
||||
_sub := int32((configure.Now().Unix()-activity.Stime)/(24*3600)) + 1
|
||||
for index, v := range _days {
|
||||
for i := 0; i < int(v); i++ {
|
||||
pos++
|
||||
if _sub == pos {
|
||||
list.Val = int32(index) + 1 // 计算val 值
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
this.module.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
||||
}
|
||||
}
|
||||
}
|
||||
result = append(result, list)
|
||||
if list != nil {
|
||||
result = append(result, list)
|
||||
}
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "gethddata", &pb.ActivityGetHdDataResp{
|
||||
|
@ -22,7 +22,7 @@ type Activity struct {
|
||||
modelhdList *modelHdList
|
||||
modelhdData *modelhdData
|
||||
|
||||
mail *comm.Imail
|
||||
mail comm.Imail
|
||||
//warorder comm.IWarorder // 战令
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ func (this *Activity) Start() (err error) {
|
||||
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
this.mail = module.(comm.Imail)
|
||||
event.RegisterGO(comm.EventUserLogin, this.EventUserLogin)
|
||||
if !db.IsCross() {
|
||||
if rst, err := this.modelhdList.getHdInfoByHdType(comm.HdTypeWarorder); err == nil {
|
||||
@ -265,7 +265,7 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
|
||||
|
||||
func (this *Activity) EventUserLogin(session comm.IUserSession) {
|
||||
// 转盘活动
|
||||
if a, err := this.GetHdInfoByItype(pb.HdType_HdTypeTurntable); err != nil { //
|
||||
if a, err := this.GetHdInfoByItype(pb.HdType_HdTypeTurntable); err == nil { //
|
||||
bEnd := false
|
||||
for _, v := range a {
|
||||
if configure.Now().Unix() > v.Etime {
|
||||
@ -288,7 +288,7 @@ func (this *Activity) EventUserLogin(session comm.IUserSession) {
|
||||
})
|
||||
}
|
||||
// 发邮件
|
||||
//this.mail.SendMailByCid(session, comm.Venturegifts, reward)
|
||||
this.mail.SendMailByCid(session, comm.Venturegifts, reward)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user