package addrecharge import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) // 参数校验 func (this *apiComp) ReceiveAllCheck(session comm.IUserSession, req *pb.AddRechargeReceiveAllReq) (errdata *pb.ErrorData) { return } // /获取自己的排行榜信息 func (this *apiComp) ReceiveAll(session comm.IUserSession, req *pb.AddRechargeReceiveAllReq) (errdata *pb.ErrorData) { var ( info *pb.DBAddRecharge confs []*cfg.GameAccumulateData atns []*cfg.Gameatn = make([]*cfg.Gameatn, 0) award []*pb.UserAssets = make([]*pb.UserAssets, 0) err error ) if errdata = this.ReceiveAllCheck(session, req); errdata != nil { return } if confs, err = this.module.configure.getGameAccumulates(); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } if info, err = this.module.modelRecharge.getUserDTasks(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } for _, conf := range confs { if info.Integral < conf.Integral { continue } if info.Record[conf.Integral] { continue } atns = append(atns, conf.Reward...) info.Record[conf.Integral] = true } if len(atns) == 0 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: "no can receive !", } return } if errdata = this.module.DispenseRes(session, atns, true); errdata != nil { return } for _, v := range atns { award = append(award, &pb.UserAssets{ A: v.A, T: v.T, N: v.N, }) } this.module.modelRecharge.Change(session.GetUserId(), map[string]interface{}{ "record": info.Record, }) session.SendMsg(string(this.module.GetType()), "receiveall", &pb.AddRechargeReceiveAllResp{Record: info.Record, Award: award}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), "AddRechargeReceiveAllReq", award) }) return }