service/app/mix/controller/zone_vas_api.go

158 lines
4.5 KiB
Go
Raw Normal View History

2024-04-15 15:17:30 +08:00
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/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
}
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)
2024-04-18 21:17:41 +08:00
if req.Mid <= 0 || req.Zid <= 0 || len(req.ProductId) <= 0 {
logger.Error("ZoneGetCashier, invalid param, req: %v", util.ToJson(req))
2024-04-15 15:17:30 +08:00
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)
2024-04-18 21:17:41 +08:00
if req.Mid <= 0 || req.Zid <= 0 {
logger.Error("ZoneRefund, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2024-04-15 15:17:30 +08:00
name, price, 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{
Price: price,
Name: name,
}
ReplyOk(ctx, data)
}
func ZoneRefund(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.ZoneRefundReq)
2024-04-18 21:17:41 +08:00
if req.Mid <= 0 || req.Zid <= 0 {
logger.Error("ZoneRefund, invalid param, req: %v", util.ToJson(req))
2024-04-15 15:17:30 +08:00
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)
2024-04-18 21:17:41 +08:00
if req.Mid <= 0 || req.Zid <= 0 {
2024-04-15 15:17:30 +08:00
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)
}
2024-04-16 20:20:53 +08:00
func ZoneFreeJoin(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.ZoneFreeJoinReq)
2024-04-18 21:17:41 +08:00
if req.Mid <= 0 || req.Zid <= 0 {
logger.Error("ZoneFreeJoin, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2024-04-16 20:20:53 +08:00
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)
}
2024-04-18 21:17:41 +08:00
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)
}