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