package controller import ( "service/api/errcode" vasproto "service/api/proto/vas/proto" "service/app/mix/service" "service/bizcommon/common" "service/bizcommon/util" "service/library/logger" "time" "github.com/gin-gonic/gin" ) // 获取充值商品 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 GetMembershipProductList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.GetMembershipProductListReq) if req.Channel == "h5" { req.DevType = common.DeviceTypeH5 } data, ec := service.DefaultService.GetMembershipProductList(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("GetMembershipProductList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, data) } // 充值 创建订单 func CreateOrder(ctx *gin.Context) { 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) { 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) { 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) { 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) { 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) { 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) { 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) } // 提现页面 func WithdrawPage(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.WithdrawPageReq) data, ec := service.DefaultService.WithdrawPage(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("WithdrawPage fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, data) } var WithdrawFreezeMidMap = map[int64]bool{ 16311: true, 159: true, } func isWithdrawFreeze(mid int64) bool { return WithdrawFreezeMidMap[mid] } // 提现发送验证码 func WithdrawSendVerifycode(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.WithdrawSendVerifycodeReq) if isWithdrawFreeze(req.Mid) { ReplyErrorMsg(ctx, "当前提现功能已冻结") return } ec := service.DefaultService.WithdrawSendVerifycode(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("WithdrawSendVerifycode fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } // 提现申请 func WithdrawApply(ctx *gin.Context) { //ReplyErrorMsg(ctx, "提现功能维护中,请72小时后再试") //return req := ctx.MustGet("client_req").(*vasproto.WithdrawApplyReq) if isWithdrawFreeze(req.Mid) { ReplyErrorMsg(ctx, "当前提现功能已冻结") return } if req.Diamonds < 2000 { ReplyErrorMsg(ctx, "最低提现金额不能小于200元") return } if !vasproto.IsWithdrawAnyDiasEnable(req.Mid) && req.Diamonds > 20000 { ReplyErrorMsg(ctx, "最大提现金额不能大于2000元") return } time.Sleep(time.Second * 1) data, ec := service.DefaultService.WithdrawApply(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("WithdrawApply fail, req: %v, data: %v, ec: %v", util.ToJson(req), data, ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } // 处理一个订单 func DealOneCoinOrder(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.DealOneCoinOrderReq) ec, err := service.DefaultService.DealOneCoinOrder(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("DealOneCoinOrder fail, req: %v, ec: %v", util.ToJson(req), ec) if err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } // 处理一个订单 func DealOneOrder(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.DealOneOrderReq) ec, err := service.DefaultService.DealOneOrder(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("DealOneOrder fail, req: %v, ec: %v", util.ToJson(req), ec) if err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } // 订单退款 func RefundOrder(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.RefundOrderReq) ec, err := service.DefaultService.RefundOrder(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("RefundOrder fail, req: %v, ec: %v", util.ToJson(req), ec) if err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } // 金币订单退款 func RefundCoinOrder(ctx *gin.Context) { req := ctx.MustGet("client_req").(*vasproto.RefundCoinOrderReq) ec, err := service.DefaultService.RefundCoinOrder(ctx, req) if ec != errcode.ErrCodeVasSrvOk { logger.Error("RefundCoinOrder fail, req: %v, ec: %v", util.ToJson(req), ec) if err != nil { ReplyErrorMsg(ctx, err.Error()) return } ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) }