65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 公会解散
|
|
|
|
func (this *apiComp) DismissCheck(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode, data proto.Message) {
|
|
uid := session.GetUserId()
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty.Id == "" {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Errorf("uid:%s not in sociaty", uid)
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatyDismissResp{
|
|
Uid: uid,
|
|
SociatyId: sociaty.Id,
|
|
}
|
|
|
|
if !this.module.modelSociaty.isRight(uid, sociaty,
|
|
pb.SociatyJob_PRESIDENT) {
|
|
code = pb.ErrorCode_SociatyNoRight
|
|
return
|
|
}
|
|
update := map[string]interface{}{}
|
|
|
|
if sociaty.DismissTime == 0 {
|
|
//更新解散倒计时
|
|
update["dismissTime"] = utils.AddHour(24).Unix()
|
|
} else {
|
|
if req.Dismiss == 1 { //取消解散
|
|
if utils.IsInCDHour(int64(sociaty.DismissCD)) {
|
|
code = pb.ErrorCode_SociatyCDLimit
|
|
return
|
|
} else {
|
|
// 设置冷区时间
|
|
update["dismissCD"] = utils.AddHour(72).Unix()
|
|
}
|
|
//取消倒计时
|
|
update["dismissTime"] = 0
|
|
}
|
|
}
|
|
|
|
if err := this.module.modelSociaty.updateSociaty(sociaty.Id, update); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDismiss, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|