From 3a83ade89f5ab06866bac72f7dd6ac776619ddb5 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 28 Jun 2024 23:13:21 +0800 Subject: [PATCH] by Robin at 20240628 --- api/errs/error.go | 42 ++++++++++++++++++----------------- app/mix/service/apiservice.go | 16 ++++++++----- app/mix/service/logic/vas.go | 17 ++++++++++---- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/api/errs/error.go b/api/errs/error.go index 683cf0e0..a4f351c5 100644 --- a/api/errs/error.go +++ b/api/errs/error.go @@ -1,8 +1,9 @@ package errs import ( - "github.com/pkg/errors" "service/api/errcode" + + "github.com/pkg/errors" ) func DealVasErr(err error) (errcode.ErrCode, error) { @@ -42,23 +43,24 @@ var ErrEcMap = map[error]errcode.ErrCode{ } var ( - ErrVasProductNotExists = errors.New("vas product not exists") - ErrVasNotMoneyProduct = errors.New("not money product") - ErrVasWalletNotExist = errors.New("vas wallet not exists") - ErrVasInvalidContactProduct = errors.New("invalid contact product") - ErrVasUserVasNotExist = errors.New("user vas not exists") - ErrVasNoEnoughCoin = errors.New("no enough coin") - ErrVasInvalidCoinPrice = errors.New("invalid coin price") - ErrVasInvalidOrder = errors.New("invalid order") - ErrVasOrderNotMatch = errors.New("order not match") - ErrVasOrderNotExists = errors.New("order not exists") - ErrVasNotUnlock = errors.New("not unlock") - ErrVasAlreadyUnlock = errors.New("already unlock") - ErrVasRepeatDeal = errors.New("repeat deal") - ErrVasInvalidCalcPrice = errors.New("invalid calc price") - ErrVasInvalidParam = errors.New("invalid param") - ErrVasNoEnoughWithdrawDias = errors.New("no enough withdraw dias") - ErrVasAlipayUniTransferFail = errors.New("alipay uni transfer fail") - ErrVasOverTodayWithdrawCnt = errors.New("over today withdraw cnt") - ErrVasRefundLimit = errors.New("账号已受限,解限请联系客服") + ErrVasProductNotExists = errors.New("vas product not exists") + ErrVasNotMoneyProduct = errors.New("not money product") + ErrVasWalletNotExist = errors.New("vas wallet not exists") + ErrVasInvalidContactProduct = errors.New("invalid contact product") + ErrVasUserVasNotExist = errors.New("user vas not exists") + ErrVasNoEnoughCoin = errors.New("no enough coin") + ErrVasInvalidCoinPrice = errors.New("invalid coin price") + ErrVasInvalidOrder = errors.New("invalid order") + ErrVasOrderNotMatch = errors.New("order not match") + ErrVasOrderNotExists = errors.New("order not exists") + ErrVasNotUnlock = errors.New("not unlock") + ErrVasAlreadyUnlock = errors.New("already unlock") + ErrVasRepeatDeal = errors.New("repeat deal") + ErrVasInvalidCalcPrice = errors.New("invalid calc price") + ErrVasInvalidParam = errors.New("invalid param") + ErrVasNoEnoughWithdrawDias = errors.New("no enough withdraw dias") + ErrVasAlipayUniTransferFail = errors.New("alipay uni transfer fail") + ErrVasOverTodayWithdrawCnt = errors.New("over today withdraw cnt") + ErrVasRefundLimit = errors.New("账号已受限,解限请联系客服") + ErrVasHvyogoSingleDistributionFail = errors.New("hvyogo single distribution fail") ) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 45ae0ba7..e0918a02 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -3487,11 +3487,6 @@ func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.A logger.Error("_DefaultSingleDistributeHis OpUpdate fail, err: %v", err) } - if resp.StatusCode != response.StatusCodeSuccess { - err = fmt.Errorf("single distribution fail") - return resp, err - } - return resp, nil } @@ -3515,6 +3510,17 @@ func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.A err = nil return } + // 下发打款接口未成功调用 + if resp.StatusCode != response.StatusCodeSuccess { + logger.Error("WithdrawApply fail, req: %v, err: %v", util.ToJson(req), resp.StatusText) + // 恢复锁 + _, err = _DefaultSingleDistributeHis.GetAndDecLock(ctx, req.BaseRequest.Mid) + if err != nil { + logger.Error("_DefaultSingleDistributeHis GetAndDecLock failed : %v", err) + ec, err = errcode.ErrCodeSingleDistributeHisSrvFail, nil + return + } + } // 组装返回结果 data = &hvyogoproto.ApiSingleDistributeData{} diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 896a447a..39adf960 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -11,6 +11,7 @@ import ( "fmt" "service/api/base" "service/api/errs" + "service/api/message/response" accountproto "service/api/proto/account/proto" hvyogoproto "service/api/proto/hvyogo/proto" vasproto "service/api/proto/vas/proto" @@ -3870,10 +3871,18 @@ func (v *Vas) UnilaterallyHvyogoWithdrawApply(ctx *gin.Context, req *vasproto.Un if err != nil { logger.Error("global err, req: %v, err: %v", util.ToJson(req), err) } - errTx := v.store.DealTxCR(tx, err) - if errTx != nil { - logger.Error("DealTxCR fail, err: %v", errTx) - return + if resp.StatusCode != response.StatusCodeSuccess { + errTx := v.store.DealTxCR(tx, errs.ErrVasHvyogoSingleDistributionFail) + if errTx != nil { + logger.Error("DealTxCR fail, err: %v", errTx) + return + } + } else { + errTx := v.store.DealTxCR(tx, err) + if errTx != nil { + logger.Error("DealTxCR fail, err: %v", errTx) + return + } } }()