package smithy import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "github.com/golang/protobuf/proto" ) // 贸易 func (this *apiComp) SellCheck(session comm.IUserSession, req *pb.SmithySellReq) (code pb.ErrorCode) { if req.CustomerId == 0 || len(req.Ids) == 0 { code = pb.ErrorCode_ReqParameterError } return } func (this *apiComp) SellItem(session comm.IUserSession, req *pb.SmithySellReq) (code pb.ErrorCode, data proto.Message) { if code = this.SellCheck(session, req); code != pb.ErrorCode_Success { return } //校验customer类型,因为有的类型是不能进入交易逻辑的 //TODO _ = this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId) conf := this.module.configure.GetSmithyCustomerConf(req.CustomerId) if conf == nil { code = pb.ErrorCode_ConfigNoFound return } // 发奖励 this.module.DispenseRes(session, conf.Reword, true) rsp := &pb.SmithySellResp{ CustomerId: req.CustomerId, Ids: req.Ids, } session.SendMsg(string(this.module.GetType()), "sell", rsp) return }