Merge branch 'sub' into feature/subscription

This commit is contained in:
t0ng7u
2026-02-03 01:24:40 +08:00

View File

@@ -81,20 +81,6 @@ func SubscriptionRequestEpay(c *gin.Context) {
return
}
uri, params, err := client.Purchase(&epay.PurchaseArgs{
Type: req.PaymentMethod,
ServiceTradeNo: tradeNo,
Name: fmt.Sprintf("SUB:%s", plan.Title),
Money: strconv.FormatFloat(plan.PriceAmount, 'f', 2, 64),
Device: epay.PC,
NotifyUrl: notifyUrl,
ReturnUrl: returnUrl,
})
if err != nil {
common.ApiErrorMsg(c, "拉起支付失败")
return
}
order := &model.SubscriptionOrder{
UserId: userId,
PlanId: plan.Id,
@@ -108,6 +94,20 @@ func SubscriptionRequestEpay(c *gin.Context) {
common.ApiErrorMsg(c, "创建订单失败")
return
}
uri, params, err := client.Purchase(&epay.PurchaseArgs{
Type: req.PaymentMethod,
ServiceTradeNo: tradeNo,
Name: fmt.Sprintf("SUB:%s", plan.Title),
Money: strconv.FormatFloat(plan.PriceAmount, 'f', 2, 64),
Device: epay.PC,
NotifyUrl: notifyUrl,
ReturnUrl: returnUrl,
})
if err != nil {
_ = model.ExpireSubscriptionOrder(tradeNo)
common.ApiErrorMsg(c, "拉起支付失败")
return
}
c.JSON(http.StatusOK, gin.H{"message": "success", "data": params, "url": uri})
}