go_dreamfactory/modules/parkour/api_invitehandle.go
2023-10-11 17:12:26 +08:00

116 lines
3.6 KiB
Go

package parkour
// import (
// "go_dreamfactory/comm"
// "go_dreamfactory/pb"
// "go_dreamfactory/sys/configure"
// "time"
// )
// //参数校验
// func (this *apiComp) InviteHandleCheck(session comm.IUserSession, req *pb.ParkourInviteHandleReq) (errdata *pb.ErrorData) {
// return
// }
// ///邀请组队
// func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInviteHandleReq) (errdata *pb.ErrorData) {
// var (
// info *pb.DBParkour
// tean *pb.DBParkour
// invite *pb.DBRaceInvite
// member *pb.DBRaceMember
// users []string
// ok bool
// index int32
// err error
// )
// if errdata = this.InviteHandleCheck(session, req); errdata != nil {
// return
// }
// if info, err = this.module.parkourComp.queryinfo(session.GetUserId()); err != nil {
// errdata = &pb.ErrorData{
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// return
// }
// if tean, err = this.module.parkourComp.queryinfo(req.Captainid); err != nil {
// errdata = &pb.ErrorData{
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// return
// }
// if len(tean.Member) >= 3 {
// errdata = &pb.ErrorData{
// Code: pb.ErrorCode_ParkourMemberFull,
// Title: pb.ErrorCode_ParkourMemberFull.ToString(),
// }
// return
// }
// if req.State == 3 {
// ok = false
// for i, v := range tean.Invite {
// if v.Uid == session.GetUserId() && configure.Now().Before(time.Unix(v.Expired, 0)) { //邀请未过期
// invite = v
// index = int32(i)
// ok = true
// }
// }
// if !ok {
// errdata = &pb.ErrorData{
// Code: pb.ErrorCode_ParkourInviteOverdue,
// Title: pb.ErrorCode_ParkourInviteOverdue.ToString(),
// }
// return
// }
// tean.Invite = append(tean.Invite[0:index], tean.Invite[index+1:]...)
// users = make([]string, len(tean.Member))
// for i, v := range tean.Member {
// users[i] = v.Uid
// }
// users = append(users, invite.Uid)
// member = &pb.DBRaceMember{Uid: invite.Uid, Name: invite.Name, Avatar: invite.Avatar, Lv: invite.Lv, Mount: info.Dfmount, Maxhp: 10}
// tean.Captainid = tean.Uid
// tean.State = pb.RaceTeamState_teaming
// tean.Member = append(tean.Member, member)
// if err = this.module.parkourComp.Change(session.GetUserId(), map[string]interface{}{
// "captainid": tean.Captainid,
// "state": tean.State,
// }); err != nil {
// errdata = &pb.ErrorData{
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// return
// }
// if err = this.module.parkourComp.Change(tean.Captainid, map[string]interface{}{
// "state": tean.State,
// "invite": tean.Invite,
// "captainid": tean.Captainid,
// "member": tean.Member,
// }); err != nil {
// errdata = &pb.ErrorData{
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// return
// }
// this.module.SendMsgToUsers(string(this.module.GetType()), "teamjoinnotice",
// &pb.ParkourTeamJoinNoticePush{Member: member}, users...)
// this.module.SendMsgToUsers(string(this.module.GetType()), "teamchanage",
// &pb.ParkourTeamChanagePush{Team: tean}, users...)
// } else {
// this.module.SendMsgToUser(string(this.module.GetType()), "invitenotice",
// &pb.ParkourInviteNoticePush{Team: tean, State: 3}, tean.Captainid)
// }
// session.SendMsg(string(this.module.GetType()), "invitehandle", &pb.ParkourInviteHandleResp{IsSucc: true})
// return
// }