48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package caravan
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.CaravanGetListReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.CaravanGetListReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
resp *pb.CaravanGetListResp
|
|
)
|
|
resp = &pb.CaravanGetListResp{}
|
|
if errdata = this.GetListCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
list, err := this.module.modelCaravan.getCaravanList(session.GetUserId())
|
|
|
|
if configure.Now().Unix() >= list.Resettime || err == mgo.MongodbNil { // 初始化门票和虚拟币
|
|
if conf, err := this.module.configure.GetCaravanLv(list.Lv); err == nil {
|
|
this.module.ModuleItems.CleanItemById(session, conf.Tickettop.T) // 清理之前的门票数据
|
|
} else {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if errdata = this.module.InitCaravanTicket(session, list.Lv); errdata != nil {
|
|
return
|
|
}
|
|
}
|
|
// 刷新城市货物信息
|
|
this.module.refreshCaravanCityInfo(session.GetUserId(), list)
|
|
resp.TaskTimeOut = this.module.CheckCaravanTask(session, list)
|
|
resp.Data = list
|
|
session.SendMsg(string(this.module.GetType()), "getlist", resp)
|
|
return
|
|
}
|