package addrecharge import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) // 参数校验 func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.AddRechargeReceiveReq) (errdata *pb.ErrorData) { return } // /获取自己的排行榜信息 func (this *apiComp) Receive(session comm.IUserSession, req *pb.AddRechargeReceiveReq) (errdata *pb.ErrorData) { var ( info *pb.DBAddRecharge conf *cfg.GameAccumulateData award []*pb.UserAssets err error ) if errdata = this.ReceiveCheck(session, req); errdata != nil { return } if conf, err = this.module.configure.getGameAccumulate(req.Id); 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 } if info.Integral < conf.Integral { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: "Integral no achieve", } } if info.Record[req.Id] { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), Message: fmt.Sprintf("%d received", req.Id), } return } if errdata = this.module.DispenseRes(session, conf.Reward, true); errdata != nil { return } award = make([]*pb.UserAssets, 0) for _, v := range conf.Reward { award = append(award, &pb.UserAssets{ A: v.A, T: v.T, N: v.N, }) } info.Record[req.Id] = true this.module.modelRecharge.Change(session.GetUserId(), map[string]interface{}{ "record": info.Record, }) session.SendMsg(string(this.module.GetType()), "receive", &pb.AddRechargeReceiveResp{Id: req.Id, Award: award}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "AddRechargeReceiveReq", award) }) return }