package catchbugs import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" 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 awards map[int32]bool 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 _, conf := range confs { if req.Atype == conf.Type { if req.Atype == 1 { if _, ok = info.Weekaward[conf.Key]; !ok && info.Integral >= conf.Condition { res = append(res, conf.Reward...) info.Weekaward[conf.Key] = true } } else { if _, ok = info.Allaward[conf.Key]; !ok && info.Accruedintegral >= conf.Condition { res = append(res, conf.Reward...) info.Allaward[conf.Key] = true } } } } if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { return } if req.Atype == 1 { info.Weektime = configure.Now().Unix() awards = info.Weekaward } else { awards = info.Allaward } this.module.model.Change(session.GetUserId(), map[string]interface{}{ "weekaward": info.Weekaward, "allaward": info.Allaward, "weektime": info.Weektime, }) session.SendMsg(string(this.module.GetType()), "award", &pb.CatchbugsAwardResp{Atype: req.Atype, Award: atno, Awardmap: awards}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "CatchbugsAwardReq", atno) }) return }