73 lines
1.7 KiB
Go
73 lines
1.7 KiB
Go
package practice
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 切磋终止
|
|
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.PracticeRefuseReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
//拒绝切磋
|
|
func (this *apiComp) Refuse(session comm.IUserSession, req *pb.PracticeRefuseReq) (errdata *pb.ErrorData) {
|
|
if code = this.RefuseCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
var (
|
|
err error
|
|
result *pb.DBPracticeQiecuoRecord
|
|
keep bool
|
|
room *pb.DBPracticeRoom
|
|
)
|
|
|
|
//切磋请求处理
|
|
if result, err = this.module.modelQiecuo.queryQiecuo(req.Uid); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
keep = false
|
|
for i, v := range result.Targets {
|
|
if v.Uid == session.GetUserId() {
|
|
result.Targets = append(result.Targets[0:i], result.Targets[i+1:]...)
|
|
keep = true
|
|
}
|
|
}
|
|
|
|
if !keep {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
|
|
this.module.modelQiecuo.Change(session.GetUserId(), map[string]interface{}{
|
|
"targets": result.Targets,
|
|
})
|
|
|
|
if room, err = this.module.modelPandata.queryUserMartialhall(req.Uid); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
for i, v := range room.Statuers {
|
|
if v.Uid == session.GetUserId() { //移除雕像
|
|
room.Statuers = append(room.Statuers[0:i], room.Statuers[i+1:]...)
|
|
this.module.modelPandata.Change(req.Uid, map[string]interface{}{
|
|
"statuers": room.Statuers,
|
|
})
|
|
break
|
|
}
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), "refuse", &pb.PracticeRefuseResp{
|
|
IsSucc: true,
|
|
}); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
return
|
|
}
|
|
|
|
this.module.SendMsgToUser(string(this.module.GetType()), "qiecuonotify",
|
|
&pb.PracticeQiecuonotifyPush{Uid: session.GetUserId(), Name: "", NotifyType: 3}, req.Uid)
|
|
return
|
|
}
|