go_dreamfactory/modules/plunder/api_getlist.go
2024-01-26 15:01:49 +08:00

79 lines
1.9 KiB
Go

package plunder
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
)
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.PlunderGetListReq) (errdata *pb.ErrorData) {
return
}
// 获取基本信息
func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListReq) (errdata *pb.ErrorData) {
var (
err error
list *pb.DBPlunder
land *pb.DBPlunderLand
update map[string]interface{}
)
if errdata = this.GetListCheck(session, req); errdata != nil {
return
}
update = make(map[string]interface{})
if list, err = this.module.modelPlunder.getPlunderData(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
if list.Landid == "" {
if land, err = this.module.modelLand.createPlunderLandData(session.GetUserId(), list.Score); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
list.Landid = land.Id
} else {
// 校验是否过期
if list.Etime > configure.Now().Unix() {
}
if land, err = this.module.modelLand.getPlunderLandData(list.Landid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
}
if len(list.Source) == 0 {
list.Source, err = this.module.modelPlunder.refreshGoodsInfo()
list.Setout = []int32{}
update["setout"] = list.Setout
update["source"] = list.Source
}
// 校验解锁的是否到期
for _, v := range list.Line {
if v.Closetime > 0 && v.Closetime < configure.Now().Unix() {
v.Closetime = -1
update["line"] = list.Line
}
}
if len(update) > 0 {
this.module.modelPlunder.changePlunderData(session.GetUserId(), update)
}
session.SendMsg(string(this.module.GetType()), "getlist", &pb.PlunderGetListResp{
List: list,
Land: land,
})
return
}