更新配置
This commit is contained in:
parent
8b20ec9f53
commit
3fe6f8d115
@ -2,7 +2,9 @@ package task
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -21,38 +23,33 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
|
|||||||
if code = this.ActiveReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.ActiveReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp := &pb.TaskActiveReceiveResp{
|
uid := session.GetUserId()
|
||||||
TaskTag: req.TaskTag,
|
|
||||||
Id: req.Id,
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() {
|
// ua := this.moduleTask.modelTaskActive.getUserActive(uid, req.Id, comm.TaskTag(req.TaskTag))
|
||||||
err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeActiveReceive, resp)
|
// if ua == nil {
|
||||||
if err != nil {
|
// code = pb.ErrorCode_TaskActiveNofound
|
||||||
code = pb.ErrorCode_SystemError
|
// return
|
||||||
}
|
// }
|
||||||
}()
|
|
||||||
|
|
||||||
ua := this.moduleTask.modelTaskActive.getUserActive(session.GetUserId(), req.Id, comm.TaskTag(req.TaskTag))
|
|
||||||
if ua == nil {
|
|
||||||
code = pb.ErrorCode_TaskActiveNofound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断是否已领取
|
//判断是否已领取
|
||||||
if ua.Received == 1 {
|
// if ua.Received == 1 {
|
||||||
code = pb.ErrorCode_TaskReceived
|
// code = pb.ErrorCode_TaskReceived
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
conf := this.moduleTask.configure.getTaskActiveById(ua.RId)
|
var rewards []*cfg.Gameatn
|
||||||
|
// 玩家的
|
||||||
|
activeList := this.moduleTask.modelTaskActive.getActiveListByTag(uid, comm.TaskTag(req.TaskTag))
|
||||||
|
for _, v := range activeList {
|
||||||
|
if v.Received != 1 { //未领取
|
||||||
|
conf := this.moduleTask.configure.getTaskActiveById(v.RId)
|
||||||
if conf == nil {
|
if conf == nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// get user expand
|
// get user expand
|
||||||
ue, err := this.moduleTask.ModuleUser.GetUserExpand(session.GetUserId())
|
ue, err := this.moduleTask.ModuleUser.GetUserExpand(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
@ -81,7 +78,7 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
|
|||||||
}
|
}
|
||||||
if len(update) > 0 {
|
if len(update) > 0 {
|
||||||
if err := this.moduleTask.modelTaskActive.updateReceive(session.GetUserId(),
|
if err := this.moduleTask.modelTaskActive.updateReceive(session.GetUserId(),
|
||||||
ua.Id,
|
v.Id,
|
||||||
comm.TaskTag(req.TaskTag),
|
comm.TaskTag(req.TaskTag),
|
||||||
update); err != nil {
|
update); err != nil {
|
||||||
this.moduleTask.Errorf("updateReceive err %v", err)
|
this.moduleTask.Errorf("updateReceive err %v", err)
|
||||||
@ -89,8 +86,26 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rewards = append(rewards, conf.Reword...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(rewards) > 0 {
|
||||||
//派发奖励
|
//派发奖励
|
||||||
code = this.moduleTask.DispenseRes(session, conf.Reword, true)
|
if code = this.moduleTask.DispenseRes(session, rewards, true); code != pb.ErrorCode_Success {
|
||||||
|
this.moduleTask.Error("活跃度奖励", log.Fields{"uid": uid, "rewards": rewards, "code": code})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := &pb.TaskActiveReceiveResp{
|
||||||
|
TaskTag: req.TaskTag,
|
||||||
|
Id: req.Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeActiveReceive, resp)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user