package controller import ( "github.com/gin-gonic/gin" "service/api/errcode" vasproto "service/api/proto/vas/proto" "service/app/mix/service" "service/bizcommon/common" "service/bizcommon/util" "service/library/logger" ) // 获取充值商品 func GetCoinsProductList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.GetCoinsProductListReq) if req.Channel == "h5" { req.DevType = common.DeviceTypeH5 } 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) { defer logger.Recover() req := ctx.MustGet("client_req").(*vasproto.CreateOrderReq) 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 := 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) if req.Operator != "yezian" { logger.Warn("invalid operator, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeVasInvalidParam) return } 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) 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 } 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) { defer logger.Recover() req := ctx.MustGet("client_req").(*vasproto.ConsumerFillContactReq) if req.Mid <= 0 || len(req.OrderId) <= 0 { logger.Error("ConsumerFillContact, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } 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) { defer logger.Recover() req := ctx.MustGet("client_req").(*vasproto.GetAddWechatListReq) if !req.IsValid() { logger.Error("GetAddWechatList, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } 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) { defer logger.Recover() req := ctx.MustGet("client_req").(*vasproto.ConfirmAddWechatReq) if !req.IsValid() { logger.Error("ConfirmAddWechat, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } 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) { defer logger.Recover() req := ctx.MustGet("client_req").(*vasproto.GetUnlockWechatListReq) if req.Mid <= 0 { logger.Error("GetUnlockWechatList, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } 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) { defer logger.Recover() req := ctx.MustGet("client_req").(*vasproto.GetCHListReq) if !req.IsValid() { logger.Error("GetCHList, invalid param, req: %v", util.ToJson(req)) ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) return } 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) }