78 lines
2.1 KiB
Go
78 lines
2.1 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) AllWeekRewardCheck(session comm.IUserSession, req *pb.CapturesheepAllWeekRewardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) AllWeekReward(session comm.IUserSession, req *pb.CapturesheepAllWeekRewardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf []*cfg.GameDragonWeeklyrewardData
|
|
info *pb.DBCaptureSheep
|
|
award []*pb.UserAtno
|
|
temp []*pb.UserAtno
|
|
ok bool
|
|
err error
|
|
)
|
|
|
|
if errdata = this.AllWeekRewardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameDragonWeeklyrewards(); 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
|
|
}
|
|
|
|
for _, v := range conf {
|
|
if ok = info.Weekreward[v.Id]; ok {
|
|
continue
|
|
}
|
|
|
|
if info.Weekintegral < v.Point {
|
|
continue
|
|
}
|
|
if errdata, temp = this.module.DispenseAtno(session, v.Rewarditem, true); errdata != nil {
|
|
return
|
|
}
|
|
award = append(award, temp...)
|
|
info.Weekreward[v.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()), "allweekreward", &pb.CapturesheepAllWeekRewardResp{Weekreward: info.Weekreward, Award: award})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "CapturesheepAllWeekRewardReq", award)
|
|
})
|
|
return
|
|
}
|