95 lines
2.8 KiB
Go
95 lines
2.8 KiB
Go
package activity
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
"go_dreamfactory/utils"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetHdDataCheck(session comm.IUserSession, req *pb.ActivityGetHdDataReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// 活动活动
|
|
func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdDataReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
result []*pb.DBActivityData
|
|
activity *pb.DBHuodong
|
|
err error
|
|
list *pb.DBActivityData
|
|
)
|
|
curTime := configure.Now().Unix()
|
|
for _, id := range req.Oid {
|
|
if activity, err = this.module.modelhdList.getHdListByHdId(id); err != nil {
|
|
if activity.Stime > curTime || curTime > activity.Etime { // 不在活动范围内数据不给活动记录数据
|
|
continue
|
|
}
|
|
}
|
|
list, _ = this.module.modelhdData.getHddataByOid(session.GetUserId(), id)
|
|
if activity.Itype == comm.HdTypeSign && !utils.IsToday(list.Lasttime) {
|
|
list.Lasttime = curTime
|
|
list.Val += 1
|
|
update := make(map[string]interface{})
|
|
update["lasttime"] = list.Lasttime
|
|
update["val"] = list.Val
|
|
this.module.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
|
}
|
|
|
|
// 开服等级活动
|
|
if activity.Itype == comm.HdLevel {
|
|
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
|
if list.Val != user.Lv {
|
|
list.Val = user.Lv
|
|
list.Lasttime = curTime
|
|
update := make(map[string]interface{})
|
|
update["lasttime"] = list.Lasttime
|
|
update["val"] = list.Val
|
|
this.module.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取开服庆典活动
|
|
if activity.Itype == comm.HdCelebration {
|
|
// key := fmt.Sprintf("%s-%s", session.GetUserId(), id)
|
|
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{})
|
|
// 计算进度
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
if list != nil {
|
|
result = append(result, list)
|
|
}
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "gethddata", &pb.ActivityGetHdDataResp{
|
|
Data: result,
|
|
})
|
|
return
|
|
}
|