活动优化
This commit is contained in:
parent
40f4650305
commit
12adac2095
@ -3,8 +3,6 @@ package activity
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
|
||||||
"go_dreamfactory/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
@ -15,79 +13,8 @@ func (this *apiComp) GetHdDataCheck(session comm.IUserSession, req *pb.ActivityG
|
|||||||
|
|
||||||
// 活动活动
|
// 活动活动
|
||||||
func (this *apiComp) GetHdData(session comm.IUserSession, req *pb.ActivityGetHdDataReq) (errdata *pb.ErrorData) {
|
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["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 值
|
|
||||||
update["val"] = list.Val
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.module.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if list != nil {
|
|
||||||
result = append(result, list)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
result := this.module.GetHdData(session, req.Oid)
|
||||||
session.SendMsg(string(this.module.GetType()), "gethddata", &pb.ActivityGetHdDataResp{
|
session.SendMsg(string(this.module.GetType()), "gethddata", &pb.ActivityGetHdDataResp{
|
||||||
Data: result,
|
Data: result,
|
||||||
})
|
})
|
||||||
|
@ -15,22 +15,19 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ActivityGet
|
|||||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.ActivityGetListReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.ActivityGetListReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
data []*pb.DBHuodong
|
data []*pb.DBHuodong
|
||||||
hdlist []*pb.DBActivityData
|
hdlist []string
|
||||||
|
result []*pb.DBActivityData
|
||||||
)
|
)
|
||||||
list := this.module.modelhdList.getHdInfo()
|
list := this.module.modelhdList.getHdInfo()
|
||||||
|
|
||||||
for _, szhd := range list {
|
for _, szhd := range list {
|
||||||
// for _, v := range szhd {
|
|
||||||
data = append(data, szhd)
|
data = append(data, szhd)
|
||||||
if c, err := this.module.modelhdData.getHddataByOid(session.GetUserId(), szhd.Id); err == nil {
|
hdlist = append(hdlist, szhd.Id)
|
||||||
hdlist = append(hdlist, c)
|
|
||||||
}
|
}
|
||||||
// }
|
result = this.module.GetHdData(session, hdlist)
|
||||||
}
|
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ActivityGetListResp{
|
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ActivityGetListResp{
|
||||||
Hddata: data,
|
Hddata: data,
|
||||||
Actdata: hdlist,
|
Actdata: result,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -253,10 +253,11 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
|
|||||||
}
|
}
|
||||||
data.Val = 1
|
data.Val = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf, err := this.configure.GetHDCelebration(data.Val); err == nil {
|
if conf, err := this.configure.GetHDCelebration(data.Val); err == nil {
|
||||||
|
|
||||||
if conf.Systemtype == systemtype {
|
if conf.Systemtype == systemtype {
|
||||||
data.Gotarr[systemtype] += 1
|
data.Gotarr[bosstype] += 1
|
||||||
// 天数
|
// 天数
|
||||||
var idays int32
|
var idays int32
|
||||||
for i, v1 := range conf.Bosstype {
|
for i, v1 := range conf.Bosstype {
|
||||||
@ -268,7 +269,7 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32,
|
|||||||
// 更新信息
|
// 更新信息
|
||||||
update["gotarr"] = data.Gotarr
|
update["gotarr"] = data.Gotarr
|
||||||
bChange = true
|
bChange = true
|
||||||
if data.Gotarr[systemtype] <= idays {
|
if data.Gotarr[bosstype] <= idays {
|
||||||
bDouble = true
|
bDouble = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,3 +321,78 @@ func (this *Activity) EventUserLogin(session comm.IUserSession) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Activity) GetHdData(session comm.IUserSession, oids []string) (result []*pb.DBActivityData) {
|
||||||
|
var (
|
||||||
|
activity *pb.DBHuodong
|
||||||
|
err error
|
||||||
|
list *pb.DBActivityData
|
||||||
|
)
|
||||||
|
curTime := configure.Now().Unix()
|
||||||
|
for _, id := range oids {
|
||||||
|
if activity, err = this.modelhdList.getHdListByHdId(id); err != nil {
|
||||||
|
if activity.Stime > curTime || curTime > activity.Etime { // 不在活动范围内数据不给活动记录数据
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list, _ = this.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.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开服等级活动
|
||||||
|
if activity.Itype == comm.HdLevel {
|
||||||
|
if user := this.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.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取开服庆典活动
|
||||||
|
if activity.Itype == comm.HdCelebration {
|
||||||
|
// key := fmt.Sprintf("%s-%s", session.GetUserId(), id)
|
||||||
|
if list, err = this.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["gotarr"] = list.Gotarr
|
||||||
|
|
||||||
|
_days := this.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 值
|
||||||
|
update["val"] = list.Val
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if list != nil {
|
||||||
|
result = append(result, list)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -25,7 +25,6 @@ func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleG
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 校验消耗
|
// 校验消耗
|
||||||
|
|
||||||
if conf, err := this.module.configure.GetPuzzleConsumConf(); err != nil {
|
if conf, err := this.module.configure.GetPuzzleConsumConf(); err != nil {
|
||||||
consum = &cfg.Gameatn{
|
consum = &cfg.Gameatn{
|
||||||
A: conf.Itemget.A,
|
A: conf.Itemget.A,
|
||||||
@ -36,10 +35,7 @@ func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleG
|
|||||||
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{consum}, true); errdata != nil {
|
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{consum}, true); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// list.Val -= 1
|
|
||||||
// if list.Val < 0 { // 拼图数量不足
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
list.Gotarr[req.Grid] = 1
|
list.Gotarr[req.Grid] = 1
|
||||||
update := make(map[string]interface{}, 0)
|
update := make(map[string]interface{}, 0)
|
||||||
update["gotarr"] = list.Gotarr
|
update["gotarr"] = list.Gotarr
|
||||||
|
Loading…
Reference in New Issue
Block a user