(c *gin.Context)
| 75 | } |
| 76 | |
| 77 | func UpdateSubscriptionPreference(c *gin.Context) { |
| 78 | userId := c.GetInt("id") |
| 79 | var req BillingPreferenceRequest |
| 80 | if err := c.ShouldBindJSON(&req); err != nil { |
| 81 | common.ApiErrorMsg(c, "参数错误") |
| 82 | return |
| 83 | } |
| 84 | pref := common.NormalizeBillingPreference(req.BillingPreference) |
| 85 | |
| 86 | user, err := model.GetUserById(userId, true) |
| 87 | if err != nil { |
| 88 | common.ApiError(c, err) |
| 89 | return |
| 90 | } |
| 91 | current := user.GetSetting() |
| 92 | current.BillingPreference = pref |
| 93 | if err := model.UpdateUserSetting(user.Id, current); err != nil { |
| 94 | common.ApiError(c, err) |
| 95 | return |
| 96 | } |
| 97 | common.ApiSuccess(c, gin.H{"billing_preference": pref}) |
| 98 | } |
| 99 | |
| 100 | func SubscriptionRequestBalancePay(c *gin.Context) { |
| 101 | if !requirePaymentCompliance(c) { |
nothing calls this directly
no test coverage detected