package entertainment import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) // 参数校验 func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.EntertainReceiveReq) (errdata *pb.ErrorData) { return } // /获取系统公告 func (this *apiComp) Receive(session comm.IUserSession, req *pb.EntertainReceiveReq) (errdata *pb.ErrorData) { var ( info *pb.DBXXLData confs []*cfg.GamePassCheckData awards []*cfg.Gameatn award []*pb.UserAtno err error progress int32 ) if errdata = this.ReceiveCheck(session, req); errdata != nil { return } if info, err = this.module.model.getEntertainmList(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } if confs, err = this.module.configure.getorder(req.Rtype); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } progress = info.Consumeexp //int32(this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), comm.Consumeexp)) awards = make([]*cfg.Gameatn, 0) for _, v := range confs { if v.Parameter <= progress { if info.Freeprogress < v.Parameter { awards = append(awards, v.FreeReward...) } if info.Vip { if info.Payprogress < v.Parameter { awards = append(awards, v.PayReward...) } } } } info.Freeprogress = progress if info.Vip { info.Payprogress = progress } info.Freeprogress = 1 if info.Vip { info.Payprogress = 1 } if errdata, award = this.module.DispenseAtno(session, awards, true); errdata != nil { return } this.module.model.Change(session.GetUserId(), map[string]interface{}{ "freeprogress": info.Freeprogress, "payprogress": info.Payprogress, }) session.SendMsg(string(this.module.GetType()), "receive", &pb.EntertainReceiveResp{Info: info, Award: award}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "EntertainReceiveReq", award) }) return }