From 0f96f44c3e446233b05a195829ff993e46486567 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Fri, 26 Apr 2024 01:13:35 +0800 Subject: [PATCH 1/4] fix --- app/mix/service/logic/vas.go | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 23865c4d..a62e7a0b 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -1313,7 +1313,7 @@ func (v *Vas) PayCallback(ctx *gin.Context, p *vasproto.PayCallbackParamIn) { } case product.Id == dbstruct.ProductIdMembership: // 解锁会员资格 - _, err = v.UnlockMembership(ctx, util.DerefInt64(order.Mid), product, order, wallet) + _, err = v.UnlockMembership(ctx, tx, util.DerefInt64(order.Mid), product, order, wallet) if err != nil { logger.Error("UnlockMembership fail, order: %v, err: %v", util.ToJson(order), err) return @@ -1851,7 +1851,7 @@ func (v *Vas) dealOneMembershipOrder(ctx *gin.Context, tx *sqlx.Tx, order *dbstr } // 解锁会员资格 -func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Product, order *dbstruct.Order, wallet *dbstruct.Wallet) (orderId string, err error) { +func (v *Vas) UnlockMembership(ctx *gin.Context, tx *sqlx.Tx, mid int64, product *dbstruct.Product, order *dbstruct.Order, wallet *dbstruct.Wallet) (orderId string, err error) { var ( did = util.DerefString(order.Did) productId = product.Id @@ -1867,20 +1867,6 @@ func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Pr return } - // 开启事务 - tx, err := v.store.VasBegin(ctx) - if err != nil { - logger.Error("vas begin fail, err: %v", err) - return - } - defer func() { - errTx := v.store.DealTxCR(tx, err) - if errTx != nil { - logger.Error("DealTxCR fail, err: %v", errTx) - return - } - }() - // 增加金币消费历史(伪记录,仅为对账平插入一条消费流水) ch := &dbstruct.ConsumeHistory{ Mid: goproto.Int64(mid), @@ -1934,8 +1920,15 @@ func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Pr return } + // 获取空间id + zid := int64(0) + zone, _ := v.zone.GetByMid(ctx, order.GetUid()) + if zone != nil { + zid = zone.GetId() + } + // 增加空间消费 - _err := v.IncZoneConsume(ctx, tx, 0, mid, order.GetUid(), order.GetPayAmount(), orderId, order.GetProductId()) + _err := v.IncZoneConsume(ctx, tx, zid, mid, order.GetUid(), order.GetPayAmount(), orderId, order.GetProductId()) if _err != nil { logger.Error("IncZoneConsume fail, mid: %v, orderId: %v, err: %v", mid, orderId, err) } From 60dd9b28c5fb7245ef7b4c7b781e4585b550bc77 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Fri, 26 Apr 2024 01:29:36 +0800 Subject: [PATCH 2/4] add wxpay callback manul --- api/proto/vas/proto/op.go | 6 ++++++ app/mix/controller/init.go | 1 + app/mix/controller/wxpay_callback.go | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/api/proto/vas/proto/op.go b/api/proto/vas/proto/op.go index 9c8cda35..9d7cb8f1 100644 --- a/api/proto/vas/proto/op.go +++ b/api/proto/vas/proto/op.go @@ -118,3 +118,9 @@ type OpOrderListData struct { //Offset int `json:"offset"` //More int `json:"more"` } + +type WxpayCallbackManualParam struct { + OrderId string `json:"order_id"` // 我们自己服务的订单id + OutOrderId string `json:"out_order_id"` // 外部订单id,比如支付宝、微信 + CallbackPayType string `json:"callback_pay_type"` // 支付类型 +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 973e115c..4f5651ed 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -290,6 +290,7 @@ func Init(r *gin.Engine) { extVasPayGroup := r.Group("/ext/vas") extVasPayGroup.POST("alipay_callback", AlipayCallback) extVasPayGroup.POST("wxpay_callback", WxpayCallback) + extVasPayGroup.POST("wxpay_callback_manual", middleware.JSONParamValidator(vasproto.WxpayCallbackManualParam{}), WxpayCallbackManual) opVasPayGroup := r.Group("/op/vas", PrepareOp()) opVasPayGroup.POST("create_order", middleware.JSONParamValidator(vasproto.OpCreateOrderReq{}), OpCreateOrder) diff --git a/app/mix/controller/wxpay_callback.go b/app/mix/controller/wxpay_callback.go index d39f3cb0..4e6fca8c 100644 --- a/app/mix/controller/wxpay_callback.go +++ b/app/mix/controller/wxpay_callback.go @@ -31,3 +31,13 @@ func WxpayCallback(ctx *gin.Context) { } ctx.String(200, "success") } + +func WxpayCallbackManual(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*vasproto.WxpayCallbackManualParam) + service.DefaultService.PayCallback(ctx, &vasproto.PayCallbackParamIn{ + OrderId: req.OrderId, + OutOrderId: req.OutOrderId, + CallbackPayType: vasproto.CallBackPayTypeWxpay, + }) + ctx.String(200, "success") +} From f80bfb3ab5ddf36812ca5ce537a0a46dd55c0701 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Fri, 26 Apr 2024 01:30:40 +0800 Subject: [PATCH 3/4] fix --- app/mix/controller/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 4f5651ed..bdea9db7 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -290,7 +290,6 @@ func Init(r *gin.Engine) { extVasPayGroup := r.Group("/ext/vas") extVasPayGroup.POST("alipay_callback", AlipayCallback) extVasPayGroup.POST("wxpay_callback", WxpayCallback) - extVasPayGroup.POST("wxpay_callback_manual", middleware.JSONParamValidator(vasproto.WxpayCallbackManualParam{}), WxpayCallbackManual) opVasPayGroup := r.Group("/op/vas", PrepareOp()) opVasPayGroup.POST("create_order", middleware.JSONParamValidator(vasproto.OpCreateOrderReq{}), OpCreateOrder) @@ -298,6 +297,7 @@ func Init(r *gin.Engine) { opVasPayGroup.POST("order_list", middleware.JSONParamValidator(vasproto.OpOrderListReq{}), OpOrderList) opVasPayGroup.POST("refund_order", middleware.JSONParamValidator(vasproto.RefundOrderReq{}), RefundOrder) opVasPayGroup.POST("refund_coin_order", middleware.JSONParamValidator(vasproto.RefundCoinOrderReq{}), RefundCoinOrder) + opVasPayGroup.POST("wxpay_callback_manual", middleware.JSONParamValidator(vasproto.WxpayCallbackManualParam{}), WxpayCallbackManual) // 验证码 opVeriCodeGroup := r.Group("/op/veri_code", PrepareOp()) From 30f4a9dd3716b265ffd20a784db7728c2cc76b22 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Fri, 26 Apr 2024 02:27:07 +0800 Subject: [PATCH 4/4] fix membership change --- app/mix/service/logic/vas.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index a62e7a0b..b1385e3b 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -1257,7 +1257,6 @@ func (v *Vas) PayCallback(ctx *gin.Context, p *vasproto.PayCallbackParamIn) { switch product.Id { case dbstruct.ProductIdMembership: ch.SType = goproto.Int32(dbstruct.CHSTypeChargeMembership) - ch.Change = goproto.Int64(order.GetPayAmount()) case dbstruct.ProductIdH5ZoneMoment: ch.SType = goproto.Int32(dbstruct.CHSTypeChargeZoneMoment) ch.Change = goproto.Int64(order.GetPayAmount())