59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
package friend
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 领取奖励
|
|
func (this *apiComp) GetrewardCheck(session comm.IUserSession, req *pb.FriendGetrewardReq) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewardReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
uid := session.GetUserId()
|
|
//获取玩家自己好友数据
|
|
self := this.moduleFriend.modelFriend.GetFriend(uid)
|
|
if self == nil {
|
|
code = pb.ErrorCode_FriendSelfNoData
|
|
return
|
|
}
|
|
|
|
if self.Received != 1 {
|
|
code = pb.ErrorCode_FriendNoreceived
|
|
return
|
|
}
|
|
|
|
received := 2 //已领
|
|
update := map[string]interface{}{
|
|
"received": received,
|
|
}
|
|
if err := this.moduleFriend.modelFriend.Change(self.Uid, update); err != nil {
|
|
code = pb.ErrorCode_FriendApplyError
|
|
this.moduleFriend.Error("领奖",
|
|
log.Field{Key: "uid", Value: uid},
|
|
log.Field{Key: "err", Value: err.Error()},
|
|
)
|
|
return
|
|
}
|
|
|
|
globalConf := this.moduleFriend.ModuleTools.GetGlobalConf()
|
|
if code = this.moduleFriend.DispenseRes(session, globalConf.FriendPeize, true); code != pb.ErrorCode_Success {
|
|
this.moduleFriend.Error("好友领奖励",
|
|
log.Field{Key: "uid", Value: uid},
|
|
log.Field{Key: "reward", Value: globalConf.FriendPeize},
|
|
log.Field{Key: "code", Value: code},
|
|
)
|
|
return
|
|
}
|
|
|
|
rsp := &pb.FriendGetrewardResp{Received: int32(received)}
|
|
|
|
if err := session.SendMsg(string(this.moduleFriend.GetType()), "getreward", rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
|
|
return
|
|
}
|