service/app/mix/controller/vas.go

212 lines
6.2 KiB
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
package controller
import (
"github.com/gin-gonic/gin"
"service/api/errcode"
vasproto "service/api/proto/vas/proto"
"service/app/mix/service"
2023-12-29 15:03:50 +08:00
"service/bizcommon/common"
2023-12-21 22:17:40 +08:00
"service/bizcommon/util"
"service/library/logger"
)
// 获取充值商品
func GetCoinsProductList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.GetCoinsProductListReq)
2023-12-29 15:03:50 +08:00
if req.Channel == "h5" {
req.DevType = common.DeviceTypeH5
}
2023-12-21 22:17:40 +08:00
data, ec := service.DefaultService.GetCoinsProductList(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("GetCoinsProductList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}
// 充值 创建订单
func CreateOrder(ctx *gin.Context) {
2023-12-29 21:30:59 +08:00
defer logger.Recover()
2023-12-21 22:17:40 +08:00
req := ctx.MustGet("client_req").(*vasproto.CreateOrderReq)
2023-12-29 21:30:59 +08:00
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
}
2023-12-21 22:17:40 +08:00
data, ec := service.DefaultService.CreateOrder(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("CreateOrder fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}
// op充值
func OpCreateOrder(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.OpCreateOrderReq)
2023-12-25 01:14:14 +08:00
if req.Operator != "yezian" {
logger.Warn("invalid operator, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeVasInvalidParam)
return
}
2023-12-21 22:17:40 +08:00
ec := service.DefaultService.OpCreateOrder(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("OpCreateOrder fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
// 一键解锁
func OneStepUnlock(ctx *gin.Context) {
defer logger.Recover()
req := ctx.MustGet("client_req").(*vasproto.OneStepUnlockContactReq)
2023-12-29 21:30:59 +08:00
if !req.IsValid() || req.Uid <= 0 || len(req.ContactProductId) <= 0 {
logger.Error("OneStepUnlock, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2023-12-21 22:17:40 +08:00
data, ec := service.DefaultService.OneStepUnlockContact(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("GetAddWechatList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}
// 填写地址
func ConsumerFillContact(ctx *gin.Context) {
2023-12-29 21:30:59 +08:00
defer logger.Recover()
2023-12-21 22:17:40 +08:00
req := ctx.MustGet("client_req").(*vasproto.ConsumerFillContactReq)
2023-12-30 14:22:02 +08:00
if req.Mid <= 0 || len(req.OrderId) <= 0 {
2023-12-29 21:30:59 +08:00
logger.Error("ConsumerFillContact, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2023-12-21 22:17:40 +08:00
ec := service.DefaultService.ConsumerFillContact(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("ConsumerFillContact fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
// 待添加微信列表
func GetAddWechatList(ctx *gin.Context) {
2023-12-29 21:30:59 +08:00
defer logger.Recover()
2023-12-21 22:17:40 +08:00
req := ctx.MustGet("client_req").(*vasproto.GetAddWechatListReq)
2023-12-29 21:30:59 +08:00
if !req.IsValid() {
logger.Error("GetAddWechatList, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2023-12-21 22:17:40 +08:00
data, ec := service.DefaultService.GetAddWechatList(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("GetAddWechatList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}
// 完成添加微信
func ConfirmAddWechat(ctx *gin.Context) {
2023-12-29 21:30:59 +08:00
defer logger.Recover()
2023-12-21 22:17:40 +08:00
req := ctx.MustGet("client_req").(*vasproto.ConfirmAddWechatReq)
2023-12-29 21:30:59 +08:00
if !req.IsValid() {
logger.Error("ConfirmAddWechat, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2023-12-21 22:17:40 +08:00
data, ec := service.DefaultService.ConfirmAddWechat(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("ConfirmAddWechat fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}
// 已解锁微信列表
func GetUnlockWechatList(ctx *gin.Context) {
2023-12-29 21:30:59 +08:00
defer logger.Recover()
2023-12-21 22:17:40 +08:00
req := ctx.MustGet("client_req").(*vasproto.GetUnlockWechatListReq)
2023-12-30 13:49:05 +08:00
if req.Mid <= 0 {
2023-12-29 21:30:59 +08:00
logger.Error("GetUnlockWechatList, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2023-12-21 22:17:40 +08:00
data, ec := service.DefaultService.GetUnlockWechatList(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("GetUnlockWechatList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}
// 明细
func GetCHList(ctx *gin.Context) {
2023-12-29 21:30:59 +08:00
defer logger.Recover()
2023-12-21 22:17:40 +08:00
req := ctx.MustGet("client_req").(*vasproto.GetCHListReq)
2023-12-29 21:30:59 +08:00
if !req.IsValid() {
logger.Error("GetCHList, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
2023-12-21 22:17:40 +08:00
data, ec := service.DefaultService.GetCHList(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("GetCHList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}
// 网红设置微信
func UpdateWechat(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.UpdateWechatReq)
ec := service.DefaultService.UpdateWechat(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("UpdateWechat fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
// 查看微信
func QueryWechat(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.QueryWechatReq)
isUnlock, lockType, wechat, ec := service.DefaultService.QueryWechat(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("QueryWechat fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &vasproto.QueryWechatData{
IsUnlock: isUnlock,
LockType: lockType,
WechatContact: wechat,
}
ReplyOk(ctx, data)
}
// h5直接解锁
func H5DirectUnlockWechat(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.H5DirectUnlockWechatReq)
data, ec := service.DefaultService.H5DirectUnlockWechat(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("H5DirectUnlockWechat fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}