feat: integrate unified payment and wallet refunds
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"git.apinb.com/bsm-sdk/core/infra"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/config"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/payment"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@@ -126,6 +127,8 @@ func CreateRecharge(client string) gin.HandlerFunc {
|
||||
Amount int64 `json:"amount" binding:"required,gt=0"`
|
||||
Channel string `json:"channel" binding:"required,oneof=mock wechat alipay"`
|
||||
RequestNo string `json:"request_no" binding:"required"`
|
||||
PayType string `json:"pay_type"`
|
||||
OpenID string `json:"openid"`
|
||||
}
|
||||
if ctx.ShouldBindJSON(&request) != nil || request.Amount > config.Spec.Global.ManualRechargeMaxAmount ||
|
||||
(request.Channel == "mock" && !config.Spec.Global.MockPaymentEnabled) {
|
||||
@@ -150,6 +153,16 @@ func CreateRecharge(client string) gin.HandlerFunc {
|
||||
}
|
||||
order = existing
|
||||
}
|
||||
if request.Channel != "mock" {
|
||||
payOrder, payErr := payment.Create(ctx, payment.CreateInput{RequestNo: request.RequestNo, BusinessType: "recharge", BusinessIdentity: order.Identity,
|
||||
UserIdentity: owner.Identity, Channel: request.Channel, PayType: request.PayType, Subject: "和气钱包充值 " + order.RechargeNo, OpenID: request.OpenID, Amount: order.Amount})
|
||||
if payErr != nil {
|
||||
infra.Response.Error(ctx, payErr)
|
||||
return
|
||||
}
|
||||
infra.Response.Success(ctx, payment.PublicResponse(payOrder))
|
||||
return
|
||||
}
|
||||
infra.Response.Success(ctx, ResourceResponse(order))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user