refactor: remove PaymentChannel, reuse upstream Channel with features field

- Delete payment_channels table and PaymentChannel Ent schema
- Add `features` column to upstream channels table (migration 095)
- Add Features field to Channel struct, input types, handler request/response
- Payment user/admin handlers now use ChannelService directly
- Remove Channel CRUD from PaymentConfigService and admin payment routes
- Remove "渠道管理" tab from admin orders page (use /admin/channels)
This commit is contained in:
erio committed 2026-04-05 16:39:24 +08:00
1 parent b1ef9f91f2
commit 8cb2409ea5
28 files changed
+35 -5035

No files matched your search

@@ -157,71 +157,6 @@ func (h *PaymentHandler) ProcessRefund(c *gin.Context) {
response.Success(c, result)
}
// --- Payment Channels ---
// ListChannels returns all payment channels.
// GET /api/v1/admin/payment/channels
func (h *PaymentHandler) ListChannels(c *gin.Context) {
channels, err := h.configService.ListChannels(c.Request.Context())
if err != nil {
response.ErrorFrom(c, err)
return
}
response.Success(c, channels)
}
// CreateChannel creates a new payment channel.
// POST /api/v1/admin/payment/channels
func (h *PaymentHandler) CreateChannel(c *gin.Context) {
var req service.CreateChannelRequest
if err := c.ShouldBindJSON(&req); err != nil {
response.BadRequest(c, "Invalid request: "+err.Error())
return
}
ch, err := h.configService.CreateChannel(c.Request.Context(), req)
if err != nil {
response.ErrorFrom(c, err)
return
}
response.Created(c, ch)
}
// UpdateChannel updates an existing payment channel.
// PUT /api/v1/admin/payment/channels/:id
func (h *PaymentHandler) UpdateChannel(c *gin.Context) {
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
if err != nil {
response.BadRequest(c, "Invalid channel ID")
return
}
var req service.UpdateChannelRequest
if err := c.ShouldBindJSON(&req); err != nil {
response.BadRequest(c, "Invalid request: "+err.Error())
return
}
ch, err := h.configService.UpdateChannel(c.Request.Context(), id, req)
if err != nil {
response.ErrorFrom(c, err)
return
}
response.Success(c, ch)
}
// DeleteChannel deletes a payment channel.
// DELETE /api/v1/admin/payment/channels/:id
func (h *PaymentHandler) DeleteChannel(c *gin.Context) {
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
if err != nil {
response.BadRequest(c, "Invalid channel ID")
return
}
if err := h.configService.DeleteChannel(c.Request.Context(), id); err != nil {
response.ErrorFrom(c, err)
return
}
response.Success(c, gin.H{"message": "deleted"})
}
// --- Subscription Plans ---
// ListPlans returns all subscription plans.