81 lines
2.3 KiB
Go
81 lines
2.3 KiB
Go
package capturesheep
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) WeekRewardCheck(session comm.IUserSession, req *pb.CapturesheepWeekRewardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) WeekReward(session comm.IUserSession, req *pb.CapturesheepWeekRewardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf *cfg.GameDragonWeeklyrewardData
|
|
info *pb.DBCaptureSheep
|
|
award []*pb.UserAtno
|
|
ok bool
|
|
err error
|
|
)
|
|
|
|
if errdata = this.WeekRewardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameDragonWeeklyreward(req.Id); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if info, err = this.module.modelCaptureSheep.queryInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if ok = info.Weekreward[req.Id]; ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "Already claimed !",
|
|
}
|
|
return
|
|
}
|
|
if info.Weekintegral < conf.Point {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "Not enough points !",
|
|
}
|
|
}
|
|
if errdata, award = this.module.DispenseAtno(session, conf.Rewarditem, true); errdata != nil {
|
|
return
|
|
}
|
|
info.Weekreward[req.Id] = true
|
|
if err = this.module.modelCaptureSheep.Change(session.GetUserId(), map[string]interface{}{
|
|
"weekreward": info.Weekreward,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "weekreward", &pb.CapturesheepWeekRewardResp{Id: req.Id, Award: award})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "CapturesheepWeekRewardReq", award)
|
|
})
|
|
return
|
|
}
|