55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package caravan
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GotoCityCheck(session comm.IUserSession, req *pb.CaravanGotoCityReq) (code pb.ErrorCode) {
|
|
if req.City == 0 || req.Ticket <= 0 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCityReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
var (
|
|
resp *pb.CaravanGetListResp
|
|
res *cfg.Gameatn
|
|
)
|
|
if code = this.GotoCityCheck(session, req); code != pb.ErrorCode_Success {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
list, err := this.module.api.module.modelCaravan.getCaravanList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
if list.Curcity == req.City {
|
|
code = pb.ErrorCode_TrollCity
|
|
return
|
|
}
|
|
// 校验门票
|
|
if d := this.module.configure.GetCaravanLv(list.Lv); d != nil {
|
|
//d.Tickettop
|
|
res = &cfg.Gameatn{
|
|
A: d.Tickettop.A,
|
|
T: d.Tickettop.T,
|
|
N: req.Ticket,
|
|
}
|
|
}
|
|
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success { // 校验门票数量
|
|
return
|
|
}
|
|
list.Curcity = req.City
|
|
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), map[string]interface{}{
|
|
"curcity": list.Curcity,
|
|
})
|
|
resp.Data = list
|
|
session.SendMsg(string(this.module.GetType()), "getlist", resp)
|
|
return
|
|
}
|