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"
|
2024-06-13 16:40:22 +08:00
|
|
|
"service/dbstruct"
|
2024-04-15 15:17:30 +08:00
|
|
|
"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
|
|
|
|
}
|
2024-06-13 16:40:22 +08:00
|
|
|
// 检查能用金币支付的商品
|
|
|
|
if req.PayType == vasproto.PayTypeCoin && !dbstruct.CoinPayValidProductIdMap[req.ProductId] {
|
|
|
|
ReplyErrorMsg(ctx, "商品错误")
|
|
|
|
return
|
|
|
|
}
|
2024-06-19 21:56:57 +08:00
|
|
|
if len(req.Model) >= 28 {
|
|
|
|
req.Model = req.Model[:28]
|
|
|
|
}
|
2024-06-13 16:40:22 +08:00
|
|
|
|
2024-04-15 15:17:30 +08:00
|
|
|
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-06-14 10:20:08 +08:00
|
|
|
name, price, payType, ec, err := service.DefaultService.ZoneGetRefundPage(ctx, req)
|
2024-04-15 15:17:30 +08:00
|
|
|
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{
|
2024-06-14 10:20:08 +08:00
|
|
|
Name: name,
|
|
|
|
}
|
|
|
|
if payType == vasproto.PayTypeCoin {
|
|
|
|
data.CoinPrice = price
|
|
|
|
} else {
|
|
|
|
data.Price = price
|
2024-04-15 15:17:30 +08:00
|
|
|
}
|
|
|
|
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
|
|
|
|
}
|
2024-06-14 18:37:42 +08:00
|
|
|
|
2024-04-15 15:17:30 +08:00
|
|
|
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)
|
|
|
|
}
|
2024-05-14 10:55:49 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2024-05-15 20:01:40 +08:00
|
|
|
ReplyOk(ctx, data)
|
2024-05-14 10:55:49 +08:00
|
|
|
}
|