74 lines
2.4 KiB
Go
74 lines
2.4 KiB
Go
package caravan
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
"go_dreamfactory/utils"
|
|
)
|
|
|
|
//参数校验
|
|
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
|
|
cityRtime int64
|
|
)
|
|
update := make(map[string]interface{})
|
|
resp = &pb.CaravanGetListResp{}
|
|
if errdata = this.GetListCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
list, _ := this.module.modelCaravan.getCaravanList(session.GetUserId())
|
|
endtime := utils.WeekIntervalTime()
|
|
if list.Resettime != endtime { // 初始化门票和虚拟币
|
|
this.module.ModuleUser.CleanUserMerchantmoney(session)
|
|
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 conf, _ := this.module.configure.GetCaravanLv(list.Lv); conf != nil {
|
|
if errdata = this.module.InitCaravanTicket(session, conf); errdata != nil {
|
|
return
|
|
}
|
|
// 清除玩家货物信息
|
|
list.Items = make(map[string]*pb.BagInfo, 0)
|
|
update["items"] = list.Items
|
|
list.Reward = make(map[int32]bool, 0)
|
|
update["reward"] = list.Reward // 初始化利润奖励
|
|
}
|
|
list.Resettime = endtime
|
|
update["resettime"] = list.Resettime
|
|
}
|
|
cityRtime = utils.GetZeroTime(configure.Now().Unix())
|
|
if cityRtime != list.Citystime {
|
|
list.Allgoods = make(map[int32]*pb.GoodsInfo, 0)
|
|
// 刷新城市货物信息
|
|
this.module.InitCaravanItemData(session.GetUserId(), list)
|
|
this.module.InitCaravanCityData(session.GetUserId(), list)
|
|
update["allgoods"] = list.Allgoods
|
|
update["citystime"] = list.Citystime
|
|
update["rtime"] = list.Rtime
|
|
update["city"] = list.City
|
|
update["period"] = list.Period
|
|
}
|
|
if len(update) > 0 { // 更新数据
|
|
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)
|
|
}
|
|
resp.TaskTimeOut = this.module.CheckCaravanTask(session, list)
|
|
resp.Data = list
|
|
session.SendMsg(string(this.module.GetType()), "getlist", resp)
|
|
return
|
|
}
|