package catchbugs import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.CatchbugsAwardReq) (errdata *pb.ErrorData) { return } func (this *apiComp) Award(session comm.IUserSession, req *pb.CatchbugsAwardReq) (errdata *pb.ErrorData) { var ( confs []*cfg.GameCatchbugRewardData info *pb.DBCatchBugs res []*cfg.Gameatn atno []*pb.UserAtno ok bool err error ) if errdata = this.AwardCheck(session, req); errdata != nil { return } if confs, err = this.module.configure.getGameGColorRewardDatas(); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Message: err.Error(), } return } if info, err = this.module.model.getModel(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Message: err.Error(), } return } for _, v := range confs { if _, ok = info.Awards[v.Key]; !ok && info.Integral >= v.Condition { res = append(res, v.Reward...) info.Awards[v.Key] = true } } if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { return } this.module.model.Change(session.GetUserId(), map[string]interface{}{ "award": info.Awards, }) session.SendMsg(string(this.module.GetType()), "award", &pb.CatchbugsAwardResp{Awardmap: info.Awards, Award: atno}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "CatchbugsAwardReq", atno) }) return }