From cbf4cc764c14afbe0d3b7a9b9f0edfcd80567473 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Thu, 10 Oct 2024 08:59:27 +0800 Subject: [PATCH] freeze op --- api/proto/vas/proto/op.go | 28 +++++++++++++++++++- app/mix/controller/init.go | 3 +++ app/mix/controller/vas.go | 49 +++++++++++++++++++++++++++++++++++ app/mix/dao/mongo.go | 6 +++++ app/mix/dao/mongo_vas.go | 45 ++++++++++++++++++++++++++++++++ app/mix/service/logic/vas.go | 23 ++++++++++++++++ app/mix/service/vasservice.go | 49 +++++++++++++++++++++++++++++++++++ dbstruct/vas_mongo.go | 8 ++++++ 8 files changed, 210 insertions(+), 1 deletion(-) diff --git a/api/proto/vas/proto/op.go b/api/proto/vas/proto/op.go index 1013383a..2ec2c1ee 100644 --- a/api/proto/vas/proto/op.go +++ b/api/proto/vas/proto/op.go @@ -1,6 +1,9 @@ package proto -import "service/dbstruct" +import ( + "service/api/base" + "service/dbstruct" +) // op创建订单 type OpCreateOrderReq struct { @@ -131,3 +134,26 @@ type WxpayCallbackManualParam struct { OutOrderId string `json:"out_order_id"` // 外部订单id,比如支付宝、微信 CallbackPayType string `json:"callback_pay_type"` // 支付类型 } + +// op冻结提现权限 +type OpAddWithdrawFreezeReq struct { + base.BaseRequest + UserId int64 `json:"user_id"` // 要冻结的主播user_id +} + +type OpAddWithdrawFreezeData struct{} + +type OpDelWithdrawFreezeReq struct { + base.BaseRequest + UserId int64 `json:"user_id"` // 要冻结的主播user_id +} + +type OpDelWithdrawFreezeData struct{} + +type OpGetWithdrawFreezeListReq struct { + base.BaseRequest +} + +type OpGetWithdrawFreezeListData struct { + List []*dbstruct.WithdrawFreeze `json:"list"` +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index bea12fb3..5b669899 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -350,6 +350,9 @@ func Init(r *gin.Engine) { opVasPayGroup.POST("manual_unlock_wechat", middleware.JSONParamValidator(zoneproto.OpManualUnlockWechatParam{}), OpManualUnlockWechat) opVasPayGroup.POST("rollback_zone_exit_status", middleware.JSONParamValidator(zoneproto.OpRollbackZoneExitStatusParam{}), OpRollbackZoneAdmissionExitStatus) opVasPayGroup.POST("rollback_zone_refund_status", middleware.JSONParamValidator(zoneproto.OpRollbackZoneRefundStatusParam{}), OpRollbackZoneRefundStatus) + opVasPayGroup.POST("add_withdraw_freeze", middleware.JSONParamValidator(vasproto.OpAddWithdrawFreezeReq{}), OpAddWithdrawFreeze) + opVasPayGroup.POST("del_withdraw_freeze", middleware.JSONParamValidator(vasproto.OpDelWithdrawFreezeReq{}), OpDelWithdrawFreeze) + opVasPayGroup.POST("get_withdraw_freeze_list", middleware.JSONParamValidator(vasproto.OpGetWithdrawFreezeListReq{}), OpGetWithdrawFreezeList) // 慧用工 extHvyogoGroup := r.Group("/ext/hvyogo") diff --git a/app/mix/controller/vas.go b/app/mix/controller/vas.go index d5e75250..31c2d803 100644 --- a/app/mix/controller/vas.go +++ b/app/mix/controller/vas.go @@ -469,3 +469,52 @@ func PayMeans(ctx *gin.Context) { } ReplyOk(ctx, data) } + +// 提现冻结 +func OpAddWithdrawFreeze(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*vasproto.OpAddWithdrawFreezeReq) + ec, err := service.DefaultService.OpAddWithdrawFreeze(ctx, req) + if ec != errcode.ErrCodeVasSrvOk { + logger.Error("OpAddWithdrawFreeze 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 OpDelWithdrawFreeze(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*vasproto.OpDelWithdrawFreezeReq) + ec, err := service.DefaultService.OpDelWithdrawFreeze(ctx, req) + if ec != errcode.ErrCodeVasSrvOk { + logger.Error("OpDelWithdrawFreeze 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 OpGetWithdrawFreezeList(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*vasproto.OpGetWithdrawFreezeListReq) + list, ec, err := service.DefaultService.OpGetWithdrawFreezeList(ctx, req) + if ec != errcode.ErrCodeVasSrvOk { + logger.Error("OpGetWithdrawFreezeList fail, req: %v, ec: %v", util.ToJson(req), ec) + if err != nil { + ReplyErrorMsg(ctx, err.Error()) + return + } + ReplyErrCodeMsg(ctx, ec) + return + } + data := &vasproto.OpGetWithdrawFreezeListData{ + List: list, + } + ReplyOk(ctx, data) +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 4035a559..6d5a9ee1 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -91,6 +91,7 @@ const ( COLZoneMomentStat = "zone_moment_stat" COLUserIncome = "user_income" COLWithdrawHis = "withdraw_his" + COLWithdrawFreeze = "withdraw_freeze" DBCatalog = "catalog" COLCatalog = "catalog" @@ -294,6 +295,11 @@ func (m *Mongo) getColWithdrawHis() *qmgo.Collection { return m.clientMix.Database(DBVas).Collection(COLWithdrawHis) } +// 提现冻结 +func (m *Mongo) getColWithdrawFreeze() *qmgo.Collection { + return m.clientMix.Database(DBVas).Collection(COLWithdrawFreeze) +} + // 分类表 func (m *Mongo) getColCatalog() *qmgo.Collection { return m.clientMix.Database(DBCatalog).Collection(COLCatalog) diff --git a/app/mix/dao/mongo_vas.go b/app/mix/dao/mongo_vas.go index 7c999a84..1a7a1896 100644 --- a/app/mix/dao/mongo_vas.go +++ b/app/mix/dao/mongo_vas.go @@ -289,3 +289,48 @@ func (m *Mongo) AddWithdrawHis(ctx *gin.Context, doc *dbstruct.WithdrawHis) erro _, err := col.InsertOne(ctx, doc) return err } + +// 提现冻结 +func (m *Mongo) AddWithdrawFreeze(ctx *gin.Context, doc *dbstruct.WithdrawFreeze) error { + col := m.getColWithdrawFreeze() + _, err := col.InsertOne(ctx, doc) + return err +} + +func (m *Mongo) DelWithdrawFreeze(ctx *gin.Context, userId int64) error { + col := m.getColWithdrawFreeze() + err := col.RemoveId(ctx, userId) + return err +} + +func (m *Mongo) GetWithdrawFreezeList(ctx *gin.Context) ([]*dbstruct.WithdrawFreeze, error) { + list := make([]*dbstruct.WithdrawFreeze, 0) + col := m.getColWithdrawFreeze() + query := qmgo.M{} + err := col.Find(ctx, query).All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return make([]*dbstruct.WithdrawFreeze, 0), nil + } + if err != nil { + return make([]*dbstruct.WithdrawFreeze, 0), err + } + return list, nil +} + +func (m *Mongo) GetWithdrawFreezeByUserId(ctx *gin.Context, userId int64) (*dbstruct.WithdrawFreeze, error) { + doc := new(dbstruct.WithdrawFreeze) + col := m.getColWithdrawFreeze() + query := qmgo.M{ + "_id": userId, + } + err := col.Find(ctx, query).One(&doc) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return nil, nil + } + if err != nil { + return nil, err + } + return doc, nil +} diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 50f46151..d4935952 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -4267,3 +4267,26 @@ func (v *Vas) UnilaterallyWithdrawAccomplish(ctx *gin.Context, orderId string) ( return } + +// 提现冻结 +func (v *Vas) AddWithdrawFreeze(ctx *gin.Context, userId, mid, opMid int64) error { + wf := &dbstruct.WithdrawFreeze{ + UserId: userId, + Mid: mid, + Ct: time.Now().Unix(), + OperatorMid: opMid, + } + return v.store.AddWithdrawFreeze(ctx, wf) +} + +func (v *Vas) DelWithdrawFreeze(ctx *gin.Context, userId int64) error { + return v.store.DelWithdrawFreeze(ctx, userId) +} + +func (v *Vas) GetWithdrawFreezeByUserId(ctx *gin.Context, userId int64) (*dbstruct.WithdrawFreeze, error) { + return v.store.GetWithdrawFreezeByUserId(ctx, userId) +} + +func (v *Vas) GetWithdrawFreezeList(ctx *gin.Context) ([]*dbstruct.WithdrawFreeze, error) { + return v.store.GetWithdrawFreezeList(ctx) +} diff --git a/app/mix/service/vasservice.go b/app/mix/service/vasservice.go index 090938a3..f57c4d78 100644 --- a/app/mix/service/vasservice.go +++ b/app/mix/service/vasservice.go @@ -1429,3 +1429,52 @@ func (s *Service) SearchZoneMember(ctx *gin.Context, req *vasproto.SearchMemberR list = append(list, item) return } + +func (s *Service) OpAddWithdrawFreeze(ctx *gin.Context, req *vasproto.OpAddWithdrawFreezeReq) (ec errcode.ErrCode, err error) { + defer func() { + ec, err = errs.DealVasErr(err) + }() + + // 检查重复添加 + doc, _ := _DefaultVas.GetWithdrawFreezeByUserId(ctx, req.UserId) + if doc != nil { + err = fmt.Errorf("该主播权限已冻结,请勿重复添加") + return + } + + // 获取mid + userAcnt, _ := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{UserId: goproto.Int64(req.UserId)}) + + err = _DefaultVas.AddWithdrawFreeze(ctx, req.UserId, userAcnt.GetMid(), req.Mid) + if err != nil { + logger.Error("AddWithdrawFreeze fail, req: %v, err: %v", util.ToJson(req), err) + return + } + return +} + +func (s *Service) OpDelWithdrawFreeze(ctx *gin.Context, req *vasproto.OpDelWithdrawFreezeReq) (ec errcode.ErrCode, err error) { + defer func() { + ec, err = errs.DealVasErr(err) + }() + + err = _DefaultVas.DelWithdrawFreeze(ctx, req.UserId) + if err != nil { + logger.Error("DelWithdrawFreeze fail, req: %v, err: %v", util.ToJson(req), err) + return + } + return +} + +func (s *Service) OpGetWithdrawFreezeList(ctx *gin.Context, req *vasproto.OpGetWithdrawFreezeListReq) (list []*dbstruct.WithdrawFreeze, ec errcode.ErrCode, err error) { + defer func() { + ec, err = errs.DealVasErr(err) + }() + + list, err = _DefaultVas.GetWithdrawFreezeList(ctx) + if err != nil { + logger.Error("GetWithdrawFreezeList fail, req: %v, err: %v", util.ToJson(req), err) + return + } + return +} diff --git a/dbstruct/vas_mongo.go b/dbstruct/vas_mongo.go index 8d1898fa..d1d592ca 100644 --- a/dbstruct/vas_mongo.go +++ b/dbstruct/vas_mongo.go @@ -195,3 +195,11 @@ type WithdrawHis struct { Err string `json:"err" bson:"err"` Ct int64 `json:"ct" bson:"ct"` } + +// 提现冻结 +type WithdrawFreeze struct { + UserId int64 `json:"user_id" bson:"_id"` + Mid int64 `json:"mid" bson:"mid"` + Ct int64 `json:"ct" bson:"ct"` + OperatorMid int64 `json:"operator_mid" bson:"operator_mid"` +}