From e47ed25ed070cc329fe984f7f3d3eb3b46cd5bcd Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 10 Jul 2024 05:47:56 +0800 Subject: [PATCH] by Robin at 20240710 --- api/consts/option.go | 1 + .../service/apiservice_business_validation.go | 15 +++++++++++++++ app/mix/service/logic/vas.go | 16 ++++++++++++++++ app/mix/service/service.go | 7 +++++++ 4 files changed, 39 insertions(+) diff --git a/api/consts/option.go b/api/consts/option.go index eb520052..35ccd93b 100644 --- a/api/consts/option.go +++ b/api/consts/option.go @@ -26,6 +26,7 @@ const ( AccountPunishment_BlockFromBeingSearched = 4 // 禁止被搜索到 AccountPunishment_BlockFromBeingDiscovered = 5 // 禁止在推荐被发现 AccountPunishment_BlockFromBeingSeenAtMoment = 6 // 禁止在广场被发现 + AccountPunishment_BlockFromPaying = 7 // 禁止付款 ) const ( diff --git a/app/mix/service/apiservice_business_validation.go b/app/mix/service/apiservice_business_validation.go index 4a0d38f5..d8fd9559 100644 --- a/app/mix/service/apiservice_business_validation.go +++ b/app/mix/service/apiservice_business_validation.go @@ -1,6 +1,7 @@ package service import ( + "fmt" "service/api/consts" "service/api/errcode" accountproto "service/api/proto/account/proto" @@ -9,6 +10,7 @@ import ( momentproto "service/api/proto/moment/proto" streamerproto "service/api/proto/streamer/proto" streamerauthapprovalproto "service/api/proto/streamerauthapproval/proto" + vasproto "service/api/proto/vas/proto" vericodeproto "service/api/proto/vericode/proto" zone_collaborator_proto "service/api/proto/zone_collaborator/proto" zone_third_partner_proto "service/api/proto/zone_third_partner/proto" @@ -730,3 +732,16 @@ func (s *Service) ApiUpdateZoneCollaboratorBusinessValidate(ctx *gin.Context, re return } + +func (s *Service) ApiCreateOrderBusinessValidate(ctx *gin.Context, req *vasproto.CreateOrderReq) (err error) { + + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + EnsureSuchAccountPunishmentNotExist(req.BaseRequest.Mid, consts.AccountPunishment_BlockFromPaying, _DefaultAccountPunishment.OpListByMidAndType). + Validate(). + Collect() + ec := result[0].(errcode.ErrCode) + if ec == errcode.ErrCodeAccountPunishmentExist { + return fmt.Errorf("账号已受限,解限请联系客服") + } + return nil +} diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 28235e4d..648f83d4 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -41,6 +41,8 @@ type Vas struct { zone *Zone zonetp *ZoneThirdPartner zoneclr *ZoneCollaborator + + createOrderProxy *CreateOrderProxy } func NewVas(store *dao.Store, streamer *Streamer, account *Account, zone *Zone, zonetp *ZoneThirdPartner, zoneclr *ZoneCollaborator) (v *Vas) { @@ -54,6 +56,10 @@ func NewVas(store *dao.Store, streamer *Streamer, account *Account, zone *Zone, } } +func (v *Vas) RegisterProxyForCreateOrder(proxy *CreateOrderProxy) { + v.createOrderProxy = proxy +} + func (v *Vas) GetCoinsProductList(ctx *gin.Context, req *vasproto.GetCoinsProductListReq) (listAlipayH5 []*dbstruct.Product, err error) { // 获取所有金币商品 list, err := v.store.GetProductByDtType(ctx, req.DevType, dbstruct.ProductTypeCoins) @@ -118,7 +124,17 @@ var CreateOrderBlacklist = map[int64]bool{ 359498: true, } +type CreateOrderProxy struct { + PreProc func(ctx *gin.Context, req *vasproto.CreateOrderReq) (data any, err error) +} + func (v *Vas) CreateOrder(ctx *gin.Context, req *vasproto.CreateOrderReq) (data *vasproto.CreateOrderData, err error) { + + _, err = v.createOrderProxy.PreProc(ctx, req) + if err != nil { + return + } + if CreateOrderBlacklist[req.Mid] { err = fmt.Errorf("账号已受限,解限请联系客服") return diff --git a/app/mix/service/service.go b/app/mix/service/service.go index c0e7be09..79121b6c 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -238,6 +238,13 @@ func (s *Service) Init(c any) (err error) { _DefaultVas = logic.NewVas(store, _DefaultStreamer, _DefaultAccount, _DefaultZone, _DefaultZoneThirdPartner, _DefaultZoneCollaborator) _DefaultStreamerAcct = logic.NewStreamerAcct(store) + + _DefaultVas.RegisterProxyForCreateOrder(&logic.CreateOrderProxy{ + PreProc: func(ctx *gin.Context, req *vasproto.CreateOrderReq) (data any, err error) { + err = s.ApiCreateOrderBusinessValidate(ctx, req) + return nil, err + }, + }) return }