61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package expedition
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.ExpeditionInfoReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// 获取工会boos战信息
|
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.ExpeditionInfoReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBExpedition
|
|
boos *pb.DBExpeditionBoos
|
|
err error
|
|
)
|
|
if errdata = this.InfoCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
state := getSysDayTimeState()
|
|
lock, _ := this.module.model.userlock(req.Guildid)
|
|
err = lock.Lock()
|
|
if err != nil {
|
|
this.module.Error("公会战分布式锁 err!", log.Field{Key: "Guildid", Value: req.Guildid}, log.Field{Key: "err", Value: err.Error()})
|
|
return
|
|
}
|
|
defer lock.Unlock()
|
|
if info, err = this.module.model.getInfo(req.Guildid); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if state == 3 {
|
|
boos = info.Boos[info.Indexboos]
|
|
if boos == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_SystemError,
|
|
Message: fmt.Sprintf("no found currboos:%d", info.Indexboos),
|
|
}
|
|
return
|
|
}
|
|
if !boos.Crusaded {
|
|
if this.module.model.settlementboos(info, boos) {
|
|
this.module.model.updateExpedition(info)
|
|
}
|
|
}
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.ExpeditionInfoResp{Info: info, State: state})
|
|
return
|
|
}
|