商队任务超时处理

This commit is contained in:
meixiongfeng 2023-07-11 20:33:19 +08:00
parent 62a6b30293
commit ba1d0f0ad3
4 changed files with 41 additions and 41 deletions

View File

@ -403,7 +403,7 @@ type (
JumpTaskByTaskId(session IUserSession, rtaskId int32) error JumpTaskByTaskId(session IUserSession, rtaskId int32) error
// 查询我的世界任务 // 查询我的世界任务
GetMyWorldtask(uid string) *pb.DBWorldtask GetMyWorldtask(uid string) *pb.DBWorldtask
//接取商队任务 //接取商队任务 //接口废弃
AcceptCaravanTask(session IUserSession, groupId int32) (task *pb.Worldtask, errdata *pb.ErrorData) AcceptCaravanTask(session IUserSession, groupId int32) (task *pb.Worldtask, errdata *pb.ErrorData)
//更新接取任务 //更新接取任务
UpdateTaskStatus(uid string, taskId int32) UpdateTaskStatus(uid string, taskId int32)

View File

@ -21,6 +21,8 @@ func (this *apiComp) GetStory(session comm.IUserSession, req *pb.CaravanGetStory
var ( var (
resp *pb.CaravanGetStoryResp resp *pb.CaravanGetStoryResp
update map[string]interface{} update map[string]interface{}
taskid int32
//group int32
) )
resp = &pb.CaravanGetStoryResp{} resp = &pb.CaravanGetStoryResp{}
update = make(map[string]interface{}) update = make(map[string]interface{})
@ -41,16 +43,16 @@ func (this *apiComp) GetStory(session comm.IUserSession, req *pb.CaravanGetStory
if req.Citystory == conf.Citynormal { //接受剧情 if req.Citystory == conf.Citynormal { //接受剧情
module, err := this.service.GetModule(comm.ModuleWorldtask) module, err := this.service.GetModule(comm.ModuleWtask)
if err != nil { if err != nil {
return return
} }
if wt, ok := module.(comm.IWorldtask); ok { if wt, ok := module.(comm.IWtask); ok {
resp.Task, errdata = wt.AcceptCaravanTask(session, conf.Worldtask) taskid, _, errdata = wt.AcceptCaravanTask(session, conf.Worldtask)
if errdata != nil { if errdata != nil {
return return
} }
list.Taskid = resp.Task.TaskId list.Taskid = taskid
if list.Taskid != 0 { // 任务接取成功 if list.Taskid != 0 { // 任务接取成功
resp.BSuccess = true resp.BSuccess = true
list.Tasktime = configure.Now().Unix() list.Tasktime = configure.Now().Unix()

View File

@ -92,6 +92,11 @@ func (this *Caravan) InitCaravanCityData(uid string, data *pb.DBCaravan) {
} else { } else {
city.Special = append(city.Special, v.Special...) city.Special = append(city.Special, v.Special...)
} }
// for _, v1 := range city.Special {
// if conf, err := this.configure.GetCaravanGoods(v1); err == nil {
// city.Count[v1] = conf.Goodsnum
// }
// }
data.City[v.Id] = city data.City[v.Id] = city
} }
} }
@ -156,7 +161,6 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) {
subTime := int32(curTime - caravan.Citystime) subTime := int32(curTime - caravan.Citystime)
if subTime >= changeTime { if subTime >= changeTime {
bChange = true bChange = true
for k, v := range caravan.City { for k, v := range caravan.City {
if c, _ := this.configure.GetCaravanCity(k); c != nil { if c, _ := this.configure.GetCaravanCity(k); c != nil {
v.Count = make(map[string]int32) // 初始化城市信息 v.Count = make(map[string]int32) // 初始化城市信息
@ -169,6 +173,12 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) {
} else { } else {
v.Special = append(v.Special, c.Special...) v.Special = append(v.Special, c.Special...)
} }
// for _, v1 := range v.Special {
// if conf, err := this.configure.GetCaravanGoods(v1); err == nil {
// v.Count[v1] = conf.Goodsnum
// }
// }
} }
} }
@ -254,12 +264,12 @@ func (this *Caravan) CheckCaravanTask(session comm.IUserSession, data *pb.DBCara
if list, err := this.configure.GetCaravanEventById(data.Eventid); err == nil { if list, err := this.configure.GetCaravanEventById(data.Eventid); err == nil {
// 校验任务是否超时 // 校验任务是否超时
if configure.Now().Unix()-data.Tasktime > int64(list.Eventtime) { //TODO 任务超时 通知任务模块处理 并清理相关数据 if configure.Now().Unix()-data.Tasktime > int64(list.Eventtime) { //TODO 任务超时 通知任务模块处理 并清理相关数据
module, err := this.service.GetModule(comm.ModuleWorldtask) module, err := this.service.GetModule(comm.ModuleWtask)
if err != nil { if err != nil {
return return
} }
if wt, ok := module.(comm.IWorldtask); ok { if wt, ok := module.(comm.IWtask); ok {
wt.UpdateTaskStatus(session.GetUserId(), data.Taskid) // 通知任务模块 任务超时 wt.ClearCaravanTask(session, data.Taskid) // 通知任务模块 任务超时
} }
this.CleanCaravanTask(session.GetUserId(), data) //任务超时 清理任务数据 this.CleanCaravanTask(session.GetUserId(), data) //任务超时 清理任务数据

View File

@ -399,7 +399,6 @@ type CaravanGetStoryResp struct {
Data *DBCaravan `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` Data *DBCaravan `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
BSuccess bool `protobuf:"varint,2,opt,name=bSuccess,proto3" json:"bSuccess"` // 是否成功接取到任务 BSuccess bool `protobuf:"varint,2,opt,name=bSuccess,proto3" json:"bSuccess"` // 是否成功接取到任务
Task *Worldtask `protobuf:"bytes,3,opt,name=task,proto3" json:"task"` // 任务进度
} }
func (x *CaravanGetStoryResp) Reset() { func (x *CaravanGetStoryResp) Reset() {
@ -448,13 +447,6 @@ func (x *CaravanGetStoryResp) GetBSuccess() bool {
return false return false
} }
func (x *CaravanGetStoryResp) GetTask() *Worldtask {
if x != nil {
return x.Task
}
return nil
}
// 任务完成推送 // 任务完成推送
type CaravanTaskCompletePush struct { type CaravanTaskCompletePush struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -766,14 +758,12 @@ var file_caravan_caravan_msg_proto_rawDesc = []byte{
0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63,
0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x69, 0x74, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x69, 0x74, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x69, 0x74, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x69, 0x74, 0x79, 0x73, 0x74, 0x6f, 0x72, 0x79,
0x22, 0x71, 0x0a, 0x13, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x22, 0x51, 0x0a, 0x13, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x47, 0x65, 0x74, 0x53, 0x74,
0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61,
0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x53, 0x75, 0x63, 0x63, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x53, 0x75, 0x63, 0x63,
0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x62, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x62, 0x53, 0x75, 0x63, 0x63,
0x65, 0x73, 0x73, 0x12, 0x1e, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x65, 0x73, 0x73, 0x22, 0x7a, 0x0a, 0x17, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x54, 0x61,
0x0b, 0x32, 0x0a, 0x2e, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x04, 0x74,
0x61, 0x73, 0x6b, 0x22, 0x7a, 0x0a, 0x17, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x54, 0x61,
0x73, 0x6b, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1e, 0x73, 0x6b, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1e,
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44,
0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a,
@ -853,11 +843,10 @@ var file_caravan_caravan_msg_proto_goTypes = []interface{}{
nil, // 15: CaravanRefreshCityResp.CityEntry nil, // 15: CaravanRefreshCityResp.CityEntry
nil, // 16: CaravanRefreshCityResp.OldpriceEntry nil, // 16: CaravanRefreshCityResp.OldpriceEntry
(*DBCaravan)(nil), // 17: DBCaravan (*DBCaravan)(nil), // 17: DBCaravan
(*Worldtask)(nil), // 18: Worldtask (*UserAssets)(nil), // 18: UserAssets
(*UserAssets)(nil), // 19: UserAssets (*CaravanRankInfo)(nil), // 19: CaravanRankInfo
(*CaravanRankInfo)(nil), // 20: CaravanRankInfo (*Goods)(nil), // 20: Goods
(*Goods)(nil), // 21: Goods (*CityInfo)(nil), // 21: CityInfo
(*CityInfo)(nil), // 22: CityInfo
} }
var file_caravan_caravan_msg_proto_depIdxs = []int32{ var file_caravan_caravan_msg_proto_depIdxs = []int32{
17, // 0: CaravanGetListResp.data:type_name -> DBCaravan 17, // 0: CaravanGetListResp.data:type_name -> DBCaravan
@ -865,21 +854,20 @@ var file_caravan_caravan_msg_proto_depIdxs = []int32{
17, // 2: CaravanBuyOrSellResp.data:type_name -> DBCaravan 17, // 2: CaravanBuyOrSellResp.data:type_name -> DBCaravan
17, // 3: CaravanGotoCityResp.data:type_name -> DBCaravan 17, // 3: CaravanGotoCityResp.data:type_name -> DBCaravan
17, // 4: CaravanGetStoryResp.data:type_name -> DBCaravan 17, // 4: CaravanGetStoryResp.data:type_name -> DBCaravan
18, // 5: CaravanGetStoryResp.task:type_name -> Worldtask 17, // 5: CaravanTaskCompletePush.data:type_name -> DBCaravan
17, // 6: CaravanTaskCompletePush.data:type_name -> DBCaravan 18, // 6: CaravanTaskCompletePush.reward:type_name -> UserAssets
19, // 7: CaravanTaskCompletePush.reward:type_name -> UserAssets 19, // 7: CaravanRankListResp.list:type_name -> CaravanRankInfo
20, // 8: CaravanRankListResp.list:type_name -> CaravanRankInfo 19, // 8: CaravanRankListResp.userinfo:type_name -> CaravanRankInfo
20, // 9: CaravanRankListResp.userinfo:type_name -> CaravanRankInfo 14, // 9: CaravanRefreshCityResp.goods:type_name -> CaravanRefreshCityResp.GoodsEntry
14, // 10: CaravanRefreshCityResp.goods:type_name -> CaravanRefreshCityResp.GoodsEntry 15, // 10: CaravanRefreshCityResp.city:type_name -> CaravanRefreshCityResp.CityEntry
15, // 11: CaravanRefreshCityResp.city:type_name -> CaravanRefreshCityResp.CityEntry 16, // 11: CaravanRefreshCityResp.Oldprice:type_name -> CaravanRefreshCityResp.OldpriceEntry
16, // 12: CaravanRefreshCityResp.Oldprice:type_name -> CaravanRefreshCityResp.OldpriceEntry 20, // 12: CaravanRefreshCityResp.GoodsEntry.value:type_name -> Goods
21, // 13: CaravanRefreshCityResp.GoodsEntry.value:type_name -> Goods 21, // 13: CaravanRefreshCityResp.CityEntry.value:type_name -> CityInfo
22, // 14: CaravanRefreshCityResp.CityEntry.value:type_name -> CityInfo 14, // [14:14] is the sub-list for method output_type
15, // [15:15] is the sub-list for method output_type 14, // [14:14] is the sub-list for method input_type
15, // [15:15] is the sub-list for method input_type 14, // [14:14] is the sub-list for extension type_name
15, // [15:15] is the sub-list for extension type_name 14, // [14:14] is the sub-list for extension extendee
15, // [15:15] is the sub-list for extension extendee 0, // [0:14] is the sub-list for field type_name
0, // [0:15] is the sub-list for field type_name
} }
func init() { file_caravan_caravan_msg_proto_init() } func init() { file_caravan_caravan_msg_proto_init() }