2023-12-21 22:17:40 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"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"
|
2024-01-08 22:38:18 +08:00
|
|
|
|
"time"
|
2024-02-01 09:52:45 +08:00
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2023-12-21 22:17:40 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 获取充值商品
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-01 09:52:45 +08:00
|
|
|
|
// 获取会员商品
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-21 22:17:40 +08:00
|
|
|
|
// 充值 创建订单
|
|
|
|
|
func CreateOrder(ctx *gin.Context) {
|
|
|
|
|
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) {
|
|
|
|
|
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) {
|
|
|
|
|
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) {
|
|
|
|
|
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) {
|
|
|
|
|
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) {
|
|
|
|
|
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) {
|
|
|
|
|
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)
|
|
|
|
|
}
|
2024-01-07 22:37:06 +08:00
|
|
|
|
|
|
|
|
|
// 提现页面
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-06 23:28:22 +08:00
|
|
|
|
var WithdrawFreezeMidMap = map[int64]bool{
|
|
|
|
|
16311: true,
|
|
|
|
|
159: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func isWithdrawFreeze(mid int64) bool {
|
|
|
|
|
return WithdrawFreezeMidMap[mid]
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-07 22:37:06 +08:00
|
|
|
|
// 提现发送验证码
|
|
|
|
|
func WithdrawSendVerifycode(ctx *gin.Context) {
|
|
|
|
|
req := ctx.MustGet("client_req").(*vasproto.WithdrawSendVerifycodeReq)
|
2024-05-06 23:28:22 +08:00
|
|
|
|
if isWithdrawFreeze(req.Mid) {
|
|
|
|
|
ReplyErrorMsg(ctx, "当前提现功能已冻结")
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-07 22:37:06 +08:00
|
|
|
|
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)
|
|
|
|
|
}
|
2024-01-08 11:49:16 +08:00
|
|
|
|
|
|
|
|
|
// 提现申请
|
|
|
|
|
func WithdrawApply(ctx *gin.Context) {
|
2024-02-21 11:36:21 +08:00
|
|
|
|
//ReplyErrorMsg(ctx, "提现功能维护中,请72小时后再试")
|
|
|
|
|
//return
|
2024-01-08 11:49:16 +08:00
|
|
|
|
req := ctx.MustGet("client_req").(*vasproto.WithdrawApplyReq)
|
2024-05-06 23:28:22 +08:00
|
|
|
|
if isWithdrawFreeze(req.Mid) {
|
|
|
|
|
ReplyErrorMsg(ctx, "当前提现功能已冻结")
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-05-15 12:40:21 +08:00
|
|
|
|
if req.Diamonds < 1000 {
|
|
|
|
|
ReplyErrorMsg(ctx, "最低提现金额不能小于100元")
|
2024-01-08 22:38:18 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2024-05-16 16:49:20 +08:00
|
|
|
|
//if !vasproto.IsWithdrawAnyDiasEnable(req.Mid) && req.Diamonds > 20000 {
|
|
|
|
|
// ReplyErrorMsg(ctx, "最大提现金额不能大于2000元")
|
|
|
|
|
// return
|
|
|
|
|
//}
|
2024-01-08 22:38:18 +08:00
|
|
|
|
|
|
|
|
|
time.Sleep(time.Second * 1)
|
|
|
|
|
|
2024-01-08 11:49:16 +08:00
|
|
|
|
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)
|
|
|
|
|
}
|
2024-01-21 12:27:34 +08:00
|
|
|
|
|
|
|
|
|
// 处理一个订单
|
|
|
|
|
func DealOneCoinOrder(ctx *gin.Context) {
|
|
|
|
|
req := ctx.MustGet("client_req").(*vasproto.DealOneCoinOrderReq)
|
2024-02-03 17:23:08 +08:00
|
|
|
|
ec, err := service.DefaultService.DealOneCoinOrder(ctx, req)
|
2024-01-21 12:27:34 +08:00
|
|
|
|
if ec != errcode.ErrCodeVasSrvOk {
|
|
|
|
|
logger.Error("DealOneCoinOrder fail, req: %v, ec: %v", util.ToJson(req), ec)
|
2024-02-03 17:23:08 +08:00
|
|
|
|
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
|
|
|
|
|
}
|
2024-01-21 12:27:34 +08:00
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
ReplyOk(ctx, nil)
|
|
|
|
|
}
|
2024-03-13 20:35:18 +08:00
|
|
|
|
|
|
|
|
|
// 订单退款
|
|
|
|
|
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)
|
|
|
|
|
}
|
2024-03-19 16:04:36 +08:00
|
|
|
|
|
|
|
|
|
// 金币订单退款
|
|
|
|
|
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)
|
|
|
|
|
}
|