Merge pull request 'main' (#352) from main into test

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/352
This commit is contained in:
chenhao 2024-04-26 14:55:04 +08:00
commit c922628f5a
4 changed files with 27 additions and 18 deletions

View File

@ -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"` // 支付类型
}

View File

@ -297,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())

View File

@ -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")
}

View File

@ -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())
@ -1313,7 +1312,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 +1850,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 +1866,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 +1919,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)
}