上传代码规范优化
This commit is contained in:
parent
1e7066a294
commit
5d0d6a9253
@ -15,7 +15,7 @@ func (this *apiComp) BuyPhysicalCheck(session comm.IUserSession, req *pb.ItemsBu
|
||||
return
|
||||
}
|
||||
|
||||
//出售道具
|
||||
//购买
|
||||
func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhysicalReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||
var (
|
||||
err error
|
||||
@ -25,15 +25,27 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
||||
sale []*cfg.Gameatn
|
||||
)
|
||||
if code = this.BuyPhysicalCheck(session, req); code != pb.ErrorCode_Success {
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: req.String(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if user, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: req.String(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if needs = this.module.ModuleTools.GetGlobalConf().PsBuy; needs == nil && len(needs) == 0 {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: comm.NewNotFoundConfErr(modelName, "global.json", "PsBuy").Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,6 +55,9 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
||||
|
||||
if req.Amount+uint32(user.Physicalbuynum) > uint32(len(needs)) {
|
||||
code = pb.ErrorCode_ItemsBuyPsUpperLimit
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@ func (this *apiComp) BuyUnifiedTicket(session comm.IUserSession, req *pb.ItemsBu
|
||||
info *pb.DBUserExpand
|
||||
)
|
||||
if code = this.BuyUnifiedTicketCheck(session, req); code != pb.ErrorCode_Success {
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: req.String(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if info, code = this.module.modelItems.buyTicket(session, req.BuyNum); code != pb.ErrorCode_Success {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package items
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
@ -14,7 +15,7 @@ func (this *apiComp) DecomposeCheck(session comm.IUserSession, req *pb.ItemsDeco
|
||||
return
|
||||
}
|
||||
|
||||
//出售道具
|
||||
//分解道具
|
||||
func (this *apiComp) Decompose(session comm.IUserSession, req *pb.ItemsDecomposeReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||
var (
|
||||
err error
|
||||
@ -27,18 +28,30 @@ func (this *apiComp) Decompose(session comm.IUserSession, req *pb.ItemsDecompose
|
||||
}
|
||||
if item, err = this.module.modelItems.QueryUserPackByGridId(session.GetUserId(), req.GridId); err != nil {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if itemcf, err = this.module.configure.GetItemConfigure(item.ItemId); err != nil {
|
||||
code = pb.ErrorCode_ConfigurationException
|
||||
return
|
||||
}
|
||||
if itemcf.Sale == nil || len(itemcf.Sale) == 0 {
|
||||
code = pb.ErrorCode_ItemsUseNoCanSell
|
||||
return
|
||||
}
|
||||
// if itemcf.Sale == nil || len(itemcf.Sale) == 0 {
|
||||
// code = pb.ErrorCode_ItemsUseNoCanSell
|
||||
// data = &pb.ErrorData{
|
||||
// Title: code.ToString(),
|
||||
// Message: fmt.Sprintf("道具未配置"),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
if itemcf.DecomposeDeplete == nil || len(itemcf.DecomposeDeplete) == 0 {
|
||||
code = pb.ErrorCode_ItemsUseNoCanSell
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: fmt.Sprintf("道具分解配置未配置! 道具id:%s", itemcf.Id),
|
||||
}
|
||||
return
|
||||
}
|
||||
sale = make([]*cfg.Gameatn, 0, len(itemcf.DecomposeDeplete))
|
||||
@ -54,8 +67,12 @@ func (this *apiComp) Decompose(session comm.IUserSession, req *pb.ItemsDecompose
|
||||
}
|
||||
|
||||
if req.Amount > item.Amount {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
this.module.Errorf("SellItemCheck over all amount:[%d:%d]", req.Amount, item.Amount)
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: fmt.Sprintf("道具数量不足! 道具数量:%s", item.Amount),
|
||||
}
|
||||
return
|
||||
}
|
||||
sale = make([]*cfg.Gameatn, len(itemcf.Sale))
|
||||
|
@ -37,6 +37,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
|
||||
if items, err = this.module.modelItems.QueryUserPack(session.GetUserId()); err != nil {
|
||||
this.module.Errorf("QueryUserPackReq err:%v", err)
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
} else {
|
||||
// tempgrids = this.module.configure.GetPackItemByType(items, req.IType)
|
||||
|
@ -22,6 +22,10 @@ func (this *apiComp) PotionSynthesis(session comm.IUserSession, req *pb.ItemsPot
|
||||
)
|
||||
if configure, err = this.module.configure.GetMaterialConfigure(req.Id); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
need = make([]*cfg.Gameatn, len(configure.Material))
|
||||
|
@ -37,6 +37,10 @@ func (this *apiComp) Sellinbulk(session comm.IUserSession, req *pb.ItemsSellinbu
|
||||
}
|
||||
if itemcf, err = this.module.configure.GetItemConfigures(cids); err != nil {
|
||||
code = pb.ErrorCode_ConfigurationException
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
issucc = make([]bool, len(items))
|
||||
@ -68,12 +72,13 @@ func (this *apiComp) Sellinbulk(session comm.IUserSession, req *pb.ItemsSellinbu
|
||||
if err = this.module.modelItems.UpdateUserPack(session.GetUserId(), items...); err != nil {
|
||||
this.module.Errorln(err)
|
||||
code = pb.ErrorCode_DBError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if err = this.module.itemsChangePush(session, items); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
this.module.itemsChangePush(session, items)
|
||||
session.SendMsg(string(this.module.GetType()), "sellitem", &pb.ItemsSellinbulkResp{Grids: req.Grids, Amount: req.Amount, Issucc: issucc})
|
||||
return
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import (
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
)
|
||||
|
||||
const modelName = "道具背包"
|
||||
|
||||
/*
|
||||
模块名:Pack
|
||||
描述:背包系统模块
|
||||
|
Loading…
Reference in New Issue
Block a user