package controller import ( "github.com/gin-gonic/gin" "service/api/errcode" vasproto "service/api/proto/vas/proto" "service/app/mix/service" "service/bizcommon/util" "service/dbstruct" "service/library/logger" ) func ZoneCreateOrder(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.ZoneCreateOrderReq) if !req.IsValid() || len(req.PayType) <= 0 || len(req.ProductId) <= 0 { logger.Error("CreateOrder, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } // 检查能用金币支付的商品 if req.PayType == vasproto.PayTypeCoin && !dbstruct.CoinPayValidProductIdMap[req.ProductId] { ReplyErrorMsg(ctx, "商品错误") return } if len(req.Model) >= 28 { req.Model = req.Model[:28] } data, ec, err := service.DefaultService.ZoneCreateOrder(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneCreateOrder fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, data) } func ZoneGetCashier(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.ZoneGetCashierReq) if req.Mid <= 0 || req.Zid <= 0 || len(req.ProductId) <= 0 { logger.Error("ZoneGetCashier, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } data, ec, err := service.DefaultService.ZoneGetCashier(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneGetCashier fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, data) } func ZoneRefundPage(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.ZoneRefundPageReq) if req.Mid <= 0 || req.Zid <= 0 { logger.Error("ZoneRefund, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } name, price, payType, ec, err := service.DefaultService.ZoneGetRefundPage(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneGetRefundPage fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } data := &vasproto.ZoneRefundPageData{ Name: name, } if payType == vasproto.PayTypeCoin { data.CoinPrice = price } else { data.Price = price } ReplyOk(ctx, data) } func ZoneRefund(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.ZoneRefundReq) if req.Mid <= 0 || req.Zid <= 0 { logger.Error("ZoneRefund, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } ec, err := service.DefaultService.ZoneRefund(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneRefund fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func ZoneMemberList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.GetZoneMemberListReq) if req.Mid <= 0 || req.Zid <= 0 { logger.Error("ZoneMemberList, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } list, ec, err := service.DefaultService.ZoneMemberList(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneMemberList fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } data := &vasproto.GetZoneMemberListData{ List: list, } ReplyOk(ctx, data) } func ZoneFreeJoin(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.ZoneFreeJoinReq) if req.Mid <= 0 || req.Zid <= 0 { logger.Error("ZoneFreeJoin, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } ec, err := service.DefaultService.ZoneFreeJoin(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneFreeJoin fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func ZoneExit(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.ZoneExitReq) if req.Mid <= 0 || req.Zid <= 0 { logger.Error("ZoneExit, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } ec, err := service.DefaultService.ZoneExit(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneExit fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func ZoneMomentOrderList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.ZoneMomentOrderListReq) if req.Mid <= 0 || req.MomentId <= 0 { logger.Error("ZoneExit, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } list, ec, err := service.DefaultService.ZoneMomentOrderList(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("ZoneExit fail, req: %v, ec: %v", util.ToJson(req), ec) if ec == errcode.ErrCodeVasSrvFail && err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } data := &vasproto.ZoneMomentOrderListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) }